feat: update topology

This commit is contained in:
Fine 2023-05-29 16:37:19 +08:00
parent 7313a11ee3
commit 34ff6d9e9c

View File

@ -55,11 +55,15 @@ limitations under the License. -->
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { ElMessage } from "element-plus";
import { useSelectorStore } from "@/store/modules/selectors"; import { useSelectorStore } from "@/store/modules/selectors";
import { useContinousProfilingStore } from "@/store/modules/continous-profiling"; import { useContinousProfilingStore } from "@/store/modules/continous-profiling";
import { useNetworkProfilingStore } from "@/store/modules/network-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 ProcessTopology from "@/views/dashboard/related/network-profiling/components/ProcessTopology.vue";
import { TargetTypes } from "../data"; import { TargetTypes } from "../data";
import dateFormatStep from "@/utils/dateFormat";
import getLocalTime from "@/utils/localtime";
/*global defineProps */ /*global defineProps */
defineProps({ defineProps({
@ -70,6 +74,7 @@ limitations under the License. -->
}); });
const continousProfilingStore = useContinousProfilingStore(); const continousProfilingStore = useContinousProfilingStore();
const networkProfilingStore = useNetworkProfilingStore(); const networkProfilingStore = useNetworkProfilingStore();
const appStore = useAppStoreWithOut();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const { t } = useI18n(); const { t } = useI18n();
const processId = ref<string>(""); const processId = ref<string>("");
@ -83,8 +88,35 @@ limitations under the License. -->
processId.value = opt[0].id; processId.value = opt[0].id;
} }
function analyzeTask() { async function analyzeTask() {
networkProfilingStore.setSelectedNetworkTask(continousProfilingStore.selectedContinousTask); 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() { async function getSelectors() {