2022-09-29 12:02:09 -06:00
import React from "react" ;
2025-12-06 14:49:46 -07:00
import { SettingsContext , StatusContext } from "../../contexts/contexts" ;
2025-12-11 18:32:55 -07:00
import { checkUpgrade , postRestart , postShutdown , saveSettings as saveSettingsApi , triggerUpgrade } from "../../api" ;
2025-12-19 16:42:36 -07:00
import { getServices , stopService , startService } from "../../api/controller" ;
2024-03-09 16:27:34 -07:00
import {
Button ,
Divider ,
Form ,
Header ,
Loader ,
Modal ,
Segment
} from "../Theme" ;
2024-07-30 19:28:53 -06:00
import { ButtonGroup , Container , Dimmer , Dropdown , GridColumn , GridRow , Icon , Input } from "semantic-ui-react" ;
import {
APIButton ,
ErrorMessage ,
2025-01-26 12:44:16 -07:00
InfoPopup ,
RefreshHeader ,
2024-07-30 19:28:53 -06:00
Toggle ,
2025-01-22 18:58:18 -07:00
useMessageDismissal ,
2024-07-30 19:28:53 -06:00
WROLModeMessage
} from "../Common" ;
2022-09-29 12:02:09 -06:00
import QRCode from "react-qr-code" ;
2024-10-03 13:35:06 -06:00
import { useConfigs , useDockerized } from "../../hooks/customHooks" ;
2023-08-19 20:38:34 -06:00
import { toast } from "react-semantic-toasts-2" ;
2024-03-09 16:27:34 -07:00
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid" ;
2024-10-03 13:35:06 -06:00
import { ConfigsTable } from "./Configs" ;
2024-11-02 15:14:02 -06:00
import { semanticUIColorMap } from "../Vars" ;
2023-08-19 20:38:34 -06:00
export function ShutdownButton ( ) {
const dockerized = useDockerized ( ) ;
const handleShutdown = async ( ) => {
try {
const response = await postShutdown ( ) ;
if ( response && response [ 'code' ] === 'SHUTDOWN_FAILED' ) {
toast ( {
title : 'Shutdown Failed' ,
description : response [ 'error' ] ,
time : 5000 ,
type : "error" ,
} )
} else if ( response && response [ 'code' ] === 'NATIVE_ONLY' ) {
toast ( {
title : 'Shutdown Failed' ,
description : 'Cannot shutdown while running in Docker' ,
time : 5000 ,
type : "error" ,
} )
} else if ( response !== null ) {
toast ( {
title : 'Shutdown Failed' ,
description : 'Unknown error when attempting shutdown' ,
time : 5000 ,
type : "error" ,
} )
}
} catch ( e ) {
toast ( {
title : 'Shutdown Failed' ,
description : 'Failed to request WROLPi shutdown' ,
time : 5000 ,
type : "error" ,
} )
throw e ;
}
}
return < APIButton
size = 'huge'
color = 'red'
onClick = { handleShutdown }
confirmContent = 'Are you sure you want to turn off your WROLPi?'
confirmButton = 'Shutdown'
disabled = { dockerized }
>
Shutdown
< / A P I B u t t o n >
}
2025-10-29 22:16:33 -06:00
function UpgradeSegment ( ) {
const { status , fetchStatus } = React . useContext ( StatusContext ) ;
const dockerized = useDockerized ( ) ;
const [ upgrading , setUpgrading ] = React . useState ( false ) ;
const [ checking , setChecking ] = React . useState ( false ) ;
const handleCheckUpgrade = async ( ) => {
setChecking ( true ) ;
try {
await checkUpgrade ( true ) ; // Force a fresh check
toast ( {
type : 'info' ,
title : 'Update Check Complete' ,
description : 'Checked for updates from git remote.' ,
time : 3000 ,
} ) ;
} finally {
setChecking ( false ) ;
await fetchStatus ( ) ;
}
} ;
const handleUpgrade = async ( ) => {
setUpgrading ( true ) ;
try {
const response = await triggerUpgrade ( ) ;
if ( response . ok ) {
2025-12-11 18:32:55 -07:00
// Redirect to Controller UI for upgrade status
window . location . href = '/controller/?upgrade=true' ;
2025-10-29 22:16:33 -06:00
}
} catch ( e ) {
setUpgrading ( false ) ;
}
} ;
// Not available in Docker
if ( dockerized ) {
2025-12-07 10:53:49 -07:00
return < Segment id = 'upgrade' >
2025-10-29 22:16:33 -06:00
< Header as = 'h3' > System Upgrade < / H e a d e r >
< p > Upgrades are not available in Docker environments . Please upgrade your Docker images manually . < / p >
< / S e g m e n t > ;
}
// No update available
if ( ! status ? . update _available ) {
2025-12-07 10:53:49 -07:00
return < Segment id = 'upgrade' >
2025-10-29 22:16:33 -06:00
< Header as = 'h3' > System Upgrade < / H e a d e r >
< p > Your WROLPi is up to date . < / p >
2025-12-06 14:49:46 -07:00
< p > Version : < strong > v { status ? . version } < / s t r o n g > o n b r a n c h < s t r o n g > { s t a t u s ? . g i t _ b r a n c h | | ' u n k n o w n ' } < / s t r o n g >
< / p >
2025-10-29 22:16:33 -06:00
< APIButton
color = 'blue'
onClick = { handleCheckUpgrade }
disabled = { checking }
>
2025-12-06 14:49:46 -07:00
{ checking ? 'Checking...' : 'Check for Upgrades' }
2025-10-29 22:16:33 -06:00
< / A P I B u t t o n >
< / S e g m e n t > ;
}
// Update available
2025-12-07 10:53:49 -07:00
return < Segment id = 'upgrade' >
2025-10-29 22:16:33 -06:00
< Header as = 'h3' >
< Icon name = 'arrow alternate circle up' / >
Upgrade Available
< / H e a d e r >
< p > Branch : < strong > { status ? . git _branch } < / s t r o n g > < / p >
< p > Current commit : < strong > { status ? . current _commit } < / s t r o n g > < / p >
< p > Latest commit : < strong > { status ? . latest _commit } < / s t r o n g > < / p >
< p > < strong > { status ? . commits _behind } < / s t r o n g > c o m m i t ( s ) b e h i n d < / p >
< APIButton
color = 'green'
size = 'big'
onClick = { handleUpgrade }
disabled = { upgrading }
confirmContent = 'This will upgrade WROLPi. The system will be temporarily unavailable during the upgrade. Are you sure?'
confirmButton = 'Start Upgrade'
>
{ upgrading ? 'Starting Upgrade...' : 'Upgrade Now' }
< / A P I B u t t o n >
< / S e g m e n t > ;
}
2023-08-19 20:38:34 -06:00
export function RestartButton ( ) {
const dockerized = useDockerized ( ) ;
const handleRestart = async ( ) => {
try {
const response = await postRestart ( ) ;
if ( response && response [ 'code' ] === 'SHUTDOWN_FAILED' ) {
toast ( {
title : 'Restart Failed' ,
description : response [ 'error' ] ,
time : 5000 ,
type : "error" ,
} )
} else if ( response && response [ 'code' ] === 'NATIVE_ONLY' ) {
toast ( {
title : 'Restart Failed' ,
description : 'Cannot restart while running in Docker' ,
time : 5000 ,
type : "error" ,
} )
} else if ( response !== null ) {
toast ( {
title : 'Restart Failed' ,
description : 'Unknown error when attempting restart' ,
time : 5000 ,
type : "error" ,
} )
}
} catch ( e ) {
toast ( {
title : 'Restart Failed' ,
description : 'Failed to request WROLPi restart' ,
time : 5000 ,
type : "error" ,
} )
throw e ;
}
}
return < APIButton
size = 'huge'
color = 'yellow'
onClick = { handleRestart }
2023-08-28 09:47:51 -06:00
confirmContent = 'Are you sure you want to reboot your WROLPi?'
2023-08-19 20:38:34 -06:00
confirmButton = 'Restart'
disabled = { dockerized }
>
Restart
< / A P I B u t t o n >
}
2023-08-17 20:07:02 -06:00
2023-09-08 17:10:15 -06:00
const levelNameMap = {
2024-12-11 11:52:33 -07:00
5 : 'Trace' ,
2023-09-08 17:10:15 -06:00
4 : 'Debug' ,
3 : 'Info' ,
2 : 'Warning' ,
1 : 'Critical'
}
function logLevelToName ( logLevel ) {
// Convert app log level to name.
return levelNameMap [ logLevel ]
}
function fromApiLogLevel ( logLevel ) {
// Python API uses levels on the left. App uses levels on the right to display <input> direction correctly.
return {
40 : 1 ,
30 : 2 ,
20 : 3 ,
10 : 4 ,
2024-12-11 11:52:33 -07:00
5 : 5 ,
2023-09-08 17:10:15 -06:00
} [ logLevel ]
}
function toApiLogLevel ( logLevel ) {
// Reverse the above levels.
return {
2024-12-11 11:52:33 -07:00
5 : 5 ,
2023-09-08 17:10:15 -06:00
4 : 10 ,
3 : 20 ,
2 : 30 ,
1 : 40 ,
} [ logLevel ]
}
2025-12-11 18:32:55 -07:00
function WROLModeSection ( ) {
const { settings , fetchSettings } = React . useContext ( SettingsContext ) ;
const wrolMode = settings ? . wrol _mode || false ;
const toggleWROLMode = async ( checked ) => {
try {
await saveSettingsApi ( { wrol _mode : checked } ) ;
await fetchSettings ( ) ; // Refresh context immediately
} catch ( e ) {
toast ( {
type : 'error' ,
title : 'Failed to toggle WROL Mode' ,
description : e . message ,
time : 5000 ,
} ) ;
}
} ;
return (
< Segment >
< Header as = 'h3' >
< Icon name = 'shield' / >
WROL Mode
< / H e a d e r >
< p >
Enable read - only mode . No content can be deleted or modified .
Enable this when the SHTF and you want to prevent any potential loss of data .
< / p >
< p style = { { fontSize : '0.9em' , color : '#888' } } >
Note : User settings and tags can still be modified .
< / p >
< Toggle
checked = { wrolMode }
onChange = { toggleWROLMode }
label = { wrolMode ? 'WROL Mode Enabled' : 'WROL Mode Disabled' }
/ >
< / S e g m e n t >
) ;
}
2024-10-03 13:35:06 -06:00
export function SettingsPage ( ) {
const [ disabled , setDisabled ] = React . useState ( false ) ;
const [ editSpecialDirectories , setEditSpecialDirectories ] = React . useState ( false ) ;
const [ qrCodeValue , setQrCodeValue ] = React . useState ( '' ) ;
const [ qrOpen , setQrOpen ] = React . useState ( false ) ;
const [ ready , setReady ] = React . useState ( false ) ;
const [ pendingSave , setPendingSave ] = React . useState ( false ) ;
2025-01-22 18:58:18 -07:00
const { clearAll } = useMessageDismissal ( ) ;
2025-12-06 14:53:15 -07:00
const dockerized = useDockerized ( ) ;
2022-09-29 12:02:09 -06:00
2025-12-19 16:42:36 -07:00
// Trace level modal state
const [ traceModalOpen , setTraceModalOpen ] = React . useState ( false ) ;
const [ traceCountdown , setTraceCountdown ] = React . useState ( 5 ) ;
const [ traceSwitching , setTraceSwitching ] = React . useState ( false ) ;
const [ isDevMode , setIsDevMode ] = React . useState ( false ) ;
2024-10-03 13:35:06 -06:00
// Get current settings from the API.
const { settings , saveSettings , fetchSettings } = React . useContext ( SettingsContext ) ;
// Used to track changes to the settings form between saves/loads.
const [ state , setState ] = React . useState ( { } ) ;
const { configs , loading , importConfig , saveConfig , fetchConfigs } = useConfigs ( ) ;
2022-09-29 12:02:09 -06:00
2024-10-03 13:35:06 -06:00
React . useEffect ( ( ) => {
fetchConfigs ( ) ;
} , [ ] ) ;
2025-12-19 16:42:36 -07:00
// Check if we're running in dev mode (wrolpi-api-dev service)
React . useEffect ( ( ) => {
if ( ! dockerized ) {
const checkDevMode = async ( ) => {
try {
const services = await getServices ( ) ;
const apiDevService = services . find ( s => s . name === 'wrolpi-api-dev' ) ;
setIsDevMode ( apiDevService ? . status === 'running' ) ;
} catch ( e ) {
console . error ( 'Failed to check dev mode status:' , e ) ;
}
} ;
checkDevMode ( ) ;
}
} , [ dockerized ] ) ;
2024-10-03 13:35:06 -06:00
const localFetchSettings = async ( ) => {
console . debug ( 'fetching settings...' ) ;
2022-09-29 12:02:09 -06:00
try {
2024-10-03 13:35:06 -06:00
await fetchSettings ( ) ;
console . debug ( 'successfully fetched settings' ) ;
2022-09-29 12:02:09 -06:00
} catch ( e ) {
2024-10-03 13:35:06 -06:00
console . error ( 'failed to fetch settings!' ) ;
throw e ;
2022-09-29 12:02:09 -06:00
}
}
2024-10-03 13:35:06 -06:00
const localSaveSettings = async ( newSettings ) => {
2025-12-19 16:42:36 -07:00
// Check if trace level is selected (5 = trace in frontend)
const isTraceLevel = newSettings . log _level === 5 ;
// In native mode, if trace is selected and not already in dev mode, show confirmation modal
if ( isTraceLevel && ! dockerized && ! isDevMode ) {
setTraceModalOpen ( true ) ;
return ;
}
// Otherwise, save normally
await doSaveSettings ( newSettings ) ;
}
const doSaveSettings = async ( newSettings ) => {
2024-10-03 13:35:06 -06:00
setDisabled ( true ) ;
setPendingSave ( true ) ;
newSettings . download _timeout = parseInt ( newSettings . download _timeout ) ;
newSettings . log _level = toApiLogLevel ( newSettings . log _level ) ;
2023-09-08 17:10:15 -06:00
try {
2024-10-03 13:35:06 -06:00
await saveSettings ( newSettings ) ;
await localFetchSettings ( ) ;
2023-09-08 17:10:15 -06:00
} finally {
2024-10-03 13:35:06 -06:00
setDisabled ( false ) ;
setPendingSave ( false ) ;
2023-09-08 17:10:15 -06:00
}
2022-09-29 12:02:09 -06:00
}
2025-12-19 16:42:36 -07:00
const handleTraceModalConfirm = async ( ) => {
setTraceSwitching ( true ) ;
setTraceCountdown ( 5 ) ;
// Start countdown
const countdownInterval = setInterval ( ( ) => {
setTraceCountdown ( prev => {
if ( prev <= 1 ) {
clearInterval ( countdownInterval ) ;
return 0 ;
}
return prev - 1 ;
} ) ;
} , 1000 ) ;
// Wait for countdown
await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
try {
// Save settings first
await doSaveSettings ( { ... state } ) ;
// Switch to dev mode: stop wrolpi-api, start wrolpi-api-dev
toast ( {
type : 'info' ,
title : 'Switching to Debug Mode' ,
description : 'Stopping production API and starting debug API...' ,
time : 3000 ,
} ) ;
await stopService ( 'wrolpi-api' ) ;
await startService ( 'wrolpi-api-dev' ) ;
toast ( {
type : 'success' ,
title : 'Debug Mode Enabled' ,
description : 'API is now running in debug mode with trace logging enabled.' ,
time : 5000 ,
} ) ;
setIsDevMode ( true ) ;
} catch ( e ) {
console . error ( 'Failed to switch to dev mode:' , e ) ;
toast ( {
type : 'error' ,
title : 'Service Switch Failed' ,
description : ` Failed to switch API services: ${ e . message } . You may need to manually restart services. ` ,
time : 10000 ,
} ) ;
} finally {
setTraceSwitching ( false ) ;
setTraceModalOpen ( false ) ;
setTraceCountdown ( 5 ) ;
}
}
const handleTraceModalCancel = ( ) => {
// Reset log level to previous value and close modal
setState ( { ... state , log _level : fromApiLogLevel ( settings . log _level ) } ) ;
setTraceModalOpen ( false ) ;
}
2024-10-03 13:35:06 -06:00
const handleHotspotChange = async ( ) => {
let { hotspot _ssid , hotspot _encryption , hotspot _password } = state ;
// Special string which allows a mobile device to connect to a specific Wi-Fi.
setQrCodeValue ( ` WIFI:S: ${ hotspot _ssid } ;T: ${ hotspot _encryption } ;P: ${ hotspot _password } ;; ` ) ;
}
React . useEffect ( ( ) => {
console . debug ( 'settings changed, replacing state...' ) ;
setReady ( settings ? true : undefined ) ;
setState ( {
// Only these settings can be changed on the SettingsPage.
archive _destination : settings . archive _destination ,
download _on _startup : settings . download _on _startup ,
download _timeout : settings . download _timeout ,
hotspot _device : settings . hotspot _device ,
hotspot _on _startup : settings . hotspot _on _startup ,
hotspot _password : settings . hotspot _password ,
hotspot _ssid : settings . hotspot _ssid ,
2025-12-06 14:47:52 -07:00
check _for _upgrades : settings . check _for _upgrades ,
2024-10-03 13:35:06 -06:00
ignore _outdated _zims : settings . ignore _outdated _zims ,
log _level : fromApiLogLevel ( settings . log _level ) ,
map _destination : settings . map _destination ,
nav _color : settings . nav _color ,
media _directory : settings . media _directory ,
2026-01-31 12:54:27 -07:00
tags _directory : settings . tags _directory ,
2024-10-03 13:35:06 -06:00
throttle _on _startup : settings . throttle _on _startup ,
videos _destination : settings . videos _destination ,
zims _destination : settings . zims _destination ,
2026-02-07 18:40:56 -07:00
save _ffprobe _json : settings . save _ffprobe _json ,
2024-10-03 13:35:06 -06:00
} ) ;
} , [ JSON . stringify ( settings ) ] ) ;
React . useEffect ( ( ) => {
handleHotspotChange ( ) ;
} , [ state . hotspot _ssid , state . hotspot _password , state . hotspot _device ] ) ;
const handleInputChange = async ( e , name , value ) => {
2022-09-29 12:02:09 -06:00
if ( e ) {
e . preventDefault ( )
}
2024-10-03 13:35:06 -06:00
setState ( { ... state , [ name ] : value } ) ;
2022-09-29 12:02:09 -06:00
}
2024-10-03 13:35:06 -06:00
const handleTimeoutChange = async ( e , name , value ) => {
2022-09-29 12:02:09 -06:00
if ( e ) {
e . preventDefault ( )
}
// Restrict timeout to numbers.
value = value . replace ( /[^\d]/ , '' ) ;
2024-10-03 13:35:06 -06:00
setState ( { ... state , [ name ] : value } ) ;
2022-09-29 12:02:09 -06:00
}
2024-10-03 13:35:06 -06:00
const handleQrOpen = async ( e ) => {
2022-09-29 14:58:16 -06:00
e . preventDefault ( ) ;
2024-10-03 13:35:06 -06:00
setQrOpen ( true ) ;
2022-09-29 14:58:16 -06:00
}
2024-10-04 12:19:49 -06:00
const qrButton = < Button icon color = 'violet' style = { { marginBottom : '1em' } } >
2024-10-03 13:35:06 -06:00
< Icon name = 'qrcode' size = 'big' / >
< / B u t t o n > ;
const navColorOptions = Object . keys ( semanticUIColorMap ) . map ( i => {
return { key : i , value : i , text : i . charAt ( 0 ) . toUpperCase ( ) + i . slice ( 1 ) }
} ) ;
const mediaDirectoryLabel = ` ${ settings . media _directory } / ` ;
let body ;
if ( ready === true ) {
// Settings have been fetched, display form.
body = < >
< p > Any changes will be written to < i > { settings . media _directory } / config / wrolpi . yaml < / i > . < / p >
< Form id = "settings" >
< div style = { { margin : '0.5em' } } >
< Toggle
label = 'Download on Startup'
disabled = { disabled || state . download _on _startup === null }
checked = { state . download _on _startup === true }
onChange = { checked => handleInputChange ( null , 'download_on_startup' , checked ) }
/ >
< / d i v >
< div style = { { margin : '0.5em' } } >
< Toggle
label = 'CPU Power-save on Startup'
disabled = { disabled || state . throttle _on _startup === null }
checked = { state . throttle _on _startup === true }
onChange = { checked => handleInputChange ( null , 'throttle_on_startup' , checked ) }
/ >
< / d i v >
< div style = { { margin : '0.5em' } } >
< Toggle
label = 'Ignore outdated Zims'
disabled = { disabled || state . ignore _outdated _zims === null }
checked = { state . ignore _outdated _zims === true }
onChange = { checked => handleInputChange ( null , 'ignore_outdated_zims' , checked ) }
/ >
< / d i v >
2025-12-06 14:47:52 -07:00
< div style = { { margin : '0.5em' } } >
< Toggle
label = 'Check for upgrades hourly'
2025-12-06 14:53:15 -07:00
disabled = { disabled || dockerized || state . check _for _upgrades === null }
checked = { ! dockerized && state . check _for _upgrades === true }
2025-12-06 14:47:52 -07:00
onChange = { checked => handleInputChange ( null , 'check_for_upgrades' , checked ) }
/ >
< / d i v >
2026-01-31 12:54:27 -07:00
< div style = { { margin : '0.5em' } } >
< Toggle
label = 'Tags Directory'
disabled = { disabled || state . tags _directory === null }
checked = { state . tags _directory === true }
onChange = { checked => handleInputChange ( null , 'tags_directory' , checked ) }
info = 'When enabled, WROLPi creates a "tags" directory with hardlinks to all tagged files, organized by tag name.'
/ >
< / d i v >
2026-02-07 18:40:56 -07:00
< div style = { { margin : '0.5em' } } >
< Toggle
label = 'Save FFprobe Cache Files'
disabled = { disabled || state . save _ffprobe _json === null }
checked = { state . save _ffprobe _json === true }
onChange = { checked => handleInputChange ( null , 'save_ffprobe_json' , checked ) }
info = 'When enabled, FFprobe results are saved as .ffprobe.json files alongside videos. This speeds up reindexing but uses additional disk space (~5KB per video).'
/ >
< / d i v >
2025-12-07 11:32:07 -07:00
< Form . Group inline >
< Form . Input
2024-10-03 13:35:06 -06:00
label = { < >
< b > Download Timeout < / b >
2025-01-24 14:28:04 -07:00
< InfoPopup content = ' Downloads will be stopped after this many seconds have elapsed .
2024-10-03 13:35:06 -06:00
Downloads will never timeout if this is empty . ' / >
< / > }
value = { state . download _timeout }
disabled = { disabled || state . download _timeout === null }
onChange = { ( e , i ) => handleTimeoutChange ( e , 'download_timeout' , i . value ) }
/ >
2025-12-07 11:32:07 -07:00
< / F o r m . G r o u p >
2024-10-03 13:35:06 -06:00
2025-12-07 11:32:07 -07:00
< Form . Group inline >
< Form . Input
2024-10-03 13:35:06 -06:00
label = 'Hotspot SSID'
value = { state . hotspot _ssid }
disabled = { disabled || state . hotspot _ssid === null }
onChange = { ( e , i ) => setState ( { ... state , hotspot _ssid : i . value } ) }
/ >
2025-12-07 11:32:07 -07:00
< Form . Input
2024-10-03 13:35:06 -06:00
label = 'Hotspot Password'
disabled = { disabled || state . hotspot _password === null }
value = { state . hotspot _password }
onChange = { ( e , i ) => setState ( { ... state , hotspot _password : i . value } ) }
/ >
2025-12-07 11:32:07 -07:00
< Form . Input
2024-10-03 13:35:06 -06:00
label = 'Hotspot Device'
disabled = { disabled || state . hotspot _password === null }
value = { state . hotspot _device }
onChange = { ( e , i ) => handleInputChange ( e , 'hotspot_device' , i . value ) }
/ >
2025-12-07 11:32:07 -07:00
< / F o r m . G r o u p >
2024-10-03 13:35:06 -06:00
< Modal closeIcon
onClose = { ( ) => setQrOpen ( false ) }
onOpen = { handleQrOpen }
open = { qrOpen }
trigger = { qrButton }
>
2025-12-07 11:32:07 -07:00
< Modal . Header >
2024-10-03 13:35:06 -06:00
Scan this code to join the hotspot
2025-12-07 11:32:07 -07:00
< / M o d a l . H e a d e r >
< Modal . Content >
2024-10-03 13:35:06 -06:00
< div style = { { display : 'inline-block' , backgroundColor : '#ffffff' , padding : '1em' } } >
< QRCode value = { qrCodeValue } size = { 300 } / >
2024-03-09 16:27:34 -07:00
< / d i v >
2025-12-07 11:32:07 -07:00
< / M o d a l . C o n t e n t >
2024-10-03 13:35:06 -06:00
< / M o d a l >
< br / >
< label htmlFor = 'log_levels_input' > Log Level : { logLevelToName ( state . log _level ) } < / l a b e l >
< br / >
< input type = 'range'
id = 'log_levels_input'
list = 'log_levels'
min = '1'
max = '5'
value = { state . log _level }
onChange = { e => setState ( { ... state , log _level : parseInt ( e . target . value ) } ) }
style = { { marginBottom : '1em' } }
/ >
< datalist id = 'log_levels' >
< option value = '1' > Critical < / o p t i o n >
< option value = '2' > Warning < / o p t i o n >
< option value = '3' > Info < / o p t i o n >
< option value = '4' > Debug < / o p t i o n >
2024-12-11 11:52:33 -07:00
< option value = '5' > Trace < / o p t i o n >
2024-10-03 13:35:06 -06:00
< / d a t a l i s t >
< br / >
< ButtonGroup >
2024-10-04 12:19:49 -06:00
< Button color = { state . nav _color } onClick = { e => e . preventDefault ( ) } > Navbar Color < / B u t t o n >
2024-10-03 13:35:06 -06:00
< Dropdown
2024-11-02 15:14:02 -06:00
id = 'settings_navbar_color_dropdown'
2024-10-03 13:35:06 -06:00
className = 'button icon'
floating
options = { navColorOptions }
2024-10-04 12:19:49 -06:00
onChange = { ( e , { value } ) => setState ( { ... state , nav _color : value } ) }
value = { state . nav _color }
2024-10-03 13:35:06 -06:00
/ >
< / B u t t o n G r o u p >
< Divider / >
< Header as = 'h3' > Special Directories < / H e a d e r >
< p > WROLPi will save files to these directories ( any video files will be saved to
the < i > videos < / i > b y d e f a u l t , e t c . ) . < / p >
< Grid stackable >
< GridRow columns = { 2 } >
< GridColumn >
2025-12-07 11:32:07 -07:00
< Form . Field >
2024-10-03 13:35:06 -06:00
< label > Archive Directory < / l a b e l >
< Input
label = { mediaDirectoryLabel }
value = { state . archive _destination }
disabled = { ! editSpecialDirectories }
onChange = { ( e , d ) => handleInputChange ( e , 'archive_destination' , d . value ) }
/ >
2025-12-07 11:32:07 -07:00
< / F o r m . F i e l d >
2024-10-03 13:35:06 -06:00
< / G r i d C o l u m n >
< GridColumn >
2025-12-07 11:32:07 -07:00
< Form . Field >
2024-10-03 13:35:06 -06:00
< label > Videos Directory < / l a b e l >
< Input
label = { mediaDirectoryLabel }
value = { state . videos _destination }
disabled = { ! editSpecialDirectories }
onChange = { ( e , d ) => handleInputChange ( e , 'videos_destination' , d . value ) }
/ >
2025-12-07 11:32:07 -07:00
< / F o r m . F i e l d >
2024-10-03 13:35:06 -06:00
< / G r i d C o l u m n >
< / G r i d R o w >
< GridRow columns = { 2 } >
< GridColumn >
2025-12-07 11:32:07 -07:00
< Form . Field >
2024-10-03 13:35:06 -06:00
< label > Map Directory < / l a b e l >
< Input
label = { mediaDirectoryLabel }
value = { state . map _destination }
disabled = { ! editSpecialDirectories }
onChange = { ( e , d ) => handleInputChange ( e , 'map_destination' , d . value ) }
/ >
2025-12-07 11:32:07 -07:00
< / F o r m . F i e l d >
2024-10-03 13:35:06 -06:00
< / G r i d C o l u m n >
< GridColumn >
2025-12-07 11:32:07 -07:00
< Form . Field >
2024-10-03 13:35:06 -06:00
< label > Zims Directory < / l a b e l >
< Input
label = { mediaDirectoryLabel }
value = { state . zims _destination }
disabled = { ! editSpecialDirectories }
onChange = { ( e , d ) => handleInputChange ( e , 'zims_destination' , d . value ) }
/ >
2025-12-07 11:32:07 -07:00
< / F o r m . F i e l d >
2024-10-03 13:35:06 -06:00
< / G r i d C o l u m n >
< / G r i d R o w >
< GridRow columns = { 1 } >
< GridColumn >
2024-03-09 16:27:34 -07:00
< Toggle
2024-10-03 13:35:06 -06:00
label = 'Edit Directories'
disabled = { disabled }
checked = { editSpecialDirectories === true }
onChange = { checked => setEditSpecialDirectories ( checked ) }
2024-03-09 16:27:34 -07:00
/ >
2024-10-03 13:35:06 -06:00
< / G r i d C o l u m n >
< / G r i d R o w >
< / G r i d >
< Divider / >
< APIButton
2024-10-14 14:20:50 -06:00
id = 'settings_save_button'
2024-10-03 13:35:06 -06:00
color = 'violet'
size = 'big'
onClick = { ( ) => localSaveSettings ( state ) }
obeyWROLMode = { true }
disabled = { disabled }
> Save < / A P I B u t t o n >
< Dimmer active = { pendingSave } >
< Loader active = { pendingSave } size = 'large' / >
< / D i m m e r >
< / F o r m >
< / >
} else if ( ready === false ) {
body = < Loader active inline = 'centered' / >
} else {
body = < ErrorMessage > Unable to fetch settings < / E r r o r M e s s a g e >
2022-09-29 12:02:09 -06:00
}
2024-10-03 13:35:06 -06:00
const configsSegment = < Segment >
2025-01-26 12:44:16 -07:00
< RefreshHeader
2025-03-25 15:52:54 -06:00
header = 'Configs'
2025-01-26 12:44:16 -07:00
popupContents = 'Check if configs are valid'
onRefresh = { fetchConfigs }
/ >
2024-10-03 13:35:06 -06:00
2024-10-04 12:19:49 -06:00
< p > These configs control this WROLPi ; they are the source of truth . Any changes to configs will be applied to
the database when imported ( typically at startup ) . < / p >
2024-10-03 13:35:06 -06:00
< ConfigsTable
configs = { configs }
loading = { loading }
importConfig = { importConfig }
saveConfig = { saveConfig }
fetchConfigs = { fetchConfigs }
/ >
< / S e g m e n t > ;
return < Container fluid >
< WROLModeMessage content = 'Settings are disabled because WROL Mode is enabled.' / >
< Segment >
< Header as = 'h2' > Settings < / H e a d e r >
{ body }
< / S e g m e n t >
{ configsSegment }
2025-01-22 18:58:18 -07:00
2025-10-29 22:16:33 -06:00
< UpgradeSegment / >
2025-12-11 18:32:55 -07:00
< WROLModeSection / >
2025-01-22 18:58:18 -07:00
< Segment >
< Header as = 'h1' > Browser Settings < / H e a d e r >
< APIButton onClick = { clearAll } > Show All Hints < / A P I B u t t o n >
< / S e g m e n t >
2025-12-19 16:42:36 -07:00
{ /* Trace Level Modal - shown when user selects trace level in native mode */ }
< Modal
open = { traceModalOpen }
onClose = { ( ) => ! traceSwitching && handleTraceModalCancel ( ) }
size = 'small'
>
< Modal . Header >
< Icon name = 'bug' / > Enable Debug Mode for Trace Logging
< / M o d a l . H e a d e r >
< Modal . Content >
{ traceSwitching ? (
< >
< p >
< Icon name = 'spinner' loading / >
{ traceCountdown > 0
? ` Switching to debug mode in ${ traceCountdown } seconds... `
: 'Switching API services...' }
< / p >
< p style = { { color : '#888' , fontSize : '0.9em' } } >
The API will restart . This page may temporarily lose connection .
< / p >
< / >
) : (
< >
< p >
Trace logging requires running the API in debug mode , which has slightly reduced
performance ( 2 workers instead of 5 ) .
< / p >
< p >
This will save your settings and restart the API service . The page may temporarily
lose connection during the switch .
< / p >
< p style = { { color : '#888' , fontSize : '0.9em' } } >
You can switch back to production mode later from the Controller page .
< / p >
< / >
) }
< / M o d a l . C o n t e n t >
< Modal . Actions >
< Button
color = 'grey'
onClick = { handleTraceModalCancel }
disabled = { traceSwitching }
>
Cancel
< / B u t t o n >
< Button
color = 'green'
onClick = { handleTraceModalConfirm }
disabled = { traceSwitching }
>
< Icon name = 'check' / > Enable Debug Mode
< / B u t t o n >
< / M o d a l . A c t i o n s >
< / M o d a l >
2024-10-03 13:35:06 -06:00
< / C o n t a i n e r > ;
2022-09-29 12:02:09 -06:00
}
2024-10-03 13:35:06 -06:00