Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
790586b7
Commit
790586b7
authored
Jul 29, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ids) add toggle selected for rulesets and rules (
https://github.com/opnsense/core/issues/239
)
parent
63db313c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
6 deletions
+96
-6
index.volt
src/opnsense/mvc/app/views/OPNsense/IDS/index.volt
+96
-6
No files found.
src/opnsense/mvc/app/views/OPNsense/IDS/index.volt
View file @
790586b7
...
...
@@ -136,6 +136,45 @@ POSSIBILITY OF SUCH DAMAGE.
});
}
/**
* toggle selected items
* @param gridId: grid id to to use
* @param url: ajax action to call
* @param state: 0/1/undefined
* @param combine: number of keys to combine (seperate with ,)
* try to avoid too much items per call (results in too long url's)
*/
function actionToggleSelected(gridId, url, state, combine) {
var rows =$("#"+gridId).bootgrid('getSelectedRows');
if (rows != undefined){
var deferreds = [];
if (state != undefined) {
var url_suffix = state;
} else {
var url_suffix = "";
}
var keyset = [];
$.each(rows, function(key,uuid){
keyset.push(uuid);
if ( combine == undefined || keyset.length > combine) {
deferreds.push(ajaxCall(url + keyset.join(',') +'/'+url_suffix, sendData={},null));
keyset = [];
}
});
// flush remaining items
if (keyset.length > 0) {
deferreds.push(ajaxCall(url + keyset.join(',') +'/'+url_suffix, sendData={},null));
}
// refresh when all toggles are executed
$.when.apply(null, deferreds).done(function(){
$("#"+gridId).bootgrid("reload");
});
}
}
/*************************************************************************************************************
* UI load grids (on tab change)
*************************************************************************************************************/
...
...
@@ -160,8 +199,6 @@ POSSIBILITY OF SUCH DAMAGE.
{ search:'/api/ids/settings/searchinstalledrules',
get:'/api/ids/settings/getRuleInfo/',
options:{
multiSelect:false,
selection:false,
requestHandler:addRuleFilters,
formatters:{
rowtoggle: function (column, row) {
...
...
@@ -210,8 +247,6 @@ POSSIBILITY OF SUCH DAMAGE.
{ search:'/api/ids/settings/listInstallableRulesets',
toggle:'/api/ids/settings/toggleInstalledRuleset/',
options:{
multiSelect:false,
selection:false,
navigation:0,
formatters:{
rowtoggle: function (column, row) {
...
...
@@ -272,6 +307,42 @@ POSSIBILITY OF SUCH DAMAGE.
});
});
/**
* disable selected rulesets
*/
$("#disableSelectedRuleSets").click(function(){
var gridId = 'grid-rule-files';
var url = '/api/ids/settings/toggleInstalledRuleset/';
actionToggleSelected(gridId, url, 0, 20);
});
/**
* enable selected rulesets
*/
$("#enableSelectedRuleSets").click(function(){
var gridId = 'grid-rule-files';
var url = '/api/ids/settings/toggleInstalledRuleset/';
actionToggleSelected(gridId, url, 1, 20);
});
/**
* disable selected rules
*/
$("#disableSelectedRules").click(function(){
var gridId = 'grid-installedrules';
var url = '/api/ids/settings/toggleRule/';
actionToggleSelected(gridId, url, 0, 100);
});
/**
* enable selected rules
*/
$("#enableSelectedRules").click(function(){
var gridId = 'grid-installedrules';
var url = '/api/ids/settings/toggleRule/';
actionToggleSelected(gridId, url, 1, 100);
});
/**
* Initialize
*/
...
...
@@ -309,13 +380,23 @@ POSSIBILITY OF SUCH DAMAGE.
<table id="grid-rule-files" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogRule">
<thead>
<tr>
<th data-column-id="
enabled" data-formatter="rowtoggle" data-sortable="false" data-width="10em">{{ lang._('Enabled') }}
</th>
<th data-column-id="
filename" data-type="string" data-visible="false" data-identifier="true">filename
</th>
<th data-column-id="description" data-type="string" data-sortable="false" data-visible="true">{{ lang._('Description') }}</th>
<th data-column-id="modified_local" data-type="string" data-sortable="false" data-visible="true">{{ lang._('Last updated') }}</th>
<th data-column-id="enabled" data-formatter="rowtoggle" data-sortable="false" data-width="10em">{{ lang._('Enabled') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button title="{{ lang._('disable selected') }}" id="disableSelectedRuleSets" type="button" class="btn btn-xs btn-default"><span class="fa fa-square-o command-toggle"></span></button>
<button title="{{ lang._('enable selected') }}" id="enableSelectedRuleSets" type="button" class="btn btn-xs btn-default"><span class="fa fa-check-square-o command-toggle"></span></button>
</td>
</tr>
</tfoot>
</table>
</td>
</tr>
...
...
@@ -336,7 +417,7 @@ POSSIBILITY OF SUCH DAMAGE.
<table id="grid-installedrules" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogRule">
<thead>
<tr>
<th data-column-id="sid" data-type="num
ber" data-visible="true" data-identifier="true" data-width="6em">sid
</th>
<th data-column-id="sid" data-type="num
eric" data-visible="true" data-identifier="true" data-width="6em">{{ lang._('sid') }}
</th>
<th data-column-id="source" data-type="string">{{ lang._('Source') }}</th>
<th data-column-id="classtype" data-type="string">{{ lang._('ClassType') }}</th>
<th data-column-id="msg" data-type="string">{{ lang._('Message') }}</th>
...
...
@@ -345,6 +426,15 @@ POSSIBILITY OF SUCH DAMAGE.
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button title="{{ lang._('disable selected') }}" id="disableSelectedRules" type="button" class="btn btn-xs btn-default"><span class="fa fa-square-o command-toggle"></span></button>
<button title="{{ lang._('enable selected') }}" id="enableSelectedRules" type="button" class="btn btn-xs btn-default"><span class="fa fa-check-square-o command-toggle"></span></button>
</td>
</tr>
</tfoot>
</table>
</div>
<div id="alerts" class="tab-pane fade in">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment