From a072b8ea397cc2fbd6e978b1ed948735e7a5fb29 Mon Sep 17 00:00:00 2001 From: Bruce Schultz Date: Mon, 12 Aug 2024 16:07:56 +0200 Subject: [PATCH] feat(analysis): update button statuses --- .../analysis/AnalysisControlButtons.vue | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/components/analysis/AnalysisControlButtons.vue b/components/analysis/AnalysisControlButtons.vue index b3e1580..c99bd64 100644 --- a/components/analysis/AnalysisControlButtons.vue +++ b/components/analysis/AnalysisControlButtons.vue @@ -7,15 +7,18 @@ import { } from "~/composables/useAPIFetch"; const props = defineProps({ - analysisStatus: String, + analysisRunStatus: String, analysisId: String, projectId: String, nodeId: String, }); + const toast = useToast(); -const playButtonActiveStates = [null, "stopped", "stopping"]; -const rerunButtonActiveStates = ["failed", "finished"]; +const loading = ref(false); + +const playButtonActiveStates = [null, ""]; +const rerunButtonActiveStates = ["failed", "finished", "stopped", "stopping"]; const stopButtonActiveStates = ["running", "starting", "started"]; const deleteButtonActiveStates = [ "failed", @@ -27,7 +30,7 @@ const deleteButtonActiveStates = [ "started", ]; -const buttonStatuses = ref(setButtonStatuses(props.analysisStatus!)); +const buttonStatuses = ref(setButtonStatuses(props.analysisRunStatus!)); function setButtonStatuses(podStatus: string) { return { @@ -56,7 +59,12 @@ const showSuccess = (summary: string, msg: string) => { }); }; +// async function updateHubAnalysisRunStatus(update: string) { +// await updateAnalysis(props.analysisId!, { run_status: update }); +// } + async function onStartAnalysis() { + loading.value = true; const analysisProps = {} as BodyCreateAnalysisPoPost; analysisProps.analysis_id = props.analysisId!; analysisProps.project_id = props.projectId!; @@ -66,12 +74,15 @@ async function onStartAnalysis() { const currentRunStatus = response.value!.status; buttonStatuses.value = setButtonStatuses(currentRunStatus); showSuccess("Start success", "Successfully started the container"); + // await updateHubAnalysisRunStatus("running"); } else { showFailure("Start failure", "Failed to start the analysis"); } + loading.value = false; } async function onStopAnalysis() { + loading.value = true; const { data: response, status } = await stopAnalysis(props.analysisId!); const podStatuses = response.value!.status; if (status.value === "success") { @@ -79,23 +90,23 @@ async function onStopAnalysis() { buttonStatuses.value = setButtonStatuses(podStatuses[podName]); showSuccess("Stop success", "Successfully stopped the container"); } + // await updateHubAnalysisRunStatus("stopped"); } else { showFailure("Stop failure", "Failed to stop the analysis container"); } + loading.value = false; } async function onDeleteAnalysis() { - const { data: response, status } = await deleteAnalysis(props.analysisId!); - const podStatuses = response.value!.status; + loading.value = true; + const { status } = await deleteAnalysis(props.analysisId!); if (status.value === "success") { - for (const podName in podStatuses) { - const pp = podStatuses[podName]; - buttonStatuses.value = setButtonStatuses(pp); - showSuccess("Delete success", "Successfully removed the container"); - } + buttonStatuses.value = setButtonStatuses(""); + showSuccess("Delete success", "Successfully removed the container"); } else { showFailure("Delete failure", "Failed to delete the analysis container"); } + loading.value = false; } @@ -104,21 +115,23 @@ async function onDeleteAnalysis() {