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;
agentId: string;
detectType: string;
attributes: { name: string; value: string };
attributes: { name: string; value: string }[];
labels: string[];
};
export type StackElement = {

View File

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