From 2aaaf2ba1f4ba5f19e809ff6157a82cf84b6658f Mon Sep 17 00:00:00 2001 From: codeman1o1 <70335544+codeman1o1@users.noreply.github.com> Date: Fri, 25 Aug 2023 18:58:02 +0200 Subject: [PATCH] Improve page title handling (#2365) I tried my best with the translations. Google Translate gives me the right English translation back for each language --- assets/composables/title.ts | 2 +- assets/layouts/default.vue | 6 +----- assets/pages/container/[id].vue | 9 +++------ assets/pages/index.vue | 10 +++++++++- locales/de.yml | 1 + locales/en.yml | 1 + locales/es.yml | 1 + locales/pr.yml | 1 + locales/ru.yml | 1 + locales/zh.yml | 1 + 10 files changed, 20 insertions(+), 13 deletions(-) diff --git a/assets/composables/title.ts b/assets/composables/title.ts index 7ca71728..acd4c903 100644 --- a/assets/composables/title.ts +++ b/assets/composables/title.ts @@ -1,6 +1,6 @@ const { hostname } = config; let subtitle = $ref(""); -const title = $computed(() => `${subtitle} - Dozzle` + (hostname ? ` @ ${hostname}` : "")); +const title = $computed(() => (subtitle ? `${subtitle} - ` : "") + "Dozzle" + (hostname ? ` @ ${hostname}` : "")); useTitle($$(title)); diff --git a/assets/layouts/default.vue b/assets/layouts/default.vue index d5d384a3..aa37aa34 100644 --- a/assets/layouts/default.vue +++ b/assets/layouts/default.vue @@ -51,11 +51,7 @@ const { oruga } = useProgrammatic(); const { authorizationNeeded } = config; const containerStore = useContainerStore(); -const { activeContainers, visibleContainers } = storeToRefs(containerStore); - -watchEffect(() => { - setTitle(`${visibleContainers.value.length} containers`); -}); +const { activeContainers } = storeToRefs(containerStore); onKeyStroke("k", (e) => { if ((e.ctrlKey || e.metaKey) && !e.shiftKey) { diff --git a/assets/pages/container/[id].vue b/assets/pages/container/[id].vue index b8127274..53cff48f 100644 --- a/assets/pages/container/[id].vue +++ b/assets/pages/container/[id].vue @@ -16,11 +16,8 @@ const { id } = defineProps<{ id: string }>(); const currentContainer = store.currentContainer($$(id)); const { activeContainers, ready } = storeToRefs(store); -setTitle("loading"); - -onMounted(() => { - setTitle(currentContainer.value?.name); +watchEffect(() => { + if (ready.value === true) + currentContainer.value !== undefined ? setTitle(currentContainer.value.name) : setTitle("Not Found"); }); - -watchEffect(() => setTitle(currentContainer.value?.name)); diff --git a/assets/pages/index.vue b/assets/pages/index.vue index 3416707f..070a0562 100644 --- a/assets/pages/index.vue +++ b/assets/pages/index.vue @@ -52,9 +52,13 @@