mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-30 11:56:18 -05:00
Upgrading Reactjs to version 18. Removing timezone select in favor of using browser's timezone. Switching to @artsy/fresnel for Responsive content.
This commit is contained in:
parent
2840f9215c
commit
6a5a73af22
10 changed files with 124 additions and 132 deletions
|
|
@ -3,11 +3,12 @@
|
|||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@artsy/fresnel": "^6.1.0",
|
||||
"lodash": "^4.17.19",
|
||||
"npm": "^6.14.7",
|
||||
"query-string": "^6.13.0",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-dropzone": "^11.4.2",
|
||||
"react-keyed-file-browser": "^1.14.0",
|
||||
"react-qr-code": "^2.0.7",
|
||||
|
|
@ -15,9 +16,8 @@
|
|||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "^3.4.1",
|
||||
"react-semantic-toasts": "^0.6.5",
|
||||
"react-timezone-select": "0.8.4",
|
||||
"semantic-ui-offline": "^2.4.1-1",
|
||||
"semantic-ui-react": "^0.88.2"
|
||||
"semantic-ui-react": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {ArchiveRoute} from "./components/Archive";
|
|||
import {FilesRoute} from "./components/Files";
|
||||
import {useStatusInterval} from "./hooks/customHooks";
|
||||
import {MapRoute} from "./components/Map";
|
||||
import {StatusContext, ThemeContext} from "./contexts/contexts";
|
||||
import {MediaContextProvider, mediaStyles, StatusContext, ThemeContext} from "./contexts/contexts";
|
||||
import {Header, ThemeWrapper} from "./components/Theme";
|
||||
import {Dashboard} from "./Dashboard";
|
||||
import {Donate} from "./components/Donate";
|
||||
|
|
@ -83,8 +83,12 @@ export default function App() {
|
|||
useEventsInterval();
|
||||
|
||||
return <ThemeWrapper>
|
||||
<StatusContext.Provider value={status}>
|
||||
<RouterProvider router={router}/>
|
||||
</StatusContext.Provider>
|
||||
</ThemeWrapper>;
|
||||
{/* Context and style to handle switching between mobile/computer. */}
|
||||
<style>{mediaStyles}</style>
|
||||
<MediaContextProvider>
|
||||
<StatusContext.Provider value={status}>
|
||||
<RouterProvider router={router}/>
|
||||
</StatusContext.Provider>
|
||||
</MediaContextProvider>
|
||||
</ThemeWrapper>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export function Dashboard() {
|
|||
searchStr={searchStr}
|
||||
onSubmit={setSearchStr}
|
||||
size='large'
|
||||
placeholder='Search Everywhere...'
|
||||
placeholder='Search everywhere...'
|
||||
actionIcon='search'
|
||||
style={{marginBottom: '2em'}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import {
|
|||
AccordionTitle,
|
||||
Grid,
|
||||
Input,
|
||||
Responsive,
|
||||
StatisticLabel,
|
||||
StatisticValue,
|
||||
TableBody,
|
||||
|
|
@ -48,6 +47,7 @@ import {
|
|||
Table
|
||||
} from "./Theme";
|
||||
import Dropdown from "semantic-ui-react/dist/commonjs/modules/Dropdown";
|
||||
import {Media} from "../contexts/contexts";
|
||||
|
||||
|
||||
function ChannelStatistics({statistics}) {
|
||||
|
|
@ -564,20 +564,20 @@ export function Channels() {
|
|||
|
||||
return <>
|
||||
{header}
|
||||
<Responsive minWidth={770}>
|
||||
<Table compact striped size='large'>
|
||||
{tableHeader}
|
||||
<TableBody>
|
||||
{filteredChannels.map(channel => <ChannelRow key={channel.id} channel={channel}/>)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Responsive>
|
||||
<Responsive maxWidth={769}>
|
||||
<Media at='mobile'>
|
||||
<Table striped unstackable size='small'>
|
||||
<TableBody>
|
||||
{filteredChannels.map(channel => <MobileChannelRow key={channel.id} channel={channel}/>)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Responsive>
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Table compact unstackable striped size='large'>
|
||||
{tableHeader}
|
||||
<TableBody>
|
||||
{filteredChannels.map(channel => <ChannelRow key={channel.id} channel={channel}/>)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Media>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import React, {useContext, useEffect, useState} from "react";
|
||||
import {Card, Container, IconGroup, Image, Input, Modal, Pagination, Responsive} from 'semantic-ui-react';
|
||||
import {Card, Container, IconGroup, Image, Input, Modal, Pagination} from 'semantic-ui-react';
|
||||
import {Link, NavLink, useNavigate} from "react-router-dom";
|
||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
import {useDirectories, useDownloaders, useHotspot, useSettings, useThrottle} from "../hooks/customHooks";
|
||||
import {StatusContext, ThemeContext} from "../contexts/contexts";
|
||||
import {Media, StatusContext, ThemeContext} from "../contexts/contexts";
|
||||
import {Button, darkTheme, Form, Header, Icon, lightTheme, Menu, Popup, Statistic} from "./Theme";
|
||||
|
||||
export const API_URI = `http://${window.location.host}/api`;
|
||||
|
|
@ -321,6 +321,7 @@ export function SearchInput({
|
|||
action,
|
||||
actionIcon,
|
||||
clearable,
|
||||
autoFocus = false,
|
||||
...props
|
||||
}) {
|
||||
let [value, setValue] = useState(searchStr || '');
|
||||
|
|
@ -397,32 +398,32 @@ export function TabLinks({links}) {
|
|||
}
|
||||
|
||||
export function PageContainer(props) {
|
||||
return (<>
|
||||
<Responsive minWidth={770}>
|
||||
<Container fluid style={{marginTop: '1em', padding: '1em'}}>
|
||||
{props.children}
|
||||
</Container>
|
||||
</Responsive>
|
||||
<Responsive maxWidth={769}>
|
||||
return <>
|
||||
<Media at='mobile'>
|
||||
<Container style={{marginTop: '1em', padding: 0}}>
|
||||
{props.children}
|
||||
</Container>
|
||||
</Responsive>
|
||||
</>)
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Container fluid style={{marginTop: '1em', padding: '1em'}}>
|
||||
{props.children}
|
||||
</Container>
|
||||
</Media>
|
||||
</>;
|
||||
}
|
||||
|
||||
export function CardGroupCentered(props) {
|
||||
return (<div style={{marginTop: '1em'}}>
|
||||
<Responsive minWidth={770}>
|
||||
<Card.Group>
|
||||
{props.children}
|
||||
</Card.Group>
|
||||
</Responsive>
|
||||
<Responsive maxWidth={769}>
|
||||
<Media at='mobile'>
|
||||
<Card.Group centered>
|
||||
{props.children}
|
||||
</Card.Group>
|
||||
</Responsive>
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Card.Group>
|
||||
{props.children}
|
||||
</Card.Group>
|
||||
</Media>
|
||||
</div>)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +1,32 @@
|
|||
import React, {useContext} from "react";
|
||||
import {NavLink} from "react-router-dom";
|
||||
import {Dropdown, Menu, Responsive} from "semantic-ui-react";
|
||||
import {StatusContext, ThemeContext} from "../contexts/contexts";
|
||||
import {Dropdown, Menu} from "semantic-ui-react";
|
||||
import {Media, StatusContext, ThemeContext} from "../contexts/contexts";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
import {DarkModeToggle, HotspotStatusIcon, NAME} from "./Common";
|
||||
|
||||
const responsiveWidth = 700;
|
||||
|
||||
const links = [
|
||||
{text: 'Videos', to: '/videos', key: 'videos'},
|
||||
{text: 'Archive', to: '/archive', key: 'archive'},
|
||||
{text: 'Map', to: '/map', key: 'map'},
|
||||
{text: 'Files', to: '/files', key: 'files'},
|
||||
{text: 'Inventory', to: '/inventory', key: 'inventory'},
|
||||
{
|
||||
key: 'apps', text: 'Apps', links: [
|
||||
{to: '/apps/otp', text: 'One Time Pad', end: true},
|
||||
{to: '/apps/statistics', text: 'Statistics', end: true},
|
||||
]
|
||||
},
|
||||
];
|
||||
const links = [{text: 'Videos', to: '/videos', key: 'videos'}, {
|
||||
text: 'Archive', to: '/archive', key: 'archive'
|
||||
}, {text: 'Map', to: '/map', key: 'map'}, {text: 'Files', to: '/files', key: 'files'}, {
|
||||
text: 'Inventory', to: '/inventory', key: 'inventory'
|
||||
}, {
|
||||
key: 'apps', text: 'Apps', links: [{to: '/apps/otp', text: 'One Time Pad', end: true}, {
|
||||
to: '/apps/statistics', text: 'Statistics', end: true
|
||||
},]
|
||||
},];
|
||||
const admin = {to: '/admin', text: 'Admin', key: 'admin'};
|
||||
const rightLinks = [admin,];
|
||||
|
||||
const collapsedLinks = links.concat([admin,]);
|
||||
|
||||
function DropdownLinks(props) {
|
||||
return (
|
||||
<Dropdown item text={props.link.text}>
|
||||
<Dropdown.Menu>
|
||||
{props.link.links.map((l) => {
|
||||
return (
|
||||
<MenuLink key={l.to} link={l}/>
|
||||
)
|
||||
})}
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
)
|
||||
return (<Dropdown item text={props.link.text}>
|
||||
<Dropdown.Menu>
|
||||
{props.link.links.map((l) => {
|
||||
return (<MenuLink key={l.to} link={l}/>)
|
||||
})}
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>)
|
||||
}
|
||||
|
||||
function MenuLink({link}) {
|
||||
|
|
@ -45,19 +35,15 @@ function MenuLink({link}) {
|
|||
|
||||
if (!link.links) {
|
||||
const end = link.end ? {end: true} : {end: undefined};
|
||||
return (
|
||||
<NavLink
|
||||
className={classes}
|
||||
to={link.to}
|
||||
{...end}
|
||||
>
|
||||
{link.text}
|
||||
</NavLink>
|
||||
)
|
||||
return (<NavLink
|
||||
className={classes}
|
||||
to={link.to}
|
||||
{...end}
|
||||
>
|
||||
{link.text}
|
||||
</NavLink>)
|
||||
} else {
|
||||
return (
|
||||
<DropdownLinks link={link}/>
|
||||
)
|
||||
return (<DropdownLinks link={link}/>)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,35 +58,36 @@ export function NavBar() {
|
|||
const topNavText = wrol_mode ? <>{name} <Icon name='lock'/></> : name;
|
||||
const {i} = useContext(ThemeContext);
|
||||
|
||||
return (
|
||||
<Menu {...i}>
|
||||
{/*Always show WROLPi home button*/}
|
||||
<MenuLink link={{to: '/', text: topNavText, end: true}}/>
|
||||
const homeLink = <MenuLink link={{to: '/', text: topNavText, end: true}}/>;
|
||||
const icons = <React.Fragment>
|
||||
<NavIcon><HotspotStatusIcon/></NavIcon>
|
||||
<NavIcon><DarkModeToggle/></NavIcon>
|
||||
</React.Fragment>;
|
||||
|
||||
{/*Show the links in a menu when on desktop*/}
|
||||
{links.map((link) => {
|
||||
return (
|
||||
<Responsive minWidth={responsiveWidth} as={MenuLink} link={link} key={link.key}/>
|
||||
)
|
||||
})}
|
||||
<Responsive minWidth={responsiveWidth} as={Menu.Menu} position="right">
|
||||
<NavIcon><HotspotStatusIcon/></NavIcon>
|
||||
<NavIcon><DarkModeToggle/></NavIcon>
|
||||
{rightLinks.map((link) => <MenuLink link={link} key={link.key}/>)}
|
||||
</Responsive>
|
||||
return <>
|
||||
<Media at='mobile'>
|
||||
<Menu {...i}>
|
||||
{homeLink}
|
||||
<Menu.Menu position='right'>
|
||||
{icons}
|
||||
<Dropdown item icon="bars">
|
||||
<Dropdown.Menu>
|
||||
{collapsedLinks.map(i =><MenuLink link={i} key={i.key}/>)}
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
</Menu.Menu>
|
||||
</Menu>
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Menu {...i}>
|
||||
{homeLink}
|
||||
{links.map(i => <MenuLink link={i} key={i.key}/>)}
|
||||
|
||||
{/*Show the menu items in a dropdown when on mobile*/}
|
||||
<Responsive as={Menu.Menu} maxWidth={responsiveWidth - 1} position='right'>
|
||||
<NavIcon><HotspotStatusIcon/></NavIcon>
|
||||
<NavIcon><DarkModeToggle/></NavIcon>
|
||||
<Dropdown item icon="bars">
|
||||
<Dropdown.Menu>
|
||||
{collapsedLinks.map((link) =>
|
||||
<MenuLink link={link} key={link.key}/>
|
||||
)}
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
</Responsive>
|
||||
</Menu>
|
||||
)
|
||||
<Menu.Menu position='right'>
|
||||
{icons}
|
||||
{rightLinks.map(i => <MenuLink link={i} key={i.key}/>)}
|
||||
</Menu.Menu>
|
||||
</Menu>
|
||||
</Media>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import React from "react";
|
||||
import {getSettings, saveSettings} from "../../api";
|
||||
import {Button, Form, FormField, FormGroup, FormInput, Header, Loader, Segment} from "../Theme";
|
||||
import {Button, Form, FormGroup, FormInput, Header, Loader, Segment} from "../Theme";
|
||||
import {Container, Dimmer, Icon, Modal} from "semantic-ui-react";
|
||||
import {ThemeContext} from "../../contexts/contexts";
|
||||
import {HelpPopup, HotspotToggle, ThrottleToggle, Toggle, WROLModeMessage} from "../Common";
|
||||
import QRCode from "react-qr-code";
|
||||
import TimezoneSelect from "react-timezone-select";
|
||||
|
||||
export class Settings extends React.Component {
|
||||
|
||||
|
|
@ -183,15 +182,13 @@ export class Settings extends React.Component {
|
|||
label='Hotspot SSID'
|
||||
value={hotspot_ssid}
|
||||
disabled={disabled || hotspot_ssid === null}
|
||||
onChange={(e, d) =>
|
||||
this.setState({hotspot_ssid: d.value}, this.handleHotspotChange)}
|
||||
onChange={(e, d) => this.setState({hotspot_ssid: d.value}, this.handleHotspotChange)}
|
||||
/>
|
||||
<FormInput
|
||||
label='Hotspot Password'
|
||||
disabled={disabled || hotspot_password === null}
|
||||
value={hotspot_password}
|
||||
onChange={(e, d) =>
|
||||
this.setState({hotspot_password: d.value}, this.handleHotspotChange)}
|
||||
onChange={(e, d) => this.setState({hotspot_password: d.value}, this.handleHotspotChange)}
|
||||
/>
|
||||
<FormInput
|
||||
label='Hotspot Device'
|
||||
|
|
@ -215,15 +212,9 @@ export class Settings extends React.Component {
|
|||
</Modal.Content>
|
||||
</Modal>
|
||||
|
||||
<FormField>
|
||||
<label>Timezone</label>
|
||||
<TimezoneSelect
|
||||
value={timezone}
|
||||
onChange={i => this.handleInputChange(null, 'timezone', i)}
|
||||
/>
|
||||
</FormField>
|
||||
<br/>
|
||||
|
||||
<Button color="blue" type="submit" disabled={disabled}>
|
||||
<Button color="blue" type="submit" disabled={disabled} size='large'>
|
||||
Save
|
||||
</Button>
|
||||
|
||||
|
|
@ -233,8 +224,7 @@ export class Settings extends React.Component {
|
|||
|
||||
</Form>
|
||||
</Segment>
|
||||
</Container>
|
||||
}
|
||||
</Container>}
|
||||
</ThemeContext.Consumer>
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import {Header, Progress, Segment, Statistic, StatisticGroup} from "../Theme";
|
||||
import React, {useContext} from "react";
|
||||
import {humanBandwidth, humanFileSize, LoadStatistic, useTitle} from "../Common";
|
||||
import {Responsive} from "semantic-ui-react";
|
||||
import {ProgressPlaceholder} from "../Placeholder";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import {StatusContext} from "../../contexts/contexts";
|
||||
import {Media, StatusContext} from "../../contexts/contexts";
|
||||
|
||||
function DriveInfo({used, size, percent, mount}) {
|
||||
let color;
|
||||
|
|
@ -182,7 +181,7 @@ export function Status() {
|
|||
}
|
||||
|
||||
return <>
|
||||
<Responsive minWidth={770}>
|
||||
<Media at='mobile'>
|
||||
<Segment>
|
||||
<CPUUsageProgress value={percent} label='CPU Usage'/>
|
||||
<StatisticGroup>
|
||||
|
|
@ -212,8 +211,8 @@ export function Status() {
|
|||
<Header as='h1'>Drive Bandwidth</Header>
|
||||
{disk_bandwidth.map((disk) => <DiskBandwidth key={disk['name']} {...disk}/>)}
|
||||
</Segment>
|
||||
</Responsive>
|
||||
<Responsive maxWidth={769}>
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Segment>
|
||||
<CPUUsageProgress value={percent} label='CPU Usage'/>
|
||||
<StatisticGroup size='mini'>
|
||||
|
|
@ -244,6 +243,6 @@ export function Status() {
|
|||
<Header as='h2'>Drive Bandwidth</Header>
|
||||
{disk_bandwidth.map((disk) => <DiskBandwidth key={disk['name']} {...disk}/>)}
|
||||
</Segment>
|
||||
</Responsive>
|
||||
</Media>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
import React from "react";
|
||||
import {createMedia} from "@artsy/fresnel";
|
||||
|
||||
export const ThemeContext = React.createContext({theme: null, i: {}});
|
||||
|
||||
export const StatusContext = React.createContext({});
|
||||
|
||||
export const AppMedia = createMedia({
|
||||
breakpoints: {
|
||||
mobile: 0, tablet: 700, computer: 1024,
|
||||
}
|
||||
});
|
||||
export const mediaStyles = AppMedia.createMediaStyle();
|
||||
export const {Media, MediaContextProvider} = AppMedia;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import {createRoot} from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
|
||||
ReactDOM.render(<App/>, document.getElementById('root'));
|
||||
const container = document.getElementById('root');
|
||||
const root = createRoot(container);
|
||||
root.render(<App/>);
|
||||
|
||||
// If you want your app to work offline and load faster, you can change
|
||||
// unregister() to register() below. Note this comes with some pitfalls.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue