From 51cf096d909c86da8e6fdd504779a9e6a70df0f1 Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 6 Jun 2023 16:18:02 +0800 Subject: [PATCH] feat: vis timeline --- src/store/modules/continous-profiling.ts | 40 +---- src/store/modules/task-timeline.ts | 74 +++++++++ src/views/dashboard/controls/TaskTimeline.vue | 92 +++++++++++ src/views/dashboard/controls/index.ts | 2 + src/views/dashboard/controls/tab.ts | 2 + src/views/dashboard/data.ts | 6 + src/views/dashboard/panel/Tool.vue | 4 + .../related/task-timeline/Content.vue | 39 +++++ .../components/ProfilingPanel.vue | 33 ++++ .../task-timeline/components/Timeline.vue | 152 ++++++++++++++++++ 10 files changed, 405 insertions(+), 39 deletions(-) create mode 100644 src/store/modules/task-timeline.ts create mode 100644 src/views/dashboard/controls/TaskTimeline.vue create mode 100644 src/views/dashboard/related/task-timeline/Content.vue create mode 100644 src/views/dashboard/related/task-timeline/components/ProfilingPanel.vue create mode 100644 src/views/dashboard/related/task-timeline/components/Timeline.vue diff --git a/src/store/modules/continous-profiling.ts b/src/store/modules/continous-profiling.ts index 2b3921e1..90cb4206 100644 --- a/src/store/modules/continous-profiling.ts +++ b/src/store/modules/continous-profiling.ts @@ -20,11 +20,10 @@ import { useAppStoreWithOut } from "@/store/modules/app"; import { useNetworkProfilingStore } from "@/store/modules/network-profiling"; import type { StrategyItem, CheckItems } from "@/types/continous-profiling"; import type { EBPFTaskList, EBPFProfilingSchedule, AnalyzationTrees } from "@/types/ebpf"; -import type { Instance, Process } from "@/types/selector"; +import type { Instance } from "@/types/selector"; import { store } from "@/store"; import graphql from "@/graphql"; import type { AxiosResponse } from "axios"; -import { EBPFProfilingTriggerType } from "../data"; import dateFormatStep from "@/utils/dateFormat"; import getLocalTime from "@/utils/localtime"; @@ -146,43 +145,6 @@ export const continousProfilingStore = defineStore({ } return res.data; }, - async getContinousTaskList(params: { - serviceId: string; - serviceInstanceId: string; - targets: string[]; - triggerType: string; - }) { - if (!params.serviceId) { - return new Promise((resolve) => resolve({})); - } - const res: AxiosResponse = await graphql.query("getEBPFTasks").params(params); - - this.errorTip = ""; - if (res.data.errors) { - return res.data; - } - this.taskList = res.data.data.queryEBPFTasks || []; - if (!this.taskList.length) { - const networkProfilingStore = useNetworkProfilingStore(); - networkProfilingStore.seNodes([]); - networkProfilingStore.setLinks([]); - this.eBPFSchedules = []; - this.analyzeTrees = []; - this.selectedTask = {}; - return; - } - // this.selectedTask = this.taskList[0] || {}; - // this.setselectedTask(this.selectedTask); - // await this.getGraphData(); - return res.data; - }, - async getGraphData() { - if (this.selectedStrategy.type === "NETWORK") { - await this.getTopology(); - } else { - await this.preAnalyzeTask(); - } - }, async getTopology() { const networkProfilingStore = useNetworkProfilingStore(); const appStore = useAppStoreWithOut(); diff --git a/src/store/modules/task-timeline.ts b/src/store/modules/task-timeline.ts new file mode 100644 index 00000000..dcf3138e --- /dev/null +++ b/src/store/modules/task-timeline.ts @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ +import { defineStore } from "pinia"; +import { store } from "@/store"; +import graphql from "@/graphql"; +import type { AxiosResponse } from "axios"; +import type { EBPFTaskList } from "@/types/ebpf"; +import { useNetworkProfilingStore } from "@/store/modules/network-profiling"; +// import { EBPFProfilingTriggerType } from "../data"; + +interface taskTimelineState { + loading: boolean; + taskList: EBPFTaskList[]; +} + +export const taskTimelineStore = defineStore({ + id: "taskTimeline", + state: (): taskTimelineState => ({ + loading: false, + taskList: [], + }), + actions: { + async getContinousTaskList(params: { + serviceId: string; + serviceInstanceId: string; + targets: string[]; + triggerType: string; + }) { + if (!params.serviceId) { + return new Promise((resolve) => resolve({})); + } + this.loading = true; + const res: AxiosResponse = await graphql.query("getEBPFTasks").params(params); + + this.loading = false; + this.errorTip = ""; + if (res.data.errors) { + return res.data; + } + this.taskList = res.data.data.queryEBPFTasks || []; + if (!this.taskList.length) { + const networkProfilingStore = useNetworkProfilingStore(); + networkProfilingStore.seNodes([]); + networkProfilingStore.setLinks([]); + this.eBPFSchedules = []; + this.analyzeTrees = []; + this.selectedTask = {}; + return; + } + // this.selectedTask = this.taskList[0] || {}; + // this.setselectedTask(this.selectedTask); + // await this.getGraphData(); + return res.data; + }, + }, +}); + +export function useTaskTimelineStore(): Recordable { + return taskTimelineStore(store); +} diff --git a/src/views/dashboard/controls/TaskTimeline.vue b/src/views/dashboard/controls/TaskTimeline.vue new file mode 100644 index 00000000..cc917859 --- /dev/null +++ b/src/views/dashboard/controls/TaskTimeline.vue @@ -0,0 +1,92 @@ + + + + diff --git a/src/views/dashboard/controls/index.ts b/src/views/dashboard/controls/index.ts index 1dd159d0..01329d33 100644 --- a/src/views/dashboard/controls/index.ts +++ b/src/views/dashboard/controls/index.ts @@ -28,6 +28,7 @@ import NetworkProfiling from "./NetworkProfiling.vue"; import ContinuousProfiling from "./ContinuousProfiling.vue"; import TimeRange from "./TimeRange.vue"; import ThirdPartyApp from "./ThirdPartyApp.vue"; +import TaskTimeline from "./TaskTimeline.vue"; export default { Tab, @@ -44,4 +45,5 @@ export default { ContinuousProfiling, TimeRange, ThirdPartyApp, + TaskTimeline, }; diff --git a/src/views/dashboard/controls/tab.ts b/src/views/dashboard/controls/tab.ts index 55996e66..008c8081 100644 --- a/src/views/dashboard/controls/tab.ts +++ b/src/views/dashboard/controls/tab.ts @@ -27,6 +27,7 @@ import NetworkProfiling from "./NetworkProfiling.vue"; import ContinuousProfiling from "./ContinuousProfiling.vue"; import TimeRange from "./TimeRange.vue"; import ThirdPartyApp from "./ThirdPartyApp.vue"; +import TaskTimeline from "./TaskTimeline.vue"; export default { Widget, @@ -42,4 +43,5 @@ export default { TimeRange, ThirdPartyApp, ContinuousProfiling, + TaskTimeline, }; diff --git a/src/views/dashboard/data.ts b/src/views/dashboard/data.ts index a91d1795..27f9b504 100644 --- a/src/views/dashboard/data.ts +++ b/src/views/dashboard/data.ts @@ -242,6 +242,12 @@ export const ProcessTools = [ { name: "library_books", content: "Add Text", id: "addText" }, { name: "add_iframe", content: "Add Iframe", id: "addIframe" }, ]; +export const ProcessRelationTools = [ + { name: "playlist_add", content: "Add Widget", id: "addWidget" }, + { name: "all_inbox", content: "Add Tabs", id: "addTab" }, + { name: "library_books", content: "Add Text", id: "addText" }, + { name: "add_iframe", content: "Add Iframe", id: "addIframe" }, +]; export const ServiceRelationTools = [ { name: "playlist_add", content: "Add Widget", id: "addWidget" }, { name: "all_inbox", content: "Add Tabs", id: "addTab" }, diff --git a/src/views/dashboard/panel/Tool.vue b/src/views/dashboard/panel/Tool.vue index 9f0d27d0..e3976360 100644 --- a/src/views/dashboard/panel/Tool.vue +++ b/src/views/dashboard/panel/Tool.vue @@ -145,6 +145,7 @@ limitations under the License. --> InstanceRelationTools, ServiceRelationTools, ProcessTools, + ProcessRelationTools, } from "../data"; import { useSelectorStore } from "@/store/modules/selectors"; import { ElMessage } from "element-plus"; @@ -702,6 +703,9 @@ limitations under the License. --> toolIcons.value = EndpointRelationTools; break; case EntityType[7].value: + toolIcons.value = ProcessRelationTools; + break; + case EntityType[8].value: toolIcons.value = ProcessTools; break; default: diff --git a/src/views/dashboard/related/task-timeline/Content.vue b/src/views/dashboard/related/task-timeline/Content.vue new file mode 100644 index 00000000..2332376c --- /dev/null +++ b/src/views/dashboard/related/task-timeline/Content.vue @@ -0,0 +1,39 @@ + + + + diff --git a/src/views/dashboard/related/task-timeline/components/ProfilingPanel.vue b/src/views/dashboard/related/task-timeline/components/ProfilingPanel.vue new file mode 100644 index 00000000..16bc8362 --- /dev/null +++ b/src/views/dashboard/related/task-timeline/components/ProfilingPanel.vue @@ -0,0 +1,33 @@ + + + + diff --git a/src/views/dashboard/related/task-timeline/components/Timeline.vue b/src/views/dashboard/related/task-timeline/components/Timeline.vue new file mode 100644 index 00000000..212f8b26 --- /dev/null +++ b/src/views/dashboard/related/task-timeline/components/Timeline.vue @@ -0,0 +1,152 @@ + + + +