Skip to content

Commit

Permalink
full screen mode implementation for dashboard (#12265)
Browse files Browse the repository at this point in the history
* full screen mode implementation

* Have Edit and Add buttons kick you out of full screen mode

* Instruct the grid to resize when switching between full screen and regular modes

* Use new styles and listen for ESC key

* handle dark theme

* Remove full screen option from edit mode

It’s awkward with no obvious save button to escape edit mode.

* Code review comments

* deregister the route handler if the user navigates away from the dashboard page.

* Use a new broadcast event rather than hijacking the window resize one
  • Loading branch information
stacey-gammon authored Jun 23, 2017
1 parent 68bdd7c commit 9981104
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 5 deletions.
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';

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;
}

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

.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

0 comments on commit 9981104

Please sign in to comment.