Add tag filter by click at trigger tag icon, #487
This commit is contained in:
3
dist/panel-triggers/partials/module.html
vendored
3
dist/panel-triggers/partials/module.html
vendored
@@ -18,7 +18,8 @@
|
||||
</span>
|
||||
|
||||
<span class="zbx-trigger-tags" ng-if="ctrl.panel.showTags && trigger.tags">
|
||||
<span ng-repeat="tag in trigger.tags" tag-color-from-name="tag.tag+tag.value" class="label label-tag zbx-tag">
|
||||
<span ng-repeat="tag in trigger.tags" ng-click="ctrl.addTagFilter(tag, trigger.datasource)"
|
||||
tag-color-from-name="tag.tag+tag.value" class="label label-tag zbx-tag">
|
||||
{{tag.tag}}: {{tag.value}}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
16
dist/panel-triggers/triggers_panel_ctrl.js
vendored
16
dist/panel-triggers/triggers_panel_ctrl.js
vendored
@@ -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) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user