reset timeline

This commit is contained in:
Fine 2022-08-22 11:11:01 +08:00
parent 82797cf8fb
commit 710306708b

View File

@ -46,6 +46,7 @@ import "vis-timeline/styles/vis-timeline-graph2d.css";
import dateFormatStep from "@/utils/dateFormat"; import dateFormatStep from "@/utils/dateFormat";
import getLocalTime from "@/utils/localtime"; import getLocalTime from "@/utils/localtime";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
/*global Nullable */ /*global Nullable */
const { t } = useI18n(); const { t } = useI18n();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
@ -54,6 +55,8 @@ const networkProfilingStore = useNetworkProfilingStore();
const timeRange = ref<Nullable<HTMLDivElement>>(null); const timeRange = ref<Nullable<HTMLDivElement>>(null);
const visGraph = ref<Nullable<any>>(null); const visGraph = ref<Nullable<any>>(null);
const task = ref<any[]>([]); const task = ref<any[]>([]);
const isUpdate = ref<boolean>(false);
function showTimeLine() { function showTimeLine() {
visTimeline(); visTimeline();
} }
@ -61,14 +64,20 @@ function visTimeline() {
if (!timeRange.value) { if (!timeRange.value) {
return; return;
} }
if (visGraph.value) {
visGraph.value.destroy();
}
if (!networkProfilingStore.selectedNetworkTask.taskId) { if (!networkProfilingStore.selectedNetworkTask.taskId) {
return; return;
} }
const { taskStartTime, fixedTriggerDuration, targetType } = const { taskStartTime, fixedTriggerDuration, targetType, taskId } =
networkProfilingStore.selectedNetworkTask; networkProfilingStore.selectedNetworkTask;
if (task.value[0] && task.value[0].data.taskId === taskId) {
if (isUpdate.value) {
return;
}
}
if (visGraph.value) {
visGraph.value.destroy();
}
isUpdate.value = false;
const startTime = const startTime =
fixedTriggerDuration > 1800 fixedTriggerDuration > 1800
? taskStartTime + fixedTriggerDuration * 1000 - 30 * 60 * 1000 ? taskStartTime + fixedTriggerDuration * 1000 - 30 * 60 * 1000
@ -91,14 +100,14 @@ function visTimeline() {
task.value = properties.data; task.value = properties.data;
}); });
const itemsAlwaysDraggable = const itemsAlwaysDraggable =
fixedTriggerDuration > 500 fixedTriggerDuration > 1800
? { ? {
item: true, item: true,
range: true, range: true,
} }
: undefined; : undefined;
const editable = const editable =
fixedTriggerDuration > 500 fixedTriggerDuration > 1800
? { ? {
updateTime: true, updateTime: true,
} }
@ -117,6 +126,7 @@ function visTimeline() {
visGraph.value = new Timeline(timeRange.value, items, opt); visGraph.value = new Timeline(timeRange.value, items, opt);
} }
async function updateTopology() { async function updateTopology() {
isUpdate.value = true;
const serviceInstanceId = const serviceInstanceId =
(selectorStore.currentPod && selectorStore.currentPod.id) || ""; (selectorStore.currentPod && selectorStore.currentPod.id) || "";