fix: status app
This commit is contained in:
@@ -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<StatusRow[]>([])
|
||||
const loading = ref(true)
|
||||
const initialized = ref(false)
|
||||
let timer: ReturnType<typeof setInterval> | null = null
|
||||
let statusTimer: ReturnType<typeof setInterval> | null = null
|
||||
let scriptTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
const statusLabel = (row: StatusRow) => {
|
||||
if (row.ok) return "OK"
|
||||
@@ -127,15 +132,34 @@ const checkStatus = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const runStatusScript = async () => {
|
||||
try {
|
||||
await apiFetch<BackupScriptRunResponse>("/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
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user