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:
@@ -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 = [
|
||||
[
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user