mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Working on panel repeat
This commit is contained in:
parent
1b59fb5be9
commit
5de499c7f6
@ -33,9 +33,15 @@ function (angular, _) {
|
||||
return;
|
||||
}
|
||||
|
||||
dashboard.scopedVars = {
|
||||
panel: {}
|
||||
};
|
||||
|
||||
_.each(variable.options, function(option) {
|
||||
var copy = dashboard.duplicatePanel(panel, row);
|
||||
copy.repeat = null;
|
||||
dashboard.scopedVars.panel[panel.id] = {};
|
||||
dashboard.scopedVars.panel[panel.id][variable.name] = option.value;
|
||||
console.log('duplicatePanel');
|
||||
});
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ function (angular, _, kbn, $) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
|
||||
module.service('panelHelper', function(timeSrv) {
|
||||
|
||||
this.updateTimeRange = function(scope) {
|
||||
|
@ -63,13 +63,18 @@ function (angular, _) {
|
||||
});
|
||||
};
|
||||
|
||||
this.replace = function(target) {
|
||||
this.replace = function(target, scopedVars) {
|
||||
if (!target) { return; }
|
||||
|
||||
var value;
|
||||
this._regex.lastIndex = 0;
|
||||
|
||||
return target.replace(this._regex, function(match, g1, g2) {
|
||||
if (scopedVars) {
|
||||
value = scopedVars[g1 || g2];
|
||||
if (value) { return value; }
|
||||
}
|
||||
|
||||
value = self._values[g1 || g2];
|
||||
if (!value) { return match; }
|
||||
|
||||
|
@ -36,7 +36,7 @@ function (angular, _, $, config, kbn, moment) {
|
||||
maxDataPoints: options.maxDataPoints,
|
||||
};
|
||||
|
||||
var params = this.buildGraphiteParams(graphOptions);
|
||||
var params = this.buildGraphiteParams(graphOptions, options.panelId);
|
||||
|
||||
if (options.format === 'png') {
|
||||
return $q.when(this.url + '/render' + '?' + params.join('&'));
|
||||
@ -231,7 +231,7 @@ function (angular, _, $, config, kbn, moment) {
|
||||
'#Y', '#Z'
|
||||
];
|
||||
|
||||
GraphiteDatasource.prototype.buildGraphiteParams = function(options) {
|
||||
GraphiteDatasource.prototype.buildGraphiteParams = function(options, panelId) {
|
||||
var graphite_options = ['from', 'until', 'rawData', 'format', 'maxDataPoints', 'cacheTimeout'];
|
||||
var clean_options = [], targets = {};
|
||||
var target, targetValue, i;
|
||||
@ -252,7 +252,7 @@ function (angular, _, $, config, kbn, moment) {
|
||||
continue;
|
||||
}
|
||||
|
||||
targetValue = templateSrv.replace(target.target);
|
||||
targetValue = templateSrv.replace(target.target, panelId);
|
||||
targetValue = targetValue.replace(intervalFormatFixRegex, fixIntervalFormat);
|
||||
targets[this._seriesRefLetters[i]] = targetValue;
|
||||
}
|
||||
|
@ -29,6 +29,18 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
describe('replace can pass scoped vars', function() {
|
||||
beforeEach(function() {
|
||||
_templateSrv.init([{ name: 'test', current: { value: 'oogle' } }]);
|
||||
});
|
||||
|
||||
it('should replace $test with scoped value', function() {
|
||||
var target = _templateSrv.replace('this.$test.filters', {'test': 'mupp'});
|
||||
expect(target).to.be('this.mupp.filters');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('can check if variable exists', function() {
|
||||
beforeEach(function() {
|
||||
_templateSrv.init([{ name: 'test', current: { value: 'oogle' } }]);
|
||||
|
Loading…
Reference in New Issue
Block a user