From e16643c48ccc86f0f2ecd2e8ff01a70cd61df241 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Apr 2022 22:49:24 +0200 Subject: [PATCH] feat: Query container state periodically --- src/routes/applications/[id]/__layout.svelte | 18 +++++++++++++++++- src/routes/applications/[id]/index.json.ts | 2 +- .../applications/[id]/logs/build/index.svelte | 3 +-- .../applications/[id]/logs/index.json.ts | 4 +++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/routes/applications/[id]/__layout.svelte b/src/routes/applications/[id]/__layout.svelte index 44acd35ef..b0384cf00 100644 --- a/src/routes/applications/[id]/__layout.svelte +++ b/src/routes/applications/[id]/__layout.svelte @@ -75,15 +75,18 @@ import { errorNotification } from '$lib/form'; import DeleteIcon from '$lib/components/DeleteIcon.svelte'; import Loading from '$lib/components/Loading.svelte'; - import { del, post } from '$lib/api'; + import { del, get, post } from '$lib/api'; import { goto } from '$app/navigation'; import { gitTokens } from '$lib/store'; import { toast } from '@zerodevx/svelte-toast'; import { disabledButton } from '$lib/store'; + import { onDestroy, onMount } from 'svelte'; + if (githubToken) $gitTokens.githubToken = githubToken; if (gitlabToken) $gitTokens.gitlabToken = gitlabToken; let loading = false; + let statusInterval; $disabledButton = !$session.isAdmin || !application.fqdn || @@ -130,6 +133,19 @@ return errorNotification(error); } } + async function getStatus() { + statusInterval = setInterval(async () => { + const data = await get(`/applications/${id}.json`); + isRunning = data.isRunning; + isExited = data.isExited; + }, 1000); + } + onDestroy(() => { + clearInterval(statusInterval); + }); + onMount(async () => { + await getStatus(); + });