Allow to use names with dot in template queries, fixes #254
This commit is contained in:
2
dist/datasource-zabbix/datasource.js
vendored
2
dist/datasource-zabbix/datasource.js
vendored
@@ -483,7 +483,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
var parts = [];
|
||||
|
||||
// Split query. Query structure: group.host.app.item
|
||||
_.each(query.split('.'), function (part) {
|
||||
_.each(utils.splitTemplateQuery(query), function (part) {
|
||||
part = _this5.replaceTemplateVars(part, {});
|
||||
|
||||
// Replace wildcard to regex
|
||||
|
||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
35
dist/datasource-zabbix/utils.js
vendored
35
dist/datasource-zabbix/utils.js
vendored
@@ -56,13 +56,7 @@ System.register(['lodash', 'moment'], function (_export, _context) {
|
||||
|
||||
params.push(param);
|
||||
return params;
|
||||
}
|
||||
|
||||
///////////
|
||||
// MACRO //
|
||||
///////////
|
||||
|
||||
function containsMacro(itemName) {
|
||||
}function containsMacro(itemName) {
|
||||
return MACRO_PATTERN.test(itemName);
|
||||
}
|
||||
|
||||
@@ -99,6 +93,33 @@ System.register(['lodash', 'moment'], function (_export, _context) {
|
||||
return macro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split template query to parts of zabbix entities
|
||||
* group.host.app.item -> [group, host, app, item]
|
||||
* {group}{host.com} -> [group, host.com]
|
||||
*/
|
||||
function splitTemplateQuery(query) {
|
||||
var splitPattern = /{[^{}]*}/g;
|
||||
var split = void 0;
|
||||
|
||||
if (isContainsBraces(query)) {
|
||||
var result = query.match(splitPattern);
|
||||
split = _.map(result, function (part) {
|
||||
return _.trim(part, '{}');
|
||||
});
|
||||
} else {
|
||||
split = query.split('.');
|
||||
}
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
_export('splitTemplateQuery', splitTemplateQuery);
|
||||
|
||||
function isContainsBraces(query) {
|
||||
return query.includes('{') && query.includes('}');
|
||||
}
|
||||
|
||||
// Pattern for testing regex
|
||||
function isRegex(str) {
|
||||
return regexPattern.test(str);
|
||||
|
||||
2
dist/datasource-zabbix/utils.js.map
vendored
2
dist/datasource-zabbix/utils.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user