diff --git a/dashboard/src/components/app/Uninstall.vue b/dashboard/src/components/app/Uninstall.vue index df95d42c1..72495f520 100644 --- a/dashboard/src/components/app/Uninstall.vue +++ b/dashboard/src/components/app/Uninstall.vue @@ -18,42 +18,6 @@ const props = defineProps([ 'app' ]); const latestBackup = ref(null); -const TARGET_RUN_STATE = { - START: Symbol('start'), - STOP: Symbol('stop'), -}; - -function targetRunState() { - const app = props.app; - - // if we have an error, we want to retry the pending state, otherwise toggle the runstate - if (app.error) { - if (app.error.details.installationState === ISTATES.PENDING_START) return TARGET_RUN_STATE.START; - else return TARGET_RUN_STATE.STOP; - } else { - if (app.runState === RSTATES.STOPPED) return TARGET_RUN_STATE.START; - else return TARGET_RUN_STATE.STOP; - } -} - -const toggleRunStateBusy = ref(false); -async function onToggleRunState() { - const app = props.app; - - toggleRunStateBusy.value = true; - - let error; - if (targetRunState() === TARGET_RUN_STATE.START) [error] = await appsModel.start(app.id); - else [error] = await appsModel.stop(app.id); - - if (error) { - toggleRunStateBusy.value = false; - console.error(error); - } else { - setTimeout(() => toggleRunStateBusy.value = false, 3000); - } -} - async function onUninstall() { const yes = await inputDialog.value.confirm({ title: t('app.uninstallDialog.title', { app: (props.app.label || props.app.fqdn) }), @@ -111,20 +75,6 @@ onMounted(async () => {
-
- -
{{ $t('app.uninstall.startStop.description') }}
-
- -
- -
-
diff --git a/dashboard/src/views/AppConfigureView.vue b/dashboard/src/views/AppConfigureView.vue index 1431294d1..6c5f6647c 100644 --- a/dashboard/src/views/AppConfigureView.vue +++ b/dashboard/src/views/AppConfigureView.vue @@ -151,6 +151,47 @@ function isViewEnabled(view, errorState) { return false; } +const TARGET_RUN_STATE = { + START: Symbol('start'), + STOP: Symbol('stop'), +}; + +function targetRunState() { + // if we have an error, we want to retry the pending state, otherwise toggle the runstate + if (app.value.error) { + if (app.value.error.details.installationState === ISTATES.PENDING_START) return TARGET_RUN_STATE.START; + else return TARGET_RUN_STATE.STOP; + } else { + if (app.value.runState === RSTATES.STOPPED) return TARGET_RUN_STATE.START; + else return TARGET_RUN_STATE.STOP; + } +} + +const toggleRunStateBusy = ref(false); +async function onStartApp() { + toggleRunStateBusy.value = true; + + const [error] = await appsModel.start(app.value.id); + if (error) { + toggleRunStateBusy.value = false; + return console.error(error); + } + + setTimeout(() => toggleRunStateBusy.value = false, 3000); +} + +async function onStopApp() { + toggleRunStateBusy.value = true; + + const [error] = await appsModel.stop(app.value.id); + if (error) { + toggleRunStateBusy.value = false; + return console.error(error); + } + + setTimeout(() => toggleRunStateBusy.value = false, 3000); +} + async function onStopAppTask() { if (!app.value.taskId) return; @@ -261,6 +302,14 @@ onBeforeUnmount(() => {
+ + +