diff --git a/src/store/modules/ebpf.ts b/src/store/modules/ebpf.ts index 66714b8b..94778da8 100644 --- a/src/store/modules/ebpf.ts +++ b/src/store/modules/ebpf.ts @@ -42,6 +42,8 @@ interface EbpfStore { aggregateType: string; nodes: ProcessNode[]; calls: Call[]; + node: Nullable; + call: Nullable; } export const ebpfStore = defineStore({ @@ -61,6 +63,8 @@ export const ebpfStore = defineStore({ aggregateType: "COUNT", nodes: [], calls: [], + node: null, + call: null, }), actions: { setSelectedTask(task: EBPFTaskList) { @@ -75,6 +79,35 @@ export const ebpfStore = defineStore({ setAnalyzeTrees(tree: AnalyzationTrees[]) { this.analyzeTrees = tree; }, + setNode(node: Node) { + this.node = node; + }, + setLink(link: Call) { + this.call = link; + }, + setTopology(data: { nodes: ProcessNode[]; calls: Call[] }) { + const obj = {} as any; + const calls = (data.calls || []).reduce((prev: Call[], next: Call) => { + if (!obj[next.id]) { + obj[next.id] = true; + next.value = next.value || 1; + for (const node of data.nodes) { + if (next.source === node.id) { + next.sourceObj = node; + } + if (next.target === node.id) { + next.targetObj = node; + } + } + next.value = next.value || 1; + prev.push(next); + } + return prev; + }, []); + + this.calls = calls; + this.nodes = data.nodes; + }, async getCreateTaskData(serviceId: string) { const res: AxiosResponse = await graphql .query("getCreateTaskData") @@ -223,7 +256,9 @@ export const ebpfStore = defineStore({ this.calls = []; return res.data; } - const topo = res.data.data; + const { topology } = res.data.data; + + this.setTopology(topology); return res.data; }, }, diff --git a/src/views/dashboard/related/network-profiling/Content.vue b/src/views/dashboard/related/network-profiling/Content.vue index 03bdfadf..fc92ec8d 100644 --- a/src/views/dashboard/related/network-profiling/Content.vue +++ b/src/views/dashboard/related/network-profiling/Content.vue @@ -45,13 +45,12 @@ import ProcessTopology from "./components/ProcessTopology.vue"; .item { width: 100%; - overflow: auto; - height: calc(100% - 100px); - padding-bottom: 10px; + height: calc(100% - 210px); + background-color: #333840; } .schedules { - min-height: 90px; + height: 200px; border-bottom: 1px solid #ccc; padding-right: 10px; } diff --git a/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue b/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue index ded7c08e..5eaa503f 100644 --- a/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue +++ b/src/views/dashboard/related/network-profiling/components/ProcessTopology.vue @@ -13,17 +13,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> diff --git a/src/views/dashboard/related/network-profiling/components/Schedules.vue b/src/views/dashboard/related/network-profiling/components/Schedules.vue index 0d30d735..fa310bc4 100644 --- a/src/views/dashboard/related/network-profiling/components/Schedules.vue +++ b/src/views/dashboard/related/network-profiling/components/Schedules.vue @@ -106,7 +106,6 @@ watch( .time-ranges { width: calc(100% - 5px); margin: 0 5px 5px 0; - height: 100%; - min-height: 150px; + height: 150px; } diff --git a/src/views/dashboard/related/network-profiling/components/Tasks.vue b/src/views/dashboard/related/network-profiling/components/Tasks.vue index d982dc86..fbd792b6 100644 --- a/src/views/dashboard/related/network-profiling/components/Tasks.vue +++ b/src/views/dashboard/related/network-profiling/components/Tasks.vue @@ -85,10 +85,14 @@ import { useSelectorStore } from "@/store/modules/selectors"; import { EBPFTaskList } from "@/types/ebpf"; import { ElMessage } from "element-plus"; import TaskDetails from "../../components/TaskDetails.vue"; +import dateFormatStep from "@/utils/dateFormat"; +import getLocalTime from "@/utils/localtime"; +import { useAppStoreWithOut } from "@/store/modules/app"; const { t } = useI18n(); const selectorStore = useSelectorStore(); const ebpfStore = useEbpfStore(); +const appStore = useAppStoreWithOut(); const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") => dayjs(date).format(pattern); const viewDetail = ref(false); @@ -97,12 +101,37 @@ fetchTasks(); async function changeTask(item: EBPFTaskList) { ebpfStore.setSelectedNetworkTask(item); - const res = await ebpfStore.getEBPFSchedules({ - taskId: item.taskId, + getTopology(); +} +async function getTopology() { + const serviceInstanceId = + (selectorStore.currentPod && selectorStore.currentPod.id) || ""; + const resp = await ebpfStore.getProcessTopology({ + serviceInstanceId, + duration: { + start: dateFormatStep( + getLocalTime( + appStore.utc, + new Date(ebpfStore.selectedNetworkTask.taskStartTime) + ), + appStore.duration.step, + true + ), + end: dateFormatStep( + getLocalTime( + appStore.utc, + new Date( + ebpfStore.selectedNetworkTask.taskStartTime + + ebpfStore.selectedNetworkTask.fixedTriggerDuration * 1000 + ) + ), + appStore.duration.step, + true + ), + step: appStore.duration.step, + }, }); - if (res.errors) { - ElMessage.error(res.errors); - } + return resp; } async function createTask() { const serviceId = @@ -132,8 +161,9 @@ async function fetchTasks() { }); if (res.errors) { - ElMessage.error(res.errors); + return ElMessage.error(res.errors); } + getTopology(); }