1
0
mirror of https://github.com/amir20/dozzle.git synced 2026-01-03 11:35:00 +01:00

feat: improves host labels and respects configurations for labels (#2369)

* feat: improves host labels and respects configurations for labels

* fixes tests
This commit is contained in:
Amir Raminfar
2023-08-25 13:42:00 -07:00
committed by GitHub
parent 512b181b48
commit 34ad45c64e
6 changed files with 29 additions and 6 deletions

View File

@@ -1,5 +1,11 @@
import { describe, expect, test } from "vitest";
import { describe, expect, test, vi } from "vitest";
import { Container } from "./Container";
vi.mock("@/stores/config", () => ({
__esModule: true,
default: { base: "", hosts: [{ name: "localhost", id: "localhost" }] },
}));
describe("Container", () => {
const names = [
[

View File

@@ -7,6 +7,16 @@ type Stat = Omit<ContainerStat, "id">;
const SWARM_ID_REGEX = /(\.[a-z0-9]{25})+$/i;
const hosts = computed(() =>
config.hosts.reduce(
(acc, item) => {
acc[item.id] = item;
return acc;
},
{} as Record<string, { name: string; id: string }>,
),
);
export class Container {
private _stat: Ref<Stat>;
private readonly throttledStatHistory: UseThrottledRefHistoryReturn<Stat, Stat>;
@@ -49,6 +59,10 @@ export class Container {
return unref(this._stat);
}
get hostLabel() {
return hosts.value[this.host]?.name;
}
get storageKey() {
return `${stripVersion(this.image)}:${this.command}`;
}