fix: dashboard statuses

This commit is contained in:
Andras Bacsai 2022-09-29 13:02:10 +02:00
parent 683b8c966f
commit 4fe436e4d1

View File

@ -57,31 +57,28 @@
doSearch(); doSearch();
async function refreshStatusApplications() { async function refreshStatusApplications() {
loading.applications = true;
noInitialStatus.applications = false; noInitialStatus.applications = false;
numberOfGetStatus = 0; numberOfGetStatus = 0;
for (const application of applications) { for (const application of applications) {
await getStatus(application, true); status[application.id] = 'loading';
getStatus(application, true);
} }
loading.applications = false;
} }
async function refreshStatusServices() { async function refreshStatusServices() {
loading.services = true;
noInitialStatus.services = false; noInitialStatus.services = false;
numberOfGetStatus = 0; numberOfGetStatus = 0;
for (const service of services) { for (const service of services) {
await getStatus(service, true); status[service.id] = 'loading';
getStatus(service, true);
} }
loading.services = false;
} }
async function refreshStatusDatabases() { async function refreshStatusDatabases() {
loading.databases = true;
noInitialStatus.databases = false; noInitialStatus.databases = false;
numberOfGetStatus = 0; numberOfGetStatus = 0;
for (const database of databases) { for (const database of databases) {
await getStatus(database, true); status[database.id] = 'loading';
getStatus(database, true);
} }
loading.databases = false;
} }
function setInitials(onlyOthers: boolean = false) { function setInitials(onlyOthers: boolean = false) {
return { return {
@ -565,11 +562,7 @@
{#if (filtered.applications.length > 0 && applications.length > 0) || filtered.otherApplications.length > 0} {#if (filtered.applications.length > 0 && applications.length > 0) || filtered.otherApplications.length > 0}
<div class="flex items-center mt-10 space-x-2"> <div class="flex items-center mt-10 space-x-2">
<h1 class="title lg:text-3xl">Applications</h1> <h1 class="title lg:text-3xl">Applications</h1>
<button <button class="btn btn-sm btn-primary" on:click={refreshStatusApplications}
class="btn btn-sm btn-primary"
class:loading={loading.applications}
disabled={loading.applications}
on:click={refreshStatusApplications}
>{noInitialStatus.applications ? 'Load Status' : 'Refresh Status'}</button >{noInitialStatus.applications ? 'Load Status' : 'Refresh Status'}</button
> >
{#if foundUnconfiguredApplication} {#if foundUnconfiguredApplication}
@ -597,7 +590,7 @@
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:then} {:then}
{#if !noInitialStatus.applications} {#if !noInitialStatus.applications}
{#if loading.applications} {#if status[application.id] === 'loading'}
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:else if status[application.id] === 'running'} {:else if status[application.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" /> <span class="indicator-item badge bg-success badge-sm" />
@ -704,7 +697,7 @@
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:then} {:then}
{#if !noInitialStatus.applications} {#if !noInitialStatus.applications}
{#if loading.applications} {#if status[application.id] === 'loading'}
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:else if status[application.id] === 'running'} {:else if status[application.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" /> <span class="indicator-item badge bg-success badge-sm" />
@ -792,11 +785,7 @@
{#if (filtered.services.length > 0 && services.length > 0) || filtered.otherServices.length > 0} {#if (filtered.services.length > 0 && services.length > 0) || filtered.otherServices.length > 0}
<div class="flex items-center mt-10 space-x-2"> <div class="flex items-center mt-10 space-x-2">
<h1 class="title lg:text-3xl">Services</h1> <h1 class="title lg:text-3xl">Services</h1>
<button <button class="btn btn-sm btn-primary" on:click={refreshStatusServices}
class="btn btn-sm btn-primary"
class:loading={loading.services}
disabled={loading.services}
on:click={refreshStatusServices}
>{noInitialStatus.services ? 'Load Status' : 'Refresh Status'}</button >{noInitialStatus.services ? 'Load Status' : 'Refresh Status'}</button
> >
{#if foundUnconfiguredService} {#if foundUnconfiguredService}
@ -824,7 +813,7 @@
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:then} {:then}
{#if !noInitialStatus.services} {#if !noInitialStatus.services}
{#if loading.services} {#if status[service.id] === 'loading'}
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:else if status[service.id] === 'running'} {:else if status[service.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" /> <span class="indicator-item badge bg-success badge-sm" />
@ -897,7 +886,7 @@
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:then} {:then}
{#if !noInitialStatus.services} {#if !noInitialStatus.services}
{#if loading.services} {#if status[service.id] === 'loading'}
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:else if status[service.id] === 'running'} {:else if status[service.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" /> <span class="indicator-item badge bg-success badge-sm" />
@ -954,11 +943,7 @@
{#if (filtered.databases.length > 0 && databases.length > 0) || filtered.otherDatabases.length > 0} {#if (filtered.databases.length > 0 && databases.length > 0) || filtered.otherDatabases.length > 0}
<div class="flex items-center mt-10 space-x-2"> <div class="flex items-center mt-10 space-x-2">
<h1 class="title lg:text-3xl">Databases</h1> <h1 class="title lg:text-3xl">Databases</h1>
<button <button class="btn btn-sm btn-primary" on:click={refreshStatusDatabases}
class="btn btn-sm btn-primary"
on:click={refreshStatusDatabases}
class:loading={loading.databases}
disabled={loading.databases}
>{noInitialStatus.databases ? 'Load Status' : 'Refresh Status'}</button >{noInitialStatus.databases ? 'Load Status' : 'Refresh Status'}</button
> >
{#if foundUnconfiguredDatabase} {#if foundUnconfiguredDatabase}
@ -986,9 +971,9 @@
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:then} {:then}
{#if !noInitialStatus.databases} {#if !noInitialStatus.databases}
{#if loading.databases} {#if status[database.id] === 'loading'}
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:else if status[databases.id] === 'running'} {:else if status[database.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" /> <span class="indicator-item badge bg-success badge-sm" />
{:else} {:else}
<span class="indicator-item badge bg-error badge-sm" /> <span class="indicator-item badge bg-error badge-sm" />
@ -1063,9 +1048,9 @@
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:then} {:then}
{#if !noInitialStatus.databases} {#if !noInitialStatus.databases}
{#if loading.databases} {#if status[database.id] === 'loading'}
<span class="indicator-item badge bg-yellow-300 badge-sm" /> <span class="indicator-item badge bg-yellow-300 badge-sm" />
{:else if status[databases.id] === 'running'} {:else if status[database.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" /> <span class="indicator-item badge bg-success badge-sm" />
{:else} {:else}
<span class="indicator-item badge bg-error badge-sm" /> <span class="indicator-item badge bg-error badge-sm" />