From 66a6a8caf0eb3697c9b45d3bb6c2c552a402ac6b Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 19 Mar 2026 09:37:55 +0100 Subject: [PATCH] fix: status app --- components/StatusSite.vue | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/components/StatusSite.vue b/components/StatusSite.vue index cbf8197..e1e4f92 100644 --- a/components/StatusSite.vue +++ b/components/StatusSite.vue @@ -66,6 +66,10 @@ interface StatusResponse { results: StatusRow[] } +interface BackupScriptRunResponse { + ok: boolean +} + const props = withDefaults( defineProps<{ endpoint?: string @@ -80,7 +84,8 @@ const props = withDefaults( const rows = ref([]) const loading = ref(true) const initialized = ref(false) -let timer: ReturnType | null = null +let statusTimer: ReturnType | null = null +let scriptTimer: ReturnType | null = null const statusLabel = (row: StatusRow) => { if (row.ok) return "OK" @@ -127,15 +132,34 @@ const checkStatus = async () => { } } +const runStatusScript = async () => { + try { + await apiFetch("/api/backup-script", { + method: "POST", + body: { key: "check-statut-recette" } + }) + await checkStatus() + } catch (error) { + console.error("Erreur execution check statut recette:", error) + } +} + onMounted(() => { checkStatus() - timer = setInterval(checkStatus, props.refreshMs) + runStatusScript() + statusTimer = setInterval(checkStatus, props.refreshMs) + scriptTimer = setInterval(runStatusScript, 5 * 60 * 1000) }) onBeforeUnmount(() => { - if (timer) { - clearInterval(timer) - timer = null + if (statusTimer) { + clearInterval(statusTimer) + statusTimer = null + } + + if (scriptTimer) { + clearInterval(scriptTimer) + scriptTimer = null } })