1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-30 17:47:28 +01:00
Files
dozzle/assets/stores/hosts.ts

36 lines
650 B
TypeScript

export type Host = {
id: string;
name: string;
nCPU: number;
memTotal: number;
type: "agent" | "local" | "remote" | "swarm";
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,
};
}