Fix merge conflicts
This commit is contained in:
@@ -78,13 +78,26 @@ export function containsMacro(itemName) {
|
||||
return MACRO_PATTERN.test(itemName);
|
||||
}
|
||||
|
||||
export function replaceMacro(item, macros) {
|
||||
let itemName = item.name;
|
||||
export function replaceMacro(item, macros, isTriggerItem) {
|
||||
let itemName = isTriggerItem ? item.url : item.name;
|
||||
const item_macros = itemName.match(MACRO_PATTERN);
|
||||
_.forEach(item_macros, macro => {
|
||||
const host_macros = _.filter(macros, m => {
|
||||
if (m.hostid) {
|
||||
if (isTriggerItem) {
|
||||
// Trigger item can have multiple hosts
|
||||
// Check all trigger host ids against macro host id
|
||||
let hostIdFound = false;
|
||||
_.forEach(item.hosts, h => {
|
||||
if (h.hostid === m.hostid) {
|
||||
hostIdFound = true;
|
||||
}
|
||||
});
|
||||
return hostIdFound;
|
||||
} else {
|
||||
// Check app host id against macro host id
|
||||
return m.hostid === item.hostid;
|
||||
}
|
||||
} else {
|
||||
// Add global macros
|
||||
return true;
|
||||
|
||||
@@ -234,14 +234,18 @@ export class Zabbix {
|
||||
.then(this.expandUserMacro.bind(this));
|
||||
}
|
||||
|
||||
expandUserMacro(items) {
|
||||
expandUserMacro(items, isTriggerItem) {
|
||||
let hostids = getHostIds(items);
|
||||
return this.getMacros(hostids)
|
||||
.then(macros => {
|
||||
_.forEach(items, item => {
|
||||
if (utils.containsMacro(item.name)) {
|
||||
if (utils.containsMacro(isTriggerItem ? item.url : item.name)) {
|
||||
if (isTriggerItem) {
|
||||
item.url = utils.replaceMacro(item, macros, isTriggerItem);
|
||||
} else {
|
||||
item.name = utils.replaceMacro(item, macros);
|
||||
}
|
||||
}
|
||||
});
|
||||
return items;
|
||||
});
|
||||
@@ -285,7 +289,8 @@ export class Zabbix {
|
||||
return query;
|
||||
})
|
||||
.then(query => this.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options))
|
||||
.then(triggers => this.filterTriggersByProxy(triggers, proxyFilter));
|
||||
.then(triggers => this.filterTriggersByProxy(triggers, proxyFilter))
|
||||
.then(triggers => this.expandUserMacro.bind(this)(triggers, true));
|
||||
}
|
||||
|
||||
filterTriggersByProxy(triggers, proxyFilter) {
|
||||
|
||||
Reference in New Issue
Block a user