This commit is contained in:
Fine 2022-08-23 11:46:49 +08:00
parent 3047aa9254
commit 878100beb7
3 changed files with 18 additions and 15 deletions

View File

@ -115,10 +115,6 @@ export const networkProfilingStore = defineStore({
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }
await this.getTaskList({
...param,
targets: ["NETWORK"],
});
return res.data; return res.data;
}, },
async getTaskList(params: { async getTaskList(params: {

View File

@ -17,7 +17,6 @@ limitations under the License. -->
<div class="profile-task-wrapper flex-v"> <div class="profile-task-wrapper flex-v">
<div class="profile-t-tool"> <div class="profile-t-tool">
<span>{{ t("taskList") }}</span> <span>{{ t("taskList") }}</span>
<span v-if="inProcess" class="new-task cp" @click="createTask"> <span v-if="inProcess" class="new-task cp" @click="createTask">
<Icon <Icon
:style="{ color: '#ccc' }" :style="{ color: '#ccc' }"
@ -110,10 +109,11 @@ fetchTasks();
async function changeTask(item: EBPFTaskList) { async function changeTask(item: EBPFTaskList) {
networkProfilingStore.setSelectedNetworkTask(item); networkProfilingStore.setSelectedNetworkTask(item);
intervalFn.value && clearInterval(intervalFn.value);
getTopology(); getTopology();
} }
async function getTopology() { async function getTopology() {
const { taskStartTime, fixedTriggerDuration } = const { taskStartTime, fixedTriggerDuration, taskId } =
networkProfilingStore.selectedNetworkTask; networkProfilingStore.selectedNetworkTask;
const serviceInstanceId = const serviceInstanceId =
(selectorStore.currentPod && selectorStore.currentPod.id) || ""; (selectorStore.currentPod && selectorStore.currentPod.id) || "";
@ -144,10 +144,14 @@ async function getTopology() {
if (resp.errors) { if (resp.errors) {
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
} }
inProcess.value = const task = networkProfilingStore.networkTasks[0] || {};
taskStartTime + fixedTriggerDuration * 1000 > new Date().getTime() if (task.taskId === taskId) {
? true inProcess.value =
: false; task.taskStartTime + task.fixedTriggerDuration * 1000 >
new Date().getTime()
? true
: false;
}
if (!inProcess.value) { if (!inProcess.value) {
intervalFn.value && clearInterval(intervalFn.value); intervalFn.value && clearInterval(intervalFn.value);
} }
@ -173,8 +177,9 @@ async function createTask() {
}); });
if (res.errors) { if (res.errors) {
ElMessage.error(res.errors); ElMessage.error(res.errors);
return;
} }
await getTopology(); await fetchTasks();
} }
async function enableInterval() { async function enableInterval() {
const res = await networkProfilingStore.keepNetworkProfiling( const res = await networkProfilingStore.keepNetworkProfiling(
@ -184,9 +189,7 @@ async function enableInterval() {
return ElMessage.error(res.errors); return ElMessage.error(res.errors);
} }
if (networkProfilingStore.aliveNetwork) { if (networkProfilingStore.aliveNetwork) {
intervalFn.value = setInterval(() => { intervalFn.value = setInterval(getTopology, 6000);
getTopology();
}, 60000);
} }
} }
async function fetchTasks() { async function fetchTasks() {

View File

@ -83,8 +83,12 @@ function visTimeline() {
if (fixedTriggerDuration > 1800) { if (fixedTriggerDuration > 1800) {
startTime = taskStartTime + fixedTriggerDuration * 1000 - 30 * 60 * 1000; startTime = taskStartTime + fixedTriggerDuration * 1000 - 30 * 60 * 1000;
} }
const d = networkProfilingStore.networkTasks[0] || {};
let endTime = taskStartTime + fixedTriggerDuration * 1000; let endTime = taskStartTime + fixedTriggerDuration * 1000;
if (taskStartTime + fixedTriggerDuration * 1000 > new Date().getTime()) { if (
taskStartTime + fixedTriggerDuration * 1000 > new Date().getTime() &&
taskId === d.taskId
) {
endTime = new Date().getTime(); endTime = new Date().getTime();
} }
task.value = [ task.value = [