Skip to content

Commit

Permalink
feat: adds new menu for custom groups (#3573)
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 authored Jan 25, 2025
1 parent 3d077b9 commit 8fbbfaf
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 47 deletions.
1 change: 1 addition & 0 deletions assets/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ declare module 'vue' {
EventSource: typeof import('./components/LogViewer/EventSource.vue')['default']
FuzzySearchModal: typeof import('./components/FuzzySearchModal.vue')['default']
GroupedLog: typeof import('./components/GroupedViewer/GroupedLog.vue')['default']
GroupMenu: typeof import('./components/GroupMenu.vue')['default']
HostIcon: typeof import('./components/common/HostIcon.vue')['default']
HostList: typeof import('./components/HostList.vue')['default']
HostLog: typeof import('./components/HostViewer/HostLog.vue')['default']
Expand Down
29 changes: 29 additions & 0 deletions assets/components/GroupMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<ul class="menu w-full p-0 text-[0.95rem]">
<li v-if="customGroups.length > 0">
<details open>
<summary class="text-base-content/80 font-light">
<ph:bounding-box-fill />
{{ $t("label.group-menu") }}
</summary>
<ul>
<li v-for="group in customGroups" :key="group.name">
<router-link :to="{ name: '/group/[name]', params: { name: group.name } }" active-class="menu-active">
<ph:stack-simple />
<div class="truncate">
{{ group.name }}
</div>
</router-link>
</li>
</ul>
</details>
</li>
</ul>
</template>

<script lang="ts" setup>
const store = useSwarmStore();
const { customGroups } = storeToRefs(store);
</script>
<style scoped></style>
17 changes: 9 additions & 8 deletions assets/components/SideMenu.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<template>
<div v-if="ready" data-testid="side-menu" class="flex min-h-0 flex-col">
<Carousel v-model="selectedCard" class="flex-1">
<CarouselItem title="Hosts and Containers" id="host">
<CarouselItem :title="$t('label.host-menu')" id="host">
<HostMenu />
</CarouselItem>
<CarouselItem title="Services and Stacks" v-if="services.length > 0" id="swarm">
<CarouselItem :title="$t('label.group-menu')" v-if="customGroups.length > 0" id="group">
<GroupMenu />
</CarouselItem>
<CarouselItem :title="$t('label.swarm-menu')" v-if="services.length > 0" id="swarm">
<SwarmMenu />
</CarouselItem>
</Carousel>
Expand All @@ -20,16 +23,14 @@ const containerStore = useContainerStore();
const { ready } = storeToRefs(containerStore);
const route = useRoute();
const swarmStore = useSwarmStore();
const { services } = storeToRefs(swarmStore);
const selectedCard = ref<"host" | "swarm">("host");
const { services, customGroups } = storeToRefs(swarmStore);
const selectedCard = ref<"host" | "swarm" | "group">("host");
watch(
route,
() => {
if (route.meta.swarmMode) {
selectedCard.value = "swarm";
} else if (route.meta.containerMode) {
selectedCard.value = "host";
if (route.meta.menu && ["host", "swarm", "group"].includes(route.meta.menu as string)) {
selectedCard.value = route.meta.menu as "host" | "swarm" | "group";
}
},
{ immediate: true },
Expand Down
26 changes: 1 addition & 25 deletions assets/components/SwarmMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,13 @@
</ul>
</details>
</li>

<li v-if="customGroups.length > 0">
<details open>
<summary class="text-base-content/80 font-light">
<ph:bounding-box-fill />
{{ $t("label.custom-groups") }}
</summary>
<ul>
<li v-for="group in customGroups" :key="group.name">
<router-link :to="{ name: '/group/[name]', params: { name: group.name } }" active-class="menu-active">
<ph:stack-simple />
<div class="truncate">
{{ group.name }}
</div>
</router-link>
</li>
</ul>
</details>
</li>
</ul>
</template>

<script lang="ts" setup>
const store = useSwarmStore();
const { stacks, services, customGroups } = storeToRefs(store);
const { stacks, services } = storeToRefs(store);
const servicesWithoutStacks = computed(() => services.value.filter((service) => !service.stack));
</script>
<style scoped>
.menu {
@apply text-[0.95rem];
}
</style>
2 changes: 1 addition & 1 deletion assets/pages/container/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ watchEffect(() => {
</script>
<route lang="yaml">
meta:
containerMode: true
menu: host
</route>
2 changes: 1 addition & 1 deletion assets/pages/group/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ watchEffect(() => {
</script>
<route lang="yaml">
meta:
swarmMode: true
menu: group
</route>
2 changes: 1 addition & 1 deletion assets/pages/host/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ watchEffect(() => {
</script>
<route lang="yaml">
meta:
containerMode: true
menu: host
</route>
2 changes: 1 addition & 1 deletion assets/pages/merged/[ids].vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ watchEffect(() => {
</script>
<route lang="yaml">
meta:
containerMode: true
menu: host
</route>
2 changes: 1 addition & 1 deletion assets/pages/service/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ watchEffect(() => {
</script>
<route lang="yaml">
meta:
swarmMode: true
menu: swarm
</route>
2 changes: 1 addition & 1 deletion assets/pages/stack/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ watchEffect(() => {
</script>
<route lang="yaml">
meta:
swarmMode: true
menu: swarm
</route>
4 changes: 3 additions & 1 deletion locales/da.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ label:
per-page: Rækker per side
swarm-mode: Swarm Tilstand
services: Tjenester
custom-groups: Brugerdefinerede Grupper
host-menu: Værter og Containere
swarm-menu: Tjenester og Stacks
group-menu: Brugerdefinerede Grupper

tooltip:
search: Søg containere (⌘ + k, ⌃k)
Expand Down
4 changes: 3 additions & 1 deletion locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ label:
swarm-mode: Swarm Modus
services: Service
running: Laufende
custom-groups: Benutzerdefinierte Gruppen
host-menu: Hosts und Container
swarm-menu: Services und Stacks
group-menu: Benutzerdefinierte Gruppen
total-cpu-usage: Gesamte CPU Auslastung
total-mem-usage: Gesamte Speicher Auslastung
dozzle-version: Dozzle Version
Expand Down
5 changes: 3 additions & 2 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ label:
avg-mem: Avg. MEM (%)
pinned: Pinned
per-page: Rows per page
swarm-mode: Swarm Mode
custom-groups: Custom Groups
host-menu: Hosts and Containers
swarm-menu: Services and Stacks
group-menu: Custom Groups
tooltip:
search: Search containers (⌘ + k, ⌃k)
pin-column: Pin as column
Expand Down
4 changes: 3 additions & 1 deletion locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ label:
per-page: Filas por página
swarm-mode: Modo Swarm
services: Servicios
custom-groups: Grupos Personalizados
host-menu: Hosts y Contenedores
swarm-menu: Servicios y Stacks
group-menu: Grupos Personalizados
tooltip:
search: Buscar contenedores (⌘ + K, CTRL + K)
pin-column: Anclar como columna
Expand Down
4 changes: 3 additions & 1 deletion locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ label:
per-page: Colonnes par page
swarm-mode: Mode Swarm
services: Services
custom-groups: Groupes personnalisés
host-menu: Hôtes et Conteneurs
swarm-menu: Services et Stacks
group-menu: Groupes Personnalisés

tooltip:
search: Recherche de conteneurs (⌘ + k, ⌃k)
Expand Down
5 changes: 4 additions & 1 deletion locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ label:
avg-cpu: CPU (%)
avg-mem: MEM (%)
pinned: Spuntato
host-menu: Host e Container
swarm-menu: Servizi e Stack
group-menu: Gruppi Personalizzati
tooltip:
merge-services: Unisci tutti i servizi in una vista
merge-containers: Unisci tutti i container in una vista
Expand All @@ -55,7 +58,7 @@ error:
message: >-
Dozzle ha trovato un container simile {containerId} in esecuzione sullo stesso
host e passerà automaticamente ad esso a meno che non si faccia clic su 'Annulla'.
settings:
log:
preview: Questa è un'anteprima dei log
Expand Down
4 changes: 3 additions & 1 deletion locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ label:
avg-mem: Średnie zużycie pamięci (%)
pinned: Przypięte
per-page: Wierszy na strone

host-menu: Hosty i Kontenery
swarm-menu: Usługi i Stosy
group-menu: Grupy Niestandardowe
tooltip:
search: Przeszukaj kontenery (⌘ + k, ⌃k)
pin-column: Przypnij jako kolumna
Expand Down
3 changes: 3 additions & 0 deletions locales/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ label:
created: Criado
avg-cpu: Média de CPU (%)
avg-mem: Média de MEM (%)
host-menu: Anfitriões e Contentores
swarm-menu: Serviços e Stacks
group-menu: Grupos Personalizados
tooltip:
search: Pesquisar contentores (⌘ + K, CTRL + K)
pin-column: Alfinete como coluna
Expand Down
3 changes: 3 additions & 0 deletions locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ label:
created: Создан
avg-cpu: средний процессор (%)
avg-mem: средняя память (%)
host-menu: Хосты и Контейнеры
swarm-menu: Сервисы и Стеки
group-menu: Пользовательские Группы
tooltip:
search: Поиск контейнеров (⌘ + k, ⌃k)
pin-column: Закрепить столбец
Expand Down
3 changes: 3 additions & 0 deletions locales/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ label:
avg-cpu: Ort. CPU (%)
avg-mem: Ort. Bellek (%)
pinned: Sabitlenmiş
host-menu: Sunucular ve Konteynerler
swarm-menu: Servisler ve Yığınlar
group-menu: Özel Gruplar
tooltip:
search: Konteynerlerde ara (⌘ + k, ⌃k)
pin-column: Sütun olarak sabitle
Expand Down
3 changes: 3 additions & 0 deletions locales/zh-tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ label:
swarm-mode: Swarm 模式
services: 服務
custom-groups: 自訂群組
host-menu: 主機和容器
swarm-menu: 服務和堆疊
group-menu: 自定義群組
tooltip:
search: 查詢容器 (⌘ + k, ⌃k)
pin-column: 固定此列
Expand Down
3 changes: 3 additions & 0 deletions locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ label:
swarm-mode: 集群模式
services: 服务
custom-groups: 自定义组
host-menu: 主机和容器
swarm-menu: 服务和堆栈
group-menu: 自定义组
tooltip:
search: 搜索 (⌘ + k, ⌃k)
pin-column: 固定为列
Expand Down

0 comments on commit 8fbbfaf

Please sign in to comment.