add ability to uninstall an app again

This commit is contained in:
Johannes Zellner
2025-02-21 14:07:07 +01:00
parent 6a5de6606c
commit e4c47de90a
3 changed files with 64 additions and 17 deletions

View File

@@ -1,24 +1,24 @@
<script setup>
import { ref, onMounted, computed } from 'vue';
import { Button } from 'pankow';
import { useI18n } from 'vue-i18n';
const i18n = useI18n();
const t = i18n.t;
import { ref, onMounted, computed, useTemplateRef } from 'vue';
import { Button, InputDialog } from 'pankow';
import { prettyLongDate } from 'pankow/utils';
import { APP_TYPES, ISTATES, RSTATES } from '../../constants.js';
import { APP_TYPES } from '../../constants.js';
import AppsModel from '../../models/AppsModel.js';
const appsModel = AppsModel.create();
const inputDialog = useTemplateRef('inputDialog');
const props = defineProps([ 'app' ]);
const emit = defineEmits([ 'changed' ]);
const latestBackup = ref(null);
const isAppStopped = computed(() => {
// show 'Start App' if app is starting or is stopped
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;
}
return appsModel.isStopped(props.app);
});
async function onToggleRunState() {
@@ -31,8 +31,21 @@ async function onToggleRunState() {
}
}
function onUninstall() {
// TODO
async function onUninstall() {
const yes = await inputDialog.value.confirm({
title: t('app.uninstallDialog.title', { app: (props.app.label || props.app.fqdn) }),
message: t('app.uninstallDialog.description', { app: (props.app.label || props.app.fqdn) }),
confirmStyle: 'danger',
confirmLabel: t('app.uninstallDialog.uninstallAction'),
rejectLabel: t('main.dialog.cancel')
});
if (!yes) return;
const [error] = await appsModel.uninstall(props.app.id);
if (error) return console.error(error);
window.location.href = '/#/apps';
}
function onArchive() {
@@ -46,6 +59,8 @@ onMounted(() => {
</script>
<template>
<InputDialog ref="inputDialog" />
<div>
<div>
<label>{{ $t('app.uninstall.startStop.title') }}</label>