Commit 4c64bcfa by Torkel Ödegaard

keyboard binding now work again

parent 99d2f537
...@@ -31,16 +31,13 @@ function (angular, $, config, _) { ...@@ -31,16 +31,13 @@ function (angular, $, config, _) {
var module = angular.module('kibana.controllers'); var module = angular.module('kibana.controllers');
module.controller('DashCtrl', function( module.controller('DashCtrl', function(
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, alertSrv, timer) { $scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, timer) {
$scope.editor = { index: 0 }; $scope.editor = { index: 0 };
$scope.init = function() { $scope.init = function() {
$scope.availablePanels = config.panels; $scope.availablePanels = config.panels;
$scope.onAppEvent('setup-dashboard', $scope.setupDashboard);
dashboardKeybindings.shortcuts();
$scope.onAppEvent('setup-dashboard', $scope.setupDashboard, $scope);
}; };
$scope.setupDashboard = function(event, dashboardData) { $scope.setupDashboard = function(event, dashboardData) {
...@@ -62,6 +59,8 @@ function (angular, $, config, _) { ...@@ -62,6 +59,8 @@ function (angular, $, config, _) {
window.document.title = 'Grafana - ' + $scope.dashboard.title; window.document.title = 'Grafana - ' + $scope.dashboard.title;
dashboardKeybindings.shortcuts($scope);
$scope.emitAppEvent("dashboard-loaded", $scope.dashboard); $scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
}; };
......
...@@ -17,12 +17,12 @@ function (angular, config, _) { ...@@ -17,12 +17,12 @@ function (angular, config, _) {
$scope.dashAlerts = alertSrv; $scope.dashAlerts = alertSrv;
}; };
$scope.onAppEvent = function(name, callback, scope) { $rootScope.onAppEvent = function(name, callback) {
var unbind = $rootScope.$on(name, callback); var unbind = $rootScope.$on(name, callback);
scope.$on('$destroy', unbind); this.$on('$destroy', unbind);
}; };
$scope.emitAppEvent = function(name, payload) { $rootScope.emitAppEvent = function(name, payload) {
$rootScope.$emit(name, payload); $rootScope.$emit(name, payload);
}; };
......
...@@ -16,7 +16,7 @@ function (angular, _, config, $) { ...@@ -16,7 +16,7 @@ function (angular, _, config, $) {
$scope.selectedIndex = -1; $scope.selectedIndex = -1;
$scope.results = {dashboards: [], tags: [], metrics: []}; $scope.results = {dashboards: [], tags: [], metrics: []};
$scope.query = { query: 'title:' }; $scope.query = { query: 'title:' };
$scope.onAppEvent('open-search', $scope.openSearch, $scope); $scope.onAppEvent('open-search', $scope.openSearch);
}; };
$scope.keyDown = function (evt) { $scope.keyDown = function (evt) {
......
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
], ],
"editable": true, "editable": true,
"failover": false, "failover": false,
"panel_hints": true,
"style": "dark", "style": "dark",
"pulldowns": [ "pulldowns": [
{ {
......
<div ng-controller="DashCtrl"> <div ng-controller="DashCtrl" body-class>
<div class="navbar navbar-static-top"> <div class="navbar navbar-static-top">
<div class="navbar-inner"> <div class="navbar-inner">
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<div class="row-open" ng-show="!row.collapse"> <div class="row-open" ng-show="!row.collapse">
<div ng-show="row.collapsable" class='row-tab bgPrimary' ng-click="toggle_row(row)"> <div ng-show="row.collapsable" class='row-tab bgPrimary' ng-click="toggle_row(row)">
<span class="row-tab-button"> <span class="row-tab-button">
<i class="icon-caret-right" ></i> <i class="icon-caret-right"></i>
</span> </span>
</div> </div>
<div class='row-tab bgSuccess dropdown' ng-show="row.editable"> <div class='row-tab bgSuccess dropdown' ng-show="row.editable">
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
</div> </div>
<div ng-show='dashboard.editable && dashboard.panel_hints' class="row-fluid add-row-panel-hint"> <div ng-show='dashboard.editable' class="row-fluid add-row-panel-hint">
<div class="span12" style="text-align:right;"> <div class="span12" style="text-align:right;">
<span style="margin-right: 10px;" ng-click="add_row_default()" class="pointer btn btn-info btn-mini"> <span style="margin-right: 10px;" ng-click="add_row_default()" class="pointer btn btn-info btn-mini">
<span><i class="icon-plus-sign"></i> ADD A ROW</span> <span><i class="icon-plus-sign"></i> ADD A ROW</span>
......
...@@ -22,10 +22,7 @@ ...@@ -22,10 +22,7 @@
<select ng-model="dashboard.timezone" class='input-small' ng-options="f for f in ['browser','utc']"></select> <select ng-model="dashboard.timezone" class='input-small' ng-options="f for f in ['browser','utc']"></select>
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small"> Hints <tip>Show 'Add panel' hints in empty spaces</tip></label><input type="checkbox" ng-model="dashboard.panel_hints" ng-checked="dashboard.panel_hints" /> <label class="small">Hide controls (CTRL+H)</label>
</div>
<div class="editor-option">
<label class="small">Hide controls</label>
<input type="checkbox" ng-model="dashboard.hideControls" ng-checked="dashboard.hideControls"> <input type="checkbox" ng-model="dashboard.hideControls" ng-checked="dashboard.hideControls">
</div> </div>
</div> </div>
......
...@@ -8,50 +8,54 @@ function(angular, $) { ...@@ -8,50 +8,54 @@ function(angular, $) {
var module = angular.module('kibana.services'); var module = angular.module('kibana.services');
module.service('dashboardKeybindings', function($rootScope, keyboardManager, dashboard) { module.service('dashboardKeybindings', function($rootScope, keyboardManager) {
this.hasRegistered = false; this.hasRegistered = false;
this.shortcuts = function() { this.shortcuts = function(scope) {
if (this.hasRegistered) {
return;
}
this.hasRegistered = true;
$rootScope.$on('panel-fullscreen-enter', function() { scope.onAppEvent('panel-fullscreen-enter', function() {
$rootScope.fullscreen = true; $rootScope.fullscreen = true;
}); });
$rootScope.$on('panel-fullscreen-exit', function() { scope.onAppEvent('panel-fullscreen-exit', function() {
$rootScope.fullscreen = false; $rootScope.fullscreen = false;
}); });
$rootScope.$on('dashboard-saved', function() { scope.onAppEvent('dashboard-saved', function() {
if ($rootScope.fullscreen) { if ($rootScope.fullscreen) {
$rootScope.$emit('panel-fullscreen-exit'); scope.emitAppEvent('panel-fullscreen-exit');
} }
}); });
scope.$on('$destroy', function() {
console.log('unbind keyboardManager');
keyboardManager.unbind('ctrl+f');
keyboardManager.unbind('ctrl+h');
keyboardManager.unbind('ctrl+s');
keyboardManager.unbind('ctrl+r');
keyboardManager.unbind('ctrl+z');
keyboardManager.unbind('esc');
});
keyboardManager.bind('ctrl+f', function(evt) { keyboardManager.bind('ctrl+f', function(evt) {
$rootScope.$emit('open-search', evt); scope.emitAppEvent('open-search', evt);
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('ctrl+h', function() { keyboardManager.bind('ctrl+h', function() {
var current = dashboard.current.hideControls; var current = scope.dashboard.hideControls;
dashboard.current.hideControls = !current; scope.dashboard.hideControls = !current;
dashboard.current.panel_hints = current;
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('ctrl+s', function(evt) { keyboardManager.bind('ctrl+s', function(evt) {
$rootScope.$emit('save-dashboard', evt); scope.emitAppEvent('save-dashboard', evt);
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('ctrl+r', function() { keyboardManager.bind('ctrl+r', function() {
dashboard.emit_refresh(); scope.dashboard.emit_refresh();
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('ctrl+z', function(evt) { keyboardManager.bind('ctrl+z', function(evt) {
$rootScope.$emit('zoom-out', evt); scope.emitAppEvent('zoom-out', evt);
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('esc', function() { keyboardManager.bind('esc', function() {
...@@ -59,7 +63,7 @@ function(angular, $) { ...@@ -59,7 +63,7 @@ function(angular, $) {
if (popups.length > 0) { if (popups.length > 0) {
return; return;
} }
$rootScope.$emit('panel-fullscreen-exit'); scope.emitAppEvent('panel-fullscreen-exit');
}, { inputDisabled: true }); }, { inputDisabled: true });
}; };
}); });
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</head> </head>
<body ng-cloak body-class ng-controller="GrafanaCtrl"> <body ng-cloak ng-controller="GrafanaCtrl">
<link rel="stylesheet" href="css/bootstrap.light.min.css" ng-if="dashboard.style === 'light'"> <link rel="stylesheet" href="css/bootstrap.light.min.css" ng-if="dashboard.style === 'light'">
<link rel="stylesheet" href="css/bootstrap-responsive.min.css"> <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment