diff --git a/src/stores/operationStore.js b/src/stores/operationStore.js index 5d99799..a225902 100644 --- a/src/stores/operationStore.js +++ b/src/stores/operationStore.js @@ -27,6 +27,15 @@ export const useOperationStore = defineStore("operationStore", { console.error("Error fetching operations", error); } }, + async getOperation($api, operationID) { + try { + const response = await $api.get(`/api/v2/operations/${operationID}`); + let operation = response.data; + this.operations[operation.id] = operation; + } catch (error) { + console.error("Error fetching operations", error); + } + }, async createOperation($api, operation) { try { const response = await $api.post("/api/v2/operations", operation); diff --git a/src/views/OperationsView.vue b/src/views/OperationsView.vue index df05c10..aa4a225 100644 --- a/src/views/OperationsView.vue +++ b/src/views/OperationsView.vue @@ -190,13 +190,14 @@ const resetFilter = () => { }; function selectOperation() { - //TODO: Stop updating if operation is finished if (updateInterval) clearInterval(updateInterval); if (operationStore.selectedOperationID === "") return; resetFilter(); updateInterval = setInterval(async () => { - if (operationStore.selectedOperationID !== "") { - await operationStore.getOperations($api); + if (operationStore.selectedOperationID !== "" && + operationStore.operations[operationStore.selectedOperationID].state !== "finished") + { + await operationStore.getOperation($api, operationStore.selectedOperationID); } else { clearInterval(updateInterval); }