From 20ce356296413d25e1dde32787e9dc41a676be47 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 14:47:37 +0200 Subject: [PATCH] fix: move restart button to settings --- apps/ui/src/lib/components/Usage.svelte | 50 ++--------------------- apps/ui/src/routes/settings/global.svelte | 49 +++++++++++++++++++--- 2 files changed, 47 insertions(+), 52 deletions(-) diff --git a/apps/ui/src/lib/components/Usage.svelte b/apps/ui/src/lib/components/Usage.svelte index e5437a1d5..a5128c6b6 100644 --- a/apps/ui/src/lib/components/Usage.svelte +++ b/apps/ui/src/lib/components/Usage.svelte @@ -20,13 +20,12 @@ let usageInterval: any; let loading = { usage: false, - cleanup: false, - restart: false + cleanup: false }; import { addToast, appSession } from '$lib/store'; import { onDestroy, onMount } from 'svelte'; import { get, post } from '$lib/api'; - import { asyncSleep, errorNotification } from '$lib/common'; + import { errorNotification } from '$lib/common'; async function getStatus() { if (loading.usage) return; loading.usage = true; @@ -34,45 +33,7 @@ usage = data.usage; loading.usage = false; } - async function restartCoolify() { - const sure = confirm( - 'Are you sure you would like to restart Coolify? Currently running deployments will be stopped and restarted.' - ); - if (sure) { - loading.restart = true; - try { - await post(`/internal/restart`, {}); - await asyncSleep(10000); - let reachable = false; - let tries = 0; - do { - await asyncSleep(4000); - try { - await get(`/undead`); - reachable = true; - } catch (error) { - reachable = false; - } - if (reachable) break; - tries++; - } while (!reachable || tries < 120); - addToast({ - message: 'New version reachable. Reloading...', - type: 'success' - }); - await asyncSleep(3000); - return window.location.reload(); - addToast({ - type: 'success', - message: 'Coolify restarted successfully. It will take a moment.' - }); - } catch (error) { - return errorNotification(error); - } finally { - loading.restart = false; - } - } - } + onDestroy(() => { clearInterval(usageInterval); }); @@ -112,11 +73,6 @@ - {/if} diff --git a/apps/ui/src/routes/settings/global.svelte b/apps/ui/src/routes/settings/global.svelte index 98da276be..ee64d908e 100644 --- a/apps/ui/src/routes/settings/global.svelte +++ b/apps/ui/src/routes/settings/global.svelte @@ -23,7 +23,7 @@ import { browser } from '$app/env'; import { t } from '$lib/translations'; import { addToast, appSession, features } from '$lib/store'; - import { errorNotification, getDomain } from '$lib/common'; + import { asyncSleep, errorNotification, getDomain } from '$lib/common'; import Menu from './_Menu.svelte'; import Explainer from '$lib/components/Explainer.svelte'; @@ -45,7 +45,8 @@ let loading = { save: false, remove: false, - proxyMigration: false + proxyMigration: false, + restart: false }; async function removeFqdn() { @@ -156,6 +157,41 @@ function resetView() { forceSave = false; } + async function restartCoolify() { + const sure = confirm( + 'Are you sure you would like to restart Coolify? Currently running deployments will be stopped and restarted.' + ); + if (sure) { + loading.restart = true; + try { + await post(`/internal/restart`, {}); + await asyncSleep(10000); + let reachable = false; + let tries = 0; + do { + await asyncSleep(4000); + try { + await get(`/undead`); + reachable = true; + } catch (error) { + reachable = false; + } + if (reachable) break; + tries++; + } while (!reachable || tries < 120); + addToast({ + message: 'New version reachable. Reloading...', + type: 'success' + }); + await asyncSleep(3000); + return window.location.reload(); + } catch (error) { + return errorNotification(error); + } finally { + loading.restart = false; + } + } + }
@@ -186,11 +222,14 @@ on:click|preventDefault={removeFqdn} disabled={loading.remove} class="btn btn-sm" - class:bg-red-600={!loading.remove} - class:hover:bg-red-500={!loading.remove} >{loading.remove ? $t('forms.removing') : $t('forms.remove_domain')} {/if} +
@@ -319,7 +358,7 @@ id="isAPIDebuggingEnabled" bind:setting={isAPIDebuggingEnabled} title="API Debugging" - description="Enable API debugging. This will log all API requests and responses.

You need to restart the Coolify (button on dashboard) for this to take effect." + description="Enable API debugging. This will log all API requests and responses.

You need to restart the Coolify for this to take effect." on:click={() => changeSettings('isAPIDebuggingEnabled')} />