Commit bd5f92be authored by Ad Schellevis's avatar Ad Schellevis

(ids) UI load grid on tab open

parent 14d1ccf1
...@@ -32,16 +32,14 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -32,16 +32,14 @@ POSSIBILITY OF SUCH DAMAGE.
// //
var data_get_map = {'frm_GeneralSettings':"/api/ids/settings/get"}; var data_get_map = {'frm_GeneralSettings':"/api/ids/settings/get"};
// load initial data
mapDataToFormUI(data_get_map).done(function(){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
// list all known classtypes and add to selection box /**
* list all known classtypes and add to selection box
*/
function updateRuleClassTypes() { function updateRuleClassTypes() {
ajaxGet(url="/api/ids/settings/listRuleClasstypes",sendData={}, callback=function(data, status) { ajaxGet(url="/api/ids/settings/listRuleClasstypes",sendData={}, callback=function(data, status) {
if (status == "success") { if (status == "success") {
$('#ruleclass').html('<option value="">ALL</option>');
$.each(data['items'], function(key, value) { $.each(data['items'], function(key, value) {
$('#ruleclass').append($("<option></option>").attr("value",value).text(value)); $('#ruleclass').append($("<option></option>").attr("value",value).text(value));
}); });
...@@ -54,12 +52,13 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -54,12 +52,13 @@ POSSIBILITY OF SUCH DAMAGE.
}); });
} }
// delay refresh for a bit /**
setTimeout(updateRuleClassTypes, 500); * update list of available alert logs
*/
// update list of alert logs function updateAlertLogs() {
ajaxGet(url="/api/ids/service/getAlertLogs",sendData={}, callback=function(data, status) { ajaxGet(url="/api/ids/service/getAlertLogs",sendData={}, callback=function(data, status) {
if (status == "success") { if (status == "success") {
$('#alert-logfile').html("");
$.each(data, function(key, value) { $.each(data, function(key, value) {
if (value['sequence'] == undefined) { if (value['sequence'] == undefined) {
$('#alert-logfile').append($("<option></option>").attr("value",'none').text(value['modified'])); $('#alert-logfile').append($("<option></option>").attr("value",'none').text(value['modified']));
...@@ -74,6 +73,7 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -74,6 +73,7 @@ POSSIBILITY OF SUCH DAMAGE.
}); });
} }
}); });
}
/** /**
* Add classtype to rule filter * Add classtype to rule filter
...@@ -97,9 +97,28 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -97,9 +97,28 @@ POSSIBILITY OF SUCH DAMAGE.
return request; return request;
} }
// load initial data
mapDataToFormUI(data_get_map).done(function(){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
/**
* load content on tab changes
*/
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if (e.target.id == 'rule_tab'){
//
// activate rule tab page
//
// delay refresh for a bit
setTimeout(updateRuleClassTypes, 500);
/** /**
* grid installed rules * grid installed rules
*/ */
$('#grid-installedrules').bootgrid('destroy'); // always destroy previous grid, so data is always fresh
$("#grid-installedrules").UIBootgrid( $("#grid-installedrules").UIBootgrid(
{ search:'/api/ids/settings/searchinstalledrules', { search:'/api/ids/settings/searchinstalledrules',
get:'/api/ids/settings/getRuleInfo/', get:'/api/ids/settings/getRuleInfo/',
...@@ -122,10 +141,12 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -122,10 +141,12 @@ POSSIBILITY OF SUCH DAMAGE.
toggle:'/api/ids/settings/toggleRule/' toggle:'/api/ids/settings/toggleRule/'
} }
); );
} else if (e.target.id == 'alert_tab') {
updateAlertLogs();
/** /**
* grid query alerts * grid query alerts
*/ */
$('#grid-alerts').bootgrid('destroy'); // always destroy previous grid, so data is always fresh
$("#grid-alerts").UIBootgrid( $("#grid-alerts").UIBootgrid(
{ search:'/api/ids/service/queryAlerts', { search:'/api/ids/service/queryAlerts',
get:'/api/ids/service/getAlertInfo/', get:'/api/ids/service/getAlertInfo/',
...@@ -140,6 +161,10 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -140,6 +161,10 @@ POSSIBILITY OF SUCH DAMAGE.
} }
} }
}); });
}
})
/** /**
* grid for installable rule files * grid for installable rule files
...@@ -209,9 +234,9 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -209,9 +234,9 @@ POSSIBILITY OF SUCH DAMAGE.
</script> </script>
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs"> <ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#settings">{{ lang._('Settings') }}</a></li> <li class="active"><a data-toggle="tab" href="#settings" id="settings_tab">{{ lang._('Settings') }}</a></li>
<li><a data-toggle="tab" href="#rules">{{ lang._('Rules') }}</a></li> <li><a data-toggle="tab" href="#rules" id="rule_tab">{{ lang._('Rules') }}</a></li>
<li><a data-toggle="tab" href="#alerts">{{ lang._('Alerts') }}</a></li> <li><a data-toggle="tab" href="#alerts" id="alert_tab">{{ lang._('Alerts') }}</a></li>
</ul> </ul>
<div class="tab-content content-box tab-content"> <div class="tab-content content-box tab-content">
<div id="settings" class="tab-pane fade in active"> <div id="settings" class="tab-pane fade in active">
...@@ -251,7 +276,7 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -251,7 +276,7 @@ POSSIBILITY OF SUCH DAMAGE.
<div class="row"> <div class="row">
<div class="col-sm-12 actionBar"> <div class="col-sm-12 actionBar">
<b>Classtype &nbsp;</b> <b>Classtype &nbsp;</b>
<select id="ruleclass" class="selectpicker" data-width="200px"><option value="">ALL</option></select> <select id="ruleclass" class="selectpicker" data-width="200px"></select>
</div> </div>
</div> </div>
</div> </div>
......
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