Fixes MOD-160 (#2948)

* fix: refresh backups automatically when ongoing backups are running

Signed-off-by: Evan Song <theevansong@gmail.com>

* chore: improve backup creation rate limit msg

Signed-off-by: Evan Song <theevansong@gmail.com>

* chore: increase polling timeout

Signed-off-by: Evan Song <theevansong@gmail.com>

* chore: clean

Signed-off-by: Evan Song <theevansong@gmail.com>

* chore: add notice of automatic refresh

Signed-off-by: Evan Song <theevansong@gmail.com>

---------

Signed-off-by: Evan Song <theevansong@gmail.com>
This commit is contained in:
Evan Song
2024-11-17 19:59:01 -07:00
committed by GitHub
parent a1a920ee67
commit 1f230383ce
2 changed files with 52 additions and 5 deletions

View File

@@ -66,7 +66,11 @@
: ''
"
class="w-full sm:w-fit"
:disabled="isServerRunning && !userPreferences.backupWhileRunning"
:disabled="
(isServerRunning && !userPreferences.backupWhileRunning) ||
data.used_backup_quota >= data.backup_quota ||
backups.some((backup) => backup.ongoing)
"
@click="showCreateModel"
>
<PlusIcon class="h-5 w-5" />
@@ -77,6 +81,15 @@
</div>
</div>
<div
v-if="backups.some((backup) => backup.ongoing)"
data-pyro-server-backup-ongoing
class="flex w-full flex-row items-center gap-4 rounded-2xl bg-bg-orange p-4 text-contrast"
>
A backup is currently being created. This may take a few minutes. This page will
automatically refresh when the backup is complete.
</div>
<li
v-for="(backup, index) in backups"
:key="backup.id"
@@ -246,6 +259,8 @@ const backupSettingsModal = ref<typeof NewModal>();
const renameBackupName = ref("");
const currentBackup = ref("");
const refreshInterval = ref<ReturnType<typeof setInterval>>();
const currentBackupDetails = computed(() => {
return backups.value.find((backup) => backup.id === currentBackup.value);
});
@@ -319,6 +334,29 @@ const initiateDownload = async (backupId: string) => {
console.error("Download failed:", error);
}
};
onMounted(() => {
watchEffect(() => {
const hasOngoingBackups = backups.value.some((backup) => backup.ongoing);
if (refreshInterval.value) {
clearInterval(refreshInterval.value);
refreshInterval.value = undefined;
}
if (hasOngoingBackups) {
refreshInterval.value = setInterval(() => {
props.server.refresh(["backups"]);
}, 10000);
}
});
});
onUnmounted(() => {
if (refreshInterval.value) {
clearInterval(refreshInterval.value);
}
});
</script>
<style scoped>