mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 23:16:17 -05:00
Copying some settings values to status to avoid calling both /settings and /status.
This commit is contained in:
parent
78218d3559
commit
dbdcc7a57c
10 changed files with 105 additions and 68 deletions
|
|
@ -3,7 +3,7 @@ import {Card, Container, Image, Input, Pagination, Responsive, TableCell, TableR
|
|||
import {Link, NavLink} from "react-router-dom";
|
||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
import {useDownloaders, useHotspot, useThrottle} from "../hooks/customHooks";
|
||||
import {darkTheme, SettingsContext, ThemeContext} from "../contexts/contexts";
|
||||
import {darkTheme, StatusContext, ThemeContext} from "../contexts/contexts";
|
||||
import {Button, CardIcon, Form, Header, Icon, Menu, Popup, Statistic} from "./Theme";
|
||||
|
||||
export const API_URI = `http://${window.location.host}/api`;
|
||||
|
|
@ -471,8 +471,8 @@ export function SearchInput({
|
|||
}
|
||||
|
||||
export function WROLModeMessage({content}) {
|
||||
const settings = useContext(SettingsContext);
|
||||
const wrol_mode = settings ? settings.wrol_mode : null;
|
||||
const {status} = useContext(StatusContext);
|
||||
const wrol_mode = status ? status.wrol_mode : null;
|
||||
|
||||
if (wrol_mode) {
|
||||
return <Message icon='lock' header='WROL Mode Enabled' content={content}/>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React, {useContext} from "react";
|
||||
import {NavLink} from "react-router-dom";
|
||||
import {Dropdown, Menu, Responsive} from "semantic-ui-react";
|
||||
import {SettingsContext, ThemeContext} from "../contexts/contexts";
|
||||
import {StatusContext, ThemeContext} from "../contexts/contexts";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
import {DarkModeToggle} from "./Common";
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ function MenuLink(props) {
|
|||
}
|
||||
|
||||
export function NavBar() {
|
||||
const settings = useContext(SettingsContext);
|
||||
const wrol_mode = settings ? settings.wrol_mode : null;
|
||||
const {status} = useContext(StatusContext);
|
||||
const wrol_mode = status ? status['wrol_mode'] : null;
|
||||
const topNavText = wrol_mode ? <>WROLPi <Icon name='lock'/></> : 'WROLPi';
|
||||
const {i} = useContext(ThemeContext);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import {Container} from "semantic-ui-react";
|
||||
import {getSettings, saveSettings} from "../../api";
|
||||
import {getStatus, saveSettings} from "../../api";
|
||||
import {PageContainer, TabLinks, Toggle} from "../Common";
|
||||
import {Route, Routes} from "react-router-dom";
|
||||
import {ThemeContext} from "../../contexts/contexts";
|
||||
|
|
@ -20,8 +20,8 @@ class WROLMode extends React.Component {
|
|||
|
||||
async componentDidMount() {
|
||||
try {
|
||||
let settings = await getSettings();
|
||||
this.setState({ready: true, WROLMode: settings.wrol_mode});
|
||||
const {wrol_mode} = await getStatus();
|
||||
this.setState({ready: true, WROLMode: wrol_mode});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ class WROLMode extends React.Component {
|
|||
}
|
||||
|
||||
return <ThemeContext.Consumer>
|
||||
{({i, t}) => <Container fluid>
|
||||
{({t}) => <Container fluid>
|
||||
|
||||
<Header as="h1">WROL Mode</Header>
|
||||
<Header as='h4'>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue