1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00
Files
dozzle/assets/models/Container.ts
Amir Raminfar 9ba1a0f76a Adds health status by parsing the label from status (#2099)
* Adds healthcheck to status in menu

* Fixes bug with crated

* Moves colors to vars

* Updates icons
2023-03-29 08:58:12 -07:00

33 lines
995 B
TypeScript

import type { ContainerHealth, ContainerStat, ContainerState } from "@/types/Container";
import type { UseThrottledRefHistoryReturn } from "@vueuse/core";
import { Ref } from "vue";
type Stat = Omit<ContainerStat, "id">;
export class Container {
public stat: Ref<Stat>;
private readonly throttledStatHistory: UseThrottledRefHistoryReturn<Stat, Stat>;
constructor(
public readonly id: string,
public readonly created: Date,
public readonly image: string,
public readonly name: string,
public readonly command: string,
public status: string,
public state: ContainerState,
public health?: ContainerHealth
) {
this.stat = ref({ cpu: 0, memory: 0, memoryUsage: 0 });
this.throttledStatHistory = useThrottledRefHistory(this.stat, { capacity: 300, deep: true, throttle: 1000 });
}
public getStatHistory() {
return unref(this.throttledStatHistory.history);
}
public getLastStat() {
return unref(this.throttledStatHistory.last);
}
}