diff --git a/app/package.json b/app/package.json index 7434d09e..8fad226b 100644 --- a/app/package.json +++ b/app/package.json @@ -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", diff --git a/app/src/App.js b/app/src/App.js index 9ad38d68..8be35c63 100644 --- a/app/src/App.js +++ b/app/src/App.js @@ -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 - - - - ; + {/* Context and style to handle switching between mobile/computer. */} + + + + + + + } diff --git a/app/src/Dashboard.js b/app/src/Dashboard.js index 9fffe98e..3819a797 100644 --- a/app/src/Dashboard.js +++ b/app/src/Dashboard.js @@ -80,7 +80,7 @@ export function Dashboard() { searchStr={searchStr} onSubmit={setSearchStr} size='large' - placeholder='Search Everywhere...' + placeholder='Search everywhere...' actionIcon='search' style={{marginBottom: '2em'}} /> diff --git a/app/src/components/Channels.js b/app/src/components/Channels.js index 57b5fd50..4c19c6b5 100644 --- a/app/src/components/Channels.js +++ b/app/src/components/Channels.js @@ -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} - - - {tableHeader} - - {filteredChannels.map(channel => )} - -
-
- + {filteredChannels.map(channel => )}
-
+ + + + {tableHeader} + + {filteredChannels.map(channel => )} + +
+
} diff --git a/app/src/components/Common.js b/app/src/components/Common.js index 6e271bfd..04c7a772 100644 --- a/app/src/components/Common.js +++ b/app/src/components/Common.js @@ -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 (<> - - - {props.children} - - - + return <> + {props.children} - - ) + + + + {props.children} + + + ; } export function CardGroupCentered(props) { return (
- - - {props.children} - - - + {props.children} - + + + + {props.children} + +
) } diff --git a/app/src/components/Nav.js b/app/src/components/Nav.js index 95d47b52..023c4acc 100644 --- a/app/src/components/Nav.js +++ b/app/src/components/Nav.js @@ -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 ( - - - {props.link.links.map((l) => { - return ( - - ) - })} - - - ) + return ( + + {props.link.links.map((l) => { + return () + })} + + ) } function MenuLink({link}) { @@ -45,19 +35,15 @@ function MenuLink({link}) { if (!link.links) { const end = link.end ? {end: true} : {end: undefined}; - return ( - - {link.text} - - ) + return ( + {link.text} + ) } else { - return ( - - ) + return () } } @@ -72,35 +58,36 @@ export function NavBar() { const topNavText = wrol_mode ? <>{name}  : name; const {i} = useContext(ThemeContext); - return ( - - {/*Always show WROLPi home button*/} - + const homeLink = ; + const icons = + + + ; - {/*Show the links in a menu when on desktop*/} - {links.map((link) => { - return ( - - ) - })} - - - - {rightLinks.map((link) => )} - + return <> + + + {homeLink} + + {icons} + + + {collapsedLinks.map(i =>)} + + + + + + + + {homeLink} + {links.map(i => )} - {/*Show the menu items in a dropdown when on mobile*/} - - - - - - {collapsedLinks.map((link) => - - )} - - - - - ) + + {icons} + {rightLinks.map(i => )} + + + + } diff --git a/app/src/components/admin/Settings.js b/app/src/components/admin/Settings.js index 27e987cf..e83fe722 100644 --- a/app/src/components/admin/Settings.js +++ b/app/src/components/admin/Settings.js @@ -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)} /> - this.setState({hotspot_password: d.value}, this.handleHotspotChange)} + onChange={(e, d) => this.setState({hotspot_password: d.value}, this.handleHotspotChange)} /> - - - this.handleInputChange(null, 'timezone', i)} - /> - +
- @@ -233,8 +224,7 @@ export class Settings extends React.Component { - - } + } } } diff --git a/app/src/components/admin/Status.js b/app/src/components/admin/Status.js index 1ba25a34..873c95f3 100644 --- a/app/src/components/admin/Status.js +++ b/app/src/components/admin/Status.js @@ -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 <> - + @@ -212,8 +211,8 @@ export function Status() {
Drive Bandwidth
{disk_bandwidth.map((disk) => )}
-
- + + @@ -244,6 +243,6 @@ export function Status() {
Drive Bandwidth
{disk_bandwidth.map((disk) => )}
-
+ } diff --git a/app/src/contexts/contexts.js b/app/src/contexts/contexts.js index b3c352f5..9d05db35 100644 --- a/app/src/contexts/contexts.js +++ b/app/src/contexts/contexts.js @@ -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; diff --git a/app/src/index.js b/app/src/index.js index 229b75ea..f1966be4 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -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(, document.getElementById('root')); +const container = document.getElementById('root'); +const root = createRoot(container); +root.render(); // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls.