You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[-] I have searched the existing issues and I'm convinced that mine is new.
Is your feature request related to a problem? Please describe.
Hi!
At this moment, when filtering the live log of the firewall, all filter parameters applied with logical operator AND (that is, the row must satisfy all filters in order for it to be displayed).
Sometimes it is useful to select rows that satisfy at least one condition (OR logical operator).
Describe the solution you'd like
the live view page might look like this
I think this can be useful and will not harm anyone
I'm not sure about the quality of my code, so I didn't make a PR.
for myself, I added several lines in apply_filter function in the fw_log.volt file:
`
function apply_filter()
{
let filters = [];
let filters_operator = $('#filter_operator option:selected').val();
$("#filters > span.badge").each(function(){
filters.push($(this).data('filter'));
});
$("#grid-log > tbody > tr").each(function(){
let selected_tr = $(this);
let this_data = $(this).data('details');
if (this_data === undefined) {
return;
}
let is_matched = true;
if (filters_operator == "and") {
for (let i=0; i < filters.length; i++) {
let filter_tag = filters[i].tag;
let filter_value = filters[i].value.toLowerCase();
let filter_condition = filters[i].condition;
if (this_data[filter_tag] === undefined) {
is_matched = false;
break;
} else if (filter_condition === '= ' && this_data[filter_tag].toLowerCase() != filter_value) {
is_matched = false;
break;
} else if (filter_condition === '~ ' && !this_data[filter_tag].toLowerCase().match(filter_value)) {
is_matched = false;
break;
}
}
}
else if (filters_operator == "or") {
if (filters.length > 0 ) {
is_matched = false;}
for (let i=0; i < filters.length; i++) {
let filter_tag = filters[i].tag;
let filter_value = filters[i].value.toLowerCase();
let filter_condition = filters[i].condition;
if (this_data[filter_tag] !== undefined){
if (filter_condition === '= ' && this_data[filter_tag].toLowerCase() == filter_value) {
is_matched = true;
break;
} else if (filter_condition === '~ ' && this_data[filter_tag].toLowerCase().match(filter_value)) {
is_matched = true;
break;
}}
}
}
if (is_matched) {
selected_tr.show();
} else {
selected_tr.hide();
}
});
}
`
and add select in html part
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
Although I'm a bit afraid the next question would be to support combinations (which is what I'm not planning to implement), a simple toggle to switch between the normal AND condition and the OR variant might be helpful in some cases indeed.
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
[-] I have read the contributing guide lines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
[-] I have searched the existing issues and I'm convinced that mine is new.
Is your feature request related to a problem? Please describe.
Hi!
At this moment, when filtering the live log of the firewall, all filter parameters applied with logical operator AND (that is, the row must satisfy all filters in order for it to be displayed).
Sometimes it is useful to select rows that satisfy at least one condition (OR logical operator).
Describe the solution you'd like
the live view page might look like this
I think this can be useful and will not harm anyone
I'm not sure about the quality of my code, so I didn't make a PR.
for myself, I added several lines in apply_filter function in the fw_log.volt file:
`
function apply_filter()
{
let filters = [];
let filters_operator = $('#filter_operator option:selected').val();
$("#filters > span.badge").each(function(){
filters.push($(this).data('filter'));
});
$("#grid-log > tbody > tr").each(function(){
let selected_tr = $(this);
let this_data = $(this).data('details');
if (this_data === undefined) {
return;
}
let is_matched = true;
if (filters_operator == "and") {
for (let i=0; i < filters.length; i++) {
let filter_tag = filters[i].tag;
let filter_value = filters[i].value.toLowerCase();
let filter_condition = filters[i].condition;
if (this_data[filter_tag] === undefined) {
is_matched = false;
break;
} else if (filter_condition === '= ' && this_data[filter_tag].toLowerCase() != filter_value) {
is_matched = false;
break;
} else if (filter_condition === '~ ' && !this_data[filter_tag].toLowerCase().match(filter_value)) {
is_matched = false;
break;
}
}
}
else if (filters_operator == "or") {
if (filters.length > 0 ) {
is_matched = false;}
for (let i=0; i < filters.length; i++) {
let filter_tag = filters[i].tag;
let filter_value = filters[i].value.toLowerCase();
let filter_condition = filters[i].condition;
if (this_data[filter_tag] !== undefined){
if (filter_condition === '= ' && this_data[filter_tag].toLowerCase() == filter_value) {
is_matched = true;
break;
} else if (filter_condition === '~ ' && this_data[filter_tag].toLowerCase().match(filter_value)) {
is_matched = true;
break;
}}
}
}
if (is_matched) {
selected_tr.show();
} else {
selected_tr.hide();
}
});
`
and add select in html part
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: