2023-04-09 14:34:33 -06:00
|
|
|
import React from "react";
|
2025-12-07 11:54:20 -07:00
|
|
|
import {Link, NavLink} from "react-router";
|
2024-08-15 21:45:06 -06:00
|
|
|
import {Dropdown, Icon as SIcon, Menu} from "semantic-ui-react";
|
|
|
|
|
import {Media, SettingsContext, StatusContext, ThemeContext} from "../contexts/contexts";
|
2025-01-11 12:04:14 -07:00
|
|
|
import {DarkModeToggle, HotspotStatusIcon, useLocalStorage} from "./Common";
|
2023-04-10 13:15:34 -06:00
|
|
|
import {ShareButton} from "./Share";
|
2026-06-03 18:46:29 -06:00
|
|
|
import {
|
|
|
|
|
useCPUTemperature,
|
2026-06-03 20:02:59 -06:00
|
|
|
useDriveHealth,
|
2026-06-03 18:46:29 -06:00
|
|
|
useDriveTemperature,
|
|
|
|
|
useIOStats,
|
|
|
|
|
useLoad,
|
|
|
|
|
useMemoryStats,
|
|
|
|
|
usePowerStats,
|
|
|
|
|
useWROLMode
|
|
|
|
|
} from "../hooks/customHooks";
|
2026-01-23 19:51:02 -07:00
|
|
|
import {useReorganizationStatus} from "../contexts/FileWorkerStatusContext";
|
2024-01-01 11:31:17 -07:00
|
|
|
import {SearchIconButton} from "./Search";
|
2025-01-10 11:33:21 -07:00
|
|
|
import {Icon, Popup} from "./Theme";
|
2026-02-04 12:23:28 -07:00
|
|
|
import {HELP_VIEWER_URI, NAME, semanticUIColorMap} from "./Vars";
|
2026-04-09 16:01:59 -06:00
|
|
|
import {useOverflowNav} from "../hooks/useOverflowNav";
|
2024-12-18 16:39:50 -07:00
|
|
|
import _ from "lodash";
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2026-02-04 12:23:28 -07:00
|
|
|
function updateFavicon(colorName) {
|
|
|
|
|
// Fall back to violet if invalid color
|
|
|
|
|
const safeColor = colorName in semanticUIColorMap ? colorName : 'violet';
|
|
|
|
|
const faviconPath = `/favicon-${safeColor}.svg`;
|
|
|
|
|
|
|
|
|
|
// Update all favicon links
|
|
|
|
|
const iconLinks = document.querySelectorAll('link[rel="icon"], link[rel="shortcut icon"]');
|
|
|
|
|
iconLinks.forEach(link => {
|
|
|
|
|
link.href = faviconPath;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Also update the 32x32 and 16x16 specific icons if they exist
|
|
|
|
|
const icon32 = document.querySelector('link[sizes="32x32"]');
|
|
|
|
|
const icon16 = document.querySelector('link[sizes="16x16"]');
|
|
|
|
|
if (icon32) icon32.href = faviconPath;
|
|
|
|
|
if (icon16) icon16.href = faviconPath;
|
|
|
|
|
|
|
|
|
|
// Update theme-color meta tag for iOS/Android status bar
|
|
|
|
|
const hexColor = semanticUIColorMap[safeColor];
|
|
|
|
|
const themeColorMeta = document.querySelector('meta[name="theme-color"]');
|
|
|
|
|
if (themeColorMeta) themeColorMeta.content = hexColor;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-09 16:01:59 -06:00
|
|
|
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 allLinks = [
|
2023-02-21 15:49:11 -07:00
|
|
|
{text: 'Videos', to: '/videos', key: 'videos'},
|
2026-03-20 15:38:32 -06:00
|
|
|
{text: 'Archive', to: '/archives', key: 'archive'},
|
2026-03-17 18:35:57 -06:00
|
|
|
{text: 'Docs', to: '/docs', key: 'docs'},
|
2023-02-21 15:49:11 -07:00
|
|
|
{text: 'Map', to: '/map', key: 'map'},
|
|
|
|
|
{text: 'Files', to: '/files', key: 'files'},
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
{text: 'Playlists', to: '/playlists', key: 'playlists'},
|
2026-04-09 16:01:59 -06:00
|
|
|
{text: 'Zim', to: '/zim', key: 'zim'},
|
|
|
|
|
{text: 'Inventory', to: '/inventory', key: 'inventory'},
|
|
|
|
|
{to: '/more/calculators', text: 'Calculators', key: 'calculators', end: true},
|
2026-07-01 18:48:06 -06:00
|
|
|
{text: 'Flasher', to: '/flasher', key: 'flasher'},
|
2026-04-09 16:01:59 -06:00
|
|
|
{to: '/more/statistics', text: 'Statistics', key: 'statistics', end: true},
|
2023-02-21 15:49:11 -07:00
|
|
|
];
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2023-02-21 15:32:11 -07:00
|
|
|
function DropdownLinks({link}) {
|
|
|
|
|
return <Dropdown item text={link.text} direction='left'>
|
2023-01-07 18:31:39 -07:00
|
|
|
<Dropdown.Menu>
|
2023-02-21 15:32:11 -07:00
|
|
|
{link.links.map(l => <MenuLink key={l.to} link={l}/>)}
|
2023-01-07 18:31:39 -07:00
|
|
|
</Dropdown.Menu>
|
2023-02-17 16:09:24 -07:00
|
|
|
</Dropdown>
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2022-11-04 09:19:51 -06:00
|
|
|
function MenuLink({link}) {
|
2022-01-29 22:25:35 -07:00
|
|
|
// Wrapper around NavLink to handle Navlink/Dropdown change.
|
2023-02-21 15:49:11 -07:00
|
|
|
if (link.links) {
|
|
|
|
|
return <DropdownLinks link={link}/>
|
|
|
|
|
} else {
|
2022-11-04 09:19:51 -06:00
|
|
|
const end = link.end ? {end: true} : {end: undefined};
|
2024-10-14 14:44:35 -06:00
|
|
|
const target = link.target ? {target: link.target} : {};
|
2023-02-17 16:09:24 -07:00
|
|
|
return <NavLink
|
2023-02-21 15:49:11 -07:00
|
|
|
className='item'
|
2023-01-07 18:31:39 -07:00
|
|
|
to={link.to}
|
|
|
|
|
{...end}
|
2024-10-14 14:44:35 -06:00
|
|
|
{...target}
|
2023-01-07 18:31:39 -07:00
|
|
|
>
|
|
|
|
|
{link.text}
|
2023-02-17 16:09:24 -07:00
|
|
|
</NavLink>
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 11:33:21 -07:00
|
|
|
function NavIconWrapper({children}) {
|
2025-01-11 12:04:14 -07:00
|
|
|
if (children) {
|
|
|
|
|
return <div style={{marginTop: '0.8em', marginLeft: '1.5em'}}>{children}</div>
|
|
|
|
|
} else {
|
|
|
|
|
// Do not use navbar space if children is empty.
|
|
|
|
|
return <React.Fragment/>
|
2025-01-11 11:06:31 -07:00
|
|
|
}
|
2022-10-19 09:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
2024-10-05 14:06:13 -06:00
|
|
|
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(() => {
|
2024-12-18 17:31:50 -07:00
|
|
|
if (!_.isEmpty(settings)) {
|
|
|
|
|
setNavColor(settings.nav_color);
|
|
|
|
|
}
|
2024-10-05 14:06:13 -06:00
|
|
|
}, [settings.nav_color]);
|
|
|
|
|
|
2026-02-04 12:23:28 -07:00
|
|
|
// Update favicon to match nav color
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
if (navColor) {
|
|
|
|
|
updateFavicon(navColor);
|
|
|
|
|
}
|
|
|
|
|
}, [navColor]);
|
|
|
|
|
|
2024-10-05 14:06:13 -06:00
|
|
|
return navColor
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-01 16:42:52 -06:00
|
|
|
export function NavBar() {
|
2023-07-21 15:14:09 -06:00
|
|
|
const wrolModeEnabled = useWROLMode();
|
2024-08-15 21:45:06 -06:00
|
|
|
const {status} = React.useContext(StatusContext);
|
2024-10-05 14:06:13 -06:00
|
|
|
const navColor = useNavColorSetting();
|
2023-02-09 13:47:25 -07:00
|
|
|
const wrolpiIcon = <img src='/icon.svg' height='32px' width='32px' alt='WROLPi Home Icon'/>;
|
2024-05-18 17:51:06 -06:00
|
|
|
const name = <i>{NAME || wrolpiIcon}</i>;
|
2024-08-15 21:45:06 -06:00
|
|
|
const topNavText = wrolModeEnabled ? <>{name} <SIcon name='lock'/></> : name;
|
2023-04-06 11:16:45 -06:00
|
|
|
const {i} = React.useContext(ThemeContext);
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2023-02-09 13:47:25 -07:00
|
|
|
const homeLink = <NavLink className='item' to='/' style={{paddingTop: 0, paddingBottom: 0}}>
|
|
|
|
|
{topNavText}
|
|
|
|
|
</NavLink>;
|
2023-10-06 12:48:20 -06:00
|
|
|
|
2025-01-10 11:33:21 -07:00
|
|
|
// Red/Yellow colors will blend in to some navbar colors, swap the colors for high contrast.
|
|
|
|
|
const conflictingColors = ['red', 'orange', 'yellow', 'olive', 'pink'];
|
2025-01-18 10:08:11 -07:00
|
|
|
const [lowWarningColor, highWarningColor] = conflictingColors.includes(navColor)
|
|
|
|
|
? [null, 'black']
|
|
|
|
|
: ['yellow', 'red'];
|
2025-01-10 11:33:21 -07:00
|
|
|
|
|
|
|
|
// Generic system load, the least important warning.
|
|
|
|
|
const {minute_1, mediumLoad, highLoad} = useLoad();
|
|
|
|
|
let systemLoadIcon;
|
|
|
|
|
if (mediumLoad || highLoad) {
|
|
|
|
|
// System load is high, display a warning icon.
|
|
|
|
|
const color = highLoad ? highWarningColor : lowWarningColor;
|
|
|
|
|
const icon = <Link to='/admin/status'>
|
|
|
|
|
<Icon name='tachometer alternate' size='large' color={color}/>
|
|
|
|
|
</Link>;
|
|
|
|
|
systemLoadIcon = <Popup content={`Load: ${minute_1}`} trigger={icon}/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RAM consumption.
|
|
|
|
|
const {percent: memoryPercent} = useMemoryStats();
|
|
|
|
|
let memoryIcon;
|
|
|
|
|
if (memoryPercent > 80) {
|
|
|
|
|
const color = memoryPercent > 90 ? highWarningColor : lowWarningColor;
|
|
|
|
|
const icon = <Link to='/admin/status' color={color}>
|
|
|
|
|
<Icon name='microchip' size='large'/>
|
|
|
|
|
</Link>;
|
2025-01-22 17:18:16 -07:00
|
|
|
memoryIcon = <Popup content={`System Memory: ${memoryPercent.toFixed()}%`} trigger={icon}/>
|
2025-01-10 11:33:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Any disk is busy and processes are waiting.
|
|
|
|
|
const {percentIOWait} = useIOStats();
|
|
|
|
|
let diskWaitIcon;
|
|
|
|
|
if (percentIOWait >= 50) {
|
|
|
|
|
// Processes are waiting on disk, display a warning icon.
|
|
|
|
|
const color = percentIOWait > 75 ? highWarningColor : lowWarningColor;
|
2025-01-22 17:18:16 -07:00
|
|
|
const icon = <Link to='/admin/status'>
|
|
|
|
|
<Icon name='disk' size='large' color={color}/>
|
2025-01-10 11:33:21 -07:00
|
|
|
</Link>;
|
2025-01-22 17:18:16 -07:00
|
|
|
diskWaitIcon = <Popup content={`Processes waiting on disk: ${percentIOWait.toFixed()}%`} trigger={icon}/>
|
2025-01-10 11:33:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CPU temperature.
|
|
|
|
|
const {temperature, highTemperature, criticalTemperature} = useCPUTemperature();
|
|
|
|
|
let temperatureIcon;
|
|
|
|
|
if (temperature && temperature >= highTemperature) {
|
|
|
|
|
// CPU temperature is high, display a warning icon.
|
|
|
|
|
const color = temperature >= criticalTemperature ? highWarningColor : lowWarningColor;
|
|
|
|
|
const name = temperature >= criticalTemperature ? 'thermometer' : 'thermometer half';
|
|
|
|
|
const icon = <Icon data-testid='cpuTemperatureIcon' name={name} size='large' color={color}/>
|
|
|
|
|
const link = <Link to='/admin/status'>{icon}</Link>;
|
2025-01-22 17:18:16 -07:00
|
|
|
temperatureIcon = <Popup content={`CPU: ${temperature.toFixed()}°C`} trigger={link}/>;
|
2025-01-10 11:33:21 -07:00
|
|
|
}
|
|
|
|
|
|
2026-06-03 18:46:29 -06:00
|
|
|
// Hard-drive temperature. An overheating drive risks data loss.
|
|
|
|
|
const {
|
|
|
|
|
device: hotDrive,
|
|
|
|
|
temperature: driveTemperature,
|
|
|
|
|
highTemperature: driveHighTemperature,
|
|
|
|
|
criticalTemperature: driveCriticalTemperature,
|
|
|
|
|
} = useDriveTemperature();
|
|
|
|
|
let driveTemperatureIcon;
|
|
|
|
|
if (driveTemperature && driveTemperature >= driveHighTemperature) {
|
|
|
|
|
const color = driveTemperature >= driveCriticalTemperature ? highWarningColor : lowWarningColor;
|
|
|
|
|
const icon = <Icon data-testid='driveTemperatureIcon' name='hdd' size='large' color={color}/>
|
2026-06-24 15:59:34 -06:00
|
|
|
const link = <Link to='/admin/controller'>{icon}</Link>;
|
2026-06-03 18:46:29 -06:00
|
|
|
driveTemperatureIcon = <Popup content={`${hotDrive}: ${driveTemperature.toFixed()}°C`} trigger={link}/>;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-24 15:59:34 -06:00
|
|
|
// A drive's SMART health is degraded. FAIL is an imminent failure (back
|
|
|
|
|
// up now); WARN means unreadable/pending sectors are accumulating. Always
|
|
|
|
|
// displayed (like power); too important to hide behind a transient warning
|
|
|
|
|
// in the priority chain. Links to the Controller page, which shows the
|
|
|
|
|
// SMART detail (the Status page does not).
|
|
|
|
|
const {failingDevices, failing: driveFailing, warningDevices, warning: driveWarning} = useDriveHealth();
|
2026-06-03 20:02:59 -06:00
|
|
|
let driveHealthIcon;
|
|
|
|
|
if (driveFailing) {
|
|
|
|
|
const icon = <Icon data-testid='driveHealthIcon' name='warning sign' size='large' color={highWarningColor}/>;
|
2026-06-24 15:59:34 -06:00
|
|
|
const link = <Link to='/admin/controller'>{icon}</Link>;
|
2026-06-03 20:02:59 -06:00
|
|
|
const message = failingDevices.length === 1
|
|
|
|
|
? `Drive ${failingDevices[0]} is failing its SMART health check! Back up your data.`
|
|
|
|
|
: `Drives failing SMART health check: ${failingDevices.join(', ')}. Back up your data.`;
|
|
|
|
|
driveHealthIcon = <Popup content={message} trigger={link}/>;
|
2026-06-24 15:59:34 -06:00
|
|
|
} else if (driveWarning) {
|
|
|
|
|
const icon = <Icon data-testid='driveHealthIcon' name='warning sign' size='large' color={lowWarningColor}/>;
|
|
|
|
|
const link = <Link to='/admin/controller'>{icon}</Link>;
|
|
|
|
|
const message = warningDevices.length === 1
|
|
|
|
|
? `Drive ${warningDevices[0]} has unreadable or pending sectors — check its SMART health.`
|
|
|
|
|
: `Drives with unreadable or pending sectors: ${warningDevices.join(', ')}. Check their SMART health.`;
|
|
|
|
|
driveHealthIcon = <Popup content={message} trigger={link}/>;
|
2026-06-03 20:02:59 -06:00
|
|
|
}
|
|
|
|
|
|
2025-01-10 11:33:21 -07:00
|
|
|
// Power issues, this is always displayed if detected.
|
|
|
|
|
const {underVoltage, overCurrent} = usePowerStats();
|
|
|
|
|
let powerIcon;
|
|
|
|
|
if (underVoltage || overCurrent) {
|
|
|
|
|
const name = underVoltage ? 'power cord' : 'lightning';
|
|
|
|
|
const icon = <Icon name={name} size='large' color={highWarningColor}/>;
|
|
|
|
|
const message = underVoltage
|
|
|
|
|
? 'Under-voltage detected! Your power supply is insufficient!'
|
|
|
|
|
: 'Over-current detected! Your peripherals are using too much power!';
|
|
|
|
|
powerIcon = <Popup content={message} trigger={icon}/>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Display the temperature icon first because it can cause the system to throttle. The rest are in order of effects
|
|
|
|
|
// that will slow down the system and the user should address. Generic load is last because it is probably not an
|
|
|
|
|
// issue.
|
2026-06-03 18:46:29 -06:00
|
|
|
const warningIcon = temperatureIcon || driveTemperatureIcon || diskWaitIcon || memoryIcon || systemLoadIcon;
|
2024-08-15 21:45:06 -06:00
|
|
|
|
2026-01-23 19:51:02 -07:00
|
|
|
const {isReorganizing, taskType, collectionId, collectionKind} = useReorganizationStatus();
|
|
|
|
|
|
2024-12-18 16:39:50 -07:00
|
|
|
let processingLink;
|
|
|
|
|
if (status && status.flags) {
|
2026-01-09 14:01:25 -07:00
|
|
|
if (status.flags.file_worker_busy) {
|
2026-01-23 19:51:02 -07:00
|
|
|
// Smart navigation based on what the file worker is doing
|
|
|
|
|
if (isReorganizing && collectionId && collectionKind) {
|
|
|
|
|
// Single collection reorganization - navigate to that collection
|
|
|
|
|
if (collectionKind === 'channel') {
|
|
|
|
|
processingLink = `/videos/channel/${collectionId}/edit`;
|
|
|
|
|
} else if (collectionKind === 'domain') {
|
2026-03-20 15:38:32 -06:00
|
|
|
processingLink = `/archives/domain/${collectionId}/edit`;
|
2026-01-23 19:51:02 -07:00
|
|
|
} else {
|
|
|
|
|
processingLink = '/files';
|
|
|
|
|
}
|
|
|
|
|
} else if (isReorganizing && taskType === 'batch_reorganize' && collectionKind) {
|
|
|
|
|
// Batch reorganization - navigate to settings page for that kind
|
|
|
|
|
if (collectionKind === 'channel') {
|
|
|
|
|
processingLink = '/videos/settings';
|
|
|
|
|
} else if (collectionKind === 'domain') {
|
2026-03-20 15:38:32 -06:00
|
|
|
processingLink = '/archives/settings';
|
2026-01-23 19:51:02 -07:00
|
|
|
} else {
|
|
|
|
|
processingLink = '/files';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
processingLink = '/files';
|
|
|
|
|
}
|
2024-12-18 16:39:50 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const processingIcon = processingLink &&
|
|
|
|
|
<Link to={processingLink}>
|
|
|
|
|
<Icon loading name='circle notch' size='large'/>
|
|
|
|
|
</Link>;
|
2023-10-06 12:48:20 -06:00
|
|
|
|
2025-01-24 15:35:26 -07:00
|
|
|
let apiDownIcon;
|
|
|
|
|
if (window.apiDown) {
|
|
|
|
|
apiDownIcon = <Popup
|
|
|
|
|
content='API is not responding'
|
2025-03-03 19:53:21 -07:00
|
|
|
trigger={<Icon name='plug' color={highWarningColor}/>}
|
2025-01-24 15:35:26 -07:00
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-06 14:47:52 -07:00
|
|
|
// Upgrade available notification - only show on native (non-Docker) installs and when WROL Mode is disabled
|
2025-10-29 22:16:33 -06:00
|
|
|
let upgradeIcon;
|
2025-12-06 14:47:52 -07:00
|
|
|
if (status?.update_available && !status?.dockerized && !wrolModeEnabled) {
|
2025-10-29 22:16:33 -06:00
|
|
|
const commitsBehind = status.commits_behind || 0;
|
|
|
|
|
const branch = status.git_branch || 'unknown';
|
2025-12-07 10:53:49 -07:00
|
|
|
const icon = <Link to='/admin/settings#upgrade'>
|
2025-10-29 22:16:33 -06:00
|
|
|
<Icon name='arrow alternate circle up' size='large' color='green'/>
|
|
|
|
|
</Link>;
|
|
|
|
|
upgradeIcon = <Popup
|
|
|
|
|
content={`Upgrade available: ${commitsBehind} commit(s) behind on ${branch}`}
|
|
|
|
|
trigger={icon}
|
|
|
|
|
/>;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-07 18:31:39 -07:00
|
|
|
const icons = <React.Fragment>
|
2025-01-24 15:35:26 -07:00
|
|
|
<NavIconWrapper>{apiDownIcon}</NavIconWrapper>
|
2025-01-10 11:33:21 -07:00
|
|
|
<NavIconWrapper>{processingIcon}</NavIconWrapper>
|
2025-10-29 22:16:33 -06:00
|
|
|
<NavIconWrapper>{upgradeIcon}</NavIconWrapper>
|
2026-06-03 20:02:59 -06:00
|
|
|
<NavIconWrapper>{driveHealthIcon}</NavIconWrapper>
|
2025-01-10 11:33:21 -07:00
|
|
|
<NavIconWrapper>{powerIcon}</NavIconWrapper>
|
|
|
|
|
<NavIconWrapper>{warningIcon}</NavIconWrapper>
|
|
|
|
|
<NavIconWrapper><ShareButton/></NavIconWrapper>
|
|
|
|
|
<NavIconWrapper><HotspotStatusIcon/></NavIconWrapper>
|
|
|
|
|
<NavIconWrapper><DarkModeToggle/></NavIconWrapper>
|
2023-01-07 18:31:39 -07:00
|
|
|
</React.Fragment>;
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2023-01-07 18:31:39 -07:00
|
|
|
return <>
|
2026-04-09 16:01:59 -06:00
|
|
|
<Media between={['mobile', 'tablet']}>
|
2024-10-14 14:20:50 -06:00
|
|
|
<Menu {...i} attached='top' color={navColor} id='global_navbar'>
|
2023-01-07 18:31:39 -07:00
|
|
|
{homeLink}
|
|
|
|
|
<Menu.Menu position='right'>
|
|
|
|
|
{icons}
|
2024-12-18 16:39:50 -07:00
|
|
|
<SearchIconButton/>
|
2023-01-07 18:31:39 -07:00
|
|
|
<Dropdown item icon="bars">
|
|
|
|
|
<Dropdown.Menu>
|
2026-04-09 16:01:59 -06:00
|
|
|
{allLinks.map(i => <MenuLink link={i} key={i.key}/>)}
|
|
|
|
|
{rightLinks.map(i => <MenuLink link={i} key={i.key}/>)}
|
2023-01-07 18:31:39 -07:00
|
|
|
</Dropdown.Menu>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</Menu.Menu>
|
|
|
|
|
</Menu>
|
|
|
|
|
</Media>
|
2026-04-09 16:01:59 -06:00
|
|
|
<Media greaterThanOrEqual='tablet'>
|
|
|
|
|
<DesktopNav i={i} navColor={navColor} homeLink={homeLink} icons={icons}/>
|
|
|
|
|
</Media>
|
|
|
|
|
</>
|
|
|
|
|
}
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2026-04-09 16:01:59 -06:00
|
|
|
function DesktopNav({i, navColor, homeLink, icons}) {
|
|
|
|
|
const containerRef = React.useRef(null);
|
|
|
|
|
const homeRef = React.useRef(null);
|
|
|
|
|
const rightMenuRef = React.useRef(null);
|
|
|
|
|
const moreRef = React.useRef(null);
|
|
|
|
|
const {visibleLinks, overflowLinks, itemRefCallback, isReady} = useOverflowNav({
|
|
|
|
|
links: allLinks,
|
|
|
|
|
containerRef,
|
|
|
|
|
homeRef,
|
|
|
|
|
rightMenuRef,
|
|
|
|
|
moreRef,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div ref={containerRef}>
|
|
|
|
|
<Menu {...i} attached='top' color={navColor} id='global_navbar'>
|
|
|
|
|
<span ref={homeRef} style={{display: 'contents'}}>{homeLink}</span>
|
|
|
|
|
{(isReady ? visibleLinks : allLinks).map((link, idx) => (
|
|
|
|
|
<span
|
|
|
|
|
key={link.key}
|
|
|
|
|
ref={itemRefCallback(idx)}
|
2026-04-10 15:27:15 -06:00
|
|
|
style={isReady ? {display: 'contents'} : {visibility: 'hidden', flexShrink: 0}}
|
2026-04-09 16:01:59 -06:00
|
|
|
>
|
|
|
|
|
<MenuLink link={link}/>
|
|
|
|
|
</span>
|
|
|
|
|
))}
|
2026-04-10 15:27:15 -06:00
|
|
|
{!isReady && <span ref={moreRef} style={{visibility: 'hidden', flexShrink: 0}}>
|
2026-04-09 16:01:59 -06:00
|
|
|
<Dropdown item text='More'><Dropdown.Menu/></Dropdown>
|
|
|
|
|
</span>}
|
|
|
|
|
{isReady && overflowLinks.length > 0 &&
|
|
|
|
|
<DropdownLinks link={{text: 'More', key: 'more', links: overflowLinks}}/>}
|
|
|
|
|
<div ref={rightMenuRef} className='right menu'>
|
2023-01-07 18:31:39 -07:00
|
|
|
{icons}
|
2024-12-18 16:39:50 -07:00
|
|
|
<SearchIconButton/>
|
2023-01-07 18:31:39 -07:00
|
|
|
{rightLinks.map(i => <MenuLink link={i} key={i.key}/>)}
|
2026-04-09 16:01:59 -06:00
|
|
|
</div>
|
2023-01-07 18:31:39 -07:00
|
|
|
</Menu>
|
2026-04-09 16:01:59 -06:00
|
|
|
</div>
|
|
|
|
|
);
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|