diff --git a/assets/components/HostList.vue b/assets/components/HostList.vue index bff93833..e9ec85b0 100644 --- a/assets/components/HostList.vue +++ b/assets/components/HostList.vue @@ -16,7 +16,7 @@ -
+
; - ready: Ref; }; const runningContainers = computed(() => containers.value.filter((container) => container.state === "running")); @@ -64,10 +63,8 @@ type TotalStat = { totalCPU: number; totalMem: number; }; - const weightedStats: Record = {}; - -watchOnce(hostContainers, (value) => { +const initWeightedStats = () => { for (const [host, containers] of Object.entries(hostContainers.value)) { const mostRecent = ref({ totalCPU: 0, totalMem: 0 }); for (const container of containers) { @@ -76,7 +73,10 @@ watchOnce(hostContainers, (value) => { } weightedStats[host] = reactive({ mostRecent, weighted: useExponentialMovingAverage(mostRecent) }); } -}); +}; + +watchOnce(hostContainers, initWeightedStats); +initWeightedStats(); useIntervalFn( () => {