From 32e0ce1beb8c738fae6e08784be441e8e0c3e240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 30 Apr 2015 10:50:23 +0200 Subject: [PATCH] Minor code refinements to panel repeat code, #1888 --- .../features/dashboard/dynamicDashboardSrv.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/public/app/features/dashboard/dynamicDashboardSrv.js b/public/app/features/dashboard/dynamicDashboardSrv.js index 51309a0841d..cfa824e3402 100644 --- a/public/app/features/dashboard/dynamicDashboardSrv.js +++ b/public/app/features/dashboard/dynamicDashboardSrv.js @@ -24,14 +24,11 @@ function (angular, _) { if (dashboard.templating.list.length === 0) { return; } this.dashboard = dashboard; - this.handlePanelRepeats(); - this.handleRowRepeats(); - }; - - this.handlePanelRepeats = function() { var i, j, row, panel; for (i = 0; i < this.dashboard.rows.length; i++) { row = this.dashboard.rows[i]; + + // repeat panels first for (j = 0; j < row.panels.length; j++) { panel = row.panels[j]; if (panel.repeat) { @@ -43,13 +40,8 @@ function (angular, _) { j = j - 1; } } - } - }; - this.handleRowRepeats = function() { - var i, row; - for (i = 0; i < this.dashboard.rows.length; i++) { - row = this.dashboard.rows[i]; + // handle row repeats if (row.repeat) { this.repeatRow(row); } @@ -61,6 +53,7 @@ function (angular, _) { } }; + // returns a new row clone or reuses a clone from previous iteration this.getRowClone = function(sourceRow, index) { if (index === 0) { return sourceRow; @@ -95,6 +88,7 @@ function (angular, _) { return copy; }; + // returns a new panel clone or reuses a clone from previous iteration this.repeatRow = function(row) { var variables = this.dashboard.templating.list; var variable = _.findWhere(variables, {name: row.repeat.replace('$', '')});