Fixed annotations.

This commit is contained in:
Alexander Zobnin
2016-03-19 15:09:13 +03:00
parent e74824f840
commit af59f87246
3 changed files with 28 additions and 24 deletions

View File

@@ -334,7 +334,7 @@ export class ZabbixAPIDatasource {
var to = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000);
var annotation = options.annotation;
var self = this;
var showEvents = annotation.showOkEvents ? [0, 1] : 1;
var showOkEvents = annotation.showOkEvents ? [0, 1] : 1;
var buildQuery = self.queryProcessor.buildTriggerQuery(this.templateSrv.replace(annotation.group),
this.templateSrv.replace(annotation.host),
@@ -343,7 +343,7 @@ export class ZabbixAPIDatasource {
return self.zabbixAPI.getTriggers(query.groupids,
query.hostids,
query.applicationids,
showEvents)
true)
.then(function(triggers) {
// Filter triggers by description
@@ -363,17 +363,7 @@ export class ZabbixAPIDatasource {
});
var objectids = _.map(triggers, 'triggerid');
var params = {
output: 'extend',
time_from: from,
time_till: to,
objectids: objectids,
select_acknowledges: 'extend',
selectHosts: 'extend',
value: showEvents
};
return self.zabbixAPI.request('event.get', params)
return self.zabbixAPI.getEvents(objectids, from, to, showOkEvents)
.then(function (events) {
var indexedTriggers = _.indexBy(triggers, 'triggerid');

View File

@@ -8,7 +8,7 @@
</li>
<li>
<input type="text"
ng-model="annotation.group"
ng-model="ctrl.annotation.group"
class="input-large tight-form-input">
</li>
<li class="tight-form-item" style="width: 50px">
@@ -16,7 +16,7 @@
</li>
<li>
<input type="text"
ng-model="annotation.host"
ng-model="ctrl.annotation.host"
class="input-large tight-form-input last">
</li>
</ul>
@@ -29,7 +29,7 @@
</li>
<li>
<input type="text"
ng-model="annotation.application"
ng-model="ctrl.annotation.application"
class="input-large tight-form-input">
</li>
<li class="tight-form-item" style="width: 50px">
@@ -37,7 +37,7 @@
</li>
<li>
<input type="text"
ng-model="annotation.trigger"
ng-model="ctrl.annotation.trigger"
class="input-large tight-form-input last">
</li>
</ul>
@@ -52,10 +52,10 @@
<div class="editor-option">
<label class="small">Minimum severity
</label>
<select class="small" style="width: 113px" ng-init='annotation.minseverity = annotation.minseverity || 0' ng-model='annotation.minseverity' ng-options="v as k for (k, v) in {'Not classified': 0, 'Information': 1, 'Warning': 2, 'Average': 3, 'High': 4, 'Disaster': 5}" ng-change="render()"></select>
<select class="small" style="width: 113px" ng-init='ctrl.annotation.minseverity = ctrl.annotation.minseverity || 0' ng-model='ctrl.annotation.minseverity' ng-options="v as k for (k, v) in {'Not classified': 0, 'Information': 1, 'Warning': 2, 'Average': 3, 'High': 4, 'Disaster': 5}" ng-change="render()"></select>
</div>
<editor-opt-bool text="Show OK events" model="annotation.showOkEvents"></editor-opt-bool>
<editor-opt-bool text="Hide acknowledged events" model="annotation.hideAcknowledged"></editor-opt-bool>
<editor-opt-bool text="Show hostname" model="annotation.showHostname"></editor-opt-bool>
<editor-opt-bool text="Show OK events" model="ctrl.annotation.showOkEvents"></editor-opt-bool>
<editor-opt-bool text="Hide acknowledged events" model="ctrl.annotation.hideAcknowledged"></editor-opt-bool>
<editor-opt-bool text="Show hostname" model="ctrl.annotation.showHostname"></editor-opt-bool>
</div>
</div>

View File

@@ -312,7 +312,7 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
return this.request('service.getsla', params);
}
getTriggers(groupids, hostids, applicationids, showEvents) {
getTriggers(groupids, hostids, applicationids, showAll) {
var params = {
output: 'extend',
groupids: groupids,
@@ -332,13 +332,27 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
selectLastEvent: 'extend'
};
if (showEvents) {
params.filter.value = showEvents;
if (showAll) {
params.filter = {};
}
return this.request('trigger.get', params);
}
getEvents(objectids, from, to, showOkEvents) {
var params = {
output: 'extend',
time_from: from,
time_till: to,
objectids: objectids,
select_acknowledges: 'extend',
selectHosts: 'extend',
value: showOkEvents
};
return this.request('event.get', params);
}
getAcknowledges(eventids) {
var params = {
output: 'extend',