Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full screen mode implementation for dashboard #12265

Merged
merged 12 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/core_plugins/kibana/public/dashboard/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<dashboard-app class="app-container dashboard-container">
<div class="fullScreenModePlaceholder">
<div
ng-if="fullScreenMode"
class="kuiButton exitFullScreenMode"
ng-click="exitFullScreenMode()"
>
<div class="kuiIcon fa fa-angle-double-up"></div>
Exit Full Screen Mode
</div>
</div>
<!-- Local nav. -->
<kbn-top-nav name="dashboard" config="topNavMenu">
<!-- Transcluded elements. -->
Expand Down Expand Up @@ -71,6 +81,7 @@

<!-- Filters. -->
<filter-bar
ng-show="showFilterBar()"
state="state"
index-patterns="indexPatterns"
></filter-bar>
Expand All @@ -84,7 +95,7 @@ <h2 class="kuiTitle kuiVerticalRhythm">
</h2>

<p class="kuiText kuiVerticalRhythm">
Click the <a kbn-accessible-click class="kuiButton kuiButton--primary kuiButton--small" ng-click="kbnTopNav.open('add'); toggleAddVisualization = !toggleAddVisualization" aria-label="Add visualization">Add</a> button in the menu bar above to add a visualization to the dashboard. <br/>If you haven't set up any visualizations yet, <a class="kuiLink" href="#/visualize">visit the Visualize app</a> to create your first visualization.
Click the <a kbn-accessible-click class="kuiButton kuiButton--primary kuiButton--small" ng-click="showAddPanel()" aria-label="Add visualization">Add</a> button in the menu bar above to add a visualization to the dashboard. <br/>If you haven't set up any visualizations yet, <a class="kuiLink" href="#/visualize">visit the Visualize app</a> to create your first visualization.
</p>
</div>

Expand All @@ -94,7 +105,7 @@ <h2 class="kuiTitle kuiVerticalRhythm">
</h2>

<p class="kuiText kuiVerticalRhythm">
Click the <a kbn-accessible-click class="kuiButton kuiButton--primary kuiButton--small" ng-click="kbnTopNav.click('edit');">Edit</a> button in the menu bar above to start working on your new dashboard.
Click the <a kbn-accessible-click class="kuiButton kuiButton--primary kuiButton--small" ng-click="enterEditMode()">Edit</a> button in the menu bar above to start working on your new dashboard.
</p>
</div>

Expand Down
45 changes: 45 additions & 0 deletions src/core_plugins/kibana/public/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { notify } from 'ui/notify';
import './panel/get_object_loaders_for_dashboard';
import { documentationLinks } from 'ui/documentation_links/documentation_links';
import { showCloneModal } from './top_nav/show_clone_modal';
import { ESC_KEY_CODE } from 'ui_framework/services';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️


