Add tag filter by click at trigger tag icon, #487

This commit is contained in:
Alexander Zobnin
2017-12-16 14:39:53 +03:00
parent 401ad69687
commit b7dab30a74
5 changed files with 36 additions and 3 deletions

View File

@@ -548,6 +548,10 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap
}, {
key: 'parseTags',
value: function parseTags(tagStr) {
if (!tagStr) {
return [];
}
var tags = _.map(tagStr.split(','), function (tag) {
return tag.trim();
});
@@ -564,6 +568,18 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap
return tag.tag + ':' + tag.value;
}).join(', ');
}
}, {
key: 'addTagFilter',
value: function addTagFilter(tag, ds) {
var tagFilter = this.panel.targets[ds].tags.filter;
var targetTags = this.parseTags(tagFilter);
var newTag = { tag: tag.tag, value: tag.value };
targetTags.push(newTag);
targetTags = _.uniqWith(targetTags, _.isEqual);
var newFilter = this.tagsToString(targetTags);
this.panel.targets[ds].tags.filter = newFilter;
this.refresh();
}
}, {
key: 'switchComment',
value: function switchComment(trigger) {