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 } })