From e7dd50eda501612ea684a0634fbb971280f29fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 29 Dec 2013 11:46:36 +0100 Subject: [PATCH] added more keyboard shortcuts to open search, save and toggle controls --- src/app/controllers/dash.js | 27 +++++++++++++++++++++++++-- src/app/controllers/dashLoader.js | 6 +++++- src/app/controllers/search.js | 20 ++++++++++---------- src/app/directives/kibanaPanel.js | 2 +- src/app/panels/graphite/module.js | 21 ++++++++------------- src/app/partials/search.html | 2 +- src/vendor/angular/angular-strap.js | 1 + 7 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index 39e9fe7e9ee..ffc57721385 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -19,11 +19,12 @@ define([ 'angular', + 'jquery', 'config', 'underscore', 'services/all' ], -function (angular, config, _) { +function (angular, $, config, _) { "use strict"; var module = angular.module('kibana.controllers'); @@ -60,6 +61,10 @@ function (angular, config, _) { $scope.ejs = ejsResource(config.elasticsearch); + $scope.bindKeyboardShortcuts(); + }; + + $scope.bindKeyboardShortcuts = function() { $rootScope.$on('panel-fullscreen-enter', function() { $scope.fullscreenPanelExists = true; }); @@ -68,9 +73,27 @@ function (angular, config, _) { $scope.fullscreenPanelExists = false; }); + keyboardManager.bind('ctrl+f', function(evt) { + $rootScope.$emit('open-search', evt); + }, { inputDisabled: true }); + + keyboardManager.bind('ctrl+h', function(evt) { + var current = dashboard.current.hideControls; + dashboard.current.hideControls = !current; + dashboard.current.panel_hints = !current; + }, { inputDisabled: true }); + + keyboardManager.bind('ctrl+s', function(evt) { + $rootScope.$emit('save-dashboard', evt); + }, { inputDisabled: true }); + keyboardManager.bind('esc', function() { + var popups = $('.popover.in'); + if (popups.length > 0) { + return; + } $rootScope.$emit('panel-fullscreen-exit'); - }); + }, { inputDisabled: true }); }; $scope.countWatchers = function (scopeStart) { diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index 78b415f8351..15f12ea6b61 100644 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -7,13 +7,17 @@ function (angular, _) { var module = angular.module('kibana.controllers'); - module.controller('dashLoader', function($scope, $http, timer, dashboard, alertSrv, $location) { + module.controller('dashLoader', function($scope, $rootScope, $http, timer, dashboard, alertSrv, $location) { $scope.loader = dashboard.current.loader; $scope.init = function() { $scope.gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/; $scope.gist = $scope.gist || {}; $scope.elasticsearch = $scope.elasticsearch || {}; + + $rootScope.$on('save-dashboard', function() { + $scope.elasticsearch_save('dashboard', false); + }); }; $scope.showDropdown = function(type) { diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index 025656aca8f..59f621a9cd9 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -9,24 +9,20 @@ function (angular, _, config, $) { var module = angular.module('kibana.controllers'); - module.controller('SearchCtrl', function($scope, dashboard, keyboardManager, $element, $location) { + module.controller('SearchCtrl', function($scope, $rootScope, dashboard, $element, $location) { $scope.init = function() { $scope.elasticsearch = $scope.elasticsearch || {}; $scope.giveSearchFocus = 0; $scope.selectedIndex = -1; - /*keyboardManager.bind('shift+s', function() { - $element.find('.dropdown').addClass('open'); - $scope.giveSearchFocus += 1; - });*/ - - keyboardManager.bind('esc', function() { - $element.find('.dropdown').removeClass('open'); - }); + $rootScope.$on('open-search', $scope.openSearch); }; $scope.keyDown = function (evt) { + if (evt.keyCode === 27) { + $element.find('.dropdown-toggle').dropdown('toggle'); + } if (evt.keyCode === 40) { $scope.selectedIndex++; } @@ -99,7 +95,11 @@ function (angular, _, config, $) { }); }; - $scope.openSearch = function () { + $scope.openSearch = function (evt) { + if (evt) { + $element.find('.dropdown-toggle').dropdown('toggle'); + } + $scope.giveSearchFocus = $scope.giveSearchFocus + 1; $scope.elasticsearch_dblist(""); }; diff --git a/src/app/directives/kibanaPanel.js b/src/app/directives/kibanaPanel.js index 27db676bc12..679d641c5e3 100644 --- a/src/app/directives/kibanaPanel.js +++ b/src/app/directives/kibanaPanel.js @@ -50,7 +50,7 @@ function (angular) { ''+ '' + - '' + + '' + '' + '{{panel.title}}' + '' + diff --git a/src/app/panels/graphite/module.js b/src/app/panels/graphite/module.js index 1e9ee882ab9..26cf9942ad2 100644 --- a/src/app/panels/graphite/module.js +++ b/src/app/panels/graphite/module.js @@ -37,14 +37,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { module.controller('graphite', function($scope, $rootScope, filterSrv, graphiteSrv, $timeout) { $scope.panelMeta = { - modals : [ - { - description: "Inspect", - icon: "icon-info-sign", - partial: "app/partials/inspector.html", - show: $scope.panel.spyable - } - ], + modals : [], editorTabs: [], fullEditorTabs : [ @@ -61,6 +54,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) { src:'app/panels/graphite/styleEditor.html' } ], + + menuItems: [ + { text: 'View fullscreen', action: $scope.toggleFullscreen }, + { text: 'Edit', action: $scope.openConfigureModal }, + { text: 'Duplicate', action: $scope.duplicate } + ], + status : "Unstable", description : "Graphite graphing panel

" }; @@ -419,11 +419,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { $scope.enterFullscreenMode({edit: true}); }; - // I really don't like this function, too much dom manip. Break out into directive? - $scope.populate_modal = function(request) { - $scope.inspector = angular.toJson(request,true); - }; - $scope.set_refresh = function (state) { $scope.refresh = state; }; diff --git a/src/app/partials/search.html b/src/app/partials/search.html index e755774e31e..610ff4a9ba8 100644 --- a/src/app/partials/search.html +++ b/src/app/partials/search.html @@ -46,7 +46,7 @@ ng-class="{'selected': $index === selectedIndex }"> - + diff --git a/src/vendor/angular/angular-strap.js b/src/vendor/angular/angular-strap.js index 281ce1145f4..187a44bb98e 100644 --- a/src/vendor/angular/angular-strap.js +++ b/src/vendor/angular/angular-strap.js @@ -546,6 +546,7 @@ angular.module('$strap.directives').directive('bsPopover', [ $('body').on('keyup', function (ev) { if (ev.keyCode === 27) { $('.popover.in').each(function () { + debugger; $(this).popover('hide'); }); }