Skip to content

Commit 478744c

Browse files
authored
Merge pull request #53 from mitre/fix/operation_data_network_usage
Refactored operation polling to only request active operation
2 parents b5f7315 + fd87628 commit 478744c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/stores/operationStore.js

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ export const useOperationStore = defineStore("operationStore", {
2727
console.error("Error fetching operations", error);
2828
}
2929
},
30+
async getOperation($api, operationID) {
31+
try {
32+
const response = await $api.get(`/api/v2/operations/${operationID}`);
33+
let operation = response.data;
34+
this.operations[operation.id] = operation;
35+
} catch (error) {
36+
console.error("Error fetching operations", error);
37+
}
38+
},
3039
async createOperation($api, operation) {
3140
try {
3241
const response = await $api.post("/api/v2/operations", operation);

src/views/OperationsView.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,14 @@ const resetFilter = () => {
190190
};
191191
192192
function selectOperation() {
193-
//TODO: Stop updating if operation is finished
194193
if (updateInterval) clearInterval(updateInterval);
195194
if (operationStore.selectedOperationID === "") return;
196195
resetFilter();
197196
updateInterval = setInterval(async () => {
198-
if (operationStore.selectedOperationID !== "") {
199-
await operationStore.getOperations($api);
197+
if (operationStore.selectedOperationID !== "" &&
198+
operationStore.operations[operationStore.selectedOperationID].state !== "finished")
199+
{
200+
await operationStore.getOperation($api, operationStore.selectedOperationID);
200201
} else {
201202
clearInterval(updateInterval);
202203
}

0 commit comments

Comments
 (0)