2023-10-17 17:54:55 -07:00
|
|
|
import Checkbox from '@mui/material/Checkbox';
|
|
|
|
import FormControl from '@mui/material/FormControl';
|
|
|
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
|
|
import FormHelperText from '@mui/material/FormHelperText';
|
|
|
|
import MenuItem from '@mui/material/MenuItem';
|
2023-10-19 12:02:54 -07:00
|
|
|
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
2023-10-17 17:54:55 -07:00
|
|
|
import Stack from '@mui/material/Stack';
|
|
|
|
import TextField from '@mui/material/TextField';
|
|
|
|
import Typography from '@mui/material/Typography';
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import globalize from 'scripts/globalize';
|
2023-10-19 12:02:54 -07:00
|
|
|
import { DisplaySettingsValues } from './types';
|
|
|
|
import { useScreensavers } from './hooks/useScreensavers';
|
|
|
|
import { useServerThemes } from './hooks/useServerThemes';
|
|
|
|
|
|
|
|
interface DisplayPreferencesProps {
|
|
|
|
onChange: (event: SelectChangeEvent | React.SyntheticEvent) => void;
|
|
|
|
values: DisplaySettingsValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function DisplayPreferences({ onChange, values }: Readonly<DisplayPreferencesProps>) {
|
|
|
|
const { screensavers } = useScreensavers();
|
|
|
|
const { themes } = useServerThemes();
|
2023-10-17 17:54:55 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Stack spacing={2}>
|
|
|
|
<Typography variant='h2'>{globalize.translate('Display')}</Typography>
|
|
|
|
|
|
|
|
<FormControl fullWidth>
|
|
|
|
<Select
|
|
|
|
aria-describedby='display-settings-layout-description'
|
2023-10-19 12:02:54 -07:00
|
|
|
inputProps={{
|
|
|
|
name: 'layout'
|
|
|
|
}}
|
2023-10-17 17:54:55 -07:00
|
|
|
label={globalize.translate('LabelDisplayMode')}
|
2023-10-19 12:02:54 -07:00
|
|
|
onChange={onChange}
|
|
|
|
value={values.layout}
|
2023-10-17 17:54:55 -07:00
|
|
|
>
|
|
|
|
<MenuItem value='auto'>{globalize.translate('Auto')}</MenuItem>
|
|
|
|
<MenuItem value='desktop'>{globalize.translate('Desktop')}</MenuItem>
|
|
|
|
<MenuItem value='mobile'>{globalize.translate('Mobile')}</MenuItem>
|
|
|
|
<MenuItem value='tv'>{globalize.translate('TV')}</MenuItem>
|
|
|
|
<MenuItem value='experimental'>{globalize.translate('Experimental')}</MenuItem>
|
|
|
|
</Select>
|
|
|
|
<FormHelperText component={Stack} id='display-settings-layout-description'>
|
|
|
|
<span>{globalize.translate('DisplayModeHelp')}</span>
|
|
|
|
<span>{globalize.translate('LabelPleaseRestart')}</span>
|
|
|
|
</FormHelperText>
|
|
|
|
</FormControl>
|
|
|
|
|
|
|
|
<FormControl fullWidth>
|
2023-10-19 12:02:54 -07:00
|
|
|
<Select
|
|
|
|
inputProps={{
|
|
|
|
name: 'theme'
|
|
|
|
}}
|
|
|
|
label={globalize.translate('LabelTheme')}
|
|
|
|
onChange={onChange}
|
|
|
|
value={values.theme}
|
|
|
|
>
|
|
|
|
{ ...themes.map(({ id, name }) => (
|
|
|
|
<MenuItem key={id} value={id}>{name}</MenuItem>
|
|
|
|
))}
|
2023-10-17 17:54:55 -07:00
|
|
|
</Select>
|
|
|
|
</FormControl>
|
|
|
|
|
|
|
|
<FormControl fullWidth>
|
|
|
|
<FormControlLabel
|
|
|
|
aria-describedby='display-settings-disable-css-description'
|
2023-10-19 12:02:54 -07:00
|
|
|
control={
|
|
|
|
<Checkbox
|
|
|
|
checked={values.disableCustomCss}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
}
|
2023-10-17 17:54:55 -07:00
|
|
|
label={globalize.translate('DisableCustomCss')}
|
2023-10-19 12:02:54 -07:00
|
|
|
name='disableCustomCss'
|
2023-10-17 17:54:55 -07:00
|
|
|
/>
|
|
|
|
<FormHelperText id='display-settings-disable-css-description'>
|
|
|
|
{globalize.translate('LabelDisableCustomCss')}
|
|
|
|
</FormHelperText>
|
|
|
|
</FormControl>
|
|
|
|
|
|
|
|
<FormControl fullWidth>
|
|
|
|
<TextField
|
|
|
|
aria-describedby='display-settings-custom-css-description'
|
2023-10-19 12:02:54 -07:00
|
|
|
defaultValue={values.customCss}
|
2023-10-17 17:54:55 -07:00
|
|
|
label={globalize.translate('LabelCustomCss')}
|
|
|
|
multiline
|
2023-10-19 12:02:54 -07:00
|
|
|
name='customCss'
|
|
|
|
onChange={onChange}
|
2023-10-17 17:54:55 -07:00
|
|
|
/>
|
|
|
|
<FormHelperText id='display-settings-custom-css-description'>
|
|
|
|
{globalize.translate('LabelLocalCustomCss')}
|
|
|
|
</FormHelperText>
|
|
|
|
</FormControl>
|
|
|
|
|
|
|
|
{/* TODO: There are some admin-only options here */}
|
|
|
|
{/* Server Dashboard Theme */}
|
|
|
|
|
|
|
|
<FormControl fullWidth>
|
2023-10-19 12:02:54 -07:00
|
|
|
<Select
|
|
|
|
inputProps={{
|
|
|
|
name: 'screensaver'
|
|
|
|
}}
|
|
|
|
label={globalize.translate('LabelScreensaver')}
|
|
|
|
onChange={onChange}
|
|
|
|
value={values.screensaver}
|
|
|
|
>
|
|
|
|
{ ...screensavers.map(({ id, name }) => (
|
|
|
|
<MenuItem key={id} value={id}>{name}</MenuItem>
|
|
|
|
))}
|
|
|
|
</Select>
|
2023-10-17 17:54:55 -07:00
|
|
|
</FormControl>
|
|
|
|
|
|
|
|
{/* TODO: There are some extra options here related to screensavers */}
|
|
|
|
|
|
|
|
<FormControl fullWidth>
|
|
|
|
<FormControlLabel
|
|
|
|
aria-describedby='display-settings-faster-animations-description'
|
2023-10-19 12:02:54 -07:00
|
|
|
control={
|
|
|
|
<Checkbox
|
|
|
|
checked={values.enableFasterAnimation}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
}
|
2023-10-17 17:54:55 -07:00
|
|
|
label={globalize.translate('EnableFasterAnimations')}
|
2023-10-19 12:02:54 -07:00
|
|
|
name='enableFasterAnimation'
|
2023-10-17 17:54:55 -07:00
|
|
|
/>
|
|
|
|
<FormHelperText id='display-settings-faster-animations-description'>
|
|
|
|
{globalize.translate('EnableFasterAnimationsHelp')}
|
|
|
|
</FormHelperText>
|
|
|
|
</FormControl>
|
|
|
|
|
|
|
|
<FormControl fullWidth>
|
|
|
|
<FormControlLabel
|
|
|
|
aria-describedby='display-settings-blurhash-description'
|
2023-10-19 12:02:54 -07:00
|
|
|
control={
|
|
|
|
<Checkbox
|
|
|
|
checked={values.enableBlurHash}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
}
|
2023-10-17 17:54:55 -07:00
|
|
|
label={globalize.translate('EnableBlurHash')}
|
2023-10-19 12:02:54 -07:00
|
|
|
name='enableBlurHash'
|
2023-10-17 17:54:55 -07:00
|
|
|
/>
|
|
|
|
<FormHelperText id='display-settings-blurhash-description'>
|
|
|
|
{globalize.translate('EnableBlurHashHelp')}
|
|
|
|
</FormHelperText>
|
|
|
|
</FormControl>
|
|
|
|
</Stack>
|
|
|
|
);
|
|
|
|
}
|