Parcourir la source

moved an expensive binding expression into a directive and a groupWatch

Torkel Ödegaard il y a 11 ans
Parent
commit
cd79b73cb0

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

@@ -84,10 +84,6 @@ function (angular, $, config, _) {
       };
     };
 
-    $scope.row_style = function(row) {
-      return { 'min-height': row.collapse ? '5px' : row.height };
-    };
-
     $scope.panel_path =function(type) {
       if(type) {
         return 'app/panels/'+type.replace(".","/");

+ 5 - 2
src/app/controllers/grafanaCtrl.js

@@ -78,10 +78,8 @@ function (angular, config, _, $) {
 
     $scope.initProfiling = function() {
       var count = 0;
-      console.log("registering digest counter");
 
       $scope.$watch(function digestCounter() {
-        console.log(1);
         count++;
       }, function() {
       });
@@ -96,6 +94,11 @@ function (angular, config, _, $) {
 
           var timeTaken = $rootScope.performance.allPanelsInitialized - $rootScope.performance.dashboardLoadStart;
           console.log("Dashboard::Performance - All panels initialized in " + timeTaken + " ms");
+
+          var rootDigestStart = window.performance.now();
+          $rootScope.$apply();
+          console.log("Dashboard::Performance Root Digest " + (window.performance.now() - rootDigestStart));
+
         }, 3000);
 
       });

+ 9 - 1
src/app/controllers/row.js

@@ -32,7 +32,7 @@ function (angular, app, _) {
       }
     };
 
-     // This can be overridden by individual panels
+    // This can be overridden by individual panels
     $scope.close_edit = function() {
       $scope.$broadcast('render');
     };
@@ -108,4 +108,12 @@ function (angular, app, _) {
 
   });
 
+  module.directive('rowHeight', function() {
+    return function(scope, element) {
+      scope.$watchGroup(['row.collapse', 'row.height'], function() {
+        element[0].style.minHeight = scope.row.collapse ? '5px' : scope.row.height;
+      });
+    };
+  });
+
 });

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

@@ -27,7 +27,7 @@
     <div>
       <div class="grafana-container container">
         <!-- Rows -->
-        <div class="grafana-row" ng-controller="RowCtrl" ng-repeat="(row_name, row) in dashboard.rows" ng-style="row_style(row)">
+        <div class="grafana-row" ng-controller="RowCtrl" ng-repeat="(row_name, row) in dashboard.rows" row-height>
           <div class="row-control">
             <div class="row-control-inner" style="padding:0px;margin:0px;position:relative;">
               <div class="row-close" ng-show="row.collapse" data-placement="bottom" >