fix: status app
This commit is contained in:
@@ -66,6 +66,10 @@ interface StatusResponse {
|
|||||||
results: StatusRow[]
|
results: StatusRow[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BackupScriptRunResponse {
|
||||||
|
ok: boolean
|
||||||
|
}
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
endpoint?: string
|
endpoint?: string
|
||||||
@@ -80,7 +84,8 @@ const props = withDefaults(
|
|||||||
const rows = ref<StatusRow[]>([])
|
const rows = ref<StatusRow[]>([])
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const initialized = ref(false)
|
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) => {
|
const statusLabel = (row: StatusRow) => {
|
||||||
if (row.ok) return "OK"
|
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(() => {
|
onMounted(() => {
|
||||||
checkStatus()
|
checkStatus()
|
||||||
timer = setInterval(checkStatus, props.refreshMs)
|
runStatusScript()
|
||||||
|
statusTimer = setInterval(checkStatus, props.refreshMs)
|
||||||
|
scriptTimer = setInterval(runStatusScript, 5 * 60 * 1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (timer) {
|
if (statusTimer) {
|
||||||
clearInterval(timer)
|
clearInterval(statusTimer)
|
||||||
timer = null
|
statusTimer = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scriptTimer) {
|
||||||
|
clearInterval(scriptTimer)
|
||||||
|
scriptTimer = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user