Commit 4c64bcfa by Torkel Ödegaard

keyboard binding now work again

parent 99d2f537
......@@ -31,16 +31,13 @@ function (angular, $, config, _) {
var module = angular.module('kibana.controllers');
module.controller('DashCtrl', function(
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, alertSrv, timer) {
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, timer) {
$scope.editor = { index: 0 };
$scope.init = function() {
$scope.availablePanels = config.panels;
dashboardKeybindings.shortcuts();
$scope.onAppEvent('setup-dashboard', $scope.setupDashboard, $scope);
$scope.onAppEvent('setup-dashboard', $scope.setupDashboard);
};
$scope.setupDashboard = function(event, dashboardData) {
......@@ -62,6 +59,8 @@ function (angular, $, config, _) {
window.document.title = 'Grafana - ' + $scope.dashboard.title;
dashboardKeybindings.shortcuts($scope);
$scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
};
......
......@@ -17,12 +17,12 @@ function (angular, config, _) {
$scope.dashAlerts = alertSrv;
};
$scope.onAppEvent = function(name, callback, scope) {
$rootScope.onAppEvent = function(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);
};
......
......@@ -16,7 +16,7 @@ function (angular, _, config, $) {
$scope.selectedIndex = -1;
$scope.results = {dashboards: [], tags: [], metrics: []};
$scope.query = { query: 'title:' };
$scope.onAppEvent('open-search', $scope.openSearch, $scope);
$scope.onAppEvent('open-search', $scope.openSearch);
};
$scope.keyDown = function (evt) {
......
......@@ -92,7 +92,6 @@
],
"editable": true,
"failover": false,
"panel_hints": true,
"style": "dark",
"pulldowns": [
{
......
<div ng-controller="DashCtrl">
<div ng-controller="DashCtrl" body-class>
<div class="navbar navbar-static-top">
<div class="navbar-inner">
......@@ -42,7 +42,7 @@
<div class="row-open" ng-show="!row.collapse">
<div ng-show="row.collapsable" class='row-tab bgPrimary' ng-click="toggle_row(row)">
<span class="row-tab-button">
<i class="icon-caret-right" ></i>
<i class="icon-caret-right"></i>
</span>
</div>
<div class='row-tab bgSuccess dropdown' ng-show="row.editable">
......@@ -110,7 +110,7 @@
</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;">
<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>
......
......@@ -22,10 +22,7 @@
<select ng-model="dashboard.timezone" class='input-small' ng-options="f for f in ['browser','utc']"></select>
</div>
<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" />
</div>
<div class="editor-option">
<label class="small">Hide controls</label>
<label class="small">Hide controls (CTRL+H)</label>
<input type="checkbox" ng-model="dashboard.hideControls" ng-checked="dashboard.hideControls">
</div>
</div>
......
......@@ -8,50 +8,54 @@ function(angular, $) {
var module = angular.module('kibana.services');
module.service('dashboardKeybindings', function($rootScope, keyboardManager, dashboard) {
module.service('dashboardKeybindings', function($rootScope, keyboardManager) {
this.hasRegistered = false;
this.shortcuts = function() {
if (this.hasRegistered) {
return;
}
this.hasRegistered = true;
this.shortcuts = function(scope) {
$rootScope.$on('panel-fullscreen-enter', function() {
scope.onAppEvent('panel-fullscreen-enter', function() {
$rootScope.fullscreen = true;
});
$rootScope.$on('panel-fullscreen-exit', function() {
scope.onAppEvent('panel-fullscreen-exit', function() {
$rootScope.fullscreen = false;
});
$rootScope.$on('dashboard-saved', function() {
scope.onAppEvent('dashboard-saved', function() {
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) {
$rootScope.$emit('open-search', evt);
scope.emitAppEvent('open-search', evt);
}, { inputDisabled: true });
keyboardManager.bind('ctrl+h', function() {
var current = dashboard.current.hideControls;
dashboard.current.hideControls = !current;
dashboard.current.panel_hints = current;
var current = scope.dashboard.hideControls;
scope.dashboard.hideControls = !current;
}, { inputDisabled: true });
keyboardManager.bind('ctrl+s', function(evt) {
$rootScope.$emit('save-dashboard', evt);
scope.emitAppEvent('save-dashboard', evt);
}, { inputDisabled: true });
keyboardManager.bind('ctrl+r', function() {
dashboard.emit_refresh();
scope.dashboard.emit_refresh();
}, { inputDisabled: true });
keyboardManager.bind('ctrl+z', function(evt) {
$rootScope.$emit('zoom-out', evt);
scope.emitAppEvent('zoom-out', evt);
}, { inputDisabled: true });
keyboardManager.bind('esc', function() {
......@@ -59,7 +63,7 @@ function(angular, $) {
if (popups.length > 0) {
return;
}
$rootScope.$emit('panel-fullscreen-exit');
scope.emitAppEvent('panel-fullscreen-exit');
}, { inputDisabled: true });
};
});
......
......@@ -18,7 +18,7 @@
</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-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