Displaying memory usage progress bar on status page.

This commit is contained in:
Roland 2023-08-23 19:08:13 -06:00
parent ac637bebcd
commit b3cec16459
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 34 additions and 12 deletions

View file

@ -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() {
<Routes>
<Route path='/' exact element={<DownloadsPage/>}/>
<Route path='settings' exact element={<SettingsPage/>}/>
<Route path='status' exact element={<Status/>}/>
<Route path='status' exact element={<StatusPage/>}/>
<Route path='wrol' exact element={<WROLMode/>}/>
</Routes>
</PageContainer>

View file

@ -126,24 +126,41 @@ export function BandwidthProgressCombined({bandwidth, ...props}) {
return <BandwidthProgress label={bandwidth['name']} bytes={combined} maxBytes={maxBytes} {...props}/>
}
export function CPUUsageProgress({value, label}) {
if (value === null) {
export function CPUUsageProgress({percent, label}) {
if (percent === null) {
return <Progress progress={0} color='grey' label='Average CPU Usage ERROR' disabled/>
}
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 <Progress percent={value} progress color={color} label={label}/>
return <Progress percent={percent} progress color={color} label={label}/>
}
export function MemoryUsageProgress({percent, label}) {
if (percent === null) {
return <Progress progress={0} color='grey' label='Memory Usage' disabled/>
}
let color = 'black';
let size = 'small';
if (percent >= 90) {
color = 'red';
size = 'large';
} else if (percent >= 70) {
color = 'orange';
size = 'large';
}
return <Progress percent={percent} progress color={color} label={label} size={size}/>
}
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 <>
<Media at='mobile'>
<Segment>
<CPUUsageProgress value={percent} label='CPU Usage'/>
<CPUUsageProgress percent={percent} label='CPU Usage'/>
<MemoryUsageProgress percent={memoryPercent} label='RAM Usage'/>
<StatisticGroup>
<CPUTemperatureStatistic
temperature={temperature}
@ -211,7 +232,8 @@ export function Status() {
</Media>
<Media greaterThanOrEqual='tablet'>
<Segment>
<CPUUsageProgress value={percent} label='CPU Usage'/>
<CPUUsageProgress percent={percent} label='CPU Usage'/>
<MemoryUsageProgress percent={memoryPercent} label='RAM Usage'/>
<StatisticGroup size='mini'>
<CPUTemperatureStatistic
temperature={temperature}