From 34ff6d9e9c6cde62ee13277b3f54834a24eceabc Mon Sep 17 00:00:00 2001 From: Fine Date: Mon, 29 May 2023 16:37:19 +0800 Subject: [PATCH] feat: update topology --- .../components/GraphPanel.vue | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/views/dashboard/related/continuous-profiling/components/GraphPanel.vue b/src/views/dashboard/related/continuous-profiling/components/GraphPanel.vue index b3535772..989bf5de 100644 --- a/src/views/dashboard/related/continuous-profiling/components/GraphPanel.vue +++ b/src/views/dashboard/related/continuous-profiling/components/GraphPanel.vue @@ -55,11 +55,15 @@ limitations under the License. --> import { ref, watch } from "vue"; import type { PropType } from "vue"; import { useI18n } from "vue-i18n"; + import { ElMessage } from "element-plus"; import { useSelectorStore } from "@/store/modules/selectors"; import { useContinousProfilingStore } from "@/store/modules/continous-profiling"; import { useNetworkProfilingStore } from "@/store/modules/network-profiling"; + import { useAppStoreWithOut } from "@/store/modules/app"; import ProcessTopology from "@/views/dashboard/related/network-profiling/components/ProcessTopology.vue"; import { TargetTypes } from "../data"; + import dateFormatStep from "@/utils/dateFormat"; + import getLocalTime from "@/utils/localtime"; /*global defineProps */ defineProps({ @@ -70,6 +74,7 @@ limitations under the License. --> }); const continousProfilingStore = useContinousProfilingStore(); const networkProfilingStore = useNetworkProfilingStore(); + const appStore = useAppStoreWithOut(); const selectorStore = useSelectorStore(); const { t } = useI18n(); const processId = ref(""); @@ -83,8 +88,35 @@ limitations under the License. --> processId.value = opt[0].id; } - function analyzeTask() { - networkProfilingStore.setSelectedNetworkTask(continousProfilingStore.selectedContinousTask); + async function analyzeTask() { + if (continousProfilingStore.selectedContinousTask.type === TargetTypes[2].value) { + await networkProfilingStore.setSelectedNetworkTask(continousProfilingStore.selectedContinousTask); + await getTopology(); + + return; + } + } + + async function getTopology() { + const { taskStartTime, fixedTriggerDuration } = networkProfilingStore.selectedNetworkTask; + const startTime = + fixedTriggerDuration > 1800 ? taskStartTime + fixedTriggerDuration * 1000 - 30 * 60 * 1000 : taskStartTime; + let endTime = taskStartTime + fixedTriggerDuration * 1000; + if (taskStartTime + fixedTriggerDuration * 1000 > new Date().getTime()) { + endTime = new Date().getTime(); + } + const resp = await networkProfilingStore.getProcessTopology({ + serviceInstanceId: instanceId.value, + duration: { + start: dateFormatStep(getLocalTime(appStore.utc, new Date(startTime)), appStore.duration.step, true), + end: dateFormatStep(getLocalTime(appStore.utc, new Date(endTime)), appStore.duration.step, true), + step: appStore.duration.step, + }, + }); + if (resp.errors) { + ElMessage.error(resp.errors); + } + return resp; } async function getSelectors() {