Some refactoring of annotationQuery() method.
This commit is contained in:
@@ -339,12 +339,12 @@ function (angular, _, dateMath) {
|
|||||||
ZabbixAPIDatasource.prototype.annotationQuery = function(options) {
|
ZabbixAPIDatasource.prototype.annotationQuery = function(options) {
|
||||||
var from = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000);
|
var from = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000);
|
||||||
var to = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000);
|
var to = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000);
|
||||||
var annotation = options.annotation;
|
var annotation = annotation;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// Remove events below the chose severity
|
// Remove events below the chose severity
|
||||||
var severities = [];
|
var severities = [];
|
||||||
for (var i = 5; i >= options.annotation.minseverity; i--) {
|
for (var i = 5; i >= annotation.minseverity; i--) {
|
||||||
severities.push(i);
|
severities.push(i);
|
||||||
}
|
}
|
||||||
var params = {
|
var params = {
|
||||||
@@ -352,16 +352,16 @@ function (angular, _, dateMath) {
|
|||||||
preservekeys: 1,
|
preservekeys: 1,
|
||||||
filter: { 'priority': severities },
|
filter: { 'priority': severities },
|
||||||
search: {
|
search: {
|
||||||
'description': options.annotation.trigger
|
'description': annotation.trigger
|
||||||
},
|
},
|
||||||
searchWildcardsEnabled: true,
|
searchWildcardsEnabled: true,
|
||||||
expandDescription: true
|
expandDescription: true
|
||||||
};
|
};
|
||||||
if (options.annotation.host) {
|
if (annotation.host) {
|
||||||
params.host = templateSrv.replace(options.annotation.host);
|
params.host = templateSrv.replace(annotation.host);
|
||||||
}
|
}
|
||||||
else if (options.annotation.group) {
|
else if (annotation.group) {
|
||||||
params.group = templateSrv.replace(options.annotation.group);
|
params.group = templateSrv.replace(annotation.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.zabbixAPI.performZabbixAPIRequest('trigger.get', params)
|
return this.zabbixAPI.performZabbixAPIRequest('trigger.get', params)
|
||||||
@@ -378,7 +378,7 @@ function (angular, _, dateMath) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Show problem events only
|
// Show problem events only
|
||||||
if (!options.annotation.showOkEvents) {
|
if (!annotation.showOkEvents) {
|
||||||
params.value = 1;
|
params.value = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,17 +388,17 @@ function (angular, _, dateMath) {
|
|||||||
|
|
||||||
_.each(result, function(e) {
|
_.each(result, function(e) {
|
||||||
var title ='';
|
var title ='';
|
||||||
if (options.annotation.showHostname) {
|
if (annotation.showHostname) {
|
||||||
title += e.hosts[0]['name'] + ': ';
|
title += e.hosts[0].name + ': ';
|
||||||
}
|
}
|
||||||
title += Number(e.value) ? 'Problem' : 'OK';
|
title += Number(e.value) ? 'Problem' : 'OK';
|
||||||
|
|
||||||
// Hide acknowledged events
|
// Hide acknowledged events
|
||||||
if (e.acknowledges.length > 0 && options.annotation.showAcknowledged) { return; }
|
if (e.acknowledges.length > 0 && annotation.showAcknowledged) { return; }
|
||||||
|
|
||||||
var formatted_acknowledges = zabbixHelperSrv.formatAcknowledges(e.acknowledges);
|
var formatted_acknowledges = zabbixHelperSrv.formatAcknowledges(e.acknowledges);
|
||||||
events.push({
|
events.push({
|
||||||
annotation: options.annotation,
|
annotation: annotation,
|
||||||
time: e.clock * 1000,
|
time: e.clock * 1000,
|
||||||
title: title,
|
title: title,
|
||||||
text: objects[e.objectid].description + formatted_acknowledges
|
text: objects[e.objectid].description + formatted_acknowledges
|
||||||
|
|||||||
Reference in New Issue
Block a user