Skip to content

Commit f91e067

Browse files
committed
ux(dashboard): keybinding changes / new, grafana#6442
1 parent 8ea2d3f commit f91e067

File tree

4 files changed

+53
-14
lines changed

4 files changed

+53
-14
lines changed

public/app/core/services/keybindingSrv.ts

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
///<reference path="../../headers/common.d.ts" />
22

33
import $ from 'jquery';
4+
import _ from 'lodash';
45

56
import coreModule from 'app/core/core_module';
67
import appEvents from 'app/core/app_events';
@@ -9,10 +10,15 @@ import Mousetrap from 'mousetrap';
910

1011
export class KeybindingSrv {
1112
helpModal: boolean;
12-
bindings: any;
1313

1414
/** @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+
1622
// clear out all shortcuts on route change
1723
$rootScope.$on('$routeChangeSuccess', () => {
1824
Mousetrap.reset();
@@ -23,9 +29,8 @@ export class KeybindingSrv {
2329
this.setupGlobal();
2430
}
2531

26-
2732
setupGlobal() {
28-
this.bind("?", this.showHelpModal);
33+
this.bind(['?', 'h'], this.showHelpModal);
2934
this.bind("g h", this.goToHome);
3035
this.bind("g a", this.openAlerting);
3136
this.bind("g p", this.goToProfile);
@@ -54,7 +59,6 @@ export class KeybindingSrv {
5459
}
5560

5661
showHelpModal() {
57-
console.log('showing help modal');
5862
appEvents.emit('show-modal', {
5963
src: 'public/app/partials/help_modal.html',
6064
model: {}
@@ -69,6 +73,11 @@ export class KeybindingSrv {
6973
});
7074
}
7175

76+
showDashEditView(view) {
77+
var search = _.extend(this.$location.search(), {editview: view});
78+
this.$location.search(search);
79+
}
80+
7281
setupDashboardBindings(scope, dashboard) {
7382
this.bind('b', () => {
7483
dashboard.toggleEditMode();
@@ -82,11 +91,6 @@ export class KeybindingSrv {
8291
this.bind(['ctrl+s', 'command+s'], () => {
8392
scope.appEvent('save-dashboard');
8493
});
85-
86-
this.bind('r', () => {
87-
scope.broadcastRefresh();
88-
});
89-
9094
this.bind('ctrl+z', () => {
9195
scope.appEvent('zoom-out');
9296
});
@@ -128,14 +132,37 @@ export class KeybindingSrv {
128132
});
129133

130134
// delete panel
131-
this.bind('d', () => {
135+
this.bind('r', () => {
132136
if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) {
133137
var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
134138
panelInfo.row.removePanel(panelInfo.panel);
135139
dashboard.meta.focusPanelId = 0;
136140
}
137141
});
138142

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+
139166
this.bind('esc', () => {
140167
var popups = $('.popover.in');
141168
if (popups.length > 0) {

public/app/features/dashboard/dashnav/dashnav.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
<li ng-if="dashboardMeta.canEdit"><a class="pointer" ng-click="viewJson();">View JSON</a></li>
6565
<li ng-if="contextSrv.isEditor && !dashboard.editable"><a class="pointer" ng-click="makeEditable();">Make Editable</a></li>
6666
<li ng-if="contextSrv.isEditor"><a class="pointer" ng-click="saveDashboardAs();">Save As...</a></li>
67+
<li class="dropdown-menu-item-with-shortcut">
68+
<a class="pointer" ng-click="showHelpModal();">
69+
Help <span class="dropdown-menu-item-shortcut">h</span>
70+
</a>
71+
</li>
6772
<li ng-if="dashboardMeta.canSave"><a class="pointer" ng-click="deleteDashboard();">Delete dashboard</a></li>
6873
</ul>
6974
</li>

public/app/features/dashboard/dashnav/dashnav.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export class DashNavCtrl {
3333
$location.search(search);
3434
};
3535

36+
$scope.showHelpModal = function() {
37+
$scope.appEvent('show-modal', {
38+
src: 'public/app/partials/help_modal.html',
39+
model: {}
40+
});
41+
};
42+
3643
$scope.starDashboard = function() {
3744
if ($scope.dashboardMeta.isStarred) {
3845
backendSrv.delete('/api/user/stars/dashboard/' + $scope.dashboard.id).then(function() {

public/app/features/org/prefs_control.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ var template = `
5353
<h3 class="page-heading">Preferences</h3>
5454
5555
<div class="gf-form">
56-
<span class="gf-form-label width-9">UI Theme</span>
56+
<span class="gf-form-label width-10">UI Theme</span>
5757
<div class="gf-form-select-wrapper max-width-20">
5858
<select class="gf-form-input" ng-model="ctrl.prefs.theme" ng-options="f.value as f.text for f in ctrl.themes"></select>
5959
</div>
6060
</div>
6161
6262
<div class="gf-form">
63-
<span class="gf-form-label width-9">Home Dashboard</span>
63+
<span class="gf-form-label width-10">Home Dashboard</span>
6464
<dashboard-selector class="gf-form-select-wrapper max-width-20 gf-form-select-wrapper--has-help-icon"
6565
model="ctrl.prefs.homeDashboardId">
6666
</dashboard-selector>
6767
</div>
6868
6969
<div class="gf-form">
70-
<label class="gf-form-label width-9">Timezone</label>
70+
<label class="gf-form-label width-10">Timezone</label>
7171
<div class="gf-form-select-wrapper max-width-20">
7272
<select class="gf-form-input" ng-model="ctrl.prefs.timezone" ng-options="f.value as f.text for f in ctrl.timezones"></select>
7373
</div>

0 commit comments

Comments
 (0)