Przeglądaj źródła

added more keyboard shortcuts to open search, save and toggle controls

Torkel Ödegaard 12 lat temu
rodzic
commit
e7dd50eda5

+ 25 - 2
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) {

+ 5 - 1
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) {

+ 10 - 10
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("");
     };

+ 1 - 1
src/app/directives/kibanaPanel.js

@@ -50,7 +50,7 @@ function (angular) {
             '</span>'+
           '</span>' +
 
-          '<span ng-if="panelMenuItems" class="dropdown" ng-show="panel.title">' +
+          '<span ng-if="panelMeta.menuItems" class="dropdown" ng-show="panel.title">' +
             '<span class="pointer dropdown-toggle row-text row-button panel-title pointer" data-toggle="dropdown" tabindex="1">' +
               '{{panel.title}}' +
             '</span>' +

+ 8 - 13
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 <br /><br />"
     };
@@ -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;
     };

+ 1 - 1
src/app/partials/search.html

@@ -46,7 +46,7 @@
               ng-class="{'selected': $index === selectedIndex }">
             <td><a ng-click="elasticsearch_delete(row._id)"><i class="icon-remove"></i></a></td>
             <td style="width:100%"><a href="#/dashboard/elasticsearch/{{row._id}}" bo-text="row._id"></a></td>
-            <td><a><i class="icon-share" ng-click="share = dashboard.share_link(row._id,'elasticsearch',row._id)" bs-modal="'app/panels/dashcontrol/share.html'"></i></a></td>
+            <td><a><i class="icon-share" ng-click="share = dashboard.share_link(row._id,'elasticsearch',row._id)" bs-modal="'app/partials/dashLoaderShare.html'"></i></a></td>
           </tr>
         </table>
       </div>

+ 1 - 0
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');
         });
       }