From b3cec164597b8e5693870469fd8c93da07a05451 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 23 Aug 2023 19:08:13 -0600 Subject: [PATCH] Displaying memory usage progress bar on status page. --- app/src/components/admin/AdminRoute.js | 4 +-- app/src/components/admin/Status.js | 42 ++++++++++++++++++++------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/app/src/components/admin/AdminRoute.js b/app/src/components/admin/AdminRoute.js index c1f670fe..f0e6f50d 100644 --- a/app/src/components/admin/AdminRoute.js +++ b/app/src/components/admin/AdminRoute.js @@ -7,7 +7,7 @@ import {ThemeContext} from "../../contexts/contexts"; import {Header, Loader, Segment} from "../Theme"; import {DownloadsPage} from "./Downloads"; import {SettingsPage} from "./Settings"; -import {Status} from "./Status"; +import {StatusPage} from "./Status"; class WROLMode extends React.Component { @@ -79,7 +79,7 @@ export default function AdminRoute() { }/> }/> - }/> + }/> }/> diff --git a/app/src/components/admin/Status.js b/app/src/components/admin/Status.js index f4470714..0028d57c 100644 --- a/app/src/components/admin/Status.js +++ b/app/src/components/admin/Status.js @@ -126,24 +126,41 @@ export function BandwidthProgressCombined({bandwidth, ...props}) { return } -export function CPUUsageProgress({value, label}) { - if (value === null) { +export function CPUUsageProgress({percent, label}) { + if (percent === null) { return } let color = 'black'; - if (value >= 90) { + if (percent >= 90) { color = 'red'; - } else if (value >= 70) { + } else if (percent >= 70) { color = 'brown'; - } else if (value >= 50) { + } else if (percent >= 50) { color = 'orange'; } - return + return +} + +export function MemoryUsageProgress({percent, label}) { + if (percent === null) { + return + } + + let color = 'black'; + let size = 'small'; + if (percent >= 90) { + color = 'red'; + size = 'large'; + } else if (percent >= 70) { + color = 'orange'; + size = 'large'; + } + return } -export function Status() { +export function StatusPage() { useTitle('Status'); const {status} = useContext(StatusContext); @@ -159,9 +176,10 @@ export function Status() { let bandwidth; let drives = []; let disk_bandwidth = []; + let memoryPercent; if (status && status['cpu_info']) { - const {cpu_info, load} = status; + const {cpu_info, load, memory_stats} = status; percent = cpu_info['percent']; cores = cpu_info['cores']; temperature = cpu_info['temperature']; @@ -175,12 +193,15 @@ export function Status() { drives = status['drives']; bandwidth = status['bandwidth']; disk_bandwidth = status['disk_bandwidth']; + + memoryPercent = Math.round(memory_stats['used'] / memory_stats['total'] * 100); } return <> - + + - + +