|
@@ -1,6 +1,7 @@
|
|
|
///<reference path="../../headers/common.d.ts" />
|
|
///<reference path="../../headers/common.d.ts" />
|
|
|
|
|
|
|
|
import $ from 'jquery';
|
|
import $ from 'jquery';
|
|
|
|
|
+import _ from 'lodash';
|
|
|
|
|
|
|
|
import coreModule from 'app/core/core_module';
|
|
import coreModule from 'app/core/core_module';
|
|
|
import appEvents from 'app/core/app_events';
|
|
import appEvents from 'app/core/app_events';
|
|
@@ -9,10 +10,15 @@ import Mousetrap from 'mousetrap';
|
|
|
|
|
|
|
|
export class KeybindingSrv {
|
|
export class KeybindingSrv {
|
|
|
helpModal: boolean;
|
|
helpModal: boolean;
|
|
|
- bindings: any;
|
|
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
/** @ngInject */
|
|
|
- constructor(private $rootScope, private $modal, private $location, private contextSrv) {
|
|
|
|
|
|
|
+ constructor(
|
|
|
|
|
+ private $rootScope,
|
|
|
|
|
+ private $modal,
|
|
|
|
|
+ private $location,
|
|
|
|
|
+ private contextSrv,
|
|
|
|
|
+ private $timeout) {
|
|
|
|
|
+
|
|
|
// clear out all shortcuts on route change
|
|
// clear out all shortcuts on route change
|
|
|
$rootScope.$on('$routeChangeSuccess', () => {
|
|
$rootScope.$on('$routeChangeSuccess', () => {
|
|
|
Mousetrap.reset();
|
|
Mousetrap.reset();
|
|
@@ -23,9 +29,8 @@ export class KeybindingSrv {
|
|
|
this.setupGlobal();
|
|
this.setupGlobal();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
setupGlobal() {
|
|
setupGlobal() {
|
|
|
- this.bind("?", this.showHelpModal);
|
|
|
|
|
|
|
+ this.bind(['?', 'h'], this.showHelpModal);
|
|
|
this.bind("g h", this.goToHome);
|
|
this.bind("g h", this.goToHome);
|
|
|
this.bind("g a", this.openAlerting);
|
|
this.bind("g a", this.openAlerting);
|
|
|
this.bind("g p", this.goToProfile);
|
|
this.bind("g p", this.goToProfile);
|
|
@@ -54,7 +59,6 @@ export class KeybindingSrv {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
showHelpModal() {
|
|
showHelpModal() {
|
|
|
- console.log('showing help modal');
|
|
|
|
|
appEvents.emit('show-modal', {
|
|
appEvents.emit('show-modal', {
|
|
|
src: 'public/app/partials/help_modal.html',
|
|
src: 'public/app/partials/help_modal.html',
|
|
|
model: {}
|
|
model: {}
|
|
@@ -69,6 +73,11 @@ export class KeybindingSrv {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ showDashEditView(view) {
|
|
|
|
|
+ var search = _.extend(this.$location.search(), {editview: view});
|
|
|
|
|
+ this.$location.search(search);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
setupDashboardBindings(scope, dashboard) {
|
|
setupDashboardBindings(scope, dashboard) {
|
|
|
this.bind('b', () => {
|
|
this.bind('b', () => {
|
|
|
dashboard.toggleEditMode();
|
|
dashboard.toggleEditMode();
|
|
@@ -82,11 +91,6 @@ export class KeybindingSrv {
|
|
|
this.bind(['ctrl+s', 'command+s'], () => {
|
|
this.bind(['ctrl+s', 'command+s'], () => {
|
|
|
scope.appEvent('save-dashboard');
|
|
scope.appEvent('save-dashboard');
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- this.bind('r', () => {
|
|
|
|
|
- scope.broadcastRefresh();
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
this.bind('ctrl+z', () => {
|
|
this.bind('ctrl+z', () => {
|
|
|
scope.appEvent('zoom-out');
|
|
scope.appEvent('zoom-out');
|
|
|
});
|
|
});
|
|
@@ -128,7 +132,7 @@ export class KeybindingSrv {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// delete panel
|
|
// delete panel
|
|
|
- this.bind('d', () => {
|
|
|
|
|
|
|
+ this.bind('r', () => {
|
|
|
if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) {
|
|
if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) {
|
|
|
var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
|
|
var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
|
|
|
panelInfo.row.removePanel(panelInfo.panel);
|
|
panelInfo.row.removePanel(panelInfo.panel);
|
|
@@ -136,6 +140,29 @@ export class KeybindingSrv {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // delete panel
|
|
|
|
|
+ this.bind('s', () => {
|
|
|
|
|
+ if (dashboard.meta.focusPanelId) {
|
|
|
|
|
+ var shareScope = scope.$new();
|
|
|
|
|
+ var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
|
|
|
|
|
+ shareScope.panel = panelInfo.panel;
|
|
|
|
|
+ shareScope.dashboard = dashboard;
|
|
|
|
|
+
|
|
|
|
|
+ appEvents.emit('show-modal', {
|
|
|
|
|
+ src: 'public/app/features/dashboard/partials/shareModal.html',
|
|
|
|
|
+ scope: shareScope
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.bind('d r', () => {
|
|
|
|
|
+ scope.broadcastRefresh();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.bind('d s', () => {
|
|
|
|
|
+ this.showDashEditView('settings');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
this.bind('esc', () => {
|
|
this.bind('esc', () => {
|
|
|
var popups = $('.popover.in');
|
|
var popups = $('.popover.in');
|
|
|
if (popups.length > 0) {
|
|
if (popups.length > 0) {
|