2014-05-15 08:04:23 -05:00
|
|
|
define([
|
2014-05-27 11:18:05 -05:00
|
|
|
'angular',
|
|
|
|
'jquery',
|
|
|
|
'services/all'
|
2014-05-15 08:04:23 -05:00
|
|
|
],
|
2014-05-27 11:18:05 -05:00
|
|
|
function(angular, $) {
|
|
|
|
"use strict";
|
|
|
|
|
2014-07-28 11:11:52 -05:00
|
|
|
var module = angular.module('grafana.services');
|
2014-05-27 11:18:05 -05:00
|
|
|
|
2014-06-12 06:37:40 -05:00
|
|
|
module.service('dashboardKeybindings', function($rootScope, keyboardManager) {
|
2014-06-08 07:40:44 -05:00
|
|
|
|
2014-06-12 06:37:40 -05:00
|
|
|
this.shortcuts = function(scope) {
|
2014-06-08 07:40:44 -05:00
|
|
|
|
2014-06-12 06:37:40 -05:00
|
|
|
scope.$on('$destroy', function() {
|
|
|
|
keyboardManager.unbind('ctrl+f');
|
|
|
|
keyboardManager.unbind('ctrl+h');
|
|
|
|
keyboardManager.unbind('ctrl+s');
|
|
|
|
keyboardManager.unbind('ctrl+r');
|
|
|
|
keyboardManager.unbind('ctrl+z');
|
2014-09-06 11:05:54 -05:00
|
|
|
keyboardManager.unbind('esc');
|
2014-06-12 06:37:40 -05:00
|
|
|
});
|
|
|
|
|
2014-08-26 09:42:15 -05:00
|
|
|
keyboardManager.bind('ctrl+f', function() {
|
2014-09-24 09:26:39 -05:00
|
|
|
scope.appEvent('show-dash-editor', { src: 'app/partials/search.html' });
|
2014-06-06 23:38:33 -05:00
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
|
|
keyboardManager.bind('ctrl+h', function() {
|
2014-06-12 06:37:40 -05:00
|
|
|
var current = scope.dashboard.hideControls;
|
|
|
|
scope.dashboard.hideControls = !current;
|
2014-06-06 23:38:33 -05:00
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
|
|
keyboardManager.bind('ctrl+s', function(evt) {
|
2014-09-24 09:26:39 -05:00
|
|
|
scope.appEvent('save-dashboard', evt);
|
2014-06-06 23:38:33 -05:00
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
|
|
keyboardManager.bind('ctrl+r', function() {
|
2014-06-12 06:37:40 -05:00
|
|
|
scope.dashboard.emit_refresh();
|
2014-06-06 23:38:33 -05:00
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
|
|
keyboardManager.bind('ctrl+z', function(evt) {
|
2014-09-24 09:26:39 -05:00
|
|
|
scope.appEvent('zoom-out', evt);
|
2014-06-06 23:38:33 -05:00
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
|
|
keyboardManager.bind('esc', function() {
|
|
|
|
var popups = $('.popover.in');
|
|
|
|
if (popups.length > 0) {
|
|
|
|
return;
|
|
|
|
}
|
2014-08-07 02:00:52 -05:00
|
|
|
// close modals
|
|
|
|
var modalData = $(".modal").data();
|
|
|
|
if (modalData && modalData.$scope && modalData.$scope.dismiss) {
|
|
|
|
modalData.$scope.dismiss();
|
|
|
|
}
|
|
|
|
|
2014-09-24 09:26:39 -05:00
|
|
|
scope.appEvent('hide-dash-editor');
|
2014-08-26 09:42:15 -05:00
|
|
|
|
2014-08-13 08:02:57 -05:00
|
|
|
scope.exitFullscreen();
|
2014-06-06 23:38:33 -05:00
|
|
|
}, { inputDisabled: true });
|
2014-05-27 11:18:05 -05:00
|
|
|
};
|
|
|
|
});
|
2014-05-15 08:04:23 -05:00
|
|
|
});
|