فهرست منبع

added dropdown menu for panel title, with view fullscreen, edit and duplicate panel options

Torkel Ödegaard 12 سال پیش
والد
کامیت
5472e5f940
2فایلهای تغییر یافته به همراه32 افزوده شده و 4 حذف شده
  1. 10 1
      src/app/directives/kibanaPanel.js
  2. 22 3
      src/app/panels/graphite/module.js

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

@@ -50,7 +50,16 @@ function (angular) {
             '</span>'+
           '</span>' +
 
-          '<span class="row-button row-text panel-title pointer" ng-show="panel.title" ng-click="toggleFullscreen()">' +
+          '<span ng-if="panelMenuItems" 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>' +
+            '<ul class="dropdown-menu" role="menu">' +
+              '<li ng-repeat="item in panelMenuItems"><a ng-click="item.action();">{{item.text}}</a></li>' +
+            '</ul>' +
+          '</span>'+
+
+          '<span ng-if="!panelMenuItems" class="row-button row-text panel-title pointer" ng-show="panel.title">' +
             '{{panel.title}}' +
           '</span>'+
 

+ 22 - 3
src/app/panels/graphite/module.js

@@ -212,6 +212,11 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
 
     $scope.init = function() {
       //$scope.openConfigureModal();
+      $scope.panelMenuItems = [
+        { text: 'View fullscreen',  action: $scope.toggleFullscreen },
+        { text: 'Edit',             action: $scope.openConfigureModal },
+        { text: 'Duplicate',        action: $scope.duplicate }
+      ];
 
       // Hide view options by default
       $scope.options = false;
@@ -439,7 +444,21 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
       series.color = color;
       $scope.panel.aliasColors[series.alias] = series.color;
       $scope.render();
-    }
+    };
+
+    $scope.duplicate = function() {
+      var panelCopy = angular.copy($scope.panel);
+
+      var currentRowSpan = $scope.rowSpan($scope.row);
+      if (currentRowSpan <= 8) {
+        $scope.row.panels.push(panelCopy);
+      }
+      else {
+        var rowCopy = angular.copy($scope.row);
+        rowCopy.panels = [panelCopy];
+        $scope.dashboard.current.rows.push(rowCopy);
+      }
+    };
 
     $scope.toggleFullscreen = function(evt) {
       if ($scope.showFullscreen) {
@@ -587,11 +606,11 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
           };
 
           if(scope.panel.y_format === 'bytes') {
-            options.yaxis.mode = "byte";
+            options.yaxes[0].mode = "byte";
           }
 
           if(scope.panel.y_format === 'short') {
-            options.yaxis.tickFormatter = function(val) {
+            options.yaxes[0].tickFormatter = function(val) {
               return kbn.shortFormat(val,0);
             };
           }