ソースを参照

Changes to unsaved changes service to ignore repeated panels and rows, #1888

Torkel Ödegaard 10 年 前
コミット
f6a61c1ec5

+ 0 - 3
public/app/features/dashboard/dynamicDashboardSrv.js

@@ -85,9 +85,6 @@ function (angular, _) {
           panel = copy.panels[i];
           panel.id = this.dashboard.getNextPanelId();
         }
-
-      } else {
-        // update reused instance
       }
 
       copy.repeat = null;

+ 23 - 0
public/app/features/dashboard/unsavedChangesSrv.js

@@ -81,6 +81,26 @@ function(angular, _, config) {
       });
     };
 
+    this.cleanDashboardFromRepeatedPanelsAndRows = function(dash) {
+      dash.rows = _.filter(dash.rows, function(row) {
+        if (row.repeatRowId) {
+          console.log('filtering out row');
+          return false;
+        }
+
+        row.panels = _.filter(row.panels, function(panel) {
+          if (panel.repeatPanelId) {
+            return false;
+          }
+          // remove scopedVars
+          panel.scopedVars = null;
+          return true;
+        });
+
+        return true;
+      });
+    };
+
     this.has_unsaved_changes = function() {
       if (!self.original) {
         return false;
@@ -106,6 +126,9 @@ function(angular, _, config) {
         }
       });
 
+      this.cleanDashboardFromRepeatedPanelsAndRows(current);
+      this.cleanDashboardFromRepeatedPanelsAndRows(original);
+
       // ignore some panel and row stuff
       current.forEachPanel(function(panel, panelIndex, row, rowIndex) {
         var originalRow = original.rows[rowIndex];