Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: refresh resource status on dashboard

Andras Bacsaibe507be3a90c
diff --git a/apps/ui/src/routes/index.svelte b/apps/ui/src/routes/index.svelte
index 08cffc0aea..15ba421ad7 100644
--- a/apps/ui/src/routes/index.svelte
+++ b/apps/ui/src/routes/index.svelte
@@ -31,7 +31,7 @@
import { get } from '$lib/api';
import { t } from '$lib/translations';
import { asyncSleep, getRndInteger } from '$lib/common';
- import { appSession, search, addToast} from '$lib/store';
+ import { appSession, search } from '$lib/store';
import ApplicationsIcons from '$lib/components/svg/applications/ApplicationIcons.svelte';
import DatabaseIcons from '$lib/components/svg/databases/DatabaseIcons.svelte';
@@ -42,6 +42,25 @@
let numberOfGetStatus = 0;
let status: any = {};
doSearch();
+
+ async function refreshStatusApplications() {
+ numberOfGetStatus = 0;
+ for (const application of applications) {
+ getStatus(application, true);
+ }
+ }
+ async function refreshStatusServices() {
+ numberOfGetStatus = 0;
+ for (const service of services) {
+ getStatus(service, true);
+ }
+ }
+ async function refreshStatusDatabases() {
+ numberOfGetStatus = 0;
+ for (const database of databases) {
+ getStatus(database, true);
+ }
+ }
function setInitials(onlyOthers: boolean = false) {
return {
applications:
@@ -87,12 +106,17 @@
filtered.otherDestinations = [];
}
-
- async function getStatus(resources: any) {
- const { id, buildPack, dualCerts } = resources;
- if (status[id]) return status[id];
+ async function getStatus(resources: any, force: boolean = false) {
+ const { id, buildPack, dualCerts, type } = resources;
+ if (buildPack && applications.length > 10 && !force) {
+ return;
+ }
+ if (type && services.length > 10 && !force) {
+ return;
+ }
+ if (status[id] && !force) return status[id];
while (numberOfGetStatus > 1) {
- await asyncSleep(getRndInteger(100, 200));
+ await asyncSleep(getRndInteger(100, 500));
}
try {
numberOfGetStatus++;
@@ -118,6 +142,7 @@
status[id] = 'error';
return 'error';
} finally {
+ status = { ...status };
numberOfGetStatus--;
}
}
@@ -275,7 +300,6 @@
filtered = setInitials();
}
}
-
</script>
<nav class="header">
@@ -375,7 +399,10 @@
{/if}
{#if (filtered.applications.length > 0 && applications.length > 0) || filtered.otherApplications.length > 0}
<div class="flex items-center mt-10">
- <h1 class="title lg:text-3xl">Applications</h1>
+ <h1 class="title lg:text-3xl pr-4">Applications</h1>
+ <button class="btn btn-sm btn-primary" on:click={refreshStatusApplications}
+ >Refresh Status</button
+ >
</div>
{/if}
{#if filtered.applications.length > 0 && applications.length > 0}
@@ -386,11 +413,13 @@
{#if filtered.applications.length > 0}
{#each filtered.applications as application}
<a class="no-underline mb-5" href={`/applications/${application.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-green-600 indicator">
+ <div
+ class="w-full rounded p-5 bg-coolgray-200 hover:bg-green-600 indicator duration-150"
+ >
{#await getStatus(application)}
<span class="indicator-item badge bg-yellow-500 badge-sm" />
- {:then status}
- {#if status === 'running'}
+ {:then}
+ {#if status[application.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" />
{:else}
<span class="indicator-item badge bg-error badge-sm" />
@@ -492,11 +521,11 @@
>
{#each filtered.otherApplications as application}
<a class="no-underline mb-5" href={`/applications/${application.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-green-600 indicator">
+ <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-green-600 indicator duration-150">
{#await getStatus(application)}
<span class="indicator-item badge bg-yellow-500 badge-sm" />
- {:then status}
- {#if status === 'running'}
+ {:then}
+ {#if status[application.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" />
{:else}
<span class="indicator-item badge bg-error badge-sm" />
@@ -580,7 +609,9 @@
{/if}
{#if (filtered.services.length > 0 && services.length > 0) || filtered.otherServices.length > 0}
<div class="flex items-center mt-10">
- <h1 class="title lg:text-3xl">Services</h1>
+ <h1 class="title lg:text-3xl pr-4">Services</h1>
+ <button class="btn btn-sm btn-primary" on:click={refreshStatusServices}>Refresh Status</button
+ >
</div>
{/if}
{#if filtered.services.length > 0 && services.length > 0}
@@ -591,11 +622,13 @@
{#if filtered.services.length > 0}
{#each filtered.services as service}
<a class="no-underline mb-5" href={`/services/${service.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-pink-600 indicator">
+ <div
+ class="w-full rounded p-5 bg-coolgray-200 hover:bg-pink-600 indicator duration-150"
+ >
{#await getStatus(service)}
<span class="indicator-item badge bg-yellow-500 badge-sm" />
- {:then status}
- {#if status === 'running'}
+ {:then}
+ {#if status[service.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" />
{:else}
<span class="indicator-item badge bg-error badge-sm" />
@@ -663,11 +696,11 @@
>
{#each filtered.otherServices as service}
<a class="no-underline mb-5" href={`/services/${service.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-pink-600 indicator">
+ <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-pink-600 indicator duration-150">
{#await getStatus(service)}
<span class="indicator-item badge bg-yellow-500 badge-sm" />
- {:then status}
- {#if status === 'running'}
+ {:then}
+ {#if status[service.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" />
{:else}
<span class="indicator-item badge bg-error badge-sm" />
@@ -720,7 +753,10 @@
{/if}
{#if (filtered.databases.length > 0 && databases.length > 0) || filtered.otherDatabases.length > 0}
<div class="flex items-center mt-10">
- <h1 class="title lg:text-3xl">Databases</h1>
+ <h1 class="title lg:text-3xl pr-4">Databases</h1>
+ <button class="btn btn-sm btn-primary" on:click={refreshStatusDatabases}
+ >Refresh Status</button
+ >
</div>
{/if}
{#if filtered.databases.length > 0 && databases.length > 0}
@@ -731,11 +767,13 @@
{#if filtered.databases.length > 0}
{#each filtered.databases as database}
<a class="no-underline mb-5" href={`/databases/${database.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-databases indicator">
+ <div
+ class="w-full rounded p-5 bg-coolgray-200 hover:bg-databases indicator duration-150"
+ >
{#await getStatus(database)}
<span class="indicator-item badge bg-yellow-500 badge-sm" />
- {:then status}
- {#if status === 'running'}
+ {:then}
+ {#if status[database.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" />
{:else}
<span class="indicator-item badge bg-error badge-sm" />
@@ -807,11 +845,11 @@
>
{#each filtered.otherDatabases as database}
<a class="no-underline mb-5" href={`/databases/${database.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-databases indicator">
+ <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-databases indicator duration-150">
{#await getStatus(database)}
<span class="indicator-item badge bg-yellow-500 badge-sm" />
- {:then status}
- {#if status === 'running'}
+ {:then}
+ {#if status[database.id] === 'running'}
<span class="indicator-item badge bg-success badge-sm" />
{:else}
<span class="indicator-item badge bg-error badge-sm" />
@@ -879,7 +917,7 @@
{#if filtered.gitSources.length > 0}
{#each filtered.gitSources as source}
<a class="no-underline mb-5" href={`/sources/${source.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-sources indicator">
+ <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-sources indicator duration-150">
<div class="w-full flex flex-row">
<div class="absolute top-0 left-0 -m-5 h-10 w-10">
{#if source?.type === 'gitlab'}
@@ -951,7 +989,7 @@
>
{#each filtered.otherGitSources as source}
<a class="no-underline mb-5" href={`/sources/${source.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-sources indicator">
+ <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-sources indicator duration-150">
<div class="w-full flex flex-row">
<div class="absolute top-0 left-0 -m-5 h-10 w-10">
{#if source?.type === 'gitlab'}
@@ -1018,7 +1056,9 @@
{#if filtered.destinations.length > 0}
{#each filtered.destinations as destination}
<a class="no-underline mb-5" href={`/destinations/${destination.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-destinations indicator">
+ <div
+ class="w-full rounded p-5 bg-coolgray-200 hover:bg-destinations indicator duration-150"
+ >
<div class="w-full flex flex-row">
<div class="absolute top-0 left-0 -m-5 h-10 w-10">
<svg
@@ -1100,7 +1140,9 @@
>
{#each filtered.otherDestinations as destination}
<a class="no-underline mb-5" href={`/destinations/${destination.id}`}>
- <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-destinations indicator">
+ <div
+ class="w-full rounded p-5 bg-coolgray-200 hover:bg-destinations indicator duration-150"
+ >
<div class="w-full flex flex-row">
<div class="absolute top-0 left-0 -m-5 h-10 w-10">
<svg