mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 06:56:18 -05:00
ui: thirty-five files off Semantic, leaving fifteen
Phase 2, part 4. Baseline 50 -> 15.
Migrated: all eight calculators, the rest of inventory and collections, the
Map/Zim/Docs cluster, Videos, Files, Search, Archive, DashboardPage,
DatesSelector, HelpModal, Events, Tags, Flasher's neighbours, admin Settings
and Status, Download, and App.
Also the three shared modules everything imports: api.js and customHooks.js
swap the Semantic toast library for the library's shim (same call shape), and
useForm.js renders the library's Message. useForm accepts both the old
`{content, header, positive|negative}` shape and the new `{kind, title}`,
because the pages building those objects migrate separately.
Two library gaps closed, both found by call sites needing them:
ActionInput is a forwardRef now. Its ref reaches the input rather than the
wrapper, because callers use it to focus or select the field -- a ref to the
surrounding div would do neither, which is why one call site had resorted to
hand-copying the component's markup.
Header takes a `color` token name. Three separate call sites had reached for
an inline style to colour a heading that carries meaning ("3 items to add"
against "2 to remove"), which is how a hex ends up in markup.
Two files needed repair after being interrupted mid-edit: MapViewer had a
Segment left in its error branch, and VideoPlayer had lost the useContext
import its own code still used. Neither jest nor tsc noticed; only
`npm run build` did, which is the whole reason that check exists.
Fifteen files remain: Archive, BulkTagModal, Channels, Docs, FileBrowser,
FilePreview, Flasher, Nav, Playlists, Theme.tsx, Upload, VideoPlayer, Zim,
ControllerPage, admin/Downloads. Theme.tsx is deliberately last -- the
unmigrated files still import its Semantic-backed wrappers, so it can only go
once they have.
This commit is contained in:
parent
16bdffbac7
commit
906705e5b4
48 changed files with 3273 additions and 3877 deletions
|
|
@ -2,18 +2,6 @@ import React from "react";
|
|||
import {SettingsContext, StatusContext} from "../../contexts/contexts";
|
||||
import {checkUpgrade, postRestart, postShutdown, saveSettings as saveSettingsApi, triggerUpgrade} from "../../api";
|
||||
import {getServices, startService, stopService} from "../../api/controller";
|
||||
import {Button, Divider, Form, Header, Loader, Modal, Segment} from "../Theme";
|
||||
import {
|
||||
ButtonGroup,
|
||||
Container,
|
||||
Dimmer,
|
||||
Dropdown,
|
||||
FormDropdown,
|
||||
GridColumn,
|
||||
GridRow,
|
||||
Icon,
|
||||
Input
|
||||
} from "semantic-ui-react";
|
||||
import {
|
||||
APIButton,
|
||||
ErrorMessage,
|
||||
|
|
@ -25,15 +13,26 @@ import {
|
|||
WROLModeMessage
|
||||
} from "../Common";
|
||||
import {useConfigs, useDockerized} from "../../hooks/customHooks";
|
||||
import {toast} from "react-semantic-toasts-2";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import {ConfigsTable} from "./Configs";
|
||||
import {semanticUIColorMap} from "../Vars";
|
||||
import {Link} from "react-router";
|
||||
import {ThemePicker} from "../ui";
|
||||
import {
|
||||
Button,
|
||||
Divider,
|
||||
Grid,
|
||||
Header,
|
||||
Icon,
|
||||
Loading,
|
||||
Modal,
|
||||
Panel,
|
||||
Select,
|
||||
ThemePicker,
|
||||
toast,
|
||||
TextInput,
|
||||
} from "../ui";
|
||||
|
||||
function ThemeSegment() {
|
||||
return <Segment>
|
||||
return <Panel>
|
||||
<Header as='h2'>Theme</Header>
|
||||
<p>Choose how WROLPi looks. The choice is saved in this browser, so each device can
|
||||
differ.</p>
|
||||
|
|
@ -45,9 +44,9 @@ function ThemeSegment() {
|
|||
<Header as='h3'>Preview</Header>
|
||||
<p>See every part of the interface in the theme you picked.</p>
|
||||
<Link to='/theme-sample'>
|
||||
<Button><Icon name='eye'/> View the components</Button>
|
||||
<Button icon='eye'>View the components</Button>
|
||||
</Link>
|
||||
</Segment>;
|
||||
</Panel>;
|
||||
}
|
||||
|
||||
export function ShutdownButton() {
|
||||
|
|
@ -91,7 +90,7 @@ export function ShutdownButton() {
|
|||
|
||||
return <APIButton
|
||||
size='huge'
|
||||
color='red'
|
||||
role='danger'
|
||||
onClick={handleShutdown}
|
||||
confirmContent='Are you sure you want to turn off your WROLPi?'
|
||||
confirmButton='Shutdown'
|
||||
|
|
@ -138,33 +137,32 @@ function UpgradeSegment() {
|
|||
|
||||
// Not available in Docker
|
||||
if (dockerized) {
|
||||
return <Segment id='upgrade'>
|
||||
return <Panel id='upgrade'>
|
||||
<Header as='h3'>System Upgrade</Header>
|
||||
<p>Upgrades are not available in Docker environments. Please upgrade your Docker images manually.</p>
|
||||
</Segment>;
|
||||
</Panel>;
|
||||
}
|
||||
|
||||
// No update available
|
||||
if (!status?.update_available) {
|
||||
return <Segment id='upgrade'>
|
||||
return <Panel id='upgrade'>
|
||||
<Header as='h3'>System Upgrade</Header>
|
||||
<p>Your WROLPi is up to date.</p>
|
||||
<p>Version: <strong>v{status?.version}</strong> on branch <strong>{status?.git_branch || 'unknown'}</strong>
|
||||
</p>
|
||||
<APIButton
|
||||
color='blue'
|
||||
role='primary'
|
||||
onClick={handleCheckUpgrade}
|
||||
disabled={checking}
|
||||
>
|
||||
{checking ? 'Checking...' : 'Check for Upgrades'}
|
||||
</APIButton>
|
||||
</Segment>;
|
||||
</Panel>;
|
||||
}
|
||||
|
||||
// Update available
|
||||
return <Segment id='upgrade'>
|
||||
<Header as='h3'>
|
||||
<Icon name='arrow alternate circle up'/>
|
||||
return <Panel id='upgrade'>
|
||||
<Header as='h3' icon='arrow alternate circle up'>
|
||||
Upgrade Available
|
||||
</Header>
|
||||
<p>Branch: <strong>{status?.git_branch}</strong></p>
|
||||
|
|
@ -173,7 +171,7 @@ function UpgradeSegment() {
|
|||
<p><strong>{status?.commits_behind}</strong> commit(s) behind</p>
|
||||
|
||||
<APIButton
|
||||
color='green'
|
||||
role='save'
|
||||
size='big'
|
||||
onClick={handleUpgrade}
|
||||
disabled={upgrading}
|
||||
|
|
@ -182,7 +180,7 @@ function UpgradeSegment() {
|
|||
>
|
||||
{upgrading ? 'Starting Upgrade...' : 'Upgrade Now'}
|
||||
</APIButton>
|
||||
</Segment>;
|
||||
</Panel>;
|
||||
}
|
||||
|
||||
export function RestartButton() {
|
||||
|
|
@ -226,7 +224,7 @@ export function RestartButton() {
|
|||
|
||||
return <APIButton
|
||||
size='huge'
|
||||
color='yellow'
|
||||
role='retry'
|
||||
onClick={handleRestart}
|
||||
confirmContent='Are you sure you want to reboot your WROLPi?'
|
||||
confirmButton='Restart'
|
||||
|
|
@ -290,16 +288,15 @@ function WROLModeSection() {
|
|||
};
|
||||
|
||||
return (
|
||||
<Segment>
|
||||
<Header as='h3'>
|
||||
<Icon name='shield'/>
|
||||
<Panel danger>
|
||||
<Header as='h3' icon='shield'>
|
||||
WROL Mode
|
||||
</Header>
|
||||
<p>
|
||||
Enable read-only mode. No content can be deleted or modified.
|
||||
Enable this when the SHTF and you want to prevent any potential loss of data.
|
||||
</p>
|
||||
<p style={{fontSize: '0.9em', color: '#888'}}>
|
||||
<p style={{fontSize: '0.9em', color: 'var(--muted)'}}>
|
||||
Note: User settings and tags can still be modified.
|
||||
</p>
|
||||
<Toggle
|
||||
|
|
@ -307,7 +304,7 @@ function WROLModeSection() {
|
|||
onChange={toggleWROLMode}
|
||||
label={wrolMode ? 'WROL Mode Enabled' : 'WROL Mode Disabled'}
|
||||
/>
|
||||
</Segment>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -494,28 +491,22 @@ export function SettingsPage() {
|
|||
});
|
||||
}, [JSON.stringify(settings)]);
|
||||
|
||||
const handleInputChange = async (e, name, value) => {
|
||||
if (e) {
|
||||
e.preventDefault()
|
||||
}
|
||||
const handleInputChange = async (name, value) => {
|
||||
setState({...state, [name]: value});
|
||||
}
|
||||
|
||||
const handleTimeoutChange = async (e, name, value) => {
|
||||
if (e) {
|
||||
e.preventDefault()
|
||||
}
|
||||
const handleTimeoutChange = async (name, value) => {
|
||||
// Restrict timeout to numbers.
|
||||
value = value.replace(/[^\d]/, '');
|
||||
setState({...state, [name]: value});
|
||||
}
|
||||
|
||||
const timezoneOptions = Intl.supportedValuesOf('timeZone').map(tz => (
|
||||
{key: tz, value: tz, text: tz}
|
||||
{value: tz, label: tz}
|
||||
));
|
||||
|
||||
const navColorOptions = Object.keys(semanticUIColorMap).map(i => {
|
||||
return {key: i, value: i, text: i.charAt(0).toUpperCase() + i.slice(1)}
|
||||
return {value: i, label: i.charAt(0).toUpperCase() + i.slice(1)}
|
||||
});
|
||||
|
||||
const mediaDirectoryLabel = `${settings.media_directory}/`;
|
||||
|
|
@ -526,94 +517,92 @@ export function SettingsPage() {
|
|||
body = <>
|
||||
<p>Any changes will be written to <i>{settings.media_directory}/config/wrolpi.yaml</i>.</p>
|
||||
|
||||
<Form id="settings">
|
||||
<Grid columns={2} stackable>
|
||||
<Grid.Row>
|
||||
<Grid.Column>
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='CPU Power-save on Startup'
|
||||
disabled={disabled || state.throttle_on_startup === null}
|
||||
checked={state.throttle_on_startup === true}
|
||||
onChange={checked => handleInputChange(null, 'throttle_on_startup', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Ignore outdated Zims'
|
||||
disabled={disabled || state.ignore_outdated_zims === null}
|
||||
checked={state.ignore_outdated_zims === true}
|
||||
onChange={checked => handleInputChange(null, 'ignore_outdated_zims', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Check for upgrades hourly'
|
||||
disabled={disabled || dockerized || state.check_for_upgrades === null}
|
||||
checked={!dockerized && state.check_for_upgrades === true}
|
||||
onChange={checked => handleInputChange(null, 'check_for_upgrades', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Tags Directory'
|
||||
disabled={disabled || state.tags_directory === null}
|
||||
checked={state.tags_directory === true}
|
||||
onChange={checked => handleInputChange(null, 'tags_directory', checked)}
|
||||
info='When enabled, WROLPi creates a "tags" directory with hardlinks to all tagged files, organized by tag name.'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Save FFprobe Cache Files'
|
||||
disabled={disabled || state.save_ffprobe_json === null}
|
||||
checked={state.save_ffprobe_json === true}
|
||||
onChange={checked => handleInputChange(null, 'save_ffprobe_json', checked)}
|
||||
info='When enabled, FFprobe results are saved as .ffprobe.json files alongside videos. This speeds up reindexing but uses additional disk space (~5KB per video).'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<label htmlFor='log_levels_input'>Log Level: {logLevelToName(state.log_level)}</label>
|
||||
<br/>
|
||||
<input type='range'
|
||||
id='log_levels_input'
|
||||
list='log_levels'
|
||||
min='1'
|
||||
max='5'
|
||||
value={state.log_level}
|
||||
onChange={e => setState({...state, log_level: parseInt(e.target.value)})}
|
||||
style={{marginBottom: '1em'}}
|
||||
<form id="settings" onSubmit={e => e.preventDefault()}>
|
||||
<Grid>
|
||||
<Grid.Col span={12}>
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='CPU Power-save on Startup'
|
||||
disabled={disabled || state.throttle_on_startup === null}
|
||||
checked={state.throttle_on_startup === true}
|
||||
onChange={checked => handleInputChange('throttle_on_startup', checked)}
|
||||
/>
|
||||
<datalist id='log_levels'>
|
||||
<option value='1'>Critical</option>
|
||||
<option value='2'>Warning</option>
|
||||
<option value='3'>Info</option>
|
||||
<option value='4'>Debug</option>
|
||||
<option value='5'>Trace</option>
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Ignore outdated Zims'
|
||||
disabled={disabled || state.ignore_outdated_zims === null}
|
||||
checked={state.ignore_outdated_zims === true}
|
||||
onChange={checked => handleInputChange('ignore_outdated_zims', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ButtonGroup>
|
||||
<Button color={state.nav_color} onClick={e => e.preventDefault()}>Navbar Color</Button>
|
||||
<Dropdown
|
||||
id='settings_navbar_color_dropdown'
|
||||
className='button icon'
|
||||
floating
|
||||
options={navColorOptions}
|
||||
onChange={(e, {value}) => setState({...state, nav_color: value})}
|
||||
value={state.nav_color}
|
||||
/>
|
||||
</ButtonGroup>
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Check for upgrades hourly'
|
||||
disabled={disabled || dockerized || state.check_for_upgrades === null}
|
||||
checked={!dockerized && state.check_for_upgrades === true}
|
||||
onChange={checked => handleInputChange('check_for_upgrades', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Tags Directory'
|
||||
disabled={disabled || state.tags_directory === null}
|
||||
checked={state.tags_directory === true}
|
||||
onChange={checked => handleInputChange('tags_directory', checked)}
|
||||
info='When enabled, WROLPi creates a "tags" directory with hardlinks to all tagged files, organized by tag name.'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{margin: '0.5em'}}>
|
||||
<Toggle
|
||||
label='Save FFprobe Cache Files'
|
||||
disabled={disabled || state.save_ffprobe_json === null}
|
||||
checked={state.save_ffprobe_json === true}
|
||||
onChange={checked => handleInputChange('save_ffprobe_json', checked)}
|
||||
info='When enabled, FFprobe results are saved as .ffprobe.json files alongside videos. This speeds up reindexing but uses additional disk space (~5KB per video).'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<label htmlFor='log_levels_input'>Log Level: {logLevelToName(state.log_level)}</label>
|
||||
<br/>
|
||||
<input type='range'
|
||||
id='log_levels_input'
|
||||
list='log_levels'
|
||||
min='1'
|
||||
max='5'
|
||||
value={state.log_level}
|
||||
onChange={e => setState({...state, log_level: parseInt(e.target.value)})}
|
||||
style={{marginBottom: '1em'}}
|
||||
/>
|
||||
<datalist id='log_levels'>
|
||||
<option value='1'>Critical</option>
|
||||
<option value='2'>Warning</option>
|
||||
<option value='3'>Info</option>
|
||||
<option value='4'>Debug</option>
|
||||
<option value='5'>Trace</option>
|
||||
</datalist>
|
||||
|
||||
<br/>
|
||||
|
||||
<div style={{display: 'flex', alignItems: 'center', gap: 0}}>
|
||||
<Button color={state.nav_color} onClick={e => e.preventDefault()}>Navbar Color</Button>
|
||||
<Select
|
||||
id='settings_navbar_color_dropdown'
|
||||
data={navColorOptions}
|
||||
value={state.nav_color || ''}
|
||||
onChange={value => setState({...state, nav_color: value})}
|
||||
allowDeselect={false}
|
||||
style={{width: '10em'}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
|
@ -626,7 +615,7 @@ export function SettingsPage() {
|
|||
label='Download on Startup'
|
||||
disabled={disabled || state.download_on_startup === null}
|
||||
checked={state.download_on_startup === true}
|
||||
onChange={checked => handleInputChange(null, 'download_on_startup', checked)}
|
||||
onChange={checked => handleInputChange('download_on_startup', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -639,7 +628,7 @@ export function SettingsPage() {
|
|||
</>}
|
||||
disabled={disabled || state.require_cookies_unlocked === null}
|
||||
checked={state.require_cookies_unlocked === true}
|
||||
onChange={checked => handleInputChange(null, 'require_cookies_unlocked', checked)}
|
||||
onChange={checked => handleInputChange('require_cookies_unlocked', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -652,107 +641,112 @@ export function SettingsPage() {
|
|||
</>}
|
||||
disabled={disabled || state.require_media_mounted === null}
|
||||
checked={state.require_media_mounted === true}
|
||||
onChange={checked => handleInputChange(null, 'require_media_mounted', checked)}
|
||||
onChange={checked => handleInputChange('require_media_mounted', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Wait Between Downloads</b>
|
||||
<InfoPopup
|
||||
content='Number of seconds to wait after each download completes. This helps download "nicely" by being polite to servers. Set to 0 to disable waiting.'/>
|
||||
</>}
|
||||
<div style={{margin: '0.5em 0'}}>
|
||||
<label>
|
||||
<b>Wait Between Downloads</b>
|
||||
<InfoPopup
|
||||
content='Number of seconds to wait after each download completes. This helps download "nicely" by being polite to servers. Set to 0 to disable waiting.'/>
|
||||
</label>
|
||||
<br/>
|
||||
<TextInput
|
||||
value={state.download_wait}
|
||||
disabled={disabled || state.download_wait === null}
|
||||
onChange={(e, i) => handleTimeoutChange(e, 'download_wait', i.value)}
|
||||
onChange={e => handleTimeoutChange('download_wait', e.currentTarget.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Download Timeout</b>
|
||||
<InfoPopup content='Downloads will be stopped after this many seconds have elapsed.
|
||||
Downloads will never timeout if this is empty.'/>
|
||||
</>}
|
||||
</div>
|
||||
<div style={{margin: '0.5em 0'}}>
|
||||
<label>
|
||||
<b>Download Timeout</b>
|
||||
<InfoPopup content='Downloads will be stopped after this many seconds have elapsed.
|
||||
Downloads will never timeout if this is empty.'/>
|
||||
</label>
|
||||
<br/>
|
||||
<TextInput
|
||||
value={state.download_timeout}
|
||||
disabled={disabled || state.download_timeout === null}
|
||||
onChange={(e, i) => handleTimeoutChange(e, 'download_timeout', i.value)}
|
||||
onChange={e => handleTimeoutChange('download_timeout', e.currentTarget.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
</div>
|
||||
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Daily Download Limit (per domain)</b>
|
||||
<InfoPopup
|
||||
content='Maximum number of downloads from any single domain per day. Recurring
|
||||
Channel/RSS catalog updates do not count; only the videos/archives they create
|
||||
and one-off downloads count. Leave empty or set to 0 for no limit.'/>
|
||||
</>}
|
||||
<div style={{margin: '0.5em 0'}}>
|
||||
<label>
|
||||
<b>Daily Download Limit (per domain)</b>
|
||||
<InfoPopup
|
||||
content='Maximum number of downloads from any single domain per day. Recurring
|
||||
Channel/RSS catalog updates do not count; only the videos/archives they create
|
||||
and one-off downloads count. Leave empty or set to 0 for no limit.'/>
|
||||
</label>
|
||||
<br/>
|
||||
<TextInput
|
||||
value={state.download_daily_limit_per_domain}
|
||||
disabled={disabled}
|
||||
onChange={(e, i) => handleTimeoutChange(e, 'download_daily_limit_per_domain', i.value)}
|
||||
onChange={e => handleTimeoutChange('download_daily_limit_per_domain', e.currentTarget.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Daily Download Limit (total)</b>
|
||||
<InfoPopup
|
||||
content='Maximum number of downloads across all domains per day. Recurring
|
||||
Channel/RSS catalog updates do not count. Leave empty or set to 0 for no limit.'/>
|
||||
</>}
|
||||
</div>
|
||||
<div style={{margin: '0.5em 0'}}>
|
||||
<label>
|
||||
<b>Daily Download Limit (total)</b>
|
||||
<InfoPopup
|
||||
content='Maximum number of downloads across all domains per day. Recurring
|
||||
Channel/RSS catalog updates do not count. Leave empty or set to 0 for no limit.'/>
|
||||
</label>
|
||||
<br/>
|
||||
<TextInput
|
||||
value={state.download_daily_limit_global}
|
||||
disabled={disabled}
|
||||
onChange={(e, i) => handleTimeoutChange(e, 'download_daily_limit_global', i.value)}
|
||||
onChange={e => handleTimeoutChange('download_daily_limit_global', e.currentTarget.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
</div>
|
||||
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Download Window Start</b>
|
||||
<InfoPopup
|
||||
content='Start time for allowed download window (HH:MM, 24-hour). Leave both empty for no restriction.'/>
|
||||
</>}
|
||||
<div style={{margin: '0.5em 0'}}>
|
||||
<label>
|
||||
<b>Download Window Start</b>
|
||||
<InfoPopup
|
||||
content='Start time for allowed download window (HH:MM, 24-hour). Leave both empty for no restriction.'/>
|
||||
</label>
|
||||
<br/>
|
||||
<TextInput
|
||||
type='time'
|
||||
value={state.download_window_start}
|
||||
disabled={disabled}
|
||||
onChange={(e, i) => handleInputChange(e, 'download_window_start', i.value)}
|
||||
onChange={e => handleInputChange('download_window_start', e.currentTarget.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
</div>
|
||||
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Download Window End</b>
|
||||
<InfoPopup
|
||||
content='End time for allowed download window (HH:MM, 24-hour). Leave both empty for no restriction.'/>
|
||||
</>}
|
||||
<div style={{margin: '0.5em 0'}}>
|
||||
<label>
|
||||
<b>Download Window End</b>
|
||||
<InfoPopup
|
||||
content='End time for allowed download window (HH:MM, 24-hour). Leave both empty for no restriction.'/>
|
||||
</label>
|
||||
<br/>
|
||||
<TextInput
|
||||
type='time'
|
||||
value={state.download_window_end}
|
||||
disabled={disabled}
|
||||
onChange={(e, i) => handleInputChange(e, 'download_window_end', i.value)}
|
||||
onChange={e => handleInputChange('download_window_end', e.currentTarget.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
</div>
|
||||
|
||||
<Form.Field width={3}>
|
||||
<div style={{margin: '0.5em 0', maxWidth: '20em'}}>
|
||||
<label><b>Timezone</b>
|
||||
<InfoPopup
|
||||
content='IANA timezone (e.g. America/Denver). Leave empty to use system timezone.'/>
|
||||
</label>
|
||||
<FormDropdown
|
||||
<Select
|
||||
placeholder='System default'
|
||||
options={timezoneOptions}
|
||||
data={timezoneOptions}
|
||||
value={state.timezone || ''}
|
||||
disabled={disabled}
|
||||
search
|
||||
selection
|
||||
searchable
|
||||
clearable
|
||||
onChange={(e, {value}) => setState({...state, timezone: value || ''})}
|
||||
onChange={value => setState({...state, timezone: value || ''})}
|
||||
/>
|
||||
</Form.Field>
|
||||
</div>
|
||||
{status && status.local_time &&
|
||||
<p>Current local time: <b>{status.local_time.slice(0, 16).replace('T', ' ')}</b></p>}
|
||||
|
||||
|
|
@ -762,139 +756,124 @@ export function SettingsPage() {
|
|||
<p>WROLPi will save files to these directories (any video files will be saved to
|
||||
the <i>videos</i> by default, etc.).</p>
|
||||
|
||||
<Grid stackable>
|
||||
<GridRow columns={2}>
|
||||
<GridColumn>
|
||||
<Form.Field>
|
||||
<label>
|
||||
Archive Directory
|
||||
<InfoPopup
|
||||
wide='very'
|
||||
content={<>
|
||||
<p>Variables:</p>
|
||||
<ul>
|
||||
<li><code>%(domain)s</code> - Domain name (e.g., "example.com")</li>
|
||||
<li><code>%(domain_tag)s</code> - Tag name for the domain (empty if no
|
||||
tag)
|
||||
</li>
|
||||
<li><code>%(tag)s</code> - Alias for the tag name</li>
|
||||
<li><code>%(name)s</code> - Alias for the domain name</li>
|
||||
</ul>
|
||||
</>}
|
||||
position='top left'
|
||||
/>
|
||||
</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
value={state.archive_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'archive_destination', d.value)}
|
||||
/>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
<GridColumn>
|
||||
<Form.Field>
|
||||
<label>
|
||||
Videos Directory
|
||||
<InfoPopup
|
||||
wide='very'
|
||||
content={<>
|
||||
<p>Variables:</p>
|
||||
<ul>
|
||||
<li><code>%(channel_name)s</code> - Channel name</li>
|
||||
<li><code>%(channel_tag)s</code> - Tag name for the channel (empty if no
|
||||
tag)
|
||||
</li>
|
||||
<li><code>%(channel_domain)s</code> - Domain from the channel URL</li>
|
||||
<li><code>%(tag)s</code> - Alias for the tag name</li>
|
||||
<li><code>%(name)s</code> - Alias for the channel name</li>
|
||||
</ul>
|
||||
</>}
|
||||
position='top left'
|
||||
/>
|
||||
</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
value={state.videos_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'videos_destination', d.value)}
|
||||
/>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
</GridRow>
|
||||
<GridRow columns={2}>
|
||||
<GridColumn>
|
||||
<Form.Field>
|
||||
<label>Map Directory</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
value={state.map_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'map_destination', d.value)}
|
||||
/>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
<GridColumn>
|
||||
<Form.Field>
|
||||
<label>Zims Directory</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
value={state.zims_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'zims_destination', d.value)}
|
||||
/>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
</GridRow>
|
||||
<GridRow columns={2}>
|
||||
<GridColumn>
|
||||
<Form.Field>
|
||||
<label>Playlists Directory</label>
|
||||
<Input
|
||||
label={mediaDirectoryLabel}
|
||||
value={state.playlists_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={(e, d) => handleInputChange(e, 'playlists_destination', d.value)}
|
||||
/>
|
||||
</Form.Field>
|
||||
</GridColumn>
|
||||
</GridRow>
|
||||
<GridRow columns={1}>
|
||||
<GridColumn>
|
||||
<Toggle
|
||||
label='Edit Directories'
|
||||
disabled={disabled}
|
||||
checked={editSpecialDirectories === true}
|
||||
onChange={checked => setEditSpecialDirectories(checked)}
|
||||
<Grid>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>
|
||||
Archive Directory
|
||||
<InfoPopup
|
||||
w={340}
|
||||
content={<>
|
||||
<p>Variables:</p>
|
||||
<ul>
|
||||
<li><code>%(domain)s</code> - Domain name (e.g., "example.com")</li>
|
||||
<li><code>%(domain_tag)s</code> - Tag name for the domain (empty if no
|
||||
tag)
|
||||
</li>
|
||||
<li><code>%(tag)s</code> - Alias for the tag name</li>
|
||||
<li><code>%(name)s</code> - Alias for the domain name</li>
|
||||
</ul>
|
||||
</>}
|
||||
position='top'
|
||||
/>
|
||||
</GridColumn>
|
||||
</GridRow>
|
||||
</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
value={state.archive_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('archive_destination', e.currentTarget.value)}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>
|
||||
Videos Directory
|
||||
<InfoPopup
|
||||
w={340}
|
||||
content={<>
|
||||
<p>Variables:</p>
|
||||
<ul>
|
||||
<li><code>%(channel_name)s</code> - Channel name</li>
|
||||
<li><code>%(channel_tag)s</code> - Tag name for the channel (empty if no
|
||||
tag)
|
||||
</li>
|
||||
<li><code>%(channel_domain)s</code> - Domain from the channel URL</li>
|
||||
<li><code>%(tag)s</code> - Alias for the tag name</li>
|
||||
<li><code>%(name)s</code> - Alias for the channel name</li>
|
||||
</ul>
|
||||
</>}
|
||||
position='top'
|
||||
/>
|
||||
</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
value={state.videos_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('videos_destination', e.currentTarget.value)}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>Map Directory</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
value={state.map_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('map_destination', e.currentTarget.value)}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>Zims Directory</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
value={state.zims_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('zims_destination', e.currentTarget.value)}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={{base: 12, sm: 6}}>
|
||||
<label>Playlists Directory</label>
|
||||
<TextInput
|
||||
leftSectionWidth='auto'
|
||||
leftSection={<span style={{fontSize: '0.85em', paddingLeft: 4}}>{mediaDirectoryLabel}</span>}
|
||||
value={state.playlists_destination}
|
||||
disabled={!editSpecialDirectories}
|
||||
onChange={e => handleInputChange('playlists_destination', e.currentTarget.value)}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={12}>
|
||||
<Toggle
|
||||
label='Edit Directories'
|
||||
disabled={disabled}
|
||||
checked={editSpecialDirectories === true}
|
||||
onChange={checked => setEditSpecialDirectories(checked)}
|
||||
/>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Divider/>
|
||||
|
||||
<APIButton
|
||||
id='settings_save_button'
|
||||
color='violet'
|
||||
role='save'
|
||||
size='big'
|
||||
onClick={() => localSaveSettings(state)}
|
||||
obeyWROLMode={true}
|
||||
disabled={disabled}
|
||||
>Save</APIButton>
|
||||
|
||||
<Dimmer active={pendingSave}>
|
||||
<Loader active={pendingSave} size='large'/>
|
||||
</Dimmer>
|
||||
{pendingSave && <Loading>Saving settings...</Loading>}
|
||||
|
||||
</Form>
|
||||
</form>
|
||||
</>
|
||||
} else if (ready === false) {
|
||||
body = <Loader active inline='centered'/>
|
||||
body = <Loading/>
|
||||
} else {
|
||||
body = <ErrorMessage>Unable to fetch settings</ErrorMessage>
|
||||
}
|
||||
|
||||
const configsSegment = <Segment>
|
||||
const configsSegment = <Panel>
|
||||
<RefreshHeader
|
||||
header='Configs'
|
||||
popupContents='Check if configs are valid'
|
||||
|
|
@ -922,17 +901,17 @@ export function SettingsPage() {
|
|||
<p>Install the WROLPi Root CA certificate on your devices to trust all HTTPS connections to this WROLPi.
|
||||
You only need to do this once per device.</p>
|
||||
<a href='/ca.crt' download='wrolpi-ca.crt'>
|
||||
<Button primary><Icon name='download'/> Download Root CA Certificate</Button>
|
||||
<Button role='primary' icon='download'>Download Root CA Certificate</Button>
|
||||
</a>
|
||||
</Segment>;
|
||||
</Panel>;
|
||||
|
||||
return <Container fluid>
|
||||
return <div>
|
||||
<WROLModeMessage content='Settings are disabled because WROL Mode is enabled.'/>
|
||||
|
||||
<Segment>
|
||||
<Panel>
|
||||
<Header as='h2'>Settings</Header>
|
||||
{body}
|
||||
</Segment>
|
||||
</Panel>
|
||||
|
||||
<ThemeSegment/>
|
||||
|
||||
|
|
@ -942,10 +921,10 @@ export function SettingsPage() {
|
|||
|
||||
<WROLModeSection/>
|
||||
|
||||
<Segment>
|
||||
<Panel>
|
||||
<Header as='h1'>Browser Settings</Header>
|
||||
<APIButton onClick={clearAll}>Show All Hints</APIButton>
|
||||
</Segment>
|
||||
</Panel>
|
||||
|
||||
{/* Trace Level Modal - shown when user selects trace level in native mode */}
|
||||
<Modal
|
||||
|
|
@ -965,7 +944,7 @@ export function SettingsPage() {
|
|||
? `Switching to debug mode in ${traceCountdown} seconds...`
|
||||
: 'Switching API services...'}
|
||||
</p>
|
||||
<p style={{color: '#888', fontSize: '0.9em'}}>
|
||||
<p style={{color: 'var(--muted)', fontSize: '0.9em'}}>
|
||||
The API will restart. This page may temporarily lose connection.
|
||||
</p>
|
||||
</>
|
||||
|
|
@ -979,7 +958,7 @@ export function SettingsPage() {
|
|||
This will save your settings and restart the API service. The page may temporarily
|
||||
lose connection during the switch.
|
||||
</p>
|
||||
<p style={{color: '#888', fontSize: '0.9em'}}>
|
||||
<p style={{color: 'var(--muted)', fontSize: '0.9em'}}>
|
||||
You can switch back to production mode later from the Controller page.
|
||||
</p>
|
||||
</>
|
||||
|
|
@ -987,21 +966,21 @@ export function SettingsPage() {
|
|||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button
|
||||
color='grey'
|
||||
role='cancel'
|
||||
onClick={handleTraceModalCancel}
|
||||
disabled={traceSwitching}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
color='green'
|
||||
role='save'
|
||||
onClick={handleTraceModalConfirm}
|
||||
disabled={traceSwitching}
|
||||
icon='check'
|
||||
>
|
||||
<Icon name='check'/> Enable Debug Mode
|
||||
Enable Debug Mode
|
||||
</Button>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
</Container>;
|
||||
</div>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
import {Accordion, Header, Progress, Segment, Statistic, Table} from "../Theme";
|
||||
import {
|
||||
Accordion,
|
||||
Grid,
|
||||
Header,
|
||||
Panel,
|
||||
Progress,
|
||||
Statistic,
|
||||
StatisticGroup,
|
||||
Table,
|
||||
} from "../ui";
|
||||
import React, {useContext} from "react";
|
||||
import {
|
||||
Duration,
|
||||
|
|
@ -11,20 +20,8 @@ import {
|
|||
useTitle
|
||||
} from "../Common";
|
||||
import {ProgressPlaceholder} from "../Placeholder";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import {Media, SettingsContext, StatusContext, ThemeContext} from "../../contexts/contexts";
|
||||
import {
|
||||
AccordionContent,
|
||||
AccordionTitle,
|
||||
SegmentGroup,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHeader,
|
||||
TableHeaderCell,
|
||||
TableRow
|
||||
} from "semantic-ui-react";
|
||||
import {Media, SettingsContext, StatusContext} from "../../contexts/contexts";
|
||||
import _ from "lodash";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
|
||||
function DriveInfo({used, size, percent, mount}) {
|
||||
let color;
|
||||
|
|
@ -33,11 +30,11 @@ function DriveInfo({used, size, percent, mount}) {
|
|||
} else if (percent >= 80) {
|
||||
color = 'orange';
|
||||
}
|
||||
return <Progress progress
|
||||
percent={percent}
|
||||
label={`${mount} ${humanFileSize(used)} of ${humanFileSize(size)}`}
|
||||
color={color}
|
||||
key={mount}
|
||||
return <Progress
|
||||
percent={percent}
|
||||
label={`${mount} ${humanFileSize(used)} of ${humanFileSize(size)}`}
|
||||
color={color}
|
||||
key={mount}
|
||||
/>
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +42,7 @@ function DiskBandwidthProgress({bytes_ps, total, label, ...props}) {
|
|||
// Calculate percent so colors can be shown.
|
||||
let percent = (bytes_ps / total) * 100;
|
||||
percent = percent || 0;
|
||||
let color = null;
|
||||
let color = undefined;
|
||||
if (percent >= 90) {
|
||||
color = 'red';
|
||||
} else if (percent >= 80) {
|
||||
|
|
@ -62,35 +59,30 @@ function DiskBandwidth({name, bytes_read_ps, bytes_write_ps, max_read_ps, max_wr
|
|||
bytes_ps={bytes_read_ps}
|
||||
total={max_read_ps}
|
||||
label={`${name} read`}
|
||||
size='tiny'
|
||||
disabled={bytes_read_ps === 0}
|
||||
/>;
|
||||
const write = <DiskBandwidthProgress
|
||||
bytes_ps={bytes_write_ps}
|
||||
total={max_write_ps}
|
||||
label={`${name} write`}
|
||||
size='tiny'
|
||||
disabled={bytes_write_ps === 0}
|
||||
/>;
|
||||
|
||||
return <Grid columns={2}>
|
||||
<Grid.Row>
|
||||
<Grid.Column>{read}</Grid.Column>
|
||||
<Grid.Column>{write}</Grid.Column>
|
||||
</Grid.Row>
|
||||
return <Grid>
|
||||
<Grid.Col span={6}>{read}</Grid.Col>
|
||||
<Grid.Col span={6}>{write}</Grid.Col>
|
||||
</Grid>
|
||||
}
|
||||
|
||||
function CPUTemperatureStatistic({temperature, high_temperature, critical_temperature, ...props}) {
|
||||
if (!temperature) {
|
||||
return <Statistic label='Temp C°' value='?'/>
|
||||
return <Statistic label='Temp C°' value='?' {...props}/>
|
||||
}
|
||||
let color;
|
||||
if ((critical_temperature && temperature >= critical_temperature) || (!critical_temperature && temperature >= 75)) {
|
||||
props['color'] = 'red';
|
||||
color = 'red';
|
||||
} else if ((high_temperature && temperature >= high_temperature) || (!high_temperature && temperature >= 55)) {
|
||||
props['color'] = 'orange';
|
||||
color = 'orange';
|
||||
}
|
||||
return <Statistic label='Temp C°' value={temperature} {...props}/>
|
||||
return <Statistic label='Temp C°' value={temperature} color={color} {...props}/>
|
||||
}
|
||||
|
||||
function FanRPMStatistic({fan_rpm, ...props}) {
|
||||
|
|
@ -103,14 +95,15 @@ function FanRPMStatistic({fan_rpm, ...props}) {
|
|||
|
||||
function IOWaitStatistic({percent_iowait, ...props}) {
|
||||
if (percent_iowait === null || percent_iowait === undefined) {
|
||||
return <Statistic label='IO Wait %' value='?'/>
|
||||
return <Statistic label='IO Wait %' value='?' {...props}/>
|
||||
}
|
||||
let color;
|
||||
if (percent_iowait >= 30) {
|
||||
props['color'] = 'red';
|
||||
color = 'red';
|
||||
} else if (percent_iowait >= 10) {
|
||||
props['color'] = 'orange';
|
||||
color = 'orange';
|
||||
}
|
||||
return <Statistic label='IO Wait %' value={percent_iowait.toFixed(1)} {...props}/>
|
||||
return <Statistic label='IO Wait %' value={percent_iowait.toFixed(1)} color={color} {...props}/>
|
||||
}
|
||||
|
||||
function formatUptime(seconds) {
|
||||
|
|
@ -140,13 +133,13 @@ export function BandwidthProgress({label = '', bytes, maxBytes, ...props}) {
|
|||
|
||||
label = `${label} (${humanBandwidth(bytes)})`;
|
||||
const percent = (bytes / maxBytes) * 100;
|
||||
let color;
|
||||
if (percent > 70) {
|
||||
props['color'] = 'yellow';
|
||||
color = 'yellow';
|
||||
} else if (percent > 90) {
|
||||
props['color'] = 'red';
|
||||
color = 'red';
|
||||
}
|
||||
const disabled = percent === 0;
|
||||
return <Progress percent={percent} label={label} disabled={disabled} {...props}/>
|
||||
return <Progress percent={percent} label={label} color={color} {...props}/>
|
||||
}
|
||||
|
||||
export function BandwidthProgressGroup({bandwidth, ...props}) {
|
||||
|
|
@ -157,7 +150,6 @@ export function BandwidthProgressGroup({bandwidth, ...props}) {
|
|||
bytes={bandwidth['bytes_recv_ps']}
|
||||
label={`${bandwidth['name']} In`}
|
||||
maxBytes={maxBytes}
|
||||
size='small'
|
||||
{...props}
|
||||
/>;
|
||||
|
||||
|
|
@ -165,19 +157,12 @@ export function BandwidthProgressGroup({bandwidth, ...props}) {
|
|||
bytes={bandwidth['bytes_sent_ps']}
|
||||
label={`${bandwidth['name']} Out`}
|
||||
maxBytes={maxBytes}
|
||||
size='small'
|
||||
{...props}
|
||||
/>;
|
||||
|
||||
return <Grid columns={2}>
|
||||
<Grid.Row>
|
||||
<Grid.Column>
|
||||
{recv}
|
||||
</Grid.Column>
|
||||
<Grid.Column>
|
||||
{sent}
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
return <Grid>
|
||||
<Grid.Col span={6}>{recv}</Grid.Col>
|
||||
<Grid.Col span={6}>{sent}</Grid.Col>
|
||||
</Grid>
|
||||
}
|
||||
|
||||
|
|
@ -189,10 +174,10 @@ export function BandwidthProgressCombined({bandwidth, ...props}) {
|
|||
|
||||
export function CPUUsageProgress({percent, label}) {
|
||||
if (percent === null) {
|
||||
return <Progress progress={0} color='grey' label='Average CPU Usage ERROR' disabled/>
|
||||
return <Progress percent={0} color='grey' label='Average CPU Usage ERROR'/>
|
||||
}
|
||||
|
||||
let color = 'black';
|
||||
let color = undefined;
|
||||
if (percent >= 90) {
|
||||
color = 'red';
|
||||
} else if (percent >= 70) {
|
||||
|
|
@ -200,44 +185,37 @@ export function CPUUsageProgress({percent, label}) {
|
|||
} else if (percent >= 50) {
|
||||
color = 'orange';
|
||||
}
|
||||
return <Progress percent={percent} progress color={color} label={label}/>
|
||||
return <Progress percent={percent} color={color} label={label}/>
|
||||
}
|
||||
|
||||
export function MemoryUsageProgress({percent, label}) {
|
||||
if (percent === null) {
|
||||
return <Progress progress={0} color='grey' label='RAM Usage' disabled/>
|
||||
return <Progress percent={0} color='grey' label='RAM Usage'/>
|
||||
}
|
||||
|
||||
let color = 'black';
|
||||
let size = 'small';
|
||||
let color = undefined;
|
||||
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}/>
|
||||
return <Progress percent={percent} color={color} label={label}/>
|
||||
}
|
||||
|
||||
function ProcessInfoRow({pid, command, percent_cpu, percent_mem}) {
|
||||
const color = percent_cpu >= 80 ? 'orange' : null;
|
||||
return <TableRow color={color}>
|
||||
<TableCell className='column-ellipsis'>{command}</TableCell>
|
||||
<TableCell textAlign='right'>{percent_cpu}</TableCell>
|
||||
<TableCell textAlign='right'>{percent_mem}</TableCell>
|
||||
<TableCell textAlign='right'>{pid}</TableCell>
|
||||
</TableRow>
|
||||
return <Table.Row failed={percent_cpu >= 80}>
|
||||
<Table.Cell className='column-ellipsis'>{command}</Table.Cell>
|
||||
<Table.Cell numeric>{percent_cpu}</Table.Cell>
|
||||
<Table.Cell numeric>{percent_mem}</Table.Cell>
|
||||
<Table.Cell numeric>{pid}</Table.Cell>
|
||||
</Table.Row>
|
||||
}
|
||||
|
||||
export function StatusPage() {
|
||||
useTitle('Status');
|
||||
|
||||
const [activeIndex, setActiveIndex] = React.useState(null);
|
||||
|
||||
const {status} = useContext(StatusContext);
|
||||
const {settings} = useContext(SettingsContext);
|
||||
const {s} = useContext(ThemeContext);
|
||||
|
||||
let percent;
|
||||
let cores;
|
||||
|
|
@ -299,23 +277,19 @@ export function StatusPage() {
|
|||
const cpuProgress = <CPUUsageProgress percent={percent} label={`CPU Usage (${cores} cores)`}/>;
|
||||
const memoryUsageProgress = <MemoryUsageProgress percent={memoryPercent} label={`RAM Usage (${memorySize})`}/>;
|
||||
|
||||
const handleAccordionClick = (e, {index}) => {
|
||||
setActiveIndex(activeIndex === index ? -1 : index);
|
||||
}
|
||||
const noProcessesRow = <Table.Row>
|
||||
<Table.Cell colSpan={4}>No top processes</Table.Cell>
|
||||
</Table.Row>
|
||||
|
||||
const noProcessesRow = <TableRow>
|
||||
<TableCell colSpan={4}>No top processes</TableCell>
|
||||
</TableRow>
|
||||
|
||||
return <SegmentGroup>
|
||||
return <>
|
||||
<Media at='mobile'>
|
||||
<Segment>
|
||||
<Panel>
|
||||
{cpuProgress}
|
||||
{memoryUsageProgress}
|
||||
<Statistic.Group size='mini'>
|
||||
<LoadStatistic label='1 Min. Load' value={minute_1} cores={cores} style={{margin: '1em'}}/>
|
||||
<LoadStatistic label='5 Min. Load' value={minute_5} cores={cores} style={{margin: '1m'}}/>
|
||||
<LoadStatistic label='15 Min. Load' value={minute_15} cores={cores} style={{margin: '1em'}}/>
|
||||
<StatisticGroup>
|
||||
<LoadStatistic label='1 Min. Load' value={minute_1} cores={cores}/>
|
||||
<LoadStatistic label='5 Min. Load' value={minute_5} cores={cores}/>
|
||||
<LoadStatistic label='15 Min. Load' value={minute_15} cores={cores}/>
|
||||
<CPUTemperatureStatistic
|
||||
id='cpu_temperature_statistic'
|
||||
temperature={temperature}
|
||||
|
|
@ -325,14 +299,14 @@ export function StatusPage() {
|
|||
<FanRPMStatistic fan_rpm={fan_rpm}/>
|
||||
<IOWaitStatistic percent_iowait={percent_iowait}/>
|
||||
<UptimeStatistic uptime_seconds={uptime_seconds}/>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
</StatisticGroup>
|
||||
</Panel>
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Segment>
|
||||
<Panel>
|
||||
{cpuProgress}
|
||||
{memoryUsageProgress}
|
||||
<Statistic.Group>
|
||||
<StatisticGroup>
|
||||
<LoadStatistic label='1 Min. Load' value={minute_1} cores={cores}/>
|
||||
<LoadStatistic label='5 Min.' value={minute_5} cores={cores}/>
|
||||
<LoadStatistic label='15 Min.' value={minute_15} cores={cores}/>
|
||||
|
|
@ -341,16 +315,15 @@ export function StatusPage() {
|
|||
temperature={temperature}
|
||||
high_temperature={high_temperature}
|
||||
critical_temperature={critical_temperature}
|
||||
style={{marginRight: 0}}
|
||||
/>
|
||||
<FanRPMStatistic fan_rpm={fan_rpm}/>
|
||||
<IOWaitStatistic percent_iowait={percent_iowait}/>
|
||||
<UptimeStatistic uptime_seconds={uptime_seconds}/>
|
||||
</Statistic.Group>
|
||||
</Segment>
|
||||
</StatisticGroup>
|
||||
</Panel>
|
||||
</Media>
|
||||
|
||||
<Segment>
|
||||
<Panel>
|
||||
<InfoHeader
|
||||
headerSize='h2'
|
||||
headerContent='Drive Bandwidth'
|
||||
|
|
@ -361,70 +334,68 @@ export function StatusPage() {
|
|||
{!_.isEmpty(diskBandwidthStats) ?
|
||||
Object.entries(diskBandwidthStats).map(([name, disk]) => <DiskBandwidth key={name} {...disk}/>)
|
||||
: <ProgressPlaceholder/>}
|
||||
</Segment>
|
||||
</Panel>
|
||||
|
||||
<Segment>
|
||||
<Panel>
|
||||
<SizedHeader>Network Bandwidth</SizedHeader>
|
||||
{!_.isEmpty(nicBandwidthStats) ?
|
||||
Object.entries(nicBandwidthStats).map(([name, stats]) => <BandwidthProgressGroup key={name}
|
||||
bandwidth={stats}/>)
|
||||
: <ProgressPlaceholder/>}
|
||||
</Segment>
|
||||
</Panel>
|
||||
|
||||
<Segment>
|
||||
<Panel>
|
||||
<SizedHeader>Top Processes</SizedHeader>
|
||||
<Table unstackable striped className='table-ellipsis'>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHeaderCell width={10}>Command</TableHeaderCell>
|
||||
<TableHeaderCell width={2} textAlign='right'>CPU %</TableHeaderCell>
|
||||
<TableHeaderCell width={2} textAlign='right'>Mem %</TableHeaderCell>
|
||||
<TableHeaderCell width={2} textAlign='right'>PID</TableHeaderCell>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<Table className='table-ellipsis'>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell>Command</Table.HeaderCell>
|
||||
<Table.HeaderCell>CPU %</Table.HeaderCell>
|
||||
<Table.HeaderCell>Mem %</Table.HeaderCell>
|
||||
<Table.HeaderCell>PID</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{processesStats && processesStats.length === 0 ?
|
||||
noProcessesRow :
|
||||
processesStats && processesStats.length > 0 ?
|
||||
processesStats.map(i => <ProcessInfoRow key={i.pid} {...i}/>)
|
||||
: <TableRow><TableCell><ProgressPlaceholder/></TableCell></TableRow>
|
||||
: <Table.Row><Table.Cell colSpan={4}><ProgressPlaceholder/></Table.Cell></Table.Row>
|
||||
}
|
||||
</TableBody>
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Segment>
|
||||
</Panel>
|
||||
|
||||
<Segment>
|
||||
<Panel>
|
||||
<SizedHeader>Drive Usage</SizedHeader>
|
||||
{drivesStats && drivesStats.length > 0 ? drivesStats.map((drive) => <DriveInfo
|
||||
key={drive['mount']} {...drive}/>)
|
||||
: <ProgressPlaceholder/>}
|
||||
</Segment>
|
||||
</Panel>
|
||||
|
||||
<Segment>
|
||||
<Panel>
|
||||
<SizedHeader sizeMobile={'h2'} sizeTablet={'h3'}>Developer</SizedHeader>
|
||||
<Accordion>
|
||||
|
||||
<AccordionTitle onClick={handleAccordionClick} index={0}>
|
||||
<Icon name='dropdown'/>
|
||||
Status Details
|
||||
</AccordionTitle>
|
||||
<AccordionContent active={activeIndex === 0}>
|
||||
<pre {...s}>
|
||||
{JSON.stringify(status, undefined, 1)}
|
||||
</pre>
|
||||
</AccordionContent>
|
||||
<Accordion.Item value='status'>
|
||||
<Accordion.Control>Status Details</Accordion.Control>
|
||||
<Accordion.Panel>
|
||||
<pre style={{background: 'var(--panel)', color: 'var(--text)', padding: '0.5em'}}>
|
||||
{JSON.stringify(status, undefined, 1)}
|
||||
</pre>
|
||||
</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
|
||||
<AccordionTitle onClick={handleAccordionClick} index={1}>
|
||||
<Icon name='dropdown'/>
|
||||
Settings Details
|
||||
</AccordionTitle>
|
||||
<AccordionContent active={activeIndex === 1}>
|
||||
<pre {...s}>
|
||||
{JSON.stringify(settings, undefined, 1)}
|
||||
</pre>
|
||||
</AccordionContent>
|
||||
<Accordion.Item value='settings'>
|
||||
<Accordion.Control>Settings Details</Accordion.Control>
|
||||
<Accordion.Panel>
|
||||
<pre style={{background: 'var(--panel)', color: 'var(--text)', padding: '0.5em'}}>
|
||||
{JSON.stringify(settings, undefined, 1)}
|
||||
</pre>
|
||||
</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
|
||||
</Accordion>
|
||||
</Segment>
|
||||
</SegmentGroup>
|
||||
</Panel>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue