Skip to content

Commit 4591296

Browse files
committed
Merge branch 'monitoring_store' into messages_store
# Conflicts: # src/Frontend/src/components/audit/AuditList.vue # src/Frontend/src/components/failedmessages/DeletedMessageGroups.vue # src/Frontend/src/composables/autoRefresh.ts # src/Frontend/src/stores/DeletedMessageGroupsStore.ts
2 parents d2c1edc + 4db6496 commit 4591296

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

src/Frontend/src/components/audit/AuditList.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ function setQuery() {
7979
}
8080
8181
watch(autoRefreshValue, (newValue) => {
82-
updateInterval(newValue || 0);
8382
if (newValue === null || newValue === 0) {
8483
stop();
85-
} else if (!isActive.value) {
86-
start();
84+
} else {
85+
updateInterval(newValue);
86+
if (!isActive.value) {
87+
start();
88+
}
8789
}
8890
});
8991
</script>

src/Frontend/src/components/failedmessages/DeletedMessageGroups.vue

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { ref, watch } from "vue";
2+
import { ref, computed, watch } from "vue";
33
import { useRouter } from "vue-router";
44
import { useShowToast } from "../../composables/toast";
55
import NoData from "../NoData.vue";
@@ -18,8 +18,10 @@ import { useStoreAutoRefresh } from "@/composables/useAutoRefresh";
1818
import { storeToRefs } from "pinia";
1919
import LoadingSpinner from "../LoadingSpinner.vue";
2020
21-
let pollingFaster = false;
22-
const { autoRefresh, isRefreshing, updateInterval } = useStoreAutoRefresh("deletedMessageGroups", useDeletedMessageGroupsStore, 5000);
21+
const POLLING_INTERVAL_NORMAL = 5000;
22+
const POLLING_INTERVAL_FAST = 1000;
23+
24+
const { autoRefresh, isRefreshing, updateInterval } = useStoreAutoRefresh("deletedMessageGroups", useDeletedMessageGroupsStore, POLLING_INTERVAL_NORMAL);
2325
const { store } = autoRefresh();
2426
const { archiveGroups, classifiers, selectedClassifier } = storeToRefs(store);
2527
const router = useRouter();
@@ -36,7 +38,6 @@ async function classifierChanged(classifier: string) {
3638
3739
//Restore operation
3840
function showRestoreGroupDialog(group: ExtendedFailureGroupView) {
39-
groupRestoreSuccessful.value = null;
4041
selectedGroup.value = group;
4142
showRestoreGroupModal.value = true;
4243
}
@@ -46,12 +47,10 @@ async function restoreGroup() {
4647
if (group) {
4748
const { result, errorMessage } = await store.restoreGroup(group);
4849
if (!result) {
49-
groupRestoreSuccessful.value = false;
5050
useShowToast(TYPE.ERROR, "Error", `Failed to restore the group: ${errorMessage}`);
5151
} else {
5252
// We're starting a restore, poll more frequently
53-
pollingFaster = true;
54-
updateInterval(1000);
53+
updateInterval(POLLING_INTERVAL_FAST);
5554
groupRestoreSuccessful.value = true;
5655
useShowToast(TYPE.INFO, "Info", "Group restore started...");
5756
}
@@ -83,19 +82,17 @@ function navigateToGroup(groupId: string) {
8382
router.push(routeLinks.failedMessage.deletedGroup.link(groupId));
8483
}
8584
86-
function isRestoreInProgress() {
85+
const isRestoreInProgress = computed(() => {
8786
return archiveGroups.value.some((group) => group.workflow_state.status !== "none" && group.workflow_state.status !== "restorecompleted");
88-
}
87+
});
8988
90-
watch(isRefreshing, () => {
91-
// If we're currently polling at 5 seconds and there is a restore in progress, then change the polling interval to poll every 1 second
92-
if (!pollingFaster && isRestoreInProgress()) {
93-
pollingFaster = true;
94-
updateInterval(1000);
95-
} else if (pollingFaster && !isRestoreInProgress()) {
96-
// if we're currently polling every 1 second and all restores are done, change polling frequency back to every 5 seconds
97-
pollingFaster = false;
98-
updateInterval(5000);
89+
watch(isRestoreInProgress, (restoreInProgress) => {
90+
if (restoreInProgress) {
91+
// If there is a restore in progress, poll every 1 second
92+
updateInterval(POLLING_INTERVAL_FAST);
93+
} else {
94+
// If all restores are done, change polling frequency back to every 5 seconds
95+
updateInterval(POLLING_INTERVAL_NORMAL);
9996
}
10097
});
10198
</script>
@@ -138,7 +135,7 @@ watch(isRefreshing, () => {
138135
<div class="row">
139136
<div class="col-sm-12 no-mobile-side-padding">
140137
<div v-if="archiveGroups.length > 0">
141-
<div :class="`row box box-group wf-${group.workflow_state.status} repeat-modify deleted-message-group`" v-for="(group, index) in archiveGroups" :key="index" :disabled="group.count == 0" @click.prevent="navigateToGroup(group.id)">
138+
<div :class="`row box box-group wf-${group.workflow_state.status} repeat-modify deleted-message-group`" v-for="group in archiveGroups" :key="group.id" :disabled="group.count == 0" @click.prevent="navigateToGroup(group.id)">
142139
<div class="col-sm-12 no-mobile-side-padding">
143140
<div class="row">
144141
<div class="col-sm-12 no-side-padding">
@@ -147,7 +144,7 @@ watch(isRefreshing, () => {
147144
<p class="lead break">{{ group.title }}</p>
148145
<p class="metadata" v-if="!isBeingRestored(group.workflow_state.status)">
149146
<MetadataItem :icon="faEnvelope">
150-
<span>{{ group.count }} message<span v-if="group.count > 1">s</span></span>
147+
<span>{{ group.count }} message<template v-if="group.count > 1">s</template></span>
151148
<span v-if="group.operation_remaining_count"> (currently restoring {{ group.operation_remaining_count }} </span>
152149
</MetadataItem>
153150

src/Frontend/src/composables/autoRefresh.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ export default function useFetchWithAutoRefresh(name: string, fetch: () => Promi
6363

6464
interval.value = newIntervalMs;
6565
console.debug(`[AutoRefresh] updated polling ${name} to ${newIntervalMs}ms`);
66-
pause();
67-
if (newIntervalMs > 0) {
66+
67+
if (isActive.value) {
68+
// We need to do this hack, because useTimeoutPoll doesn't react to interval changes while active
69+
pause();
6870
resume();
6971
}
7072
};

src/Frontend/src/stores/DeletedMessageGroupsStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const useDeletedMessageGroupsStore = defineStore("DeletedMessageGroupsSto
3232
let undismissedRestoreGroups: ExtendedFailureGroupView[] = [];
3333

3434
const serviceControlStore = useServiceControlStore();
35-
const messageGroupClient = new MessageGroupClient(serviceControlStore);
35+
const messageGroupClient = new MessageGroupClient();
3636

3737
const cookies = useCookies();
3838

@@ -113,7 +113,7 @@ export const useDeletedMessageGroupsStore = defineStore("DeletedMessageGroupsSto
113113

114114
const result = await messageGroupClient.restoreGroup(group.id);
115115
if (messageGroupClient.isError(result)) {
116-
return { result: true, errorMessage: result.message };
116+
return { result: false, errorMessage: result.message };
117117
}
118118
return { result: true };
119119
}

0 commit comments

Comments
 (0)