Commit 5b4185f2 authored by Ad Schellevis's avatar Ad Schellevis

(ids) implement log file selection

parent 3803c3de
......@@ -178,9 +178,16 @@ class ServiceController extends ApiControllerBase
$searchPhrase = '';
}
if ($this->request->getPost('fileid', 'string', '') != "") {
$fileid = $this->request->getPost('fileid', 'int', -1);
} else {
$fileid = null;
}
$backend = new Backend();
$response = $backend->configdpRun("ids query alerts", array($itemsPerPage,
($currentPage-1)*$itemsPerPage, $searchPhrase));
($currentPage-1)*$itemsPerPage, $searchPhrase,$fileid));
$result = json_decode($response, true);
if ($result != null) {
$result['rowCount'] = count($result['rows']);
......@@ -210,4 +217,26 @@ class ServiceController extends ApiControllerBase
return array();
}
}
/**
* list all available logs
* @return array list of alert logs
* @throws \Exception
*/
public function getAlertLogsAction()
{
$backend = new Backend();
$response = $backend->configdRun("ids list alertlogs");
$result = json_decode($response, true);
if ($result != null) {
$logs = array();
foreach ($result as $log) {
$log['modified'] = date('Y/m/d G:i', $log['modified']);
$logs[] = $log;
}
return $logs;
} else {
return array();
}
}
}
......@@ -57,7 +57,28 @@ POSSIBILITY OF SUCH DAMAGE.
// delay refresh for a bit
setTimeout(updateRuleClassTypes, 500);
function addFilters(request) {
// update list of alert logs
ajaxGet(url="/api/ids/service/getAlertLogs",sendData={}, callback=function(data, status) {
if (status == "success") {
$.each(data, function(key, value) {
if (value['sequence'] == undefined) {
$('#alert-logfile').append($("<option></option>").attr("value",'none').text(value['modified']));
} else {
$('#alert-logfile').append($("<option></option>").attr("value",value['sequence']).text(value['modified']));
}
});
$('.selectpicker').selectpicker('refresh');
// link on change event
$('#alert-logfile').on('change', function(){
$('#grid-alerts').bootgrid('reload');
});
}
});
/**
* Add classtype to rule filter
*/
function addRuleFilters(request) {
var selected =$('#ruleclass').find("option:selected").val();
if ( selected != "") {
request['classtype'] = selected;
......@@ -65,13 +86,24 @@ POSSIBILITY OF SUCH DAMAGE.
return request;
}
/**
* Add fileid to alert filter
*/
function addAlertQryFilters(request) {
var selected =$('#alert-logfile').find("option:selected").val();
if ( selected != "") {
request['fileid'] = selected;
}
return request;
}
$("#grid-installedrules").UIBootgrid(
{ search:'/api/ids/settings/searchinstalledrules',
get:'/api/ids/settings/getRuleInfo/',
options:{
multiSelect:false,
selection:false,
requestHandler:addFilters,
requestHandler:addRuleFilters,
formatters:{
rowtoggle: function (column, row) {
if (parseInt(row[column.id], 2) == 1) {
......@@ -94,6 +126,7 @@ POSSIBILITY OF SUCH DAMAGE.
options:{
multiSelect:false,
selection:false,
requestHandler:addAlertQryFilters,
formatters:{
info: function (column, row) {
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.filepos + "\"><span class=\"fa fa-info-circle\"></span></button> ";
......@@ -168,7 +201,14 @@ POSSIBILITY OF SUCH DAMAGE.
</table>
</div>
<div id="alerts" class="tab-pane fade in">
<!-- tab page "installed rules" -->
<div class="bootgrid-header container-fluid">
<div class="row">
<div class="col-sm-12 actionBar">
<select id="alert-logfile" class="selectpicker" data-width="200px"></select>
</div>
</div>
</div>
<!-- tab page "alerts" -->
<table id="grid-alerts" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogAlert">
<thead>
<tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment