Skip to content

Commit

Permalink
fix t.replace is not a function, #661
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Feb 12, 2019
1 parent b1327bb commit 1913430
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/datasource-zabbix/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export class ZabbixDatasource {

// Prevent changes of original object
let target = _.cloneDeep(t);

// Migrate old targets
target = migrations.migrate(target);
this.replaceTargetVariables(target, options);

// Apply Time-related functions (timeShift(), etc)
Expand All @@ -123,9 +126,6 @@ export class ZabbixDatasource {

// Metrics or Text query mode
if (!target.mode || target.mode === c.MODE_METRICS || target.mode === c.MODE_TEXT) {
// Migrate old targets
target = migrations.migrate(target);

// Don't request undefined targets
if (!target.group || !target.host || !target.item) {
return [];
Expand Down Expand Up @@ -534,6 +534,7 @@ export class ZabbixDatasource {
let enabled_targets = filterEnabledTargets(options.targets);
let getPanelItems = _.map(enabled_targets, t => {
let target = _.cloneDeep(t);
target = migrations.migrate(target);
this.replaceTargetVariables(target, options);
return this.zabbix.getItemsFromTarget(target, {itemtype: 'num'});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ export function migrateFrom2To3version(target) {

export function migrate(target) {
target.resultFormat = target.resultFormat || 'time_series';
target = fixTargetGroup(target);
if (isGrafana2target(target)) {
return migrateFrom2To3version(target);
} else {
return target;
}
return target;
}

function fixTargetGroup(target) {
if (target.group && Array.isArray(target.group)) {
target.group = { 'filter': "" };
}
return target;
}

function convertToRegex(str) {
Expand Down

0 comments on commit 1913430

Please sign in to comment.