add style to Dialog boxes

This commit is contained in:
Proddy
2023-08-08 10:35:55 +02:00
parent 643b42469e
commit ff68d23642
16 changed files with 55 additions and 31 deletions

View File

@@ -1,10 +1,19 @@
import { CssBaseline } from '@mui/material'; import { CssBaseline } from '@mui/material';
import { blueGrey, blue } from '@mui/material/colors';
import { createTheme, responsiveFontSizes, ThemeProvider } from '@mui/material/styles'; import { createTheme, responsiveFontSizes, ThemeProvider } from '@mui/material/styles';
import type { FC } from 'react'; import type { FC } from 'react';
import type { RequiredChildrenProps } from 'utils'; import type { RequiredChildrenProps } from 'utils';
export const dialogStyle = {
'& .MuiDialog-paper': {
borderRadius: '8px',
borderColor: '#565656',
borderStyle: 'solid',
borderWidth: '1px'
},
backdropFilter: 'blur(1px)'
};
const theme = responsiveFontSizes( const theme = responsiveFontSizes(
createTheme({ createTheme({
typography: { typography: {
@@ -13,10 +22,10 @@ const theme = responsiveFontSizes(
palette: { palette: {
mode: 'dark', mode: 'dark',
secondary: { secondary: {
main: blue[500] main: '#2196f3' // blue[500]
}, },
info: { info: {
main: blueGrey[500] main: '#607d8b' // blueGrey[500]
} }
} }
}) })

View File

@@ -3,6 +3,7 @@ import type { FC } from 'react';
import type { unstable_Blocker as Blocker } from 'react-router-dom'; import type { unstable_Blocker as Blocker } from 'react-router-dom';
import { dialogStyle } from 'CustomTheme';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
interface BlockNavigationProps { interface BlockNavigationProps {
@@ -13,7 +14,7 @@ const BlockNavigation: FC<BlockNavigationProps> = ({ blocker }) => {
const { LL } = useI18nContext(); const { LL } = useI18nContext();
return ( return (
<Dialog open={blocker.state === 'blocked'}> <Dialog sx={dialogStyle} open={blocker.state === 'blocked'}>
<DialogTitle>{LL.BLOCK_NAVIGATE_1()}</DialogTitle> <DialogTitle>{LL.BLOCK_NAVIGATE_1()}</DialogTitle>
<DialogContent dividers>{LL.BLOCK_NAVIGATE_2()}</DialogContent> <DialogContent dividers>{LL.BLOCK_NAVIGATE_2()}</DialogContent>
<DialogActions> <DialogActions>

View File

@@ -28,6 +28,7 @@ import type { Theme } from '@mui/material';
import type { FC } from 'react'; import type { FC } from 'react';
import type { NTPStatus } from 'types'; import type { NTPStatus } from 'types';
import { dialogStyle } from 'CustomTheme';
import * as NTPApi from 'api/ntp'; import * as NTPApi from 'api/ntp';
import { ButtonRow, FormLoader, SectionContent } from 'components'; import { ButtonRow, FormLoader, SectionContent } from 'components';
import { AuthenticatedContext } from 'contexts/authentication'; import { AuthenticatedContext } from 'contexts/authentication';
@@ -108,7 +109,7 @@ const NTPStatusForm: FC = () => {
}; };
const renderSetTimeDialog = () => ( const renderSetTimeDialog = () => (
<Dialog open={settingTime} onClose={() => setSettingTime(false)}> <Dialog sx={dialogStyle} open={settingTime} onClose={() => setSettingTime(false)}>
<DialogTitle>{LL.SET_TIME(1)}</DialogTitle> <DialogTitle>{LL.SET_TIME(1)}</DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<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}>

View File

@@ -14,6 +14,7 @@ import { useRequest } from 'alova';
import { useEffect } from 'react'; import { useEffect } from 'react';
import type { FC } from 'react'; import type { FC } from 'react';
import { dialogStyle } from 'CustomTheme';
import * as SecurityApi from 'api/security'; import * as SecurityApi from 'api/security';
import { MessageBox } from 'components'; import { MessageBox } from 'components';
@@ -39,8 +40,8 @@ const GenerateToken: FC<GenerateTokenProps> = ({ username, onClose }) => {
}, [open, generateToken]); }, [open, generateToken]);
return ( return (
<Dialog onClose={onClose} aria-labelledby="generate-token-dialog-title" open={!!username} fullWidth maxWidth="sm"> <Dialog sx={dialogStyle} onClose={onClose} open={!!username} fullWidth maxWidth="sm">
<DialogTitle id="generate-token-dialog-title">{LL.ACCESS_TOKEN_FOR() + ' ' + username}</DialogTitle> <DialogTitle>{LL.ACCESS_TOKEN_FOR() + ' ' + username}</DialogTitle>
<DialogContent dividers> <DialogContent dividers>
{token ? ( {token ? (
<> <>

View File

@@ -9,6 +9,7 @@ import type { ValidateFieldsError } from 'async-validator';
import type { FC } from 'react'; import type { FC } from 'react';
import type { User } from 'types'; import type { User } from 'types';
import { dialogStyle } from 'CustomTheme';
import { BlockFormControlLabel, ValidatedPasswordField, ValidatedTextField } from 'components'; import { BlockFormControlLabel, ValidatedPasswordField, ValidatedTextField } from 'components';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
import { updateValue } from 'utils'; import { updateValue } from 'utils';
@@ -51,7 +52,7 @@ const UserForm: FC<UserFormProps> = ({ creating, validator, user, setUser, onDon
}; };
return ( return (
<Dialog onClose={onCancelEditing} open={!!user} fullWidth maxWidth="sm"> <Dialog sx={dialogStyle} onClose={onCancelEditing} open={!!user} fullWidth maxWidth="sm">
{user && ( {user && (
<> <>
<DialogTitle id="user-form-dialog-title"> <DialogTitle id="user-form-dialog-title">

View File

@@ -34,6 +34,7 @@ import RestartMonitor from './RestartMonitor';
import SystemStatusVersionDialog from './SystemStatusVersionDialog'; import SystemStatusVersionDialog from './SystemStatusVersionDialog';
import type { FC } from 'react'; import type { FC } from 'react';
import { dialogStyle } from 'CustomTheme';
import * as SystemApi from 'api/system'; import * as SystemApi from 'api/system';
import { ButtonRow, FormLoader, SectionContent } from 'components'; import { ButtonRow, FormLoader, SectionContent } from 'components';
import { AuthenticatedContext } from 'contexts/authentication'; import { AuthenticatedContext } from 'contexts/authentication';
@@ -115,7 +116,7 @@ const SystemStatusForm: FC = () => {
}; };
const renderRestartDialog = () => ( const renderRestartDialog = () => (
<Dialog open={confirmRestart} onClose={() => setConfirmRestart(false)}> <Dialog sx={dialogStyle} open={confirmRestart} onClose={() => setConfirmRestart(false)}>
<DialogTitle>{LL.RESTART()}</DialogTitle> <DialogTitle>{LL.RESTART()}</DialogTitle>
<DialogContent dividers>{LL.RESTART_CONFIRM()}</DialogContent> <DialogContent dividers>{LL.RESTART_CONFIRM()}</DialogContent>
<DialogActions> <DialogActions>
@@ -153,7 +154,7 @@ const SystemStatusForm: FC = () => {
); );
const renderFactoryResetDialog = () => ( const renderFactoryResetDialog = () => (
<Dialog open={confirmFactoryReset} onClose={() => setConfirmFactoryReset(false)}> <Dialog sx={dialogStyle} open={confirmFactoryReset} onClose={() => setConfirmFactoryReset(false)}>
<DialogTitle>{LL.FACTORY_RESET()}</DialogTitle> <DialogTitle>{LL.FACTORY_RESET()}</DialogTitle>
<DialogContent dividers>{LL.SYSTEM_FACTORY_TEXT_DIALOG()}</DialogContent> <DialogContent dividers>{LL.SYSTEM_FACTORY_TEXT_DIALOG()}</DialogContent>
<DialogActions> <DialogActions>

View File

@@ -1,6 +1,7 @@
import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Link, Typography } from '@mui/material'; import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Link, Typography } from '@mui/material';
import { useRequest } from 'alova'; import { useRequest } from 'alova';
import { useCallback, useEffect } from 'react'; import { useCallback, useEffect } from 'react';
import { dialogStyle } from 'CustomTheme';
import * as SystemApi from 'api/system'; import * as SystemApi from 'api/system';
import MessageBox from 'components/MessageBox'; import MessageBox from 'components/MessageBox';
@@ -49,7 +50,7 @@ const SystemStatusVersionDialog = ({ open, onClose, version, platform }: SystemS
const getBinURL = (v: string) => 'EMS-ESP-' + v.replaceAll('.', '_') + '-' + platform.replaceAll('-', '_') + '.bin'; const getBinURL = (v: string) => 'EMS-ESP-' + v.replaceAll('.', '_') + '-' + platform.replaceAll('-', '_') + '.bin';
return ( return (
<Dialog open={open} onClose={onClose}> <Dialog sx={dialogStyle} open={open} onClose={onClose}>
<DialogTitle>{LL.VERSION_CHECK(1)}</DialogTitle> <DialogTitle>{LL.VERSION_CHECK(1)}</DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<MessageBox my={0} level="info" message={LL.VERSION_ON() + ' ' + version + ' (' + platform + ')'} /> <MessageBox my={0} level="info" message={LL.VERSION_ON() + ' ' + version + ' (' + platform + ')'} />

View File

@@ -45,6 +45,7 @@ import { DeviceValueUOM_s, DeviceEntityMask, DeviceType } from './types';
import { deviceValueItemValidation } from './validators'; import { deviceValueItemValidation } from './validators';
import type { Device, DeviceValue } from './types'; import type { Device, DeviceValue } from './types';
import type { FC } from 'react'; import type { FC } from 'react';
import { dialogStyle } from 'CustomTheme';
import { ButtonRow, SectionContent, MessageBox } from 'components'; import { ButtonRow, SectionContent, MessageBox } from 'components';
import { AuthenticatedContext } from 'contexts/authentication'; import { AuthenticatedContext } from 'contexts/authentication';
@@ -361,7 +362,7 @@ const DashboardDevices: FC = () => {
} }
return ( return (
<Dialog open={showDeviceInfo} onClose={() => setShowDeviceInfo(false)}> <Dialog sx={dialogStyle} open={showDeviceInfo} onClose={() => setShowDeviceInfo(false)}>
<DialogTitle>{LL.DEVICE_DETAILS()}</DialogTitle> <DialogTitle>{LL.DEVICE_DETAILS()}</DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<List dense={true}> <List dense={true}>

View File

@@ -16,7 +16,6 @@ import {
Typography, Typography,
CircularProgress CircularProgress
} from '@mui/material'; } from '@mui/material';
import { green } from '@mui/material/colors';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { DeviceValueUOM, DeviceValueUOM_s } from './types'; import { DeviceValueUOM, DeviceValueUOM_s } from './types';
@@ -24,12 +23,23 @@ import type { DeviceValue } from './types';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
import type { ValidateFieldsError } from 'async-validator'; import type { ValidateFieldsError } from 'async-validator';
import { dialogStyle } from 'CustomTheme';
import { ValidatedTextField } from 'components'; import { ValidatedTextField } from 'components';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
import { updateValue } from 'utils'; import { updateValue } from 'utils';
import { validate } from 'validators'; import { validate } from 'validators';
// const dialogStyle = {
// '& .MuiDialog-paper': {
// borderRadius: '8px',
// borderColor: '#565656',
// borderStyle: 'solid',
// borderWidth: '1px'
// },
// backdropFilter: 'blur(1px)'
// };
type DashboardDevicesDialogProps = { type DashboardDevicesDialogProps = {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
@@ -112,16 +122,7 @@ const DashboardDevicesDialog = ({
}; };
return ( return (
<Dialog <Dialog sx={dialogStyle} open={open} onClose={close}>
open={open}
onClose={close}
sx={{
'& .MuiDialog-paper': {
borderRadius: '12px'
},
backdropFilter: 'blur(1px)'
}}
>
<DialogTitle> <DialogTitle>
{selectedItem.v === '' && selectedItem.c ? LL.RUN_COMMAND() : writeable ? LL.CHANGE_VALUE() : LL.VALUE(0)} {selectedItem.v === '' && selectedItem.c ? LL.RUN_COMMAND() : writeable ? LL.CHANGE_VALUE() : LL.VALUE(0)}
</DialogTitle> </DialogTitle>
@@ -206,7 +207,7 @@ const DashboardDevicesDialog = ({
<CircularProgress <CircularProgress
size={24} size={24}
sx={{ sx={{
color: green[500], color: '#4caf50',
position: 'absolute', position: 'absolute',
right: '20%', right: '20%',
marginTop: '6px' marginTop: '6px'

View File

@@ -21,6 +21,7 @@ import { AnalogType, AnalogTypeNames, DeviceValueUOM_s } from './types';
import type { AnalogSensor } from './types'; import type { AnalogSensor } from './types';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
import type { ValidateFieldsError } from 'async-validator'; import type { ValidateFieldsError } from 'async-validator';
import { dialogStyle } from 'CustomTheme';
import { ValidatedTextField } from 'components'; import { ValidatedTextField } from 'components';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
@@ -77,7 +78,7 @@ const DashboardSensorsAnalogDialog = ({
}; };
return ( return (
<Dialog open={open} onClose={close}> <Dialog sx={dialogStyle} open={open} onClose={close}>
<DialogTitle> <DialogTitle>
{creating ? LL.ADD(1) + ' ' + LL.NEW(0) : LL.EDIT()}&nbsp;{LL.ANALOG_SENSOR(0)} {creating ? LL.ADD(1) + ' ' + LL.NEW(0) : LL.EDIT()}&nbsp;{LL.ANALOG_SENSOR(0)}
</DialogTitle> </DialogTitle>

View File

@@ -18,6 +18,7 @@ import { useState, useEffect } from 'react';
import type { TemperatureSensor } from './types'; import type { TemperatureSensor } from './types';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
import type { ValidateFieldsError } from 'async-validator'; import type { ValidateFieldsError } from 'async-validator';
import { dialogStyle } from 'CustomTheme';
import { ValidatedTextField } from 'components'; import { ValidatedTextField } from 'components';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
@@ -67,7 +68,7 @@ const DashboardSensorsTemperatureDialog = ({
}; };
return ( return (
<Dialog open={open} onClose={close}> <Dialog sx={dialogStyle} open={open} onClose={close}>
<DialogTitle> <DialogTitle>
{LL.EDIT()}&nbsp;{LL.TEMP_SENSOR()} {LL.EDIT()}&nbsp;{LL.TEMP_SENSOR()}
</DialogTitle> </DialogTitle>

View File

@@ -30,6 +30,7 @@ import type { Theme } from '@mui/material';
import type { Translation } from 'i18n/i18n-types'; import type { Translation } from 'i18n/i18n-types';
import type { FC } from 'react'; import type { FC } from 'react';
import { dialogStyle } from 'CustomTheme';
import { ButtonRow, FormLoader, SectionContent } from 'components'; import { ButtonRow, FormLoader, SectionContent } from 'components';
import { AuthenticatedContext } from 'contexts/authentication'; import { AuthenticatedContext } from 'contexts/authentication';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
@@ -173,7 +174,7 @@ const DashboardStatus: FC = () => {
}; };
const renderScanDialog = () => ( const renderScanDialog = () => (
<Dialog open={confirmScan} onClose={() => setConfirmScan(false)}> <Dialog sx={dialogStyle} open={confirmScan} onClose={() => setConfirmScan(false)}>
<DialogTitle>{LL.SCAN_DEVICES()}</DialogTitle> <DialogTitle>{LL.SCAN_DEVICES()}</DialogTitle>
<DialogContent dividers>{LL.EMS_SCAN()}</DialogContent> <DialogContent dividers>{LL.EMS_SCAN()}</DialogContent>
<DialogActions> <DialogActions>

View File

@@ -35,6 +35,7 @@ import * as EMSESP from './api';
import { DeviceEntityMask } from './types'; import { DeviceEntityMask } from './types';
import type { DeviceShort, DeviceEntity } from './types'; import type { DeviceShort, DeviceEntity } from './types';
import type { FC } from 'react'; import type { FC } from 'react';
import { dialogStyle } from 'CustomTheme';
import * as SystemApi from 'api/system'; import * as SystemApi from 'api/system';
import { ButtonRow, SectionContent, MessageBox, BlockNavigation } from 'components'; import { ButtonRow, SectionContent, MessageBox, BlockNavigation } from 'components';
@@ -484,7 +485,7 @@ const SettingsCustomization: FC = () => {
}; };
const renderResetDialog = () => ( const renderResetDialog = () => (
<Dialog open={confirmReset} onClose={() => setConfirmReset(false)}> <Dialog sx={dialogStyle} open={confirmReset} onClose={() => setConfirmReset(false)}>
<DialogTitle>{LL.RESET(1)}</DialogTitle> <DialogTitle>{LL.RESET(1)}</DialogTitle>
<DialogContent dividers>{LL.CUSTOMIZATIONS_RESET()}</DialogContent> <DialogContent dividers>{LL.CUSTOMIZATIONS_RESET()}</DialogContent>
<DialogActions> <DialogActions>

View File

@@ -18,6 +18,7 @@ import EntityMaskToggle from './EntityMaskToggle';
import { DeviceEntityMask } from './types'; import { DeviceEntityMask } from './types';
import type { DeviceEntity } from './types'; import type { DeviceEntity } from './types';
import { dialogStyle } from 'CustomTheme';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
import { updateValue } from 'utils'; import { updateValue } from 'utils';
@@ -63,7 +64,7 @@ const SettingsCustomizationDialog = ({ open, onClose, onSave, selectedItem }: Se
}; };
return ( return (
<Dialog open={open} onClose={close}> <Dialog sx={dialogStyle} open={open} onClose={close}>
<DialogTitle>{LL.EDIT() + ' ' + LL.ENTITY()}</DialogTitle> <DialogTitle>{LL.EDIT() + ' ' + LL.ENTITY()}</DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<Box color="warning.main"> <Box color="warning.main">

View File

@@ -22,6 +22,7 @@ import type { EntityItem } from './types';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
import type { ValidateFieldsError } from 'async-validator'; import type { ValidateFieldsError } from 'async-validator';
import { dialogStyle } from 'CustomTheme';
import { BlockFormControlLabel, ValidatedTextField } from 'components'; import { BlockFormControlLabel, ValidatedTextField } from 'components';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
@@ -90,7 +91,7 @@ const SettingsEntitiesDialog = ({
}; };
return ( return (
<Dialog open={open} onClose={close}> <Dialog sx={dialogStyle} open={open} onClose={close}>
<DialogTitle> <DialogTitle>
{creating ? LL.ADD(1) + ' ' + LL.NEW(1) : LL.EDIT()}&nbsp;{LL.ENTITY()} {creating ? LL.ADD(1) + ' ' + LL.NEW(1) : LL.EDIT()}&nbsp;{LL.ENTITY()}
</DialogTitle> </DialogTitle>

View File

@@ -25,6 +25,7 @@ import type { ScheduleItem } from './types';
import type Schema from 'async-validator'; import type Schema from 'async-validator';
import type { ValidateFieldsError } from 'async-validator'; import type { ValidateFieldsError } from 'async-validator';
import { dialogStyle } from 'CustomTheme';
import { BlockFormControlLabel, ValidatedTextField } from 'components'; import { BlockFormControlLabel, ValidatedTextField } from 'components';
import { useI18nContext } from 'i18n/i18n-react'; import { useI18nContext } from 'i18n/i18n-react';
@@ -129,7 +130,7 @@ const SettingsSchedulerDialog = ({
const isTimer = editItem.flags === ScheduleFlag.SCHEDULE_TIMER; const isTimer = editItem.flags === ScheduleFlag.SCHEDULE_TIMER;
return ( return (
<Dialog open={open} onClose={close}> <Dialog sx={dialogStyle} open={open} onClose={close}>
<DialogTitle> <DialogTitle>
{creating ? LL.ADD(1) + ' ' + LL.NEW(0) : LL.EDIT()}&nbsp;{LL.SCHEDULE(1)} {creating ? LL.ADD(1) + ' ' + LL.NEW(0) : LL.EDIT()}&nbsp;{LL.SCHEDULE(1)}
</DialogTitle> </DialogTitle>