Просмотр исходного кода

Panel edit state is working pretty good now, #672

Torkel Ödegaard 11 лет назад
Родитель
Сommit
4d1102db0b

+ 0 - 4
src/app/controllers/dashLoader.js

@@ -24,10 +24,6 @@ function (angular, _, moment, config) {
       });
       });
     };
     };
 
 
-    $scope.exitFullscreen = function() {
-      $scope.emitAppEvent('panel-fullscreen-exit');
-    };
-
     $scope.set_default = function() {
     $scope.set_default = function() {
       window.localStorage.grafanaDashboardDefault = $location.path();
       window.localStorage.grafanaDashboardDefault = $location.path();
       alertSrv.set('Home Set','This page has been set as your default dashboard','success',5000);
       alertSrv.set('Home Set','This page has been set as your default dashboard','success',5000);

+ 4 - 1
src/app/directives/grafanaGraph.js

@@ -21,7 +21,6 @@ function (angular, $, kbn, moment, _) {
         var legendSideLastValue = null;
         var legendSideLastValue = null;
 
 
         scope.$on('refresh',function() {
         scope.$on('refresh',function() {
-          if (scope.otherPanelInFullscreenMode()) { return; }
           scope.get_data();
           scope.get_data();
         });
         });
 
 
@@ -39,6 +38,10 @@ function (angular, $, kbn, moment, _) {
         // Receive render events
         // Receive render events
         scope.$on('render',function(event, renderData) {
         scope.$on('render',function(event, renderData) {
           data = renderData || data;
           data = renderData || data;
+          if (!data) {
+            scope.get_data();
+            return;
+          }
           annotations = data.annotations || annotations;
           annotations = data.annotations || annotations;
           render_panel();
           render_panel();
         });
         });

+ 1 - 11
src/app/services/dashboard/dashboardKeyBindings.js

@@ -12,16 +12,6 @@ function(angular, $) {
 
 
     this.shortcuts = function(scope) {
     this.shortcuts = function(scope) {
 
 
-      scope.onAppEvent('panel-fullscreen-exit', function() {
-        scope.dashboardViewState.update({ fullscreen: false });
-      });
-
-      scope.onAppEvent('dashboard-saved', function() {
-        if (scope.dashboardViewState.fullscreen) {
-          scope.emitAppEvent('panel-fullscreen-exit');
-        }
-      });
-
       scope.$on('$destroy', function() {
       scope.$on('$destroy', function() {
         keyboardManager.unbind('ctrl+f');
         keyboardManager.unbind('ctrl+f');
         keyboardManager.unbind('ctrl+h');
         keyboardManager.unbind('ctrl+h');
@@ -63,7 +53,7 @@ function(angular, $) {
           modalData.$scope.dismiss();
           modalData.$scope.dismiss();
         }
         }
 
 
-        scope.emitAppEvent('panel-fullscreen-exit');
+        scope.exitFullscreen();
       }, { inputDisabled: true });
       }, { inputDisabled: true });
     };
     };
   });
   });

+ 1 - 1
src/app/services/dashboard/dashboardSrv.js

@@ -10,7 +10,7 @@ function (angular, $, kbn, _) {
 
 
   var module = angular.module('grafana.services');
   var module = angular.module('grafana.services');
 
 
-  module.factory('dashboardSrv', function(timer, $rootScope, $timeout, $location) {
+  module.factory('dashboardSrv', function(timer, $rootScope, $timeout) {
 
 
     function DashboardModel (data) {
     function DashboardModel (data) {
 
 

+ 9 - 2
src/app/services/dashboard/dashboardViewStateSrv.js

@@ -15,6 +15,14 @@ function (angular, _, $) {
     function DashboardViewState($scope) {
     function DashboardViewState($scope) {
       var self = this;
       var self = this;
 
 
+      $scope.exitFullscreen = function() {
+        self.update({ fullscreen: false });
+      };
+
+      $scope.onAppEvent('dashboard-saved', function() {
+        self.update({ fullscreen: false });
+      });
+
       $scope.onAppEvent('$routeUpdate', function() {
       $scope.onAppEvent('$routeUpdate', function() {
         var urlState = self.getQueryStringState();
         var urlState = self.getQueryStringState();
         if (self.needsSync(urlState)) {
         if (self.needsSync(urlState)) {
@@ -45,9 +53,8 @@ function (angular, _, $) {
     };
     };
 
 
     DashboardViewState.prototype.update = function(state, skipUrlSync) {
     DashboardViewState.prototype.update = function(state, skipUrlSync) {
-      console.log('viewstate update: ', state);
-
       _.extend(this, state);
       _.extend(this, state);
+
       if (!this.fullscreen) {
       if (!this.fullscreen) {
         this.panelId = null;
         this.panelId = null;
         this.edit = false;
         this.edit = false;

+ 2 - 42
src/app/services/panelSrv.js

@@ -1,9 +1,8 @@
 define([
 define([
   'angular',
   'angular',
   'lodash',
   'lodash',
-  'jquery',
 ],
 ],
-function (angular, _, $) {
+function (angular, _) {
   'use strict';
   'use strict';
 
 
   var module = angular.module('grafana.services');
   var module = angular.module('grafana.services');
@@ -71,46 +70,6 @@ function (angular, _, $) {
         });
         });
       };
       };
 
 
-      $scope.enterFullscreenMode = function(options) {
-        var docHeight = $(window).height();
-        var editHeight = Math.floor(docHeight * 0.3);
-        var fullscreenHeight = Math.floor(docHeight * 0.7);
-        var oldTimeRange = $scope.range;
-
-        $scope.height = options.edit ? editHeight : fullscreenHeight;
-        $scope.editMode = options.edit;
-
-        if (!$scope.fullscreen) {
-          var closeEditMode = $rootScope.$on('panel-fullscreen-exit', function() {
-            $scope.editMode = false;
-            $scope.fullscreen = false;
-            delete $scope.height;
-
-            closeEditMode();
-
-            $timeout(function() {
-              if (oldTimeRange !== $scope.range) {
-                $scope.dashboard.emit_refresh();
-              }
-              else {
-                $scope.$emit('render');
-              }
-            });
-          });
-        }
-
-        $(window).scrollTop(0);
-
-        $scope.dashboardViewState.update({ fullscreen: true, edit: $scope.editMode, panelId: $scope.panel.id });
-
-        $scope.fullscreen = true;
-
-        $timeout(function() {
-          $scope.$emit('render');
-        });
-
-      };
-
       $scope.addDataQuery = function() {
       $scope.addDataQuery = function() {
         $scope.panel.targets.push({target: ''});
         $scope.panel.targets.push({target: ''});
       };
       };
@@ -165,6 +124,7 @@ function (angular, _, $) {
 
 
           panel_get_data();
           panel_get_data();
         };
         };
+
         if (!$scope.skipDataOnInit) {
         if (!$scope.skipDataOnInit) {
           $scope.get_data();
           $scope.get_data();
         }
         }