From 811686866938ce65c84a73d4006fcf428d24f447 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Tue, 25 Apr 2023 14:41:45 -0700 Subject: [PATCH] feat: makes swarm id lighter (#2145) * feat: makes swarm id lighter * fix: add swarm to title id --- assets/components/LogViewer/ContainerTitle.vue | 2 +- assets/components/SideMenu.vue | 6 +++++- assets/models/Container.ts | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/assets/components/LogViewer/ContainerTitle.vue b/assets/components/LogViewer/ContainerTitle.vue index 3d8a82a6..82e5b46c 100644 --- a/assets/components/LogViewer/ContainerTitle.vue +++ b/assets/components/LogViewer/ContainerTitle.vue @@ -6,7 +6,7 @@ - {{ container.name }} + {{ container.name }}.{{ container.swarmId }} {{ container.image.replace(/@sha.*/, "") }} diff --git a/assets/components/SideMenu.vue b/assets/components/SideMenu.vue index 16de1cf5..b5060eec 100644 --- a/assets/components/SideMenu.vue +++ b/assets/components/SideMenu.vue @@ -64,7 +64,8 @@ >
- {{ item.name }} + {{ item.name }} + .{{ item.swarmId }}
; +const SWARM_ID_REGEX = /\.([a-z0-9]{25})$/i; + export class Container { public stat: Ref; private readonly throttledStatHistory: UseThrottledRefHistoryReturn; + public readonly swarmId: string | null = null; + public readonly isSwarm: boolean = false; constructor( public readonly id: string, @@ -20,6 +24,14 @@ export class Container { ) { this.stat = ref({ cpu: 0, memory: 0, memoryUsage: 0 }); this.throttledStatHistory = useThrottledRefHistory(this.stat, { capacity: 300, deep: true, throttle: 1000 }); + + const match = name.match(SWARM_ID_REGEX); + + if (match) { + this.swarmId = match[1]; + this.name = name.replace(`.${this.swarmId}`, ""); + this.isSwarm = true; + } } public getStatHistory() {