mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 23:16:17 -05:00
Creating Controller service which will control WROLPi services, admin, SMART, disks, and status. nginx will fallback to Controller UI when React UI is unavailable (such as during upgrades).
This commit is contained in:
parent
344fe9035f
commit
b9158b60fe
66 changed files with 9920 additions and 327 deletions
|
|
@ -1,69 +1,10 @@
|
|||
import React from 'react';
|
||||
import {Container} from "semantic-ui-react";
|
||||
import {getStatus, saveSettings} from "../../api";
|
||||
import {PageContainer, TabLinks, Toggle} from "../Common";
|
||||
import {PageContainer, TabLinks} from "../Common";
|
||||
import {Route, Routes} from "react-router";
|
||||
import {ThemeContext} from "../../contexts/contexts";
|
||||
import {Header, Loader, Segment} from "../Theme";
|
||||
import {DownloadsPage} from "./Downloads";
|
||||
import {SettingsPage} from "./Settings";
|
||||
import {StatusPage} from "./Status";
|
||||
|
||||
class WROLMode extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
WROLMode: false,
|
||||
}
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
try {
|
||||
const {wrol_mode} = await getStatus();
|
||||
this.setState({ready: true, WROLMode: wrol_mode});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
toggleWROLMode = async (checked) => {
|
||||
// Handle WROL Mode toggling by itself so that other settings are not modified.
|
||||
let config = {
|
||||
wrol_mode: checked,
|
||||
}
|
||||
await saveSettings(config);
|
||||
this.setState({disabled: !this.state.WROLMode, WROLMode: checked});
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.ready === false) {
|
||||
return <Loader active inline='centered'/>
|
||||
}
|
||||
|
||||
return <ThemeContext.Consumer>
|
||||
{({t}) => <Container fluid>
|
||||
|
||||
<Segment>
|
||||
<Header as="h1">WROL Mode</Header>
|
||||
<Header as='h4'>
|
||||
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.
|
||||
</Header>
|
||||
<p {...t}>
|
||||
Note: User settings and tags can still be modified.
|
||||
</p>
|
||||
<Toggle
|
||||
checked={this.state.WROLMode}
|
||||
onChange={this.toggleWROLMode}
|
||||
label={this.state.WROLMode ? 'WROL Mode Enabled' : 'WROL Mode Disabled'}
|
||||
/>
|
||||
</Segment>
|
||||
|
||||
</Container>}
|
||||
</ThemeContext.Consumer>
|
||||
}
|
||||
}
|
||||
import {ControllerPage} from "./ControllerPage";
|
||||
|
||||
export default function AdminRoute() {
|
||||
|
||||
|
|
@ -71,7 +12,7 @@ export default function AdminRoute() {
|
|||
{text: 'Downloads', to: '/admin', key: 'admin', end: true},
|
||||
{text: 'Settings', to: '/admin/settings', key: 'settings'},
|
||||
{text: 'Status', to: '/admin/status', key: 'status'},
|
||||
{text: 'WROL Mode', to: '/admin/wrol', key: 'wrol'},
|
||||
{text: 'Controller', to: '/admin/controller', key: 'controller'},
|
||||
];
|
||||
|
||||
return <PageContainer>
|
||||
|
|
@ -80,7 +21,7 @@ export default function AdminRoute() {
|
|||
<Route path='/' exact element={<DownloadsPage/>}/>
|
||||
<Route path='settings' exact element={<SettingsPage/>}/>
|
||||
<Route path='status' exact element={<StatusPage/>}/>
|
||||
<Route path='wrol' exact element={<WROLMode/>}/>
|
||||
<Route path='controller' exact element={<ControllerPage/>}/>
|
||||
</Routes>
|
||||
</PageContainer>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue