From c5b7f92caf349b694df7dfc8d46f9962a756dd5f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 15 Feb 2022 09:38:16 +0100 Subject: [PATCH] feat: Follow logs --- src/lib/database/applications.ts | 12 +++-- .../[id]/logs/build/_BuildLog.svelte | 46 +++++++++++++++-- .../applications/[id]/logs/build/index.svelte | 44 ++--------------- .../applications/[id]/logs/index.svelte | 49 +++++++++++++++++-- 4 files changed, 100 insertions(+), 51 deletions(-) diff --git a/src/lib/database/applications.ts b/src/lib/database/applications.ts index d7d2a5d8a..738ebe594 100644 --- a/src/lib/database/applications.ts +++ b/src/lib/database/applications.ts @@ -59,10 +59,14 @@ export async function removeApplication({ id, teamId }) { const id = containerObj.ID; const preview = containerObj.Image.split('-')[1]; await removeDestinationDocker({ id, engine: destinationDocker.engine }); - if (preview) { - await removeProxyConfiguration({ domain: `${preview}.${domain}` }); - } else { - await removeProxyConfiguration({ domain }); + try { + if (preview) { + await removeProxyConfiguration({ domain: `${preview}.${domain}` }); + } else { + await removeProxyConfiguration({ domain }); + } + } catch (error) { + console.log(error); } } } diff --git a/src/routes/applications/[id]/logs/build/_BuildLog.svelte b/src/routes/applications/[id]/logs/build/_BuildLog.svelte index 9570bf772..0803e69de 100644 --- a/src/routes/applications/[id]/logs/build/_BuildLog.svelte +++ b/src/routes/applications/[id]/logs/build/_BuildLog.svelte @@ -1,6 +1,5 @@
@@ -138,39 +127,16 @@
{/each} - - {#if buildCount > 0 && !noMoreBuilds} - - {/if} +
{#if buildId} {#key buildId} - + {/key} {/if}
diff --git a/src/routes/applications/[id]/logs/index.svelte b/src/routes/applications/[id]/logs/index.svelte index ae45475fe..a04fca2e3 100644 --- a/src/routes/applications/[id]/logs/index.svelte +++ b/src/routes/applications/[id]/logs/index.svelte @@ -27,19 +27,23 @@ import { getDomain } from '$lib/components/common'; import { get } from '$lib/api'; import { errorNotification } from '$lib/form'; + let loadLogsInterval = null; let logs = []; + let followingBuild; + let followingInterval; + let logsEl; const { id } = $page.params; - onMount(async () => { loadLogs(); loadLogsInterval = setInterval(() => { loadLogs(); - }, 3000); + }, 1000); }); onDestroy(() => { - clearInterval(loadLogsInterval); + window.clearInterval(loadLogsInterval); + window.clearInterval(followingInterval); }); async function loadLogs() { try { @@ -50,6 +54,18 @@ return errorNotification(error); } } + + function followBuild() { + followingBuild = !followingBuild; + if (followingBuild) { + followingInterval = setInterval(() => { + logsEl.scrollTop = logsEl.scrollHeight; + window.scrollTo(0, document.body.scrollHeight); + }, 100); + } else { + window.clearInterval(followingInterval); + } + }
@@ -63,8 +79,33 @@ {:else}
+
+ +
{#each logs as log} {log + '\n'}