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:
@@ -33,9 +33,15 @@ function (angular, _) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dashboard.scopedVars = {
|
||||||
|
panel: {}
|
||||||
|
};
|
||||||
|
|
||||||
_.each(variable.options, function(option) {
|
_.each(variable.options, function(option) {
|
||||||
var copy = dashboard.duplicatePanel(panel, row);
|
var copy = dashboard.duplicatePanel(panel, row);
|
||||||
copy.repeat = null;
|
copy.repeat = null;
|
||||||
|
dashboard.scopedVars.panel[panel.id] = {};
|
||||||
|
dashboard.scopedVars.panel[panel.id][variable.name] = option.value;
|
||||||
console.log('duplicatePanel');
|
console.log('duplicatePanel');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ function (angular, _, kbn, $) {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.services');
|
var module = angular.module('grafana.services');
|
||||||
|
|
||||||
module.service('panelHelper', function(timeSrv) {
|
module.service('panelHelper', function(timeSrv) {
|
||||||
|
|
||||||
this.updateTimeRange = function(scope) {
|
this.updateTimeRange = function(scope) {
|
||||||
|
|||||||
@@ -63,13 +63,18 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.replace = function(target) {
|
this.replace = function(target, scopedVars) {
|
||||||
if (!target) { return; }
|
if (!target) { return; }
|
||||||
|
|
||||||
var value;
|
var value;
|
||||||
this._regex.lastIndex = 0;
|
this._regex.lastIndex = 0;
|
||||||
|
|
||||||
return target.replace(this._regex, function(match, g1, g2) {
|
return target.replace(this._regex, function(match, g1, g2) {
|
||||||
|
if (scopedVars) {
|
||||||
|
value = scopedVars[g1 || g2];
|
||||||
|
if (value) { return value; }
|
||||||
|
}
|
||||||
|
|
||||||
value = self._values[g1 || g2];
|
value = self._values[g1 || g2];
|
||||||
if (!value) { return match; }
|
if (!value) { return match; }
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ function (angular, _, $, config, kbn, moment) {
|
|||||||
maxDataPoints: options.maxDataPoints,
|
maxDataPoints: options.maxDataPoints,
|
||||||
};
|
};
|
||||||
|
|
||||||
var params = this.buildGraphiteParams(graphOptions);
|
var params = this.buildGraphiteParams(graphOptions, options.panelId);
|
||||||
|
|
||||||
if (options.format === 'png') {
|
if (options.format === 'png') {
|
||||||
return $q.when(this.url + '/render' + '?' + params.join('&'));
|
return $q.when(this.url + '/render' + '?' + params.join('&'));
|
||||||
@@ -231,7 +231,7 @@ function (angular, _, $, config, kbn, moment) {
|
|||||||
'#Y', '#Z'
|
'#Y', '#Z'
|
||||||
];
|
];
|
||||||
|
|
||||||
GraphiteDatasource.prototype.buildGraphiteParams = function(options) {
|
GraphiteDatasource.prototype.buildGraphiteParams = function(options, panelId) {
|
||||||
var graphite_options = ['from', 'until', 'rawData', 'format', 'maxDataPoints', 'cacheTimeout'];
|
var graphite_options = ['from', 'until', 'rawData', 'format', 'maxDataPoints', 'cacheTimeout'];
|
||||||
var clean_options = [], targets = {};
|
var clean_options = [], targets = {};
|
||||||
var target, targetValue, i;
|
var target, targetValue, i;
|
||||||
@@ -252,7 +252,7 @@ function (angular, _, $, config, kbn, moment) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetValue = templateSrv.replace(target.target);
|
targetValue = templateSrv.replace(target.target, panelId);
|
||||||
targetValue = targetValue.replace(intervalFormatFixRegex, fixIntervalFormat);
|
targetValue = targetValue.replace(intervalFormatFixRegex, fixIntervalFormat);
|
||||||
targets[this._seriesRefLetters[i]] = targetValue;
|
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() {
|
describe('can check if variable exists', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
_templateSrv.init([{ name: 'test', current: { value: 'oogle' } }]);
|
_templateSrv.init([{ name: 'test', current: { value: 'oogle' } }]);
|
||||||
|
|||||||
Reference in New Issue
Block a user