@@ -104,8 +104,10 @@ const padGraph = (data: number[]) => {
104104const cpuData = computed (() => padGraph (props .data ?.graph .cpu ?? []))
105105const ramData = computed (() => padGraph (props .data ?.graph .ram ?? []))
106106
107- const cpuPercent = computed (() => stats .value .cpu_percent )
108- const ramPercent = computed (() => (stats .value .ram_usage_bytes / stats .value .ram_total_bytes ) * 100 )
107+ const cpuPercent = computed (() => stats .value .cpu_percent ?? 0 )
108+ const ramPercent = computed (
109+ () => ((stats .value .ram_usage_bytes ?? 0 ) / (stats .value .ram_total_bytes || 1 )) * 100 ,
110+ )
109111
110112const cpuWarning = computed (() => cpuPercent .value >= 90 )
111113const ramWarning = computed (() => ramPercent .value >= 90 )
@@ -167,7 +169,7 @@ const formatBytes = (bytes: number) => {
167169const metrics = computed (() => {
168170 const storageMetric = {
169171 title: ' Storage' ,
170- value: props .loading ? ' 0 B' : formatBytes (stats .value .storage_usage_bytes ),
172+ value: props .loading ? ' 0 B' : formatBytes (stats .value .storage_usage_bytes ?? 0 ),
171173 icon: FolderOpenIcon ,
172174 showGraph: false ,
173175 chartOptions: null as ReturnType <typeof buildChartOptions > | null ,
@@ -213,7 +215,7 @@ const metrics = computed(() => {
213215 title: ' Memory' ,
214216 value:
215217 props .showMemoryAsBytes || userPreferences .value .ramAsNumber
216- ? formatBytes (stats .value .ram_usage_bytes )
218+ ? formatBytes (stats .value .ram_usage_bytes ?? 0 )
217219 : ` ${ramPercent .value .toFixed (2 )}% ` ,
218220 icon: DatabaseIcon ,
219221 showGraph: true ,
0 commit comments