migrate deprecated Grid v5 to v6 (Grid2)

This commit is contained in:
proddy
2024-08-30 14:55:24 +02:00
parent eff3e3f404
commit 35cb567b62
17 changed files with 326 additions and 452 deletions

View File

@@ -109,9 +109,11 @@ const SignIn = () => {
onChange={updateLoginRequestValue} onChange={updateLoginRequestValue}
margin="normal" margin="normal"
variant="outlined" variant="outlined"
inputProps={{ slotProps={{
autoCapitalize: 'none', input: {
autoCorrect: 'off' autoCapitalize: 'none',
autoCorrect: 'off'
}
}} }}
/> />
<ValidatedPasswordField <ValidatedPasswordField

View File

@@ -12,11 +12,11 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
InputAdornment, InputAdornment,
MenuItem, MenuItem,
TextField TextField
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme'; import { dialogStyle } from 'CustomTheme';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
@@ -100,8 +100,8 @@ const CustomEntitiesDialog = ({
<Box display="flex" flexWrap="wrap" mb={1}> <Box display="flex" flexWrap="wrap" mb={1}>
<Box flexWrap="nowrap" whiteSpace="nowrap" /> <Box flexWrap="nowrap" whiteSpace="nowrap" />
</Box> </Box>
<Grid container spacing={2}> <Grid container spacing={1} rowSpacing={0}>
<Grid item xs={4}> <Grid size={12}>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="name" name="name"
@@ -112,7 +112,7 @@ const CustomEntitiesDialog = ({
onChange={updateFormValue} onChange={updateFormValue}
/> />
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="ram" name="ram"
label={LL.VALUE(0) + ' ' + LL.TYPE(1)} label={LL.VALUE(0) + ' ' + LL.TYPE(1)}
@@ -128,7 +128,7 @@ const CustomEntitiesDialog = ({
</TextField> </TextField>
</Grid> </Grid>
{editItem.ram === 1 && ( {editItem.ram === 1 && (
<Grid item xs={4}> <Grid>
<TextField <TextField
name="value" name="value"
label={LL.DEFAULT(0) + ' ' + LL.VALUE(0)} label={LL.DEFAULT(0) + ' ' + LL.VALUE(0)}
@@ -143,7 +143,7 @@ const CustomEntitiesDialog = ({
)} )}
{editItem.ram === 0 && ( {editItem.ram === 0 && (
<> <>
<Grid item xs={4} mt={3}> <Grid mt={3} size={9}>
<BlockFormControlLabel <BlockFormControlLabel
control={ control={
<Checkbox <Checkbox
@@ -155,63 +155,67 @@ const CustomEntitiesDialog = ({
label={LL.WRITEABLE()} label={LL.WRITEABLE()}
/> />
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="device_id" name="device_id"
label={LL.ID_OF(LL.DEVICE())} label={LL.ID_OF(LL.DEVICE())}
margin="normal" margin="normal"
sx={{ width: '11ch' }}
type="string" type="string"
fullWidth
value={editItem.device_id as string} value={editItem.device_id as string}
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ style: { textTransform: 'uppercase' } }} slotProps={{
InputProps={{ input: {
startAdornment: ( startAdornment: (
<InputAdornment position="start">0x</InputAdornment> <InputAdornment position="start">0x</InputAdornment>
) )
},
htmlInput: { style: { textTransform: 'uppercase' } }
}} }}
/> />
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="type_id" name="type_id"
label={LL.ID_OF(LL.TYPE(1))} label={LL.ID_OF(LL.TYPE(1))}
margin="normal" margin="normal"
fullWidth sx={{ width: '11ch' }}
type="string" type="string"
value={editItem.type_id as string} value={editItem.type_id as string}
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ style: { textTransform: 'uppercase' } }} slotProps={{
InputProps={{ input: {
startAdornment: ( startAdornment: (
<InputAdornment position="start">0x</InputAdornment> <InputAdornment position="start">0x</InputAdornment>
) )
},
htmlInput: { style: { textTransform: 'uppercase' } }
}} }}
/> />
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="offset" name="offset"
label={LL.OFFSET()} label={LL.OFFSET()}
margin="normal" margin="normal"
fullWidth sx={{ width: '11ch' }}
type="number" type="number"
value={editItem.offset} value={editItem.offset}
onChange={updateFormValue} onChange={updateFormValue}
/> />
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="value_type" name="value_type"
label={LL.VALUE(0) + ' ' + LL.TYPE(1)} label={LL.VALUE(0) + ' ' + LL.TYPE(1)}
value={editItem.value_type} value={editItem.value_type}
variant="outlined" variant="outlined"
sx={{ width: '11ch' }}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
fullWidth
select select
> >
<MenuItem value={DeviceValueType.BOOL}> <MenuItem value={DeviceValueType.BOOL}>
@@ -247,26 +251,28 @@ const CustomEntitiesDialog = ({
{editItem.value_type !== DeviceValueType.BOOL && {editItem.value_type !== DeviceValueType.BOOL &&
editItem.value_type !== DeviceValueType.STRING && ( editItem.value_type !== DeviceValueType.STRING && (
<> <>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="factor" name="factor"
label={LL.FACTOR()} label={LL.FACTOR()}
value={numberValue(editItem.factor)} value={numberValue(editItem.factor)}
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
fullWidth sx={{ width: '11ch' }}
margin="normal" margin="normal"
type="number" type="number"
inputProps={{ step: '0.001' }} slotProps={{
htmlInput: { step: '0.001' }
}}
/> />
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="uom" name="uom"
label={LL.UNIT()} label={LL.UNIT()}
value={editItem.uom} value={editItem.uom}
margin="normal" margin="normal"
fullWidth sx={{ width: '11ch' }}
onChange={updateFormValue} onChange={updateFormValue}
select select
> >
@@ -281,20 +287,21 @@ const CustomEntitiesDialog = ({
)} )}
{editItem.value_type === DeviceValueType.STRING && {editItem.value_type === DeviceValueType.STRING &&
editItem.device_id !== '0' && ( editItem.device_id !== '0' && (
<Grid item xs={4}> <Grid>
<TextField <TextField
name="factor" name="factor"
label="Bytes" label="Bytes"
value={editItem.factor} value={editItem.factor}
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
fullWidth
margin="normal" margin="normal"
type="number" type="number"
inputProps={{ slotProps={{
min: '1', htmlInput: {
max: String(256 - editItem.offset), min: '1',
step: '1' max: String(256 - editItem.offset),
step: '1'
}
}} }}
/> />
</Grid> </Grid>
@@ -303,7 +310,6 @@ const CustomEntitiesDialog = ({
)} )}
</Grid> </Grid>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
{!creating && ( {!creating && (
<Box flexGrow={1}> <Box flexGrow={1}>

View File

@@ -16,7 +16,6 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
InputAdornment, InputAdornment,
Link, Link,
MenuItem, MenuItem,
@@ -25,6 +24,7 @@ import {
ToggleButtonGroup, ToggleButtonGroup,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { restart } from 'api/system'; import { restart } from 'api/system';
@@ -514,7 +514,7 @@ const Customizations = () => {
justifyContent="flex-start" justifyContent="flex-start"
alignItems="center" alignItems="center"
> >
<Grid item xs={2}> <Grid>
<TextField <TextField
size="small" size="small"
variant="outlined" variant="outlined"
@@ -522,16 +522,18 @@ const Customizations = () => {
onChange={(event) => { onChange={(event) => {
setSearch(event.target.value); setSearch(event.target.value);
}} }}
InputProps={{ slotProps={{
startAdornment: ( input: {
<InputAdornment position="start"> startAdornment: (
<SearchIcon color="primary" sx={{ fontSize: 16 }} /> <InputAdornment position="start">
</InputAdornment> <SearchIcon color="primary" sx={{ fontSize: 16 }} />
) </InputAdornment>
)
}
}} }}
/> />
</Grid> </Grid>
<Grid item> <Grid>
<ToggleButtonGroup <ToggleButtonGroup
size="small" size="small"
color="secondary" color="secondary"
@@ -557,7 +559,7 @@ const Customizations = () => {
</ToggleButton> </ToggleButton>
</ToggleButtonGroup> </ToggleButtonGroup>
</Grid> </Grid>
<Grid item> <Grid>
<Button <Button
size="small" size="small"
sx={{ fontSize: 10 }} sx={{ fontSize: 10 }}
@@ -570,7 +572,7 @@ const Customizations = () => {
<OptionIcon type="web_exclude" isSet={false} /> <OptionIcon type="web_exclude" isSet={false} />
</Button> </Button>
</Grid> </Grid>
<Grid item> <Grid>
<Button <Button
size="small" size="small"
sx={{ fontSize: 10 }} sx={{ fontSize: 10 }}
@@ -583,7 +585,7 @@ const Customizations = () => {
<OptionIcon type="web_exclude" isSet={true} /> <OptionIcon type="web_exclude" isSet={true} />
</Button> </Button>
</Grid> </Grid>
<Grid item> <Grid>
<Typography variant="subtitle2" color="primary"> <Typography variant="subtitle2" color="primary">
{LL.SHOWING()}&nbsp;{shown_data.length}/{deviceEntities.length} {LL.SHOWING()}&nbsp;{shown_data.length}/{deviceEntities.length}
&nbsp;{LL.ENTITIES(deviceEntities.length)} &nbsp;{LL.ENTITIES(deviceEntities.length)}

View File

@@ -10,10 +10,10 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
TextField, TextField,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme'; import { dialogStyle } from 'CustomTheme';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
@@ -81,7 +81,7 @@ const CustomizationsDialog = ({
<Dialog sx={dialogStyle} open={open} onClose={handleClose}> <Dialog sx={dialogStyle} open={open} onClose={handleClose}>
<DialogTitle>{LL.EDIT() + ' ' + LL.ENTITY()}</DialogTitle> <DialogTitle>{LL.EDIT() + ' ' + LL.ENTITY()}</DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<Grid container direction="row"> <Grid container>
<Typography variant="body2" color="warning.main"> <Typography variant="body2" color="warning.main">
{LL.ID_OF(LL.ENTITY())}:&nbsp; {LL.ID_OF(LL.ENTITY())}:&nbsp;
</Typography> </Typography>
@@ -112,19 +112,18 @@ const CustomizationsDialog = ({
<EntityMaskToggle onUpdate={updateDeviceEntity} de={editItem} /> <EntityMaskToggle onUpdate={updateDeviceEntity} de={editItem} />
</Box> </Box>
<Grid container spacing={1}> <Grid container spacing={1}>
<Grid item> <Grid>
<TextField <TextField
name="cn" name="cn"
label={LL.NEW_NAME_OF(LL.ENTITY())} label={LL.NEW_NAME_OF(LL.ENTITY())}
value={editItem.cn} value={editItem.cn}
// autoFocus
sx={{ width: '30ch' }} sx={{ width: '30ch' }}
onChange={updateFormValue} onChange={updateFormValue}
/> />
</Grid> </Grid>
{isWriteableNumber && ( {isWriteableNumber && (
<> <>
<Grid item> <Grid>
<TextField <TextField
name="mi" name="mi"
label={LL.MIN()} label={LL.MIN()}
@@ -134,7 +133,7 @@ const CustomizationsDialog = ({
onChange={updateFormValue} onChange={updateFormValue}
/> />
</Grid> </Grid>
<Grid item> <Grid>
<TextField <TextField
name="ma" name="ma"
label={LL.MAX()} label={LL.MAX()}

View File

@@ -30,7 +30,6 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
IconButton, IconButton,
List, List,
ListItem, ListItem,
@@ -41,6 +40,7 @@ import {
styled, styled,
tooltipClasses tooltipClasses
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { useRowSelect } from '@table-library/react-table-library/select'; import { useRowSelect } from '@table-library/react-table-library/select';
import { SortToggleType, useSort } from '@table-library/react-table-library/sort'; import { SortToggleType, useSort } from '@table-library/react-table-library/sort';
@@ -677,7 +677,7 @@ const Devices = () => {
</IconButton> </IconButton>
</ButtonTooltip> </ButtonTooltip>
</Typography> </Typography>
<Grid item zeroMinWidth justifyContent="flex-end"> <Grid justifyContent="flex-end">
<ButtonTooltip title={LL.CANCEL()}> <ButtonTooltip title={LL.CANCEL()}>
<IconButton onClick={resetDeviceSelect}> <IconButton onClick={resetDeviceSelect}>
<HighlightOffIcon color="primary" sx={{ fontSize: 18 }} /> <HighlightOffIcon color="primary" sx={{ fontSize: 18 }} />

View File

@@ -11,12 +11,12 @@ import {
DialogContent, DialogContent,
DialogTitle, DialogTitle,
FormHelperText, FormHelperText,
Grid,
InputAdornment, InputAdornment,
MenuItem, MenuItem,
TextField, TextField,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme'; import { dialogStyle } from 'CustomTheme';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
@@ -112,15 +112,14 @@ const DevicesDialog = ({
<Box color="warning.main" p={0} pl={0} pr={0} mt={0} mb={2}> <Box color="warning.main" p={0} pl={0} pr={0} mt={0} mb={2}>
<Typography variant="body2">{editItem.id.slice(2)}</Typography> <Typography variant="body2">{editItem.id.slice(2)}</Typography>
</Box> </Box>
<Grid> <Grid container>
<Grid item> <Grid size={12}>
{editItem.l ? ( {editItem.l ? (
<TextField <TextField
name="v" name="v"
label={LL.VALUE(0)} label={LL.VALUE(0)}
value={editItem.v} value={editItem.v}
disabled={!writeable} disabled={!writeable}
// autoFocus
sx={{ width: '30ch' }} sx={{ width: '30ch' }}
select select
onChange={updateFormValue} onChange={updateFormValue}
@@ -142,17 +141,17 @@ const DevicesDialog = ({
type="number" type="number"
sx={{ width: '30ch' }} sx={{ width: '30ch' }}
onChange={updateFormValue} onChange={updateFormValue}
inputProps={ slotProps={{
editItem.s htmlInput: editItem.s
? { min: editItem.m, max: editItem.x, step: editItem.s } ? { min: editItem.m, max: editItem.x, step: editItem.s }
: {} : {},
} input: {
InputProps={{ startAdornment: (
startAdornment: ( <InputAdornment position="start">
<InputAdornment position="start"> {setUom(editItem.u)}
{setUom(editItem.u)} </InputAdornment>
</InputAdornment> )
) }
}} }}
/> />
) : ( ) : (
@@ -162,7 +161,6 @@ const DevicesDialog = ({
label={LL.VALUE(0)} label={LL.VALUE(0)}
value={editItem.v} value={editItem.v}
disabled={!writeable} disabled={!writeable}
// autoFocus
sx={{ width: '30ch' }} sx={{ width: '30ch' }}
multiline={editItem.u ? false : true} multiline={editItem.u ? false : true}
onChange={updateFormValue} onChange={updateFormValue}
@@ -170,7 +168,7 @@ const DevicesDialog = ({
)} )}
</Grid> </Grid>
{writeable && ( {writeable && (
<Grid item> <Grid>
<FormHelperText>{showHelperText(editItem)}</FormHelperText> <FormHelperText>{showHelperText(editItem)}</FormHelperText>
</Grid> </Grid>
)} )}

View File

@@ -10,9 +10,9 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
TextField TextField
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme'; import { dialogStyle } from 'CustomTheme';
import { BlockFormControlLabel } from 'components'; import { BlockFormControlLabel } from 'components';

View File

@@ -13,12 +13,12 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
TextField, TextField,
ToggleButton, ToggleButton,
ToggleButtonGroup, ToggleButtonGroup,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme'; import { dialogStyle } from 'CustomTheme';
import type Schema from 'async-validator'; import type Schema from 'async-validator';

View File

@@ -10,12 +10,12 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
InputAdornment, InputAdornment,
MenuItem, MenuItem,
TextField, TextField,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme'; import { dialogStyle } from 'CustomTheme';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
@@ -86,11 +86,12 @@ const SensorsAnalogDialog = ({
</DialogTitle> </DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid item xs={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="g" name="g"
label="GPIO" label="GPIO"
sx={{ width: '15ch' }}
value={numberValue(editItem.g)} value={numberValue(editItem.g)}
type="number" type="number"
variant="outlined" variant="outlined"
@@ -98,13 +99,13 @@ const SensorsAnalogDialog = ({
/> />
</Grid> </Grid>
{creating && ( {creating && (
<Grid item> <Grid>
<Box color="warning.main" mt={2}> <Box color="warning.main" mt={2}>
<Typography variant="body2">{LL.WARN_GPIO()}</Typography> <Typography variant="body2">{LL.WARN_GPIO()}</Typography>
</Box> </Box>
</Grid> </Grid>
)} )}
<Grid item xs={12}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="n" name="n"
@@ -115,7 +116,7 @@ const SensorsAnalogDialog = ({
onChange={updateFormValue} onChange={updateFormValue}
/> />
</Grid> </Grid>
<Grid item xs={8}> <Grid>
<TextField <TextField
name="t" name="t"
label={LL.TYPE(0)} label={LL.TYPE(0)}
@@ -132,12 +133,12 @@ const SensorsAnalogDialog = ({
</TextField> </TextField>
</Grid> </Grid>
{editItem.t >= AnalogType.COUNTER && editItem.t <= AnalogType.RATE && ( {editItem.t >= AnalogType.COUNTER && editItem.t <= AnalogType.RATE && (
<Grid item xs={4}> <Grid>
<TextField <TextField
name="u" name="u"
label={LL.UNIT()} label={LL.UNIT()}
value={editItem.u} value={editItem.u}
fullWidth sx={{ width: '15ch' }}
select select
onChange={updateFormValue} onChange={updateFormValue}
> >
@@ -150,55 +151,61 @@ const SensorsAnalogDialog = ({
</Grid> </Grid>
)} )}
{editItem.t === AnalogType.ADC && ( {editItem.t === AnalogType.ADC && (
<Grid item xs={4}> <Grid>
<TextField <TextField
name="o" name="o"
label={LL.OFFSET()} label={LL.OFFSET()}
value={numberValue(editItem.o)} value={numberValue(editItem.o)}
fullWidth
type="number" type="number"
sx={{ width: '15ch' }}
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ min: '0', max: '3300', step: '1' }} slotProps={{
InputProps={{ input: {
startAdornment: ( startAdornment: (
<InputAdornment position="start">mV</InputAdornment> <InputAdornment position="start">mV</InputAdornment>
) )
},
htmlInput: { min: '0', max: '3300', step: '1' }
}} }}
/> />
</Grid> </Grid>
)} )}
{editItem.t === AnalogType.COUNTER && ( {editItem.t === AnalogType.COUNTER && (
<Grid item xs={4}> <Grid>
<TextField <TextField
name="o" name="o"
label={LL.STARTVALUE()} label={LL.STARTVALUE()}
value={numberValue(editItem.o)} value={numberValue(editItem.o)}
fullWidth
type="number" type="number"
sx={{ width: '15ch' }}
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ step: '0.001' }} slotProps={{
htmlInput: { step: '0.001' }
}}
/> />
</Grid> </Grid>
)} )}
{editItem.t >= AnalogType.COUNTER && editItem.t <= AnalogType.RATE && ( {editItem.t >= AnalogType.COUNTER && editItem.t <= AnalogType.RATE && (
<Grid item xs={4}> <Grid>
<TextField <TextField
name="f" name="f"
label={LL.FACTOR()} label={LL.FACTOR()}
value={numberValue(editItem.f)} value={numberValue(editItem.f)}
fullWidth sx={{ width: '15ch' }}
type="number" type="number"
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ step: '0.001' }} slotProps={{
htmlInput: { step: '0.001' }
}}
/> />
</Grid> </Grid>
)} )}
{editItem.t === AnalogType.DIGITAL_OUT && {editItem.t === AnalogType.DIGITAL_OUT &&
(editItem.g === 25 || editItem.g === 26) && ( (editItem.g === 25 || editItem.g === 26) && (
<Grid item xs={4}> <Grid>
<TextField <TextField
name="o" name="o"
label={LL.VALUE(0)} label={LL.VALUE(0)}
@@ -207,7 +214,9 @@ const SensorsAnalogDialog = ({
type="number" type="number"
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ min: '0', max: '255', step: '1' }} slotProps={{
htmlInput: { min: '0', max: '255', step: '1' }
}}
/> />
</Grid> </Grid>
)} )}
@@ -215,12 +224,11 @@ const SensorsAnalogDialog = ({
editItem.g !== 25 && editItem.g !== 25 &&
editItem.g !== 26 && ( editItem.g !== 26 && (
<> <>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="o" name="o"
label={LL.VALUE(0)} label={LL.VALUE(0)}
value={numberValue(editItem.o)} value={numberValue(editItem.o)}
fullWidth
select select
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
@@ -229,12 +237,12 @@ const SensorsAnalogDialog = ({
<MenuItem value={1}>{LL.ON()}</MenuItem> <MenuItem value={1}>{LL.ON()}</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="f" name="f"
label={LL.POLARITY()} label={LL.POLARITY()}
value={editItem.f} value={editItem.f}
fullWidth sx={{ width: '15ch' }}
select select
onChange={updateFormValue} onChange={updateFormValue}
> >
@@ -242,12 +250,12 @@ const SensorsAnalogDialog = ({
<MenuItem value={-1}>{LL.ACTIVELOW()}</MenuItem> <MenuItem value={-1}>{LL.ACTIVELOW()}</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="u" name="u"
label={LL.STARTVALUE()} label={LL.STARTVALUE()}
sx={{ width: '15ch' }}
value={editItem.u} value={editItem.u}
fullWidth
select select
onChange={updateFormValue} onChange={updateFormValue}
> >
@@ -266,37 +274,41 @@ const SensorsAnalogDialog = ({
editItem.t === AnalogType.PWM_1 || editItem.t === AnalogType.PWM_1 ||
editItem.t === AnalogType.PWM_2) && ( editItem.t === AnalogType.PWM_2) && (
<> <>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="f" name="f"
label={LL.FREQ()} label={LL.FREQ()}
value={numberValue(editItem.f)} value={numberValue(editItem.f)}
fullWidth
type="number" type="number"
variant="outlined" variant="outlined"
sx={{ width: '15ch' }}
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ min: '1', max: '5000', step: '1' }} slotProps={{
InputProps={{ input: {
startAdornment: ( startAdornment: (
<InputAdornment position="start">Hz</InputAdornment> <InputAdornment position="start">Hz</InputAdornment>
) )
},
htmlInput: { min: '1', max: '5000', step: '1' }
}} }}
/> />
</Grid> </Grid>
<Grid item xs={4}> <Grid>
<TextField <TextField
name="o" name="o"
label={LL.DUTY_CYCLE()} label={LL.DUTY_CYCLE()}
value={numberValue(editItem.o)} value={numberValue(editItem.o)}
fullWidth
type="number" type="number"
sx={{ width: '15ch' }}
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ min: '0', max: '100', step: '0.1' }} slotProps={{
InputProps={{ input: {
startAdornment: ( startAdornment: (
<InputAdornment position="start">%</InputAdornment> <InputAdornment position="start">%</InputAdornment>
) )
},
htmlInput: { min: '0', max: '100', step: '0.1' }
}} }}
/> />
</Grid> </Grid>

View File

@@ -9,11 +9,11 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Grid,
InputAdornment, InputAdornment,
TextField, TextField,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme'; import { dialogStyle } from 'CustomTheme';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
@@ -80,18 +80,17 @@ const SensorsTemperatureDialog = ({
</Typography> </Typography>
</Box> </Box>
<Grid container spacing={1}> <Grid container spacing={1}>
<Grid item> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="n" name="n"
label={LL.NAME(0)} label={LL.NAME(0)}
value={editItem.n} value={editItem.n}
// autoFocus
sx={{ width: '30ch' }} sx={{ width: '30ch' }}
onChange={updateFormValue} onChange={updateFormValue}
/> />
</Grid> </Grid>
<Grid item> <Grid>
<TextField <TextField
name="o" name="o"
label={LL.OFFSET()} label={LL.OFFSET()}
@@ -100,9 +99,13 @@ const SensorsTemperatureDialog = ({
type="number" type="number"
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
inputProps={{ min: '-5', max: '5', step: '0.1' }} slotProps={{
InputProps={{ input: {
startAdornment: <InputAdornment position="start">°C</InputAdornment> startAdornment: (
<InputAdornment position="start">°C</InputAdornment>
)
},
htmlInput: { min: '-5', max: '5', step: '0.1' }
}} }}
/> />
</Grid> </Grid>

View File

@@ -420,12 +420,11 @@ export const enum DeviceValueType {
TIME, // same as UINT24 TIME, // same as UINT24
UINT32, UINT32,
ENUM, ENUM,
STRING, STRING, // RAW
CMD CMD
} }
export const DeviceValueTypeNames = [ export const DeviceValueTypeNames = [
//
'BOOL', 'BOOL',
'INT8', 'INT8',
'UINT8', 'UINT8',

View File

@@ -9,12 +9,12 @@ import {
Button, Button,
Checkbox, Checkbox,
Divider, Divider,
Grid,
InputAdornment, InputAdornment,
MenuItem, MenuItem,
TextField, TextField,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { readHardwareStatus, restart } from 'api/system'; import { readHardwareStatus, restart } from 'api/system';
@@ -114,6 +114,19 @@ const ApplicationSettings = () => {
useLayoutTitle(LL.SETTINGS_OF(LL.APPLICATION())); useLayoutTitle(LL.SETTINGS_OF(LL.APPLICATION()));
const SecondsInputProps = {
endAdornment: <InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
};
const MilliSecondsInputProps = {
endAdornment: <InputAdornment position="end">ms</InputAdornment>
};
const MinutesInputProps = {
endAdornment: <InputAdornment position="end">{LL.MINUTES()}</InputAdornment>
};
const HoursInputProps = {
endAdornment: <InputAdornment position="end">{LL.HOURS()}</InputAdornment>
};
const content = () => { const content = () => {
if (!data || !hardwareData) { if (!data || !hardwareData) {
return <FormLoader onRetry={loadData} errorMessage={errorMessage} />; return <FormLoader onRetry={loadData} errorMessage={errorMessage} />;
@@ -191,19 +204,12 @@ const ApplicationSettings = () => {
label={LL.ENABLE_MODBUS()} label={LL.ENABLE_MODBUS()}
/> />
{data.modbus_enabled && ( {data.modbus_enabled && (
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6}>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="modbus_max_clients" name="modbus_max_clients"
label={LL.AP_MAX_CLIENTS()} label={LL.AP_MAX_CLIENTS()}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.modbus_max_clients)} value={numberValue(data.modbus_max_clients)}
type="number" type="number"
@@ -211,12 +217,11 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="modbus_port" name="modbus_port"
label="Port" label="Port"
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.modbus_port)} value={numberValue(data.modbus_port)}
type="number" type="number"
@@ -224,15 +229,14 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="modbus_timeout" name="modbus_timeout"
label="Timeout" label="Timeout"
InputProps={{ slotProps={{
endAdornment: <InputAdornment position="end">ms</InputAdornment> input: MilliSecondsInputProps
}} }}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.modbus_timeout)} value={numberValue(data.modbus_timeout)}
type="number" type="number"
@@ -254,31 +258,23 @@ const ApplicationSettings = () => {
label={LL.ENABLE_SYSLOG()} label={LL.ENABLE_SYSLOG()}
/> />
{data.syslog_enabled && ( {data.syslog_enabled && (
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6}>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="syslog_host" name="syslog_host"
label="Host" label="Host"
fullWidth
variant="outlined" variant="outlined"
value={data.syslog_host} value={data.syslog_host}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="syslog_port" name="syslog_port"
label="Port" label="Port"
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.syslog_port)} value={numberValue(data.syslog_port)}
type="number" type="number"
@@ -286,7 +282,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<TextField <TextField
name="syslog_level" name="syslog_level"
label={LL.LOG_LEVEL()} label={LL.LOG_LEVEL()}
@@ -305,17 +301,14 @@ const ApplicationSettings = () => {
<MenuItem value={9}>ALL</MenuItem> <MenuItem value={9}>ALL</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="syslog_mark_interval" name="syslog_mark_interval"
label={LL.MARK_INTERVAL()} label={LL.MARK_INTERVAL()}
InputProps={{ slotProps={{
endAdornment: ( input: SecondsInputProps
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}} }}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.syslog_mark_interval)} value={numberValue(data.syslog_mark_interval)}
type="number" type="number"
@@ -358,43 +351,37 @@ const ApplicationSettings = () => {
<Typography sx={{ pb: 1, pt: 2 }} variant="h6" color="primary"> <Typography sx={{ pb: 1, pt: 2 }} variant="h6" color="primary">
{LL.FORMATTING_OPTIONS()} {LL.FORMATTING_OPTIONS()}
</Typography> </Typography>
<Grid item> <Grid container spacing={1}>
<TextField <Grid size={3}>
name="locale" <TextField
label={LL.LANGUAGE_ENTITIES()} name="locale"
value={data.locale} label={LL.LANGUAGE_ENTITIES()}
fullWidth value={data.locale}
variant="outlined" fullWidth
onChange={updateFormValue} variant="outlined"
margin="normal" onChange={updateFormValue}
select margin="normal"
> select
<MenuItem value="de">Deutsch (DE)</MenuItem> >
<MenuItem value="en">English (EN)</MenuItem> <MenuItem value="de">Deutsch (DE)</MenuItem>
<MenuItem value="fr">Français (FR)</MenuItem> <MenuItem value="en">English (EN)</MenuItem>
<MenuItem value="it">Italiano (IT)</MenuItem> <MenuItem value="fr">Français (FR)</MenuItem>
<MenuItem value="nl">Nederlands (NL)</MenuItem> <MenuItem value="it">Italiano (IT)</MenuItem>
<MenuItem value="no">Norsk (NO)</MenuItem> <MenuItem value="nl">Nederlands (NL)</MenuItem>
<MenuItem value="pl">Polski (PL)</MenuItem> <MenuItem value="no">Norsk (NO)</MenuItem>
<MenuItem value="sk">Slovenčina (SK)</MenuItem> <MenuItem value="pl">Polski (PL)</MenuItem>
<MenuItem value="sv">Svenska (SV)</MenuItem> <MenuItem value="sk">Slovenčina (SK)</MenuItem>
<MenuItem value="tr">Türk (TR)</MenuItem> <MenuItem value="sv">Svenska (SV)</MenuItem>
</TextField> <MenuItem value="tr">Türk (TR)</MenuItem>
</Grid> </TextField>
<Grid </Grid>
container <Grid size={3}>
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6} md={4}>
<TextField <TextField
name="bool_dashboard" name="bool_dashboard"
label={LL.BOOLEAN_FORMAT_DASHBOARD()} label={LL.BOOLEAN_FORMAT_DASHBOARD()}
value={data.bool_dashboard} value={data.bool_dashboard}
fullWidth
variant="outlined" variant="outlined"
fullWidth
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
select select
@@ -405,13 +392,13 @@ const ApplicationSettings = () => {
<MenuItem value={5}>1/0</MenuItem> <MenuItem value={5}>1/0</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid size={3}>
<TextField <TextField
name="bool_format" name="bool_format"
label={LL.BOOLEAN_FORMAT_API()} label={LL.BOOLEAN_FORMAT_API()}
value={data.bool_format} value={data.bool_format}
fullWidth
variant="outlined" variant="outlined"
fullWidth
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
select select
@@ -424,13 +411,13 @@ const ApplicationSettings = () => {
<MenuItem value={6}>1/0</MenuItem> <MenuItem value={6}>1/0</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid size={3}>
<TextField <TextField
name="enum_format" name="enum_format"
label={LL.ENUM_FORMAT()} label={LL.ENUM_FORMAT()}
value={data.enum_format} value={data.enum_format}
fullWidth
variant="outlined" variant="outlined"
fullWidth
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
select select
@@ -469,7 +456,6 @@ const ApplicationSettings = () => {
label={LL.BOARD_PROFILE()} label={LL.BOARD_PROFILE()}
value={data.board_profile} value={data.board_profile}
disabled={processingBoard || hardwareData.model.startsWith('BBQKees')} disabled={processingBoard || hardwareData.model.startsWith('BBQKees')}
fullWidth
variant="outlined" variant="outlined"
onChange={changeBoardProfile} onChange={changeBoardProfile}
margin="normal" margin="normal"
@@ -483,15 +469,8 @@ const ApplicationSettings = () => {
</TextField> </TextField>
{data.board_profile === 'CUSTOM' && ( {data.board_profile === 'CUSTOM' && (
<> <>
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
sx={{ pt: 1 }}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6} md={4}>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="rx_gpio" name="rx_gpio"
@@ -504,7 +483,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="tx_gpio" name="tx_gpio"
@@ -517,7 +496,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="pbutton_gpio" name="pbutton_gpio"
@@ -530,7 +509,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="dallas_gpio" name="dallas_gpio"
@@ -545,7 +524,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="led_gpio" name="led_gpio"
@@ -558,7 +537,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="phy_type" name="phy_type"
label={LL.PHY_TYPE()} label={LL.PHY_TYPE()}
@@ -576,15 +555,8 @@ const ApplicationSettings = () => {
</Grid> </Grid>
</Grid> </Grid>
{data.phy_type !== 0 && ( {data.phy_type !== 0 && (
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
sx={{ pt: 1 }}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6} md={4}>
<TextField <TextField
name="eth_power" name="eth_power"
label={LL.GPIO_OF('PHY Power') + ' (-1=' + LL.DISABLED(1) + ')'} label={LL.GPIO_OF('PHY Power') + ' (-1=' + LL.DISABLED(1) + ')'}
@@ -596,7 +568,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="eth_phy_addr" name="eth_phy_addr"
label={LL.ADDRESS_OF('PHY I²C')} label={LL.ADDRESS_OF('PHY I²C')}
@@ -608,7 +580,7 @@ const ApplicationSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="eth_clock_mode" name="eth_clock_mode"
label="PHY Clk" label="PHY Clk"
@@ -629,14 +601,8 @@ const ApplicationSettings = () => {
)} )}
</> </>
)} )}
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6}>
<TextField <TextField
name="tx_mode" name="tx_mode"
label={LL.TX_MODE()} label={LL.TX_MODE()}
@@ -653,7 +619,7 @@ const ApplicationSettings = () => {
<MenuItem value={4}>{LL.HARDWARE()}</MenuItem> <MenuItem value={4}>{LL.HARDWARE()}</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<TextField <TextField
name="ems_bus_id" name="ems_bus_id"
label={LL.ID_OF(LL.EMS_BUS(0))} label={LL.ID_OF(LL.EMS_BUS(0))}
@@ -741,10 +707,8 @@ const ApplicationSettings = () => {
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="remote_timeout" name="remote_timeout"
label={LL.REMOTE_TIMEOUT()} label={LL.REMOTE_TIMEOUT()}
InputProps={{ slotProps={{
endAdornment: ( input: HoursInputProps
<InputAdornment position="end">{LL.HOURS()}</InputAdornment>
)
}} }}
variant="outlined" variant="outlined"
value={numberValue(data.remote_timeout)} value={numberValue(data.remote_timeout)}
@@ -753,13 +717,7 @@ const ApplicationSettings = () => {
/> />
</Box> </Box>
)} )}
<Grid <Grid container spacing={1} rowSpacing={0}>
container
spacing={0}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<BlockFormControlLabel <BlockFormControlLabel
control={ control={
<Checkbox <Checkbox
@@ -782,25 +740,15 @@ const ApplicationSettings = () => {
disabled={!data.shower_timer} disabled={!data.shower_timer}
/> />
</Grid> </Grid>
<Grid <Grid container spacing={1} rowSpacing={2} sx={{ pt: 2 }}>
container
sx={{ pt: 2 }}
rowSpacing={3}
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
{data.shower_timer && ( {data.shower_timer && (
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="shower_min_duration" name="shower_min_duration"
label={LL.MIN_DURATION()} label={LL.MIN_DURATION()}
InputProps={{ slotProps={{
endAdornment: ( input: SecondsInputProps
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}} }}
variant="outlined" variant="outlined"
value={numberValue(data.shower_min_duration)} value={numberValue(data.shower_min_duration)}
@@ -812,15 +760,13 @@ const ApplicationSettings = () => {
)} )}
{data.shower_alert && ( {data.shower_alert && (
<> <>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="shower_alert_trigger" name="shower_alert_trigger"
label={LL.TRIGGER_TIME()} label={LL.TRIGGER_TIME()}
InputProps={{ slotProps={{
endAdornment: ( input: MinutesInputProps
<InputAdornment position="end">{LL.MINUTES()}</InputAdornment>
)
}} }}
variant="outlined" variant="outlined"
value={numberValue(data.shower_alert_trigger)} value={numberValue(data.shower_alert_trigger)}
@@ -830,15 +776,13 @@ const ApplicationSettings = () => {
disabled={!data.shower_timer} disabled={!data.shower_timer}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="shower_alert_coldshot" name="shower_alert_coldshot"
label={LL.COLD_SHOT_DURATION()} label={LL.COLD_SHOT_DURATION()}
InputProps={{ slotProps={{
endAdornment: ( input: SecondsInputProps
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}} }}
variant="outlined" variant="outlined"
value={numberValue(data.shower_alert_coldshot)} value={numberValue(data.shower_alert_coldshot)}

View File

@@ -5,12 +5,12 @@ import WarningIcon from '@mui/icons-material/Warning';
import { import {
Button, Button,
Checkbox, Checkbox,
Grid,
InputAdornment, InputAdornment,
MenuItem, MenuItem,
TextField, TextField,
Typography Typography
} from '@mui/material'; } from '@mui/material';
import Grid from '@mui/material/Grid2';
import * as MqttApi from 'api/mqtt'; import * as MqttApi from 'api/mqtt';
@@ -59,6 +59,10 @@ const MqttSettings = () => {
updateDataValue updateDataValue
); );
const SecondsInputProps = {
endAdornment: <InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
};
const content = () => { const content = () => {
if (!data) { if (!data) {
return <FormLoader onRetry={loadData} errorMessage={errorMessage} />; return <FormLoader onRetry={loadData} errorMessage={errorMessage} />;
@@ -86,19 +90,12 @@ const MqttSettings = () => {
} }
label={LL.ENABLE_MQTT()} label={LL.ENABLE_MQTT()}
/> />
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6}>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="host" name="host"
label={LL.ADDRESS_OF(LL.BROKER())} label={LL.ADDRESS_OF(LL.BROKER())}
fullWidth
multiline multiline
variant="outlined" variant="outlined"
value={data.host} value={data.host}
@@ -106,12 +103,11 @@ const MqttSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="port" name="port"
label="Port" label="Port"
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.port)} value={numberValue(data.port)}
type="number" type="number"
@@ -119,62 +115,55 @@ const MqttSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="base" name="base"
label={LL.BASE_TOPIC()} label={LL.BASE_TOPIC()}
fullWidth
variant="outlined" variant="outlined"
value={data.base} value={data.base}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<TextField <TextField
name="client_id" name="client_id"
label={LL.ID_OF(LL.CLIENT()) + ' (' + LL.OPTIONAL() + ')'} label={LL.ID_OF(LL.CLIENT()) + ' (' + LL.OPTIONAL() + ')'}
fullWidth
variant="outlined" variant="outlined"
value={data.client_id} value={data.client_id}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<TextField <TextField
name="username" name="username"
label={LL.USERNAME(0)} label={LL.USERNAME(0)}
fullWidth
variant="outlined" variant="outlined"
value={data.username} value={data.username}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedPasswordField <ValidatedPasswordField
name="password" name="password"
label={LL.PASSWORD()} label={LL.PASSWORD()}
fullWidth
variant="outlined" variant="outlined"
value={data.password} value={data.password}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="keep_alive" name="keep_alive"
label="Keep Alive" label="Keep Alive"
InputProps={{ slotProps={{
endAdornment: ( input: SecondsInputProps
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}} }}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.keep_alive)} value={numberValue(data.keep_alive)}
type="number" type="number"
@@ -182,12 +171,11 @@ const MqttSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid>
<TextField <TextField
name="mqtt_qos" name="mqtt_qos"
label="QoS" label="QoS"
value={data.mqtt_qos} value={data.mqtt_qos}
fullWidth
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
@@ -215,14 +203,12 @@ const MqttSettings = () => {
<ValidatedPasswordField <ValidatedPasswordField
name="rootCA" name="rootCA"
label={LL.CERT()} label={LL.CERT()}
fullWidth
variant="outlined" variant="outlined"
value={data.rootCA} value={data.rootCA}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
/> />
)} )}
<BlockFormControlLabel <BlockFormControlLabel
control={ control={
<Checkbox <Checkbox
@@ -243,7 +229,6 @@ const MqttSettings = () => {
} }
label={LL.MQTT_RETAIN_FLAG()} label={LL.MQTT_RETAIN_FLAG()}
/> />
<Typography sx={{ pt: 2 }} variant="h6" color="primary"> <Typography sx={{ pt: 2 }} variant="h6" color="primary">
{LL.FORMATTING()} {LL.FORMATTING()}
</Typography> </Typography>
@@ -251,7 +236,6 @@ const MqttSettings = () => {
name="nested_format" name="nested_format"
label={LL.MQTT_FORMAT()} label={LL.MQTT_FORMAT()}
value={data.nested_format} value={data.nested_format}
fullWidth
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
@@ -271,15 +255,8 @@ const MqttSettings = () => {
label={LL.MQTT_RESPONSE()} label={LL.MQTT_RESPONSE()}
/> />
{!data.ha_enabled && ( {!data.ha_enabled && (
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
rowSpacing={-1}
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item>
<BlockFormControlLabel <BlockFormControlLabel
control={ control={
<Checkbox <Checkbox
@@ -292,7 +269,7 @@ const MqttSettings = () => {
/> />
</Grid> </Grid>
{data.publish_single && ( {data.publish_single && (
<Grid item> <Grid>
<BlockFormControlLabel <BlockFormControlLabel
control={ control={
<Checkbox <Checkbox
@@ -308,14 +285,8 @@ const MqttSettings = () => {
</Grid> </Grid>
)} )}
{!data.publish_single && ( {!data.publish_single && (
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item>
<BlockFormControlLabel <BlockFormControlLabel
control={ control={
<Checkbox <Checkbox
@@ -328,20 +299,12 @@ const MqttSettings = () => {
/> />
</Grid> </Grid>
{data.ha_enabled && ( {data.ha_enabled && (
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
sx={{ pl: 1 }}
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6} md={4}>
<TextField <TextField
name="discovery_type" name="discovery_type"
label={LL.MQTT_PUBLISH_TEXT_5()} label={LL.MQTT_PUBLISH_TEXT_5()}
value={data.discovery_type} value={data.discovery_type}
fullWidth
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
@@ -352,23 +315,21 @@ const MqttSettings = () => {
<MenuItem value={2}>Domoticz (latest)</MenuItem> <MenuItem value={2}>Domoticz (latest)</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="discovery_prefix" name="discovery_prefix"
label={LL.MQTT_PUBLISH_TEXT_4()} label={LL.MQTT_PUBLISH_TEXT_4()}
fullWidth
variant="outlined" variant="outlined"
value={data.discovery_prefix} value={data.discovery_prefix}
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="entity_format" name="entity_format"
label={LL.MQTT_ENTITY_FORMAT()} label={LL.MQTT_ENTITY_FORMAT()}
value={data.entity_format} value={data.entity_format}
fullWidth
variant="outlined" variant="outlined"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
@@ -392,24 +353,15 @@ const MqttSettings = () => {
<Typography sx={{ pt: 2 }} variant="h6" color="primary"> <Typography sx={{ pt: 2 }} variant="h6" color="primary">
{LL.MQTT_PUBLISH_INTERVALS()}&nbsp;(0=auto) {LL.MQTT_PUBLISH_INTERVALS()}&nbsp;(0=auto)
</Typography> </Typography>
<Grid <Grid container spacing={1} rowSpacing={0}>
container <Grid>
spacing={1}
direction="row"
justifyContent="flex-start"
alignItems="flex-start"
>
<Grid item xs={12} sm={6} md={4}>
<ValidatedTextField <ValidatedTextField
fieldErrors={fieldErrors} fieldErrors={fieldErrors}
name="publish_time_heartbeat" name="publish_time_heartbeat"
label="Heartbeat" label="Heartbeat"
InputProps={{ slotProps={{
endAdornment: ( input: SecondsInputProps
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}} }}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_heartbeat)} value={numberValue(data.publish_time_heartbeat)}
type="number" type="number"
@@ -417,127 +369,105 @@ const MqttSettings = () => {
margin="normal" margin="normal"
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="publish_time_boiler" name="publish_time_boiler"
label={LL.MQTT_INT_BOILER()} label={LL.MQTT_INT_BOILER()}
InputProps={{
endAdornment: (
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_boiler)} value={numberValue(data.publish_time_boiler)}
type="number" type="number"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
slotProps={{
input: SecondsInputProps
}}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="publish_time_thermostat" name="publish_time_thermostat"
label={LL.MQTT_INT_THERMOSTATS()} label={LL.MQTT_INT_THERMOSTATS()}
InputProps={{
endAdornment: (
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_thermostat)} value={numberValue(data.publish_time_thermostat)}
type="number" type="number"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
slotProps={{
input: SecondsInputProps
}}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="publish_time_solar" name="publish_time_solar"
label={LL.MQTT_INT_SOLAR()} label={LL.MQTT_INT_SOLAR()}
InputProps={{
endAdornment: (
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_solar)} value={numberValue(data.publish_time_solar)}
type="number" type="number"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
slotProps={{
input: SecondsInputProps
}}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="publish_time_mixer" name="publish_time_mixer"
label={LL.MQTT_INT_MIXER()} label={LL.MQTT_INT_MIXER()}
InputProps={{
endAdornment: (
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_mixer)} value={numberValue(data.publish_time_mixer)}
type="number" type="number"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
slotProps={{
input: SecondsInputProps
}}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="publish_time_water" name="publish_time_water"
label={LL.MQTT_INT_WATER()} label={LL.MQTT_INT_WATER()}
InputProps={{
endAdornment: (
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_water)} value={numberValue(data.publish_time_water)}
type="number" type="number"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
slotProps={{
input: SecondsInputProps
}}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="publish_time_sensor" name="publish_time_sensor"
label={LL.TEMP_SENSORS()} label={LL.TEMP_SENSORS()}
InputProps={{
endAdornment: (
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_sensor)} value={numberValue(data.publish_time_sensor)}
type="number" type="number"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
slotProps={{
input: SecondsInputProps
}}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={6} md={4}> <Grid>
<TextField <TextField
name="publish_time_other" name="publish_time_other"
InputProps={{
endAdornment: (
<InputAdornment position="end">{LL.SECONDS()}</InputAdornment>
)
}}
label={LL.DEFAULT(0)} label={LL.DEFAULT(0)}
fullWidth
variant="outlined" variant="outlined"
value={numberValue(data.publish_time_other)} value={numberValue(data.publish_time_other)}
type="number" type="number"
onChange={updateFormValue} onChange={updateFormValue}
margin="normal" margin="normal"
slotProps={{
input: SecondsInputProps
}}
/> />
</Grid> </Grid>
</Grid> </Grid>
{dirtyFlags && dirtyFlags.length !== 0 && ( {dirtyFlags && dirtyFlags.length !== 0 && (
<ButtonRow> <ButtonRow>
<Button <Button

View File

@@ -134,8 +134,10 @@ const NTPStatus = () => {
onChange={updateLocalTime} onChange={updateLocalTime}
disabled={processing} disabled={processing}
fullWidth fullWidth
InputLabelProps={{ slotProps={{
shrink: true inputLabel: {
shrink: true
}
}} }}
/> />
</DialogContent> </DialogContent>

View File

@@ -3,15 +3,8 @@ import { toast } from 'react-toastify';
import DownloadIcon from '@mui/icons-material/GetApp'; import DownloadIcon from '@mui/icons-material/GetApp';
import WarningIcon from '@mui/icons-material/Warning'; import WarningIcon from '@mui/icons-material/Warning';
import { import { Box, Button, Checkbox, MenuItem, TextField, styled } from '@mui/material';
Box, import Grid from '@mui/material/Grid2';
Button,
Checkbox,
Grid,
MenuItem,
TextField,
styled
} from '@mui/material';
import * as SystemApi from 'api/system'; import * as SystemApi from 'api/system';
import { fetchLogES } from 'api/system'; import { fetchLogES } from 'api/system';
@@ -177,14 +170,8 @@ const SystemLog = () => {
return ( return (
<> <>
<Grid <Grid container spacing={1} alignItems="center">
container <Grid size={2}>
spacing={3}
direction="row"
justifyContent="flex-start"
alignItems="center"
>
<Grid item xs={4}>
<TextField <TextField
name="level" name="level"
label={LL.LOG_LEVEL()} label={LL.LOG_LEVEL()}
@@ -203,7 +190,7 @@ const SystemLog = () => {
<MenuItem value={9}>ALL</MenuItem> <MenuItem value={9}>ALL</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={4}> <Grid size={2}>
<TextField <TextField
name="max_messages" name="max_messages"
label={LL.BUFFER_SIZE()} label={LL.BUFFER_SIZE()}
@@ -220,7 +207,7 @@ const SystemLog = () => {
<MenuItem value={100}>100</MenuItem> <MenuItem value={100}>100</MenuItem>
</TextField> </TextField>
</Grid> </Grid>
<Grid item xs={2}> <Grid>
<BlockFormControlLabel <BlockFormControlLabel
control={ control={
<Checkbox <Checkbox
@@ -232,32 +219,24 @@ const SystemLog = () => {
label={LL.COMPACT()} label={LL.COMPACT()}
/> />
</Grid> </Grid>
<Box <Button
sx={{ startIcon={<DownloadIcon />}
'& button, & a, & .MuiCard-root': { variant="outlined"
ml: 3 color="secondary"
} onClick={onDownload}
}}
> >
{LL.EXPORT()}
</Button>
{dirtyFlags && dirtyFlags.length !== 0 && (
<Button <Button
startIcon={<DownloadIcon />} startIcon={<WarningIcon color="warning" />}
variant="outlined" variant="contained"
color="secondary" color="info"
onClick={onDownload} onClick={saveSettings}
> >
{LL.EXPORT()} {LL.APPLY_CHANGES(dirtyFlags.length)}
</Button> </Button>
{dirtyFlags && dirtyFlags.length !== 0 && ( )}
<Button
startIcon={<WarningIcon color="warning" />}
variant="contained"
color="info"
onClick={saveSettings}
>
{LL.APPLY_CHANGES(dirtyFlags.length)}
</Button>
)}
</Box>
</Grid> </Grid>
<Box <Box
sx={{ sx={{

View File

@@ -10,25 +10,23 @@ import type { ValidatedTextFieldProps } from './ValidatedTextField';
type ValidatedPasswordFieldProps = Omit<ValidatedTextFieldProps, 'type'>; type ValidatedPasswordFieldProps = Omit<ValidatedTextFieldProps, 'type'>;
const ValidatedPasswordField: FC<ValidatedPasswordFieldProps> = ({ const ValidatedPasswordField: FC<ValidatedPasswordFieldProps> = ({ ...props }) => {
InputProps,
...props
}) => {
const [showPassword, setShowPassword] = useState<boolean>(false); const [showPassword, setShowPassword] = useState<boolean>(false);
return ( return (
<ValidatedTextField <ValidatedTextField
{...props} {...props}
type={showPassword ? 'text' : 'password'} type={showPassword ? 'text' : 'password'}
InputProps={{ slotProps={{
...InputProps, input: {
endAdornment: ( endAdornment: (
<InputAdornment position="end"> <InputAdornment position="end">
<IconButton onClick={() => setShowPassword(!showPassword)} edge="end"> <IconButton onClick={() => setShowPassword(!showPassword)} edge="end">
{showPassword ? <VisibilityIcon /> : <VisibilityOffIcon />} {showPassword ? <VisibilityIcon /> : <VisibilityOffIcon />}
</IconButton> </IconButton>
</InputAdornment> </InputAdornment>
) )
}
}} }}
/> />
); );

View File

@@ -88,7 +88,7 @@ const SingleUpload = ({ callRestart }) => {
sx={{ ml: 2, mt: 2 }} sx={{ ml: 2, mt: 2 }}
startIcon={<CancelIcon />} startIcon={<CancelIcon />}
variant="outlined" variant="outlined"
color="error" color="secondary"
onClick={cancelUpload} onClick={cancelUpload}
> >
{LL.CANCEL()} {LL.CANCEL()}