mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ux(dashboar): added shortcut for build mode, switched keybinding lib to mousetrap, supports sequences so also added for Go to home dashboard, open search with starred dashbords prefiltered, go to profile, #6442
This commit is contained in:
@@ -9,7 +9,6 @@ define([
|
||||
'./shareModalCtrl',
|
||||
'./shareSnapshotCtrl',
|
||||
'./dashboard_srv',
|
||||
'./keybindings',
|
||||
'./viewStateSrv',
|
||||
'./timeSrv',
|
||||
'./unsavedChangesSrv',
|
||||
|
@@ -13,7 +13,7 @@ export class DashboardCtrl {
|
||||
constructor(
|
||||
private $scope,
|
||||
private $rootScope,
|
||||
dashboardKeybindings,
|
||||
keybindingSrv,
|
||||
timeSrv,
|
||||
variableSrv,
|
||||
alertingSrv,
|
||||
@@ -61,7 +61,7 @@ export class DashboardCtrl {
|
||||
$scope.dashboardMeta = dashboard.meta;
|
||||
$scope.dashboardViewState = dashboardViewStateSrv.create($scope);
|
||||
|
||||
dashboardKeybindings.shortcuts($scope);
|
||||
keybindingSrv.setupDashboardBindings($scope, dashboard);
|
||||
|
||||
$scope.dashboard.updateSubmenuVisibility();
|
||||
$scope.setWindowTitleAndTheme();
|
||||
|
@@ -1,96 +0,0 @@
|
||||
define([
|
||||
'angular',
|
||||
'jquery',
|
||||
],
|
||||
function(angular, $) {
|
||||
"use strict";
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
|
||||
module.service('dashboardKeybindings', function($rootScope, keyboardManager, $modal, $q) {
|
||||
|
||||
this.shortcuts = function(scope) {
|
||||
|
||||
var unbindDestroy = scope.$on('$destroy', function() {
|
||||
keyboardManager.unbindAll();
|
||||
unbindDestroy();
|
||||
});
|
||||
|
||||
var helpModalScope = null;
|
||||
keyboardManager.bind('shift+?', function() {
|
||||
if (helpModalScope) { return; }
|
||||
|
||||
helpModalScope = $rootScope.$new();
|
||||
var helpModal = $modal({
|
||||
template: 'public/app/partials/help_modal.html',
|
||||
persist: false,
|
||||
show: false,
|
||||
scope: helpModalScope,
|
||||
keyboard: false
|
||||
});
|
||||
|
||||
var unbindModalDestroy = helpModalScope.$on('$destroy', function() {
|
||||
helpModalScope = null;
|
||||
unbindModalDestroy();
|
||||
});
|
||||
|
||||
$q.when(helpModal).then(function(modalEl) { modalEl.modal('show'); });
|
||||
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('f', function() {
|
||||
scope.appEvent('show-dash-search');
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('ctrl+o', function() {
|
||||
var current = scope.dashboard.sharedCrosshair;
|
||||
scope.dashboard.sharedCrosshair = !current;
|
||||
scope.broadcastRefresh();
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('b', function() {
|
||||
scope.dashboard.toggleEditMode();
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('ctrl+s', function(evt) {
|
||||
scope.appEvent('save-dashboard', evt);
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('r', function() {
|
||||
scope.broadcastRefresh();
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('ctrl+z', function(evt) {
|
||||
scope.appEvent('zoom-out', evt);
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('left', function(evt) {
|
||||
scope.appEvent('shift-time-backward', evt);
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('right', function(evt) {
|
||||
scope.appEvent('shift-time-forward', evt);
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('ctrl+i', function(evt) {
|
||||
scope.appEvent('quick-snapshot', evt);
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('esc', function() {
|
||||
var popups = $('.popover.in');
|
||||
if (popups.length > 0) {
|
||||
return;
|
||||
}
|
||||
// close modals
|
||||
var modalData = $(".modal").data();
|
||||
if (modalData && modalData.$scope && modalData.$scope.dismiss) {
|
||||
modalData.$scope.dismiss();
|
||||
}
|
||||
|
||||
scope.appEvent('hide-dash-editor');
|
||||
|
||||
scope.exitFullscreen();
|
||||
}, { inputDisabled: true });
|
||||
};
|
||||
});
|
||||
});
|
@@ -55,12 +55,6 @@
|
||||
checked="dashboard.editable"
|
||||
label-class="width-11">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Build Mode"
|
||||
tooltip="Enable build mode. Shortcut: CTRL+B"
|
||||
checked="dashboard.editMode"
|
||||
label-class="width-11">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Shared Crosshair"
|
||||
tooltip="Shared Crosshair line on all graphs. Shortcut: CTRL+O"
|
||||
|
Reference in New Issue
Block a user