Remove app start/stop button from toolbar

This commit is contained in:
Johannes Zellner
2025-07-23 13:16:13 +02:00
parent 1063dbea02
commit a839638478
4 changed files with 31 additions and 55 deletions
+3 -3
View File
@@ -61,14 +61,14 @@ onMounted(() => {
<div style="display: flex; justify-content: space-between;">
<Switch v-model="debugMode" @change="onDebugMode" :disabled="debugModeBusy || app.error || app.taskId" v-tooltip="app.taskId ? (app.error ? 'App is in error state' : 'App is busy') : ''" label="Recovery Mode"/>
<Button @click="onRestart()" :disabled="busyRestart || app.taskId || app.error || app.installationState === 'pending_restart'" :loading="busyRestart || app.installationState === 'pending_restart'" v-tooltip="app.error ? 'App is in error state' : (app.taskId ? 'App is busy' : '')">{{ $t('app.repair.recovery.restartAction') }}</Button>
<Button @click="onRestart()" :disabled="busyRestart || app.taskId || app.error" :loading="busyRestart || app.installationState === 'pending_restart'">{{ $t('app.repair.recovery.restartAction') }}</Button>
</div>
<hr/>
<label>{{ $t('app.repair.taskError.title') }}</label>
<p>{{ $t('app.repair.taskError.description') }}</p>
<p v-if="app.error">An error occurred during the <b>{{ taskNameFromInstallationState(app.error.installationState) }}</b> operation: <span class="text-danger"><b>{{ app.error.reason + ': ' + app.error.message }}</b></span></p>
<Button @click="onRepair()" :disabled="app.taskId || !app.error" v-tooltip="app.taskId ? $t('app.repair.appIsBusyTooltip') : ''">{{ $t('app.repair.taskError.retryAction', { task: app.error ? taskNameFromInstallationState(app.error.installationState) : '' }) }}</Button>
<p v-if="app.error">An error occurred during the <b>{{ taskNameFromInstallationState(app.error.details?.installationState) }}</b> operation: <span class="text-danger"><b>{{ app.error.reason + ': ' + app.error.message }}</b></span></p>
<Button @click="onRepair()" :disabled="app.taskId || !app.error" v-tooltip="app.taskId ? $t('app.repair.appIsBusyTooltip') : ''">{{ $t('app.repair.taskError.retryAction', { task: app.error ? taskNameFromInstallationState(app.error.details?.installationState) : '' }) }}</Button>
</div>
</template>
+27 -9
View File
@@ -4,10 +4,10 @@ import { useI18n } from 'vue-i18n';
const i18n = useI18n();
const t = i18n.t;
import { ref, onMounted, computed, useTemplateRef } from 'vue';
import { ref, onMounted, useTemplateRef } from 'vue';
import { Button, InputDialog } from '@cloudron/pankow';
import { prettyLongDate } from '@cloudron/pankow/utils';
import { APP_TYPES } from '../../constants.js';
import { APP_TYPES, ISTATES, RSTATES } from '../../constants.js';
import AppsModel from '../../models/AppsModel.js';
const appsModel = AppsModel.create();
@@ -17,18 +17,36 @@ const inputDialog = useTemplateRef('inputDialog');
const props = defineProps([ 'app' ]);
const latestBackup = ref(null);
const isAppStopped = computed(() => {
return appsModel.isStopped(props.app);
});
function isAppStopped() {
if (props.app.error) {
if (props.app.error.details?.installationState === ISTATES.PENDING_START) return true;
else return false;
} else if (props.app.installationState === ISTATES.PENDING_START || props.app.installationState === ISTATES.PENDING_STOP) {
return props.app.installationState === ISTATES.PENDING_START;
} else {
return props.app.runState === RSTATES.STOPPED;
}
}
const toggleRunStateBusy = ref(false);
async function onToggleRunState() {
if (isAppStopped.value) {
// on error just retry
if (props.app.error) {
toggleRunStateBusy.value = true;
const [error] = await appsModel.repair(props.app.id, {});
if (error) return console.error(error);
}
if (isAppStopped()) {
toggleRunStateBusy.value = true;
const [error] = await appsModel.start(props.app.id);
if (error) return console.error(error);
} else {
const [error] = await appsModel.stop(props.app.id);
if (error) return console.error(error);
}
setTimeout(() => toggleRunStateBusy.value = false, 2000);
}
async function onUninstall() {
@@ -84,10 +102,10 @@ onMounted(async () => {
<label>{{ $t('app.uninstall.startStop.title') }}</label>
<p>{{ $t('app.uninstall.startStop.description') }}</p>
<Button @click="onToggleRunState()"
:disabled="app.taskId || app.error || app.installationState === 'pending_start' || app.installationState === 'pending_stop'"
:loading="app.installationState === 'pending_start' || app.installationState === 'pending_stop'"
:disabled="toggleRunStateBusy || app.taskId || (app.error && (app.error.details?.installationState !== 'pending_start' && app.error.details?.installationState !== 'pending_stop')) || app.installationState === 'pending_start' || app.installationState === 'pending_stop'"
:loading="toggleRunStateBusy || app.installationState === 'pending_start' || app.installationState === 'pending_stop'"
>
{{ $t(isAppStopped ? 'app.uninstall.startStop.startAction' : 'app.uninstall.startStop.stopAction') }}
{{ $t(isAppStopped() ? 'app.uninstall.startStop.startAction' : 'app.uninstall.startStop.stopAction') }}
</Button>
</div>