1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-27 23:46:39 +01:00
Files
dozzle/assets/stores/hosts.ts
2025-02-10 09:29:39 -08:00

36 lines
658 B
TypeScript

export type Host = {
id: string;
name: string;
nCPU: number;
memTotal: number;
type: "agent" | "local" | "remote" | "swarm" | "k8s";
endpoint: string;
available: boolean;
dockerVersion: string;
agentVersion: string;
};
const hosts = ref(
config.hosts
.sort((a, b) => a.name.localeCompare(b.name))
.reduce(
(acc, item) => {
acc[item.id] = item;
return acc;
},
{} as Record<string, Host>,
),
);
const updateHost = (host: Host) => {
delete hosts.value[host.endpoint];
hosts.value[host.id] = host;
return host;
};
export function useHosts() {
return {
hosts,
updateHost,
};
}