trigers: show host groups option, #248 #418

This commit is contained in:
Alexander Zobnin
2017-12-16 15:28:24 +03:00
parent 33f71d49a3
commit 8edbae7aa1
9 changed files with 56 additions and 9 deletions

View File

@@ -16,6 +16,9 @@
<i ng-if="trigger.maintenance" class="fa fa-wrench zbx-maintenance-icon"></i>
{{ ctrl.formatHostName(trigger) }}
</span>
<span class="zabbix-hostname" ng-if="ctrl.panel.hostGroups">
{{ ctrl.formatHostGroups(trigger) }}
</span>
<span class="zbx-trigger-tags" ng-if="ctrl.panel.showTags && trigger.tags">
<span ng-repeat="tag in trigger.tags" ng-click="ctrl.addTagFilter(tag, trigger.datasource)"

View File

@@ -13,6 +13,12 @@
checked="ctrl.panel.hostTechNameField"
on-change="ctrl.render()">
</gf-form-switch>
<gf-form-switch class="gf-form"
label-class="width-9"
label="Host groups"
checked="ctrl.panel.hostGroups"
on-change="ctrl.render()">
</gf-form-switch>
<gf-form-switch class="gf-form"
label-class="width-9"
label="Tags"

View File

@@ -51,6 +51,7 @@ describe('Triggers Panel schema migration', () => {
},
hostField: true,
hostTechNameField: false,
hostGroups: false,
showTags: true,
statusField: false,
severityField: false,
@@ -87,6 +88,7 @@ describe('Triggers Panel schema migration', () => {
},
hostField: true,
hostTechNameField: false,
hostGroups: false,
showTags: true,
statusField: true,
severityField: true,

View File

@@ -35,6 +35,7 @@ export const PANEL_DEFAULTS = {
// Fields
hostField: true,
hostTechNameField: false,
hostGroups: false,
showTags: true,
statusField: true,
severityField: true,
@@ -468,13 +469,24 @@ export class TriggerPanelCtrl extends PanelCtrl {
}
formatHostName(trigger) {
let host = "";
if (this.panel.hostField && this.panel.hostTechNameField) {
return `${trigger.host} (${trigger.hostTechName})`;
host = `${trigger.host} (${trigger.hostTechName})`;
} else if (this.panel.hostField || this.panel.hostTechNameField) {
return this.panel.hostField ? trigger.host : trigger.hostTechName;
} else {
return "";
host = this.panel.hostField ? trigger.host : trigger.hostTechName;
}
return host;
}
formatHostGroups(trigger) {
let groupNames = "";
if (this.panel.hostGroups) {
let groups = _.map(trigger.groups, 'name').join(', ');
groupNames += `[ ${groups} ]`;
}
return groupNames;
}
getAlertIconClass(trigger) {