import React from "react"; import {Link, NavLink} from "react-router-dom"; import {Dropdown, Icon as SIcon, Menu} from "semantic-ui-react"; import {Media, SettingsContext, StatusContext, ThemeContext} from "../contexts/contexts"; import { CPUTemperatureIcon, DarkModeToggle, HELP_VIEWER_URI, HotspotStatusIcon, NAME, SystemLoadIcon, useLocalStorage } from "./Common"; import {ShareButton} from "./Share"; import {useWROLMode} from "../hooks/customHooks"; import {SearchIconButton} from "./Search"; import {Icon} from "./Theme"; const links = [ {text: 'Videos', to: '/videos', key: 'videos'}, {text: 'Archive', to: '/archive', key: 'archive'}, {text: 'Map', to: '/map', key: 'map'}, {text: 'Zim', to: '/zim', key: 'zim'}, {text: 'Files', to: '/files', key: 'files'}, { text: 'More', key: 'more', links: [ {text: 'Inventory', to: '/inventory', key: 'inventory'}, {to: '/more/otp', text: 'One Time Pad', end: true}, {to: '/more/vin', text: 'VIN Decoder', end: true}, {to: '/more/calculators', text: 'Calculators', end: true}, {to: '/more/statistics', text: 'Statistics', end: true}, ] }, ]; const help = {to: HELP_VIEWER_URI, text: 'Help', key: 'help', target: '_blank'}; const admin = {to: '/admin', text: 'Admin', key: 'admin'}; const rightLinks = [help, admin]; const collapsedLinks = links.concat([help, admin]); function DropdownLinks({link}) { return {link.links.map(l => )} } function MenuLink({link}) { // Wrapper around NavLink to handle Navlink/Dropdown change. if (link.links) { return } else { const end = link.end ? {end: true} : {end: undefined}; const target = link.target ? {target: link.target} : {}; return {link.text} } } function NavIconWrapper(props) { return
{props.children}
} function useNavColorSetting() { // Use localstorage to avoid flickering navbar color on startup. const {settings} = React.useContext(SettingsContext); const [navColor, setNavColor] = useLocalStorage('nav_color', 'violet'); React.useEffect(() => { const newColor = settings.nav_color || 'violet'; setNavColor(newColor); localStorage.setItem('nav_color', newColor); }, [settings.nav_color]); return navColor } export function NavBar() { const wrolModeEnabled = useWROLMode(); const {status} = React.useContext(StatusContext); const navColor = useNavColorSetting(); const wrolpiIcon = WROLPi Home Icon; const name = {NAME || wrolpiIcon}; const topNavText = wrolModeEnabled ? <>{name}  : name; const {i} = React.useContext(ThemeContext); const homeLink = {topNavText} ; // Display the temperature icon first because it can cause the system to throttle. const warningIcon = }/>; const refreshingIcon = status.flags && status.flags.refreshing ? : null; const icons = {refreshingIcon} {warningIcon} ; return <> {homeLink} {icons} {collapsedLinks.map(i => )} {homeLink} {links.map(i => )} {icons} {rightLinks.map(i => )} }