mirror of https://github.com/grafana/grafana
parent
3fe54894a5
commit
1b59fb5be9
@ -0,0 +1,48 @@ |
|||||||
|
define([ |
||||||
|
'angular', |
||||||
|
'lodash', |
||||||
|
], |
||||||
|
function (angular, _) { |
||||||
|
'use strict'; |
||||||
|
|
||||||
|
var module = angular.module('grafana.services'); |
||||||
|
|
||||||
|
module.service('dynamicDashboardSrv', function() { |
||||||
|
|
||||||
|
this.init = function(dashboard) { |
||||||
|
this.handlePanelRepeats(dashboard); |
||||||
|
}; |
||||||
|
|
||||||
|
this.handlePanelRepeats = function(dashboard) { |
||||||
|
var i, j, row, panel; |
||||||
|
for (i = 0; i < dashboard.rows.length; i++) { |
||||||
|
row = dashboard.rows[i]; |
||||||
|
for (j = 0; j < row.panels.length; j++) { |
||||||
|
panel = row.panels[j]; |
||||||
|
if (panel.repeat) { |
||||||
|
this.repeatPanel(panel, row, dashboard); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
this.repeatPanel = function(panel, row, dashboard) { |
||||||
|
var variables = dashboard.templating.list; |
||||||
|
var variable = _.findWhere(variables, {name: panel.repeat.replace('$', '')}); |
||||||
|
if (!variable) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
_.each(variable.options, function(option) { |
||||||
|
var copy = dashboard.duplicatePanel(panel, row); |
||||||
|
copy.repeat = null; |
||||||
|
console.log('duplicatePanel'); |
||||||
|
}); |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
|
Loading…
Reference in new issue