Implement app start/stop and add app state polling for the moment

This commit is contained in:
Johannes Zellner
2025-02-21 12:20:23 +01:00
parent 8132920ed8
commit 6a5de6606c
4 changed files with 78 additions and 23 deletions

View File

@@ -6,7 +6,7 @@ import { useI18n } from 'vue-i18n';
const i18n = useI18n();
const t = i18n.t;
import { ref, onMounted, useTemplateRef } from 'vue';
import { ref, onMounted, onUnmounted, useTemplateRef } from 'vue';
import { Button, ButtonGroup, TabView } from 'pankow';
import Info from '../components/app/Info.vue';
import Uninstall from '../components/app/Uninstall.vue';
@@ -41,6 +41,8 @@ const link = ref('');
const infoMenu = ref([]);
const hasLocalStorage = ref(false);
let refreshTimer = null;
function onTabChanged(tab) {
window.location.hash = `/app/${id.value}/${tab}`;
}
@@ -55,6 +57,7 @@ async function refresh() {
link.value = result.fqdn.indexOf('http') !== 0 ? 'https://' + result.fqdn : result.fqdn;
hasLocalStorage.value = result.manifest && result.manifest.addons && result.manifest.addons.localstorage;
infoMenu.value = [];
infoMenu.value.push({
label: t('app.docsAction'),
disabled: !result.manifest?.documentationUrl,
@@ -98,6 +101,8 @@ async function refresh() {
// TODO support real href links
action: () => { window.location.href = result.manifest.website; }
});
refreshTimer = setTimeout(refresh, 2000);
}
onMounted(async () => {
@@ -114,6 +119,10 @@ onMounted(async () => {
tabView.value.open(parts[1] || 'info');
});
onUnmounted(() => {
if (refreshTimer) clearTimeout(refreshTimer);
});
</script>
<template>