ui: reload compose loading

This commit is contained in:
Andras Bacsai 2022-11-14 11:53:53 +01:00
parent d5620d305d
commit 3ab87cd11e

View File

@ -61,7 +61,10 @@
$isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application); $isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application);
let statues: any = {}; let statues: any = {};
let loading = false; let loading = {
save: false,
reloadCompose: false
};
let fqdnEl: any = null; let fqdnEl: any = null;
let forceSave = false; let forceSave = false;
let isPublicRepository = application.settings.isPublicRepository; let isPublicRepository = application.settings.isPublicRepository;
@ -102,7 +105,6 @@
label: 'Uvicorn' label: 'Uvicorn'
} }
]; ];
function normalizeDockerServices(services: any[]) { function normalizeDockerServices(services: any[]) {
const tempdockerComposeServices = []; const tempdockerComposeServices = [];
for (const [name, data] of Object.entries(services)) { for (const [name, data] of Object.entries(services)) {
@ -237,8 +239,8 @@
} }
} }
async function handleSubmit(toast: boolean = true) { async function handleSubmit(toast: boolean = true) {
if (loading) return; if (loading.save) return;
if (toast) loading = true; if (toast) loading.save = true;
try { try {
nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, ''); nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, '');
if (application.deploymentType) if (application.deploymentType)
@ -299,7 +301,7 @@
} }
return errorNotification(error); return errorNotification(error);
} finally { } finally {
loading = false; loading.save = false;
} }
} }
async function selectWSGI(event: any) { async function selectWSGI(event: any) {
@ -361,6 +363,8 @@
}); });
} }
async function reloadCompose() { async function reloadCompose() {
if (loading.reloadCompose) return;
loading.reloadCompose = true;
try { try {
if (application.gitSource.type === 'github') { if (application.gitSource.type === 'github') {
const headers = isPublicRepository const headers = isPublicRepository
@ -427,6 +431,8 @@
}); });
} catch (error) { } catch (error) {
errorNotification(error); errorNotification(error);
} finally {
loading.reloadCompose = false;
} }
} }
$: if ($status.application.statuses) { $: if ($status.application.statuses) {
@ -464,10 +470,10 @@
<button <button
class="btn btn-sm btn-primary" class="btn btn-sm btn-primary"
type="submit" type="submit"
class:loading class:loading={loading.save}
class:bg-orange-600={forceSave} class:bg-orange-600={forceSave}
class:hover:bg-orange-400={forceSave} class:hover:bg-orange-400={forceSave}
disabled={loading}>{$t('forms.save')}</button disabled={loading.save}>{$t('forms.save')}</button
> >
{/if} {/if}
</div> </div>
@ -993,8 +999,11 @@
<div class="title font-bold pb-3 pt-10 border-b border-coolgray-500 mb-6"> <div class="title font-bold pb-3 pt-10 border-b border-coolgray-500 mb-6">
Stack <Beta /> Stack <Beta />
{#if $appSession.isAdmin} {#if $appSession.isAdmin}
<button class="btn btn-sm btn-primary" on:click|preventDefault={reloadCompose} <button
>Reload Docker Compose File</button class="btn btn-sm btn-primary"
class:loading={loading.reloadCompose}
disabled={loading.reloadCompose}
on:click|preventDefault={reloadCompose}>Reload Docker Compose File</button
> >
{/if} {/if}
</div> </div>