mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add set all enabled button
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
|||||||
ValidatedPasswordField,
|
ValidatedPasswordField,
|
||||||
ValidatedTextField
|
ValidatedTextField
|
||||||
} from '../../components';
|
} from '../../components';
|
||||||
|
|
||||||
import { APProvisionMode, APSettings } from '../../types';
|
import { APProvisionMode, APSettings } from '../../types';
|
||||||
import { numberValue, updateValue, useRest } from '../../utils';
|
import { numberValue, updateValue, useRest } from '../../utils';
|
||||||
import * as APApi from '../../api/ap';
|
import * as APApi from '../../api/ap';
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
ToggleButton,
|
ToggleButton,
|
||||||
ToggleButtonGroup,
|
ToggleButtonGroup,
|
||||||
Tooltip
|
Tooltip,
|
||||||
|
Grid
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
import { Table } from '@table-library/react-table-library/table';
|
import { Table } from '@table-library/react-table-library/table';
|
||||||
@@ -37,7 +38,7 @@ import * as EMSESP from './api';
|
|||||||
|
|
||||||
import { extractErrorMessage } from '../utils';
|
import { extractErrorMessage } from '../utils';
|
||||||
|
|
||||||
import { DeviceShort, Devices, DeviceEntity } from './types';
|
import { DeviceShort, Devices, DeviceEntity, DeviceEntityMask } from './types';
|
||||||
|
|
||||||
const SettingsCustomization: FC = () => {
|
const SettingsCustomization: FC = () => {
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
@@ -286,10 +287,28 @@ const SettingsCustomization: FC = () => {
|
|||||||
return new_masks;
|
return new_masks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const maskDisabled = (set: boolean) => {
|
||||||
|
setDeviceEntities(
|
||||||
|
deviceEntities
|
||||||
|
.filter((de) => de.m & selectedFilters || !selectedFilters)
|
||||||
|
.map(({ m, ...entities }) => ({
|
||||||
|
...entities,
|
||||||
|
m: set
|
||||||
|
? m | (DeviceEntityMask.DV_API_MQTT_EXCLUDE | DeviceEntityMask.DV_WEB_EXCLUDE)
|
||||||
|
: m & ~(DeviceEntityMask.DV_API_MQTT_EXCLUDE | DeviceEntityMask.DV_WEB_EXCLUDE)
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="center">
|
||||||
|
<Grid item>
|
||||||
<Typography sx={{ pt: 1, pb: 1 }} variant="subtitle2" color="primary">
|
<Typography sx={{ pt: 1, pb: 1 }} variant="subtitle2" color="primary">
|
||||||
Apply filter:
|
Apply filter:
|
||||||
|
</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item>
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
size="small"
|
size="small"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@@ -319,7 +338,18 @@ const SettingsCustomization: FC = () => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</ToggleButtonGroup>
|
</ToggleButtonGroup>
|
||||||
</Typography>
|
</Grid>
|
||||||
|
<Grid item>
|
||||||
|
<Button size="small" variant="contained" color="primary" onClick={() => maskDisabled(true)}>
|
||||||
|
set all disabled
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
<Grid item>
|
||||||
|
<Button size="small" variant="contained" color="primary" onClick={() => maskDisabled(false)}>
|
||||||
|
set all enabled
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
<Table
|
<Table
|
||||||
data={{ nodes: deviceEntities.filter((de) => de.m & selectedFilters || !selectedFilters) }}
|
data={{ nodes: deviceEntities.filter((de) => de.m & selectedFilters || !selectedFilters) }}
|
||||||
theme={entities_theme}
|
theme={entities_theme}
|
||||||
@@ -401,7 +431,7 @@ const SettingsCustomization: FC = () => {
|
|||||||
<Dialog open={confirmReset} onClose={() => setConfirmReset(false)}>
|
<Dialog open={confirmReset} onClose={() => setConfirmReset(false)}>
|
||||||
<DialogTitle>Reset</DialogTitle>
|
<DialogTitle>Reset</DialogTitle>
|
||||||
<DialogContent dividers>
|
<DialogContent dividers>
|
||||||
Are you sure you want remove all customizations? EMS-ESP will then restart.
|
Are you sure you want remove all customizations including the settings of Temperature and Analog sensors?
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button startIcon={<CancelIcon />} variant="outlined" onClick={() => setConfirmReset(false)} color="secondary">
|
<Button startIcon={<CancelIcon />} variant="outlined" onClick={() => setConfirmReset(false)} color="secondary">
|
||||||
|
|||||||
Reference in New Issue
Block a user