import {Header, Progress, Segment, Statistic, StatisticGroup} from "../Theme";
import React, {useContext} from "react";
import {humanBandwidth, humanFileSize, LoadStatistic, useTitle} from "../Common";
import {Divider, Responsive} from "semantic-ui-react";
import {ProgressPlaceholder} from "../Placeholder";
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
import {StatusContext} from "../../contexts/contexts";
function DriveInfo({used, size, percent, mount}) {
let color;
if (percent >= 90) {
color = 'red';
} else if (percent >= 80) {
color = 'orange';
}
return
}
function DiskBandwidthProgress({bytes_ps, total, label, ...props}) {
let percent = bytes_ps / total;
percent = percent || 0;
let color = null;
if (percent >= 90) {
color = 'red';
} else if (percent >= 80) {
color = 'orange';
} else if (percent >= 50) {
color = 'yellow';
}
label = `${label} ${humanBandwidth(bytes_ps)}`;
return ;
}
function DiskBandwidth({name, bytes_read_ps, bytes_write_ps}) {
const total = 10_000_000; // Arbitrary size. What is the real speed of the disk?
const read = ;
const write = ;
return
{read}
{write}
}
function CPUTemperatureStatistic({value, high_temperature, critical_temperature, ...props}) {
if (!value) {
return
}
if (critical_temperature && critical_temperature === high_temperature) {
// Critical and high are equal, manually change it so high changes color before critical.
high_temperature = critical_temperature - 25;
}
if ((critical_temperature && value >= critical_temperature) || (!critical_temperature && value >= 75)) {
props['color'] = 'red';
} else if ((high_temperature && value >= high_temperature) || (!high_temperature && value >= 55)) {
props['color'] = 'orange';
}
return
}
export function BandwidthProgress({label = '', bytes, maxBytes, ...props}) {
// Gigabit by default.
maxBytes = maxBytes || 125_000_000;
label = `${label} (${humanBandwidth(bytes)})`;
const percent = (bytes / maxBytes);
if (percent > 70) {
props['color'] = 'yellow';
} else if (percent > 90) {
props['color'] = 'red';
}
const disabled = percent === 0;
return
}
export function BandwidthProgressGroup({bandwidth, ...props}) {
// NIC speed to bytes.
const maxBytes = bandwidth['speed'] * 125_000;
const recv = ;
const sent = ;
return
{recv}
{sent}
}
export function BandwidthProgressCombined({bandwidth, ...props}) {
const maxBytes = bandwidth['speed'] ? bandwidth['speed'] * 125_000 : 125_000_000;
const combined = bandwidth['bytes_recv'] + bandwidth['bytes_sent']
return
}
export function CPUUsageProgress({value, label}) {
if (value === null) {
return
}
let color = 'black';
if (value >= 90) {
color = 'red';
} else if (value >= 70) {
color = 'brown';
} else if (value >= 50) {
color = 'orange';
}
return