From f91e06723526e04cb41300f9903706db033fef55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 3 Nov 2016 15:14:44 +0100 Subject: [PATCH] ux(dashboard): keybinding changes / new, #6442 --- public/app/core/services/keybindingSrv.ts | 49 ++++++++++++++----- .../features/dashboard/dashnav/dashnav.html | 5 ++ .../app/features/dashboard/dashnav/dashnav.ts | 7 +++ public/app/features/org/prefs_control.ts | 6 +-- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index 52e1d09a018..72c25c34303 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -1,6 +1,7 @@ /// import $ from 'jquery'; +import _ from 'lodash'; import coreModule from 'app/core/core_module'; import appEvents from 'app/core/app_events'; @@ -9,10 +10,15 @@ import Mousetrap from 'mousetrap'; export class KeybindingSrv { helpModal: boolean; - bindings: any; /** @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 $rootScope.$on('$routeChangeSuccess', () => { Mousetrap.reset(); @@ -23,9 +29,8 @@ export class KeybindingSrv { this.setupGlobal(); } - setupGlobal() { - this.bind("?", this.showHelpModal); + this.bind(['?', 'h'], this.showHelpModal); this.bind("g h", this.goToHome); this.bind("g a", this.openAlerting); this.bind("g p", this.goToProfile); @@ -54,7 +59,6 @@ export class KeybindingSrv { } showHelpModal() { - console.log('showing help modal'); appEvents.emit('show-modal', { src: 'public/app/partials/help_modal.html', 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) { this.bind('b', () => { dashboard.toggleEditMode(); @@ -82,11 +91,6 @@ export class KeybindingSrv { this.bind(['ctrl+s', 'command+s'], () => { scope.appEvent('save-dashboard'); }); - - this.bind('r', () => { - scope.broadcastRefresh(); - }); - this.bind('ctrl+z', () => { scope.appEvent('zoom-out'); }); @@ -128,7 +132,7 @@ export class KeybindingSrv { }); // delete panel - this.bind('d', () => { + this.bind('r', () => { if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) { var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId); 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', () => { var popups = $('.popover.in'); if (popups.length > 0) { diff --git a/public/app/features/dashboard/dashnav/dashnav.html b/public/app/features/dashboard/dashnav/dashnav.html index a6c32926da6..96594e3157e 100644 --- a/public/app/features/dashboard/dashnav/dashnav.html +++ b/public/app/features/dashboard/dashnav/dashnav.html @@ -64,6 +64,11 @@
  • View JSON
  • Make Editable
  • Save As...
  • +
  • Delete dashboard
  • diff --git a/public/app/features/dashboard/dashnav/dashnav.ts b/public/app/features/dashboard/dashnav/dashnav.ts index 929cc66a5b0..ad3fe8ba6ed 100644 --- a/public/app/features/dashboard/dashnav/dashnav.ts +++ b/public/app/features/dashboard/dashnav/dashnav.ts @@ -33,6 +33,13 @@ export class DashNavCtrl { $location.search(search); }; + $scope.showHelpModal = function() { + $scope.appEvent('show-modal', { + src: 'public/app/partials/help_modal.html', + model: {} + }); + }; + $scope.starDashboard = function() { if ($scope.dashboardMeta.isStarred) { backendSrv.delete('/api/user/stars/dashboard/' + $scope.dashboard.id).then(function() { diff --git a/public/app/features/org/prefs_control.ts b/public/app/features/org/prefs_control.ts index fab51ad02b8..3ea3ec95b5f 100644 --- a/public/app/features/org/prefs_control.ts +++ b/public/app/features/org/prefs_control.ts @@ -53,21 +53,21 @@ var template = `

    Preferences

    - UI Theme + UI Theme
    - Home Dashboard + Home Dashboard
    - +