From 96f2660b98b72aaabf012f6f05153317251fb925 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 28 Sep 2022 09:47:05 +0200 Subject: [PATCH] ui: loading button --- apps/ui/src/routes/index.svelte | 138 +++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 38 deletions(-) diff --git a/apps/ui/src/routes/index.svelte b/apps/ui/src/routes/index.svelte index 4b41d56e5..c349b2135 100644 --- a/apps/ui/src/routes/index.svelte +++ b/apps/ui/src/routes/index.svelte @@ -41,25 +41,44 @@ let numberOfGetStatus = 0; let status: any = {}; + let noInitialStatus: any = { + applications: false, + services: false, + databases: false + }; + let loading = { + applications: false, + services: false, + databases: false + }; doSearch(); async function refreshStatusApplications() { + loading.applications = true; + noInitialStatus.applications = false; numberOfGetStatus = 0; for (const application of applications) { - getStatus(application, true); + await getStatus(application, true); } + loading.applications = false; } async function refreshStatusServices() { + loading.services = true; + noInitialStatus.services = false; numberOfGetStatus = 0; for (const service of services) { - getStatus(service, true); + await getStatus(service, true); } + loading.services = false; } async function refreshStatusDatabases() { + loading.databases = true; + noInitialStatus.databases = false; numberOfGetStatus = 0; for (const database of databases) { - getStatus(database, true); + await getStatus(database, true); } + loading.databases = false; } function setInitials(onlyOthers: boolean = false) { return { @@ -109,9 +128,15 @@ async function getStatus(resources: any, force: boolean = false) { const { id, buildPack, dualCerts, type } = resources; if (buildPack && applications.length > 10 && !force) { + noInitialStatus.applications = true; return; } if (type && services.length > 10 && !force) { + noInitialStatus.services = true; + return; + } + if (databases.length > 10 && !force) { + noInitialStatus.databases = true; return; } if (status[id] && !force) return status[id]; @@ -498,8 +523,12 @@ {#if (filtered.applications.length > 0 && applications.length > 0) || filtered.otherApplications.length > 0}

Applications

- {noInitialStatus.applications ? 'Load Status' : 'Refresh Status'}
{/if} @@ -515,12 +544,16 @@ class="w-full rounded p-5 bg-coolgray-200 hover:bg-green-600 indicator duration-150" > {#await getStatus(application)} - + {:then} - {#if status[application.id] === 'running'} - - {:else} - + {#if !noInitialStatus.applications} + {#if loading.applications} + + {:else if status[application.id] === 'running'} + + {:else} + + {/if} {/if} {/await}
@@ -621,12 +654,16 @@
{#await getStatus(application)} - + {:then} - {#if status[application.id] === 'running'} - - {:else} - + {#if !noInitialStatus.applications} + {#if loading.applications} + + {:else if status[application.id] === 'running'} + + {:else} + + {/if} {/if} {/await}
@@ -708,7 +745,12 @@ {#if (filtered.services.length > 0 && services.length > 0) || filtered.otherServices.length > 0}

Services

- {noInitialStatus.services ? 'Load Status' : 'Refresh Status'}
{/if} @@ -724,12 +766,16 @@ class="w-full rounded p-5 bg-coolgray-200 hover:bg-pink-600 indicator duration-150" > {#await getStatus(service)} - + {:then} - {#if status[service.id] === 'running'} - - {:else} - + {#if !noInitialStatus.services} + {#if loading.services} + + {:else if status[service.id] === 'running'} + + {:else} + + {/if} {/if} {/await}