mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
(legacy) firewall, add optional rule category
This commit is contained in:
parent
1955be171e
commit
35a11180fc
@ -198,6 +198,38 @@ $( document ).ready(function() {
|
||||
$("#iform").submit();
|
||||
});
|
||||
|
||||
|
||||
// link category select/search
|
||||
$("#fw_category").change(function(){
|
||||
var stripe_color = 'transparent';
|
||||
var selected_value = $(this).val();
|
||||
$(".rule").each(function(){
|
||||
// save zebra color
|
||||
if ( $(this).children(0).css("background-color") != 'transparent') {
|
||||
$("#fw_category").data('stripe_color', $(this).children(0).css("background-color"));
|
||||
}
|
||||
if ($(this).data('category') != selected_value && selected_value != "") {
|
||||
$(this).hide();
|
||||
} else {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#rules").removeClass("table-striped");
|
||||
// add stripes again
|
||||
$(".rule:visible").each(function (index) {
|
||||
$(this).css("background-color", "inherit");
|
||||
if ( index % 2 == 0) {
|
||||
$(this).css("background-color", $("#fw_category").data('stripe_color'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// hide category search when not used
|
||||
if ($("#fw_category > option").length == 1) {
|
||||
$("#fw_category").addClass('hidden');
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -262,7 +294,7 @@ $( document ).ready(function() {
|
||||
<input type="hidden" id="id" name="id" value="" />
|
||||
<input type="hidden" id="action" name="act" value="" />
|
||||
<div class="table-responsive" >
|
||||
<table class="table table-striped">
|
||||
<table class="table table-striped table-hover" id="rules">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
@ -427,7 +459,7 @@ $( document ).ready(function() {
|
||||
|
||||
|
||||
?>
|
||||
<tr ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
||||
<tr class="rule" data-category="<?=!empty($filterent['category']) ? $filterent['category'] : "";?>">
|
||||
<td>
|
||||
<input type="checkbox" name="rule[]" value="<?=$i;?>" />
|
||||
</td>
|
||||
@ -621,7 +653,23 @@ $( document ).ready(function() {
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="5"></td>
|
||||
<td colspan="5">
|
||||
<select class="selectpicker" data-live-search="true" data-size="5" placeholder="<?=gettext("select category");?>" id="fw_category">
|
||||
<option value=""><?=gettext("Filter by category");?></value>
|
||||
<?php
|
||||
// collect unique list of categories and append to option list
|
||||
$categories = array();
|
||||
foreach ($a_filter as $tmp_rule) {
|
||||
if (!empty($tmp_rule['category']) && !in_array($tmp_rule['category'], $categories)) {
|
||||
$categories[] = $tmp_rule['category'];
|
||||
}
|
||||
}
|
||||
foreach ($categories as $category):?>
|
||||
<option value="<?=$category;?>"><?=$category;?></value>
|
||||
<?php
|
||||
endforeach;?>
|
||||
</select>
|
||||
</td>
|
||||
<td colspan="5" class="hidden-xs hidden-sm"></td>
|
||||
<td>
|
||||
<a type="submit" id="move_<?=$i;?>" name="move_<?=$i;?>_x" data-toggle="tooltip" title="<?=gettext("move selected rules to end");?>" class="act_move btn btn-default btn-xs">
|
||||
|
||||
@ -152,7 +152,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
,'descr','tcpflags_any','tcpflags1','tcpflags2','tag','tagged','quick','allowopts'
|
||||
,'disablereplyto','max','max-src-nodes','max-src-conn','max-src-states','statetype'
|
||||
,'statetimeout','nopfsync','nosync','max-src-conn-rate','max-src-conn-rates','gateway','sched'
|
||||
,'associated-rule-id','floating'
|
||||
,'associated-rule-id','floating', 'category'
|
||||
);
|
||||
|
||||
$pconfig = array();
|
||||
@ -414,7 +414,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$copy_fields = array('type', 'interface', 'ipprotocol', 'tag', 'tagged', 'max', 'max-src-nodes'
|
||||
, 'max-src-conn', 'max-src-states', 'statetimeout', 'statetype', 'os', 'descr', 'gateway'
|
||||
, 'sched', 'associated-rule-id', 'direction', 'quick'
|
||||
, 'max-src-conn-rate', 'max-src-conn-rates') ;
|
||||
, 'max-src-conn-rate', 'max-src-conn-rates', 'category') ;
|
||||
|
||||
foreach ($copy_fields as $fieldname) {
|
||||
if (!empty($pconfig[$fieldname])) {
|
||||
@ -662,6 +662,14 @@ include("head.inc");
|
||||
$("#toggleAdvanced").click();
|
||||
<?php endif;?>
|
||||
|
||||
// add typeahead for existing categories, all options are saves in the select option "existing_categories"
|
||||
var categories = [];
|
||||
$("#existing_categories > option").each(function(){
|
||||
categories.push($(this).val());
|
||||
});
|
||||
$("#category").typeahead({
|
||||
source: categories
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -1135,6 +1143,27 @@ include("head.inc");
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_category" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Category"); ?></td>
|
||||
<td>
|
||||
<input name="category" type="text" class="formfld unknown" id="category" size="40" value="<?=$pconfig['category'];?>" />
|
||||
<div class="hidden" for="help_for_category">
|
||||
<?=gettext("You may enter or select a category here to group firewall rules (not parsed)."); ?>
|
||||
</div>
|
||||
<select class="hidden" id="existing_categories">
|
||||
<?php
|
||||
$categories = array();
|
||||
foreach ($a_filter as $tmp_rule) {
|
||||
if (!empty($tmp_rule['category']) && !in_array($tmp_rule['category'], $categories)) {
|
||||
$categories[] = $tmp_rule['category'];
|
||||
}
|
||||
}
|
||||
foreach ($categories as $category):?>
|
||||
<option value="<?=$category;?>"></option>
|
||||
<?php
|
||||
endforeach;?>
|
||||
</select>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_descr" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
|
||||
<td>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user