Skip to content

Commit

Permalink
priority filter
Browse files Browse the repository at this point in the history
  • Loading branch information
PetzJohannes committed Jan 16, 2016
1 parent fe27d52 commit 86045ad
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
4 changes: 2 additions & 2 deletions css/my.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}

.trigger-label-font-color {
color: #eee;
color: #000;
}

.trigger-label-disaster {
Expand Down Expand Up @@ -65,7 +65,7 @@ thead th {

.color-swatches {
margin: 0 -5px;
overflow: hidden
overflow: hidden;
}

.color-swatch {
Expand Down
33 changes: 27 additions & 6 deletions js/actions/trigger.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define(['jquery', 'zabbix', 'actions/event', 'searcher', 'bootstraptable', 'bootstrapswitch'], function( $, zabbix, event, searcher ) {
$acknowledgeSwitch = undefined;
return {
triggerGet: function (params, acknowledgedState) {
var searchHost = searcher.host(params.data.search),
searchDescription = searcher.description(params.data.search),
order = params.data.order.toUpperCase();
order = params.data.order.toUpperCase(),
priority = $( '#priorityfilter' ).data('priority-filter');
if (searchHost === undefined && searchDescription === undefined ) {
searchDescription = params.data.search;
}
Expand All @@ -18,6 +18,7 @@ define(['jquery', 'zabbix', 'actions/event', 'searcher', 'bootstraptable', 'boot
active: true,
skipDependent: true,
sortfield: params.data.sort,
min_severity: priority,
expandExpression: true,
expandDescription: true,
search: {
Expand All @@ -34,11 +35,16 @@ define(['jquery', 'zabbix', 'actions/event', 'searcher', 'bootstraptable', 'boot
}
zabbix.tableLoad(params, "trigger.get", paramszapi);
},
toolbar: function () {
$acknowledgeSwitch = $("[name='showAcknowledge']");
$acknowledgeSwitch.bootstrapSwitch();
},
filter: function () {
var $priorityfilter = $( '#priorityfilter'),
$triggertable = $('#triggertable'),
$acknowledgeSwitch = $("[name='showAcknowledge']"),
prioritytext = localStorage.getItem("trigger-filter-priority-text");
$acknowledgeSwitch.bootstrapSwitch();
$priorityfilter.data('priority-filter', localStorage.getItem("trigger-filter-priority-value"));
if ( prioritytext !== null ) {
$priorityfilter.html(prioritytext + ' <span class="caret"></span>');
}
$triggertable.on('click', 'td.host a', function() {
$triggertable.bootstrapTable('resetSearch', "Host:" + $( this).text());
});
Expand All @@ -48,6 +54,21 @@ define(['jquery', 'zabbix', 'actions/event', 'searcher', 'bootstraptable', 'boot
$( '#resetSearch').on('click', function() {
$triggertable.bootstrapTable('resetSearch');
});
$( '#priorityfilterlist li a').on('click', function() {
var $prioelement = $( this),
priovalue = $prioelement.data('priority-filter'),
priotext = $prioelement.text();
$priorityfilter.data('priority-filter', priovalue);
$priorityfilter.html(priotext + ' <span class="caret"></span>');
$triggertable.bootstrapTable('refresh');
localStorage.setItem("trigger-filter-priority-value", priovalue);
localStorage.setItem("trigger-filter-priority-text", priotext);
});
$( '#resetpriority').on('click', function() {
$priorityfilter.data('priority-filter', 0);
$priorityfilter.html('Not classified <span class="caret"></span>');
$triggertable.bootstrapTable('refresh');
});
},
triggerCount: function ( object, severity) {
var params = {
Expand Down
2 changes: 1 addition & 1 deletion js/libs/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ define(['zabbix'], function(zabbix) {
returnval = 'Not classified';
break;
}
return '<span class="label trigger-label-' + returnval.toLowerCase().replace(/\s/g, '') + ' label-font-color">' + returnval + '</span>';
return '<span class="label trigger-label-' + returnval.toLowerCase().replace(/\s/g, '') + ' trigger-label-font-color">' + returnval + '</span>';
},
acknowledgeState: function (value) {
var type = "success",
Expand Down
21 changes: 18 additions & 3 deletions views/trigger.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,22 @@ <h6>Minimum characters: 5</h6>
data-off-text="All"
data-on-color="danger"
data-off-color="success"
data-inverse="true"
>
<div class="btn-group">
<button id="resetpriority" type="button" class="btn btn-xs btn-info">Min. priority</button>
<button id="priorityfilter" data-priority-filter="0" type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Not classified <span class="caret"></span>
</button>
<ul id="priorityfilterlist" class="dropdown-menu">
<li><a href="#" data-priority-filter="0">Not classified</a></li>
<li><a href="#" data-priority-filter="1">Information</a></li>
<li><a href="#" data-priority-filter="2">Warning</a></li>
<li><a href="#" data-priority-filter="3">Average</a></li>
<li><a href="#" data-priority-filter="4">High</a></li>
<li><a href="#" data-priority-filter="5">Disaster</a></li>
</ul>
</div>
</div>
<table id="triggertable"
data-show-refresh="true"
Expand All @@ -72,8 +87,8 @@ <h6>Minimum characters: 5</h6>
require(['main'], function () {
require(['actions/trigger', 'libs/formatter', 'domready', 'bootstraptable'], function (trigger, formatter, domReady) {
domReady( function () {
trigger.toolbar();
trigger.eventAcknowledge();
trigger.filter();
formatTime = function (value) {
return formatter.getHumanTime(value);
};
Expand All @@ -87,13 +102,13 @@ <h6>Minimum characters: 5</h6>
return formatter.hostElement(value);
};
triggerGet = function (params) {
var $acknowledgeSwitch = $("[name='showAcknowledge']");
trigger.triggerGet(params, $acknowledgeSwitch.bootstrapSwitch('state'));
};
$triggertable = $('#triggertable');
var $triggertable = $('#triggertable');
$triggertable.bootstrapTable({
ajax: "triggerGet"
});
trigger.filter();
});
});
});
Expand Down

0 comments on commit 86045ad

Please sign in to comment.