1
1
///<reference path="../../headers/common.d.ts" />
2
2
3
3
import $ from 'jquery' ;
4
+ import _ from 'lodash' ;
4
5
5
6
import coreModule from 'app/core/core_module' ;
6
7
import appEvents from 'app/core/app_events' ;
@@ -9,10 +10,15 @@ import Mousetrap from 'mousetrap';
9
10
10
11
export class KeybindingSrv {
11
12
helpModal : boolean ;
12
- bindings : any ;
13
13
14
14
/** @ngInject */
15
- constructor ( private $rootScope , private $modal , private $location , private contextSrv ) {
15
+ constructor (
16
+ private $rootScope ,
17
+ private $modal ,
18
+ private $location ,
19
+ private contextSrv ,
20
+ private $timeout ) {
21
+
16
22
// clear out all shortcuts on route change
17
23
$rootScope . $on ( '$routeChangeSuccess' , ( ) => {
18
24
Mousetrap . reset ( ) ;
@@ -23,9 +29,8 @@ export class KeybindingSrv {
23
29
this . setupGlobal ( ) ;
24
30
}
25
31
26
-
27
32
setupGlobal ( ) {
28
- this . bind ( "?" , this . showHelpModal ) ;
33
+ this . bind ( [ '?' , 'h' ] , this . showHelpModal ) ;
29
34
this . bind ( "g h" , this . goToHome ) ;
30
35
this . bind ( "g a" , this . openAlerting ) ;
31
36
this . bind ( "g p" , this . goToProfile ) ;
@@ -54,7 +59,6 @@ export class KeybindingSrv {
54
59
}
55
60
56
61
showHelpModal ( ) {
57
- console . log ( 'showing help modal' ) ;
58
62
appEvents . emit ( 'show-modal' , {
59
63
src : 'public/app/partials/help_modal.html' ,
60
64
model : { }
@@ -69,6 +73,11 @@ export class KeybindingSrv {
69
73
} ) ;
70
74
}
71
75
76
+ showDashEditView ( view ) {
77
+ var search = _ . extend ( this . $location . search ( ) , { editview : view } ) ;
78
+ this . $location . search ( search ) ;
79
+ }
80
+
72
81
setupDashboardBindings ( scope , dashboard ) {
73
82
this . bind ( 'b' , ( ) => {
74
83
dashboard . toggleEditMode ( ) ;
@@ -82,11 +91,6 @@ export class KeybindingSrv {
82
91
this . bind ( [ 'ctrl+s' , 'command+s' ] , ( ) => {
83
92
scope . appEvent ( 'save-dashboard' ) ;
84
93
} ) ;
85
-
86
- this . bind ( 'r' , ( ) => {
87
- scope . broadcastRefresh ( ) ;
88
- } ) ;
89
-
90
94
this . bind ( 'ctrl+z' , ( ) => {
91
95
scope . appEvent ( 'zoom-out' ) ;
92
96
} ) ;
@@ -128,14 +132,37 @@ export class KeybindingSrv {
128
132
} ) ;
129
133
130
134
// delete panel
131
- this . bind ( 'd ' , ( ) => {
135
+ this . bind ( 'r ' , ( ) => {
132
136
if ( dashboard . meta . focusPanelId && dashboard . meta . canEdit ) {
133
137
var panelInfo = dashboard . getPanelInfoById ( dashboard . meta . focusPanelId ) ;
134
138
panelInfo . row . removePanel ( panelInfo . panel ) ;
135
139
dashboard . meta . focusPanelId = 0 ;
136
140
}
137
141
} ) ;
138
142
143
+ // delete panel
144
+ this . bind ( 's' , ( ) => {
145
+ if ( dashboard . meta . focusPanelId ) {
146
+ var shareScope = scope . $new ( ) ;
147
+ var panelInfo = dashboard . getPanelInfoById ( dashboard . meta . focusPanelId ) ;
148
+ shareScope . panel = panelInfo . panel ;
149
+ shareScope . dashboard = dashboard ;
150
+
151
+ appEvents . emit ( 'show-modal' , {
152
+ src : 'public/app/features/dashboard/partials/shareModal.html' ,
153
+ scope : shareScope
154
+ } ) ;
155
+ }
156
+ } ) ;
157
+
158
+ this . bind ( 'd r' , ( ) => {
159
+ scope . broadcastRefresh ( ) ;
160
+ } ) ;
161
+
162
+ this . bind ( 'd s' , ( ) => {
163
+ this . showDashEditView ( 'settings' ) ;
164
+ } ) ;
165
+
139
166
this . bind ( 'esc' , ( ) => {
140
167
var popups = $ ( '.popover.in' ) ;
141
168
if ( popups . length > 0 ) {
0 commit comments