mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Minor code refinements to panel repeat code, #1888
This commit is contained in:
parent
25ef49494b
commit
32e0ce1beb
@ -24,14 +24,11 @@ function (angular, _) {
|
|||||||
if (dashboard.templating.list.length === 0) { return; }
|
if (dashboard.templating.list.length === 0) { return; }
|
||||||
this.dashboard = dashboard;
|
this.dashboard = dashboard;
|
||||||
|
|
||||||
this.handlePanelRepeats();
|
|
||||||
this.handleRowRepeats();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.handlePanelRepeats = function() {
|
|
||||||
var i, j, row, panel;
|
var i, j, row, panel;
|
||||||
for (i = 0; i < this.dashboard.rows.length; i++) {
|
for (i = 0; i < this.dashboard.rows.length; i++) {
|
||||||
row = this.dashboard.rows[i];
|
row = this.dashboard.rows[i];
|
||||||
|
|
||||||
|
// repeat panels first
|
||||||
for (j = 0; j < row.panels.length; j++) {
|
for (j = 0; j < row.panels.length; j++) {
|
||||||
panel = row.panels[j];
|
panel = row.panels[j];
|
||||||
if (panel.repeat) {
|
if (panel.repeat) {
|
||||||
@ -43,13 +40,8 @@ function (angular, _) {
|
|||||||
j = j - 1;
|
j = j - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.handleRowRepeats = function() {
|
// handle row repeats
|
||||||
var i, row;
|
|
||||||
for (i = 0; i < this.dashboard.rows.length; i++) {
|
|
||||||
row = this.dashboard.rows[i];
|
|
||||||
if (row.repeat) {
|
if (row.repeat) {
|
||||||
this.repeatRow(row);
|
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) {
|
this.getRowClone = function(sourceRow, index) {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return sourceRow;
|
return sourceRow;
|
||||||
@ -95,6 +88,7 @@ function (angular, _) {
|
|||||||
return copy;
|
return copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// returns a new panel clone or reuses a clone from previous iteration
|
||||||
this.repeatRow = function(row) {
|
this.repeatRow = function(row) {
|
||||||
var variables = this.dashboard.templating.list;
|
var variables = this.dashboard.templating.list;
|
||||||
var variable = _.findWhere(variables, {name: row.repeat.replace('$', '')});
|
var variable = _.findWhere(variables, {name: row.repeat.replace('$', '')});
|
||||||
|
Loading…
Reference in New Issue
Block a user