Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firewall log live view: add logical operator selection #4361

Closed
kulikov-a opened this issue Sep 19, 2020 · 3 comments
Closed

firewall log live view: add logical operator selection #4361

kulikov-a opened this issue Sep 19, 2020 · 3 comments
Assignees
Labels
feature Adding new functionality

Comments

@kulikov-a
Copy link
Member

kulikov-a commented Sep 19, 2020

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
ORfilter
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.

@AdSchellevis AdSchellevis self-assigned this Sep 19, 2020
@AdSchellevis AdSchellevis added the feature Adding new functionality label Sep 19, 2020
@AdSchellevis
Copy link
Member

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.

image

@kulikov-a
Copy link
Member Author

I agree. a combined search would be too tricky. checked out the new script. works great.
thanks!!

@mimugmail
Copy link
Member

Really nice 💯

fichtner pushed a commit that referenced this issue Oct 20, 2020
oshogbo pushed a commit to DynFi/opnsense-core that referenced this issue Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding new functionality
Development

No branches or pull requests

3 participants