const app = uiModules.get('app/dashboard', [
'elasticsearch',
Expand Down Expand Up @@ -117,6 +118,7 @@ app.directive('dashboardApp', function ($injector) {
description: dashboardState.getDescription(),
};
$scope.panels = dashboardState.getPanels();
$scope.fullScreenMode = dashboardState.getFullScreenMode();
};

// Part of the exposed plugin API - do not remove without careful consideration.
Expand Down Expand Up @@ -286,7 +288,50 @@ app.directive('dashboardApp', function ($injector) {
}).catch(notify.error);
};

$scope.showFilterBar = () => filterBar.getFilters().length > 0 || !$scope.fullScreenMode;
let onRouteChange;
const setFullScreenMode = (fullScreenMode) => {
$scope.fullScreenMode = fullScreenMode;
dashboardState.setFullScreenMode(fullScreenMode);
chrome.setVisible(!fullScreenMode);
$scope.$broadcast('reLayout');

// Make sure that if we exit the dashboard app, the chrome becomes visible again
// (e.g. if the user clicks the back button).
if (fullScreenMode) {
onRouteChange = $scope.$on('$routeChangeStart', () => {
chrome.setVisible(true);
onRouteChange();
});
} else if (onRouteChange) {
onRouteChange();
}
};

$scope.$watch('fullScreenMode', () => setFullScreenMode(dashboardState.getFullScreenMode()));

$scope.exitFullScreenMode = () => setFullScreenMode(false);

document.addEventListener('keydown', (e) => {
if (e.keyCode === ESC_KEY_CODE) {
setFullScreenMode(false);
}
}, false);

$scope.showAddPanel = () => {
if ($scope.fullScreenMode) {
$scope.exitFullScreenMode();
}
$scope.kbnTopNav.open('add');
};
$scope.enterEditMode = () => {
if ($scope.fullScreenMode) {
$scope.exitFullScreenMode();
}
$scope.kbnTopNav.click('edit');
};
const navActions = {};
navActions[TopNavIds.FULL_SCREEN] = () => setFullScreenMode(true);
navActions[TopNavIds.EXIT_EDIT_MODE] = () => onChangeViewMode(DashboardViewMode.VIEW);
navActions[TopNavIds.ENTER_EDIT_MODE] = () => onChangeViewMode(DashboardViewMode.EDIT);
navActions[TopNavIds.CLONE] = () => {
Expand Down
10 changes: 10 additions & 0 deletions src/core_plugins/kibana/public/dashboard/dashboard_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { createPanelState, getPersistedStateId } from 'plugins/kibana/dashboard/

function getStateDefaults(dashboard, hideWriteControls) {
return {
fullScreenMode: false,
title: dashboard.title,
description: dashboard.description,
timeRestore: dashboard.timeRestore,
Expand Down Expand Up @@ -83,6 +84,15 @@ export class DashboardState {
this.createStateMonitor();
}

getFullScreenMode() {
return this.appState.fullScreenMode;
}

setFullScreenMode(fullScreenMode) {
this.appState.fullScreenMode = fullScreenMode;
this.saveState();
}

registerPanelIndexPatternMap(panelIndex, indexPattern) {
this.panelIndexPatternMapping[panelIndex] = indexPattern;
}
Expand Down
1 change: 1 addition & 0 deletions src/core_plugins/kibana/public/dashboard/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ app.directive('dashboardGrid', function ($compile, Notifier) {
$window.on('resize', safeLayout);
$scope.$on('ready:vis', safeLayout);
$scope.$on('globalNav:update', safeLayout);
$scope.$on('reLayout', safeLayout);
}

// tell gridster to add the panel, and create additional meatadata like $scope
Expand Down
48 changes: 46 additions & 2 deletions src/core_plugins/kibana/public/dashboard/styles/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,51 @@
@import (reference) "~ui/styles/mixins";
@import "~ui/styles/local_search.less";

.fullScreenModePlaceholder {
text-align: center;
width: 100%;
z-index: 50;
height: 0;
bottom: 0;
position: absolute;
}

.exitFullScreenMode {
background-color: @globalColorLightestGray;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
width: 200px;
height: 40px;
left: 0;
right: 0;
bottom: 0;
margin-left: auto;
margin-right: auto;
padding-bottom: 0;
position: fixed;
transform: translateY(22px);
z-index: 50;
display: block;
transition: transform .2s ease-in-out;
border: solid 1px @globalColorLightGray;
border-bottom: 0;

.kuiIcon {
display: block;
}

&:hover {
transform: translateY(0px);
}
}

.exitFullScreenMode:hover {
bottom: 0px;
transition: all .5s ease;
Copy link
Contributor

@snide snide Jun 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a cleaner animation for you...

Does the following

  • Moves the bug to the top, which is where the controls originally start.
  • Uses more reliable vars.
  • Improves the transition by
    • Using transform instead of position (much smoother, gpu now takes over).
    • Puts transition on the base selector, now works on on and off hover, instead of just on.
    • Speeds it up. In general, no hover animation should take longer than 250ms.
    • When in doubt use ease-in-out, rather than just ease.

Note that you should also up the padding to .dashboard-grid to 20px if you move it up. In general I've been adding similar increased padding across Kibana, so it's not just for this PR that we need it.

.exitFullScreenMode {
  background-color: @globalColorLightestGray;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  width: 200px;
  height: 40px;
  left: 0;
  right: 0;
  top: 0;
  margin-left: auto;
  margin-right: auto;
  padding-bottom: 0;
  position: fixed;
  transform: translateY(-26px);
  z-index: 50;
  display: block;
  transition: transform .2s ease-in-out;
  border: solid 1px @globalColorLightGray;

  .kuiIcon {
    display: block;
  }

  &:hover {
    transform: translateY(-1px);
  }
}

}

.tab-dashboard {
background-color: @dashboard-bg;
}
Expand All @@ -13,13 +58,12 @@
dashboard-grid {
display: block;
margin: 0;
padding: 5px;
padding: 20px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we mean to change this here? It seems to add quite a bit of padding even when not in full-screen mode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I've increased the padding on a bunch of our inner panels (see monitoring...etc) to give the controls some space. This was actually one of the few places I missed in my big K6 PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more accessible for those of us with fat fingers! 😉

}

.start-screen {
margin: 20px auto;
background-color: @dashboard-bg;
padding: 20px;
max-width: 800px;
background: tint(@globalColorBlue, 90%);
padding: 40px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function getTopNavConfig(dashboardMode, actions) {
switch (dashboardMode) {
case DashboardViewMode.VIEW:
return [
getFullScreenConfig(actions[TopNavIds.FULL_SCREEN]),
getShareConfig(),
getCloneConfig(actions[TopNavIds.CLONE]),
getEditConfig(actions[TopNavIds.ENTER_EDIT_MODE])];
Expand All @@ -27,6 +28,15 @@ export function getTopNavConfig(dashboardMode, actions) {
}
}

function getFullScreenConfig(action) {
return {
key: 'full screen',
description: 'Full Screen Mode',
testId: 'dashboardFullScreenMode',
run: action
};
}

/**
* @returns {kbnTopNavConfig}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export const TopNavIds = {
SAVE: 'save',
EXIT_EDIT_MODE: 'exitEditMode',
ENTER_EDIT_MODE: 'enterEditMode',
CLONE: 'clone'
CLONE: 'clone',
FULL_SCREEN: 'fullScreenMode',
};
3 changes: 3 additions & 0 deletions src/ui/public/styles/dark-theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
}
}

.exitFullScreenMode {
background-color: @globalColorDarkestGray;
}

// /src/ui/public/styles/bootstrap/forms.less
.form-control {
Expand Down