fix processes fliter

This commit is contained in:
Qiuxia Fan 2022-05-18 15:59:02 +08:00
parent b02d22def3
commit 2033edbefd
2 changed files with 29 additions and 9 deletions

2
src/types/ebpf.d.ts vendored
View File

@ -52,7 +52,7 @@ export type Process = {
instanceName: string; instanceName: string;
agentId: string; agentId: string;
detectType: string; detectType: string;
attributes: { name: string; value: string }; attributes: { name: string; value: string }[];
labels: string[]; labels: string[];
}; };
export type StackElement = { export type StackElement = {

View File

@ -34,7 +34,7 @@ limitations under the License. -->
placeholder="Please input name" placeholder="Please input name"
class="input-with-search" class="input-with-search"
size="small" size="small"
@change="searchProcesses" @change="searchProcesses(0)"
> >
<template #append> <template #append>
<el-button size="small"> <el-button size="small">
@ -180,7 +180,7 @@ function visTimeline() {
}; };
} }
); );
searchProcesses(); searchProcesses(0);
if (!timeline.value) { if (!timeline.value) {
return; return;
} }
@ -200,18 +200,38 @@ function changePage(pageIndex: number) {
searchProcesses(pageIndex); searchProcesses(pageIndex);
} }
function searchProcesses(pageIndex?: any) { function searchProcesses(pageIndex: number) {
const arr = processes.value.filter( const arr = processes.value.filter(
(d: { name: string; instanceName: string }) => (d: {
name: string;
instanceName: string;
attributes: { name: string; value: string }[];
}) =>
d.name.includes(searchText.value) || d.name.includes(searchText.value) ||
d.instanceName.includes(searchText.value) d.instanceName.includes(searchText.value) ||
searchAttribute(d.attributes, searchText.value)
); );
currentProcesses.value = arr.splice( currentProcesses.value = arr.filter(
(pageIndex - 1 || 0) * pageSize, (d, index: number) =>
pageSize * (pageIndex || 1) (pageIndex - 1 || 0) * pageSize <= index &&
pageSize * (pageIndex || 1) > index
); );
} }
function searchAttribute(
attributes: { name: string; value: string }[],
text: string
) {
const item = attributes.find(
(d: { name: string; value: string }) => d.name === "command_line"
);
if (!item) {
return false;
}
return item.value.includes(text);
}
watch( watch(
() => ebpfStore.eBPFSchedules, () => ebpfStore.eBPFSchedules,
() => { () => {