Skip to content

Commit

Permalink
Add support for negative filters
Browse files Browse the repository at this point in the history
  • Loading branch information
qtc-de committed Jul 24, 2024
1 parent 4b6833b commit f04cb9d
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions frontend/src/components/ProcessTableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@
if (!filter.includes(':'))
{
return process.path.toLowerCase().includes(filter) || process.cmdline.toLowerCase().includes(filter) ||
process.user.toLowerCase().includes(filter) || process.pid == filter;
let inverse = false;
if (filter.startsWith('!'))
{
filter = filter.substring(1);
inverse = true;
}
return (process.path.toLowerCase().includes(filter) || process.cmdline.toLowerCase().includes(filter) ||
process.user.toLowerCase().includes(filter) || process.pid == filter) != inverse;
}
let result = true;
Expand All @@ -48,6 +56,8 @@
for (const entry of filterArray)
{
let key, value;
let inverse = false;
[key, value] = entry.split(':', 2);
if (value === undefined)
Expand All @@ -58,7 +68,13 @@
continue;
}
else if (key === 'uuid' || key === 'id' || key == 'location')
if (value.startsWith('!'))
{
value = value.substring(1);
inverse = true;
}
if (key === 'uuid' || key === 'id' || key == 'location')
{
let found = false;
Expand All @@ -69,14 +85,13 @@
for (const intf of process.rpc_info.interface_infos)
{
if (String(intf[key]).toLowerCase().includes(value))
if (String(intf[key]).toLowerCase().includes(value) != inverse)
{
found = true
}
}
result = result && found;
continue;
}
else if (key === 'endpoint')
Expand All @@ -85,17 +100,39 @@
for (const endpoint of process.rpc_info.server_info.endpoints)
{
if (endpoint.name.toLowerCase().includes(value))
const mergedEndpoint = `${endpoint.protocol}:${endpoint.name}`;
if (mergedEndpoint.toLowerCase().includes(value) != inverse)
{
found = true
}
}
result = result && found;
continue;
}
result = result && (Object.hasOwn(process, key) && String(process[key]).toLowerCase().includes(value));
else if (key === 'flags')
{
let found = false;
for (const intf of process.rpc_info.interface_infos)
{
for (const flag of intf.flags)
{
if (flag.toLowerCase().includes(value) != inverse)
{
found = true
}
}
}
result = result && found;
}
else
{
result = result && (Object.hasOwn(process, key) && String(process[key]).toLowerCase().includes(value) != inverse);
}
}
return result;
Expand Down

0 comments on commit f04cb9d

Please sign in to comment.