added device type, inverterSN and dataloggerSN entries for sodistorehome in frontend
This commit is contained in:
parent
3795287124
commit
c182e773dd
|
|
@ -286,7 +286,7 @@ function InformationSalidomo(props: InformationSalidomoProps) {
|
||||||
marginLeft: 1,
|
marginLeft: 1,
|
||||||
marginTop: 1,
|
marginTop: 1,
|
||||||
marginBottom: 1,
|
marginBottom: 1,
|
||||||
width: 390
|
width: 440
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<InputLabel
|
<InputLabel
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,494 @@
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Box,
|
||||||
|
CardContent,
|
||||||
|
CircularProgress,
|
||||||
|
Container,
|
||||||
|
FormControl,
|
||||||
|
Grid,
|
||||||
|
IconButton,
|
||||||
|
InputLabel,
|
||||||
|
MenuItem,
|
||||||
|
Modal,
|
||||||
|
Select,
|
||||||
|
TextField,
|
||||||
|
Typography,
|
||||||
|
useTheme
|
||||||
|
} from '@mui/material';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import { Close as CloseIcon } from '@mui/icons-material';
|
||||||
|
import React, { useContext, useState } from 'react';
|
||||||
|
import { I_S3Credentials } from '../../../interfaces/S3Types';
|
||||||
|
import { I_Installation } from '../../../interfaces/InstallationTypes';
|
||||||
|
import { InstallationsContext } from '../../../contexts/InstallationsContextProvider';
|
||||||
|
import { UserContext } from '../../../contexts/userContext';
|
||||||
|
import routes from '../../../Resources/routes.json';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { UserType } from '../../../interfaces/UserTypes';
|
||||||
|
|
||||||
|
interface InformationSodistorehomeProps {
|
||||||
|
values: I_Installation;
|
||||||
|
s3Credentials: I_S3Credentials;
|
||||||
|
type?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
|
if (props.values === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const context = useContext(UserContext);
|
||||||
|
const { currentUser } = context;
|
||||||
|
const theme = useTheme();
|
||||||
|
const [formValues, setFormValues] = useState(props.values);
|
||||||
|
const requiredFields = ['name', 'region', 'location', 'country'];
|
||||||
|
const [openModalDeleteInstallation, setOpenModalDeleteInstallation] =
|
||||||
|
useState(false);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const DeviceTypes = [
|
||||||
|
{ id: 3, name: 'Growatt' },
|
||||||
|
{ id: 4, name: 'Sinexcel' }
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
const installationContext = useContext(InstallationsContext);
|
||||||
|
const {
|
||||||
|
updateInstallation,
|
||||||
|
deleteInstallation,
|
||||||
|
loading,
|
||||||
|
setLoading,
|
||||||
|
error,
|
||||||
|
setError,
|
||||||
|
updated,
|
||||||
|
setUpdated
|
||||||
|
} = installationContext;
|
||||||
|
|
||||||
|
const handleChange = (e) => {
|
||||||
|
const { name, value } = e.target;
|
||||||
|
setFormValues({
|
||||||
|
...formValues,
|
||||||
|
[name]: value
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const handleSubmit = () => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(false);
|
||||||
|
updateInstallation(formValues, props.type);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = () => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(false);
|
||||||
|
setOpenModalDeleteInstallation(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteInstallationModalHandle = () => {
|
||||||
|
setOpenModalDeleteInstallation(false);
|
||||||
|
deleteInstallation(formValues, props.type);
|
||||||
|
setLoading(false);
|
||||||
|
|
||||||
|
navigate(routes.salidomo_installations + routes.list, {
|
||||||
|
replace: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteInstallationModalHandleCancel = () => {
|
||||||
|
setOpenModalDeleteInstallation(false);
|
||||||
|
setLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const areRequiredFieldsFilled = () => {
|
||||||
|
for (const field of requiredFields) {
|
||||||
|
if (!formValues[field]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{openModalDeleteInstallation && (
|
||||||
|
<Modal
|
||||||
|
open={openModalDeleteInstallation}
|
||||||
|
onClose={deleteInstallationModalHandleCancel}
|
||||||
|
aria-labelledby="error-modal"
|
||||||
|
aria-describedby="error-modal-description"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
width: 350,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
borderRadius: 4,
|
||||||
|
boxShadow: 24,
|
||||||
|
p: 4,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
gutterBottom
|
||||||
|
sx={{ fontWeight: 'bold' }}
|
||||||
|
>
|
||||||
|
Do you want to delete this installation?
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: 10
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
sx={{
|
||||||
|
marginTop: 2,
|
||||||
|
textTransform: 'none',
|
||||||
|
bgcolor: '#ffc04d',
|
||||||
|
color: '#111111',
|
||||||
|
'&:hover': { bgcolor: '#f7b34d' }
|
||||||
|
}}
|
||||||
|
onClick={deleteInstallationModalHandle}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
sx={{
|
||||||
|
marginTop: 2,
|
||||||
|
marginLeft: 2,
|
||||||
|
textTransform: 'none',
|
||||||
|
bgcolor: '#ffc04d',
|
||||||
|
color: '#111111',
|
||||||
|
'&:hover': { bgcolor: '#f7b34d' }
|
||||||
|
}}
|
||||||
|
onClick={deleteInstallationModalHandleCancel}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Container maxWidth="xl">
|
||||||
|
<Grid
|
||||||
|
container
|
||||||
|
direction="row"
|
||||||
|
justifyContent="center"
|
||||||
|
alignItems="stretch"
|
||||||
|
spacing={3}
|
||||||
|
>
|
||||||
|
<Grid item xs={12} md={12}>
|
||||||
|
<CardContent>
|
||||||
|
<Box
|
||||||
|
component="form"
|
||||||
|
sx={{
|
||||||
|
'& .MuiTextField-root': { m: 1, width: '50ch' }
|
||||||
|
}}
|
||||||
|
noValidate
|
||||||
|
autoComplete="off"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="installation_name"
|
||||||
|
defaultMessage="Installation Name"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="name"
|
||||||
|
value={formValues.name}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage id="region" defaultMessage="Region" />
|
||||||
|
}
|
||||||
|
name="region"
|
||||||
|
value={formValues.region}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
required
|
||||||
|
error={formValues.region === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="location"
|
||||||
|
defaultMessage="Location"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="location"
|
||||||
|
value={formValues.location}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
required
|
||||||
|
error={formValues.location === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage id="country" defaultMessage="Country" />
|
||||||
|
}
|
||||||
|
name="country"
|
||||||
|
value={formValues.country}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
required
|
||||||
|
error={formValues.country === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage id="vpnip" defaultMessage="VPN IP" />
|
||||||
|
}
|
||||||
|
name="vpnIp"
|
||||||
|
value={formValues.vpnIp}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<FormControl
|
||||||
|
fullWidth
|
||||||
|
sx={{
|
||||||
|
marginLeft: 1,
|
||||||
|
marginTop: 1,
|
||||||
|
marginBottom: 1,
|
||||||
|
width: 440
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<InputLabel
|
||||||
|
sx={{
|
||||||
|
fontSize: 14,
|
||||||
|
backgroundColor: 'white'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="DeviceType"
|
||||||
|
defaultMessage="Device Type"
|
||||||
|
/>
|
||||||
|
</InputLabel>
|
||||||
|
<Select
|
||||||
|
name="device"
|
||||||
|
value={formValues.device}
|
||||||
|
onChange={handleChange}
|
||||||
|
>
|
||||||
|
{DeviceTypes.map((device) => (
|
||||||
|
<MenuItem key={device.id} value={device.id}>
|
||||||
|
{device.name}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="inverterSN"
|
||||||
|
defaultMessage="Inverter Serial Number"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="inverterSN"
|
||||||
|
value={formValues.inverterSN}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="dataloggerSN"
|
||||||
|
defaultMessage="Datalogger Serial Number"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="dataloggerSN"
|
||||||
|
value={formValues.dataloggerSN}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="information"
|
||||||
|
defaultMessage="Information"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="information"
|
||||||
|
value={formValues.information}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{currentUser.userType == UserType.admin && (
|
||||||
|
<>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label="S3 Bucket Name"
|
||||||
|
name="s3writesecretkey"
|
||||||
|
value={
|
||||||
|
formValues.s3BucketId +
|
||||||
|
'-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e'
|
||||||
|
}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label="S3 Write Key"
|
||||||
|
name="s3writesecretkey"
|
||||||
|
value={formValues.s3WriteKey}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label="S3 Write Secret Key"
|
||||||
|
name="s3writesecretkey"
|
||||||
|
value={formValues.s3WriteSecret}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: 10
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleSubmit}
|
||||||
|
sx={{
|
||||||
|
marginLeft: '10px'
|
||||||
|
}}
|
||||||
|
disabled={!areRequiredFieldsFilled()}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="applyChanges"
|
||||||
|
defaultMessage="Apply Changes"
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{currentUser.userType == UserType.admin && (
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleDelete}
|
||||||
|
sx={{
|
||||||
|
marginLeft: '10px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="deleteInstallation"
|
||||||
|
defaultMessage="Delete Installation"
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{loading && (
|
||||||
|
<CircularProgress
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
marginLeft: '20px'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{error && (
|
||||||
|
<Alert
|
||||||
|
severity="error"
|
||||||
|
sx={{
|
||||||
|
ml: 1,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="errorOccured"
|
||||||
|
defaultMessage="An error has occurred"
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
onClick={() => setError(false)}
|
||||||
|
sx={{ marginLeft: '4px' }}
|
||||||
|
>
|
||||||
|
<CloseIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{updated && (
|
||||||
|
<Alert
|
||||||
|
severity="success"
|
||||||
|
sx={{
|
||||||
|
ml: 1,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="successfullyUpdated"
|
||||||
|
defaultMessage="Successfully updated"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
onClick={() => setUpdated(false)} // Set error state to false on click
|
||||||
|
sx={{ marginLeft: '4px' }}
|
||||||
|
>
|
||||||
|
<CloseIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</CardContent>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Container>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default InformationSodistorehome;
|
||||||
|
|
@ -19,7 +19,7 @@ import HistoryOfActions from '../History/History';
|
||||||
import BuildIcon from '@mui/icons-material/Build';
|
import BuildIcon from '@mui/icons-material/Build';
|
||||||
import AccessContextProvider from '../../../contexts/AccessContextProvider';
|
import AccessContextProvider from '../../../contexts/AccessContextProvider';
|
||||||
import Access from '../ManageAccess/Access';
|
import Access from '../ManageAccess/Access';
|
||||||
import Information from '../Information/Information';
|
import InformationSodistorehome from '../Information/InformationSodistoreHome';
|
||||||
import { TimeSpan, UnixTime } from '../../../dataCache/time';
|
import { TimeSpan, UnixTime } from '../../../dataCache/time';
|
||||||
import { fetchDataJson } from '../Installations/fetchData';
|
import { fetchDataJson } from '../Installations/fetchData';
|
||||||
import { FetchResult } from '../../../dataCache/dataCache';
|
import { FetchResult } from '../../../dataCache/dataCache';
|
||||||
|
|
@ -413,11 +413,11 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
<Route
|
<Route
|
||||||
path={routes.information}
|
path={routes.information}
|
||||||
element={
|
element={
|
||||||
<Information
|
<InformationSodistorehome
|
||||||
values={props.current_installation}
|
values={props.current_installation}
|
||||||
s3Credentials={s3Credentials}
|
s3Credentials={s3Credentials}
|
||||||
type={props.type}
|
type={props.type}
|
||||||
></Information>
|
></InformationSodistorehome>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,321 @@
|
||||||
|
import React, { useContext, useState } from 'react';
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Box,
|
||||||
|
CircularProgress,
|
||||||
|
FormControl,
|
||||||
|
IconButton,
|
||||||
|
InputLabel,
|
||||||
|
MenuItem,
|
||||||
|
Modal,
|
||||||
|
Select,
|
||||||
|
TextField,
|
||||||
|
useTheme
|
||||||
|
} from '@mui/material';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import { Close as CloseIcon } from '@mui/icons-material';
|
||||||
|
import { I_Installation } from 'src/interfaces/InstallationTypes';
|
||||||
|
import { InstallationsContext } from 'src/contexts/InstallationsContextProvider';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
interface SodistorehomeInstallationFormPros {
|
||||||
|
cancel: () => void;
|
||||||
|
submit: () => void;
|
||||||
|
parentid: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SodistorehomeInstallationForm(props: SodistorehomeInstallationFormPros) {
|
||||||
|
const theme = useTheme();
|
||||||
|
const [open, setOpen] = useState(true);
|
||||||
|
const [formValues, setFormValues] = useState<Partial<I_Installation>>({
|
||||||
|
name: '',
|
||||||
|
region: '',
|
||||||
|
location: '',
|
||||||
|
country: '',
|
||||||
|
vpnIp: '',
|
||||||
|
});
|
||||||
|
const requiredFields = ['name', 'location', 'country', 'vpnIp'];
|
||||||
|
|
||||||
|
const DeviceTypes = [
|
||||||
|
{ id: 3, name: 'Growatt' },
|
||||||
|
{ id: 4, name: 'Sinexcel' }
|
||||||
|
];
|
||||||
|
const installationContext = useContext(InstallationsContext);
|
||||||
|
const { createInstallation, loading, setLoading, error, setError } =
|
||||||
|
installationContext;
|
||||||
|
|
||||||
|
const handleChange = (e) => {
|
||||||
|
const { name, value } = e.target;
|
||||||
|
|
||||||
|
setFormValues({
|
||||||
|
...formValues,
|
||||||
|
[name]: value
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const handleSubmit = async (e) => {
|
||||||
|
setLoading(true);
|
||||||
|
formValues.parentId = props.parentid;
|
||||||
|
formValues.product = 2;
|
||||||
|
const responseData = await createInstallation(formValues);
|
||||||
|
props.submit();
|
||||||
|
};
|
||||||
|
const handleCancelSubmit = (e) => {
|
||||||
|
props.cancel();
|
||||||
|
};
|
||||||
|
|
||||||
|
const areRequiredFieldsFilled = () => {
|
||||||
|
for (const field of requiredFields) {
|
||||||
|
if (!formValues[field]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isMobile = window.innerWidth <= 1490;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Modal
|
||||||
|
open={open}
|
||||||
|
onClose={() => {}}
|
||||||
|
aria-labelledby="error-modal"
|
||||||
|
aria-describedby="error-modal-description"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: isMobile ? '50%' : '40%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
width: 500,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
borderRadius: 4,
|
||||||
|
boxShadow: 24,
|
||||||
|
p: 4
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="form"
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center', // Center items horizontally
|
||||||
|
'& .MuiTextField-root': {
|
||||||
|
m: 1,
|
||||||
|
width: 390
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
noValidate
|
||||||
|
autoComplete="off"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="installationName"
|
||||||
|
defaultMessage="Installation Name"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="name"
|
||||||
|
value={formValues.name}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
error={formValues.name === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={<FormattedMessage id="region" defaultMessage="Region" />}
|
||||||
|
name="region"
|
||||||
|
value={formValues.region}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
error={formValues.region === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage id="location" defaultMessage="Location" />
|
||||||
|
}
|
||||||
|
name="location"
|
||||||
|
value={formValues.location}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
error={formValues.location === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage id="country" defaultMessage="Country" />
|
||||||
|
}
|
||||||
|
name="country"
|
||||||
|
value={formValues.country}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
error={formValues.country === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={<FormattedMessage id="VpnIp" defaultMessage="VpnIp" />}
|
||||||
|
name="vpnIp"
|
||||||
|
value={formValues.vpnIp}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
error={formValues.vpnIp === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<FormControl
|
||||||
|
fullWidth
|
||||||
|
sx={{
|
||||||
|
marginTop: 1,
|
||||||
|
marginBottom: 1,
|
||||||
|
width: 390
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<InputLabel
|
||||||
|
sx={{
|
||||||
|
fontSize: 14,
|
||||||
|
backgroundColor: 'white'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="DeviceType"
|
||||||
|
defaultMessage="Device Type"
|
||||||
|
/>
|
||||||
|
</InputLabel>
|
||||||
|
<Select
|
||||||
|
name="device"
|
||||||
|
value={formValues.device}
|
||||||
|
onChange={handleChange}
|
||||||
|
>
|
||||||
|
{DeviceTypes.map((device) => (
|
||||||
|
<MenuItem key={device.id} value={device.id}>
|
||||||
|
{device.name}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="inverterSN"
|
||||||
|
defaultMessage="Inverter Serial Number"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="inverterSN"
|
||||||
|
value={formValues.inverterSN}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="dataloggerSN"
|
||||||
|
defaultMessage="Datalogger Serial Number"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="dataloggerSN"
|
||||||
|
value={formValues.dataloggerSN}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="Information"
|
||||||
|
defaultMessage="Information"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="information"
|
||||||
|
value={formValues.information}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: 10
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleSubmit}
|
||||||
|
sx={{
|
||||||
|
marginLeft: '20px'
|
||||||
|
}}
|
||||||
|
disabled={!areRequiredFieldsFilled()}
|
||||||
|
>
|
||||||
|
<FormattedMessage id="submit" defaultMessage="Submit" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleCancelSubmit}
|
||||||
|
sx={{
|
||||||
|
marginLeft: '10px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage id="cancel" defaultMessage="Cancel" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{loading && (
|
||||||
|
<CircularProgress
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
marginLeft: '20px'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Alert
|
||||||
|
severity="error"
|
||||||
|
sx={{
|
||||||
|
ml: 1,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="errorOccured"
|
||||||
|
defaultMessage="An error has occured"
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
onClick={() => setError(false)}
|
||||||
|
sx={{ marginLeft: '4px' }}
|
||||||
|
>
|
||||||
|
<CloseIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SodistorehomeInstallationForm;
|
||||||
|
|
@ -26,6 +26,7 @@ import { InstallationsContext } from '../../../contexts/InstallationsContextProv
|
||||||
import { UserType } from '../../../interfaces/UserTypes';
|
import { UserType } from '../../../interfaces/UserTypes';
|
||||||
import InstallationForm from '../Installations/installationForm';
|
import InstallationForm from '../Installations/installationForm';
|
||||||
import SalidomoInstallationForm from '../SalidomoInstallations/SalidomoInstallationForm';
|
import SalidomoInstallationForm from '../SalidomoInstallations/SalidomoInstallationForm';
|
||||||
|
import SodiostorehomeInstallationForm from '../SodiohomeInstallations/SodistorehomeInstallationForm';
|
||||||
|
|
||||||
interface TreeInformationProps {
|
interface TreeInformationProps {
|
||||||
folder: I_Folder;
|
folder: I_Folder;
|
||||||
|
|
@ -322,7 +323,6 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
)}
|
)}
|
||||||
{openModalInstallation &&
|
{openModalInstallation &&
|
||||||
(product == 'Salimax' ||
|
(product == 'Salimax' ||
|
||||||
product == 'SodistoreHome' ||
|
|
||||||
product == 'SodistoreMax') && (
|
product == 'SodistoreMax') && (
|
||||||
<InstallationForm
|
<InstallationForm
|
||||||
cancel={handleFormCancel}
|
cancel={handleFormCancel}
|
||||||
|
|
@ -339,6 +339,14 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{openModalInstallation && product == 'SodistoreHome' && (
|
||||||
|
<SodiostorehomeInstallationForm
|
||||||
|
cancel={handleFormCancel}
|
||||||
|
submit={handleInstallationFormSubmit}
|
||||||
|
parentid={props.folder.id}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<Container maxWidth="xl">
|
<Container maxWidth="xl">
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ export interface I_Installation extends I_S3Credentials {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
information: string;
|
information: string;
|
||||||
|
inverterSN: string;
|
||||||
|
dataloggerSN: string;
|
||||||
parentId: number;
|
parentId: number;
|
||||||
s3WriteKey: string;
|
s3WriteKey: string;
|
||||||
s3WriteSecret: string;
|
s3WriteSecret: string;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue