frontend ready to implement topology view for sodiohome
This commit is contained in:
parent
51a34d9920
commit
ac54fc6e2e
|
|
@ -505,7 +505,7 @@ public class Controller : ControllerBase
|
||||||
|
|
||||||
|
|
||||||
var foldersAndInstallations = user
|
var foldersAndInstallations = user
|
||||||
.AccessibleFoldersAndInstallations(product:productId)
|
.AccessibleFoldersAndInstallations()
|
||||||
.Do(o => o.FillOrderNumbers())
|
.Do(o => o.FillOrderNumbers())
|
||||||
.Select(o => o.HideParentIfUserHasNoAccessToParent(user))
|
.Select(o => o.HideParentIfUserHasNoAccessToParent(user))
|
||||||
.OfType<Object>(); // Important! JSON serializer must see Objects otherwise
|
.OfType<Object>(); // Important! JSON serializer must see Objects otherwise
|
||||||
|
|
|
||||||
|
|
@ -267,35 +267,44 @@ public static class SessionMethods
|
||||||
.Apply(Db.Update);
|
.Apply(Db.Update);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installation.Product==(int)ProductType.Salidomo)
|
|
||||||
{
|
return user is not null
|
||||||
return user is not null
|
&& installation is not null
|
||||||
&& installation is not null
|
&& original is not null
|
||||||
&& original is not null
|
&& user.UserType !=0
|
||||||
&& user.UserType !=0
|
&& user.HasAccessToParentOf(installation)
|
||||||
&& user.HasAccessToParentOf(installation)
|
&& installation
|
||||||
&& installation
|
.Apply(Db.Update);
|
||||||
.Apply(Db.Update);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<Boolean> Delete(this Session? session, Installation? installation)
|
public static async Task<Boolean> Delete(this Session? session, Installation? installation)
|
||||||
{
|
{
|
||||||
var user = session?.User;
|
var user = session?.User;
|
||||||
|
|
||||||
|
if (user is not null
|
||||||
|
&& installation is not null
|
||||||
|
&& user.UserType != 0)
|
||||||
|
{
|
||||||
|
if (installation.Product is (int)ProductType.Salimax or (int)ProductType.Salidomo)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
Db.Delete(installation)
|
||||||
|
&& await installation.RevokeReadKey()
|
||||||
|
&& await installation.RevokeWriteKey()
|
||||||
|
&& await installation.RemoveReadRole()
|
||||||
|
&& await installation.RemoveWriteRole()
|
||||||
|
&& await installation.DeleteBucket();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Db.Delete(installation);
|
||||||
|
|
||||||
return user is not null
|
}
|
||||||
&& installation is not null
|
}
|
||||||
&& user.UserType != 0
|
|
||||||
&& user.HasAccessTo(installation)
|
return false;
|
||||||
&& Db.Delete(installation)
|
|
||||||
&& await installation.RevokeReadKey()
|
|
||||||
&& await installation.RevokeWriteKey()
|
|
||||||
&& await installation.RemoveReadRole()
|
|
||||||
&& await installation.RemoveWriteRole()
|
|
||||||
&& await installation.DeleteBucket();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,18 @@ public static class UserMethods
|
||||||
.Distinct();
|
.Distinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<Installation> AccessibleInstallations(this User user)
|
||||||
|
{
|
||||||
|
var direct = user.DirectlyAccessibleInstallations().ToList();
|
||||||
|
var fromFolders = user
|
||||||
|
.AccessibleFolders()
|
||||||
|
.SelectMany(u => u.ChildInstallations()).ToList();
|
||||||
|
|
||||||
|
return direct
|
||||||
|
.Concat(fromFolders)
|
||||||
|
.Distinct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static IEnumerable<Folder> AccessibleFolders(this User user)
|
public static IEnumerable<Folder> AccessibleFolders(this User user)
|
||||||
{
|
{
|
||||||
|
|
@ -42,6 +54,16 @@ public static class UserMethods
|
||||||
|
|
||||||
return folders.Concat(installations);
|
return folders.Concat(installations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<TreeNode> AccessibleFoldersAndInstallations(this User user)
|
||||||
|
{
|
||||||
|
var folders = user.AccessibleFolders() as IEnumerable<TreeNode>;
|
||||||
|
|
||||||
|
user.AccessibleInstallations().ForEach(i => i.FillOrderNumbers());
|
||||||
|
var installations = user.AccessibleInstallations();
|
||||||
|
|
||||||
|
return folders.Concat(installations);
|
||||||
|
}
|
||||||
|
|
||||||
public static IEnumerable<Installation> DirectlyAccessibleInstallations(this User user)
|
public static IEnumerable<Installation> DirectlyAccessibleInstallations(this User user)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,20 @@ public static class WebsocketManager
|
||||||
Console.WriteLine("TRY TO LOCK FOR MONITOR SALIDOMO INSTALLATIONS\n");
|
Console.WriteLine("TRY TO LOCK FOR MONITOR SALIDOMO INSTALLATIONS\n");
|
||||||
lock (InstallationConnections){
|
lock (InstallationConnections){
|
||||||
Console.WriteLine("MONITOR SALIDOMO INSTALLATIONS\n");
|
Console.WriteLine("MONITOR SALIDOMO INSTALLATIONS\n");
|
||||||
foreach (var installationConnection in InstallationConnections){
|
foreach (var installationConnection in InstallationConnections)
|
||||||
Console.WriteLine("Installation ID is "+installationConnection.Key);
|
{
|
||||||
|
//Console.WriteLine("Installation ID is "+installationConnection.Key);
|
||||||
|
if (installationConnection.Value.Product == (int)ProductType.Salidomo && (DateTime.Now - installationConnection.Value.Timestamp) < TimeSpan.FromMinutes(60)){
|
||||||
|
Console.WriteLine("Installation ID is "+installationConnection.Key + " diff is "+(DateTime.Now-installationConnection.Value.Timestamp));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (installationConnection.Value.Product==(int)ProductType.Salidomo && (DateTime.Now - installationConnection.Value.Timestamp) > TimeSpan.FromMinutes(60))
|
if (installationConnection.Value.Product==(int)ProductType.Salidomo && (DateTime.Now - installationConnection.Value.Timestamp) > TimeSpan.FromMinutes(60))
|
||||||
{
|
{
|
||||||
// Console.WriteLine("Installation ID is "+installationConnection.Key);
|
//Console.WriteLine("Installation ID is "+installationConnection.Key + " diff is "+(DateTime.Now-installationConnection.Value.Timestamp));
|
||||||
// Console.WriteLine("installationConnection.Value.Timestamp is "+installationConnection.Value.Timestamp);
|
//Console.WriteLine("installationConnection.Value.Timestamp is "+installationConnection.Value.Timestamp);
|
||||||
// Console.WriteLine("diff is "+(DateTime.Now-installationConnection.Value.Timestamp));
|
//Console.WriteLine("timestamp now is is "+(DateTime.Now));
|
||||||
|
|
||||||
Installation installation = Db.Installations.FirstOrDefault(f => f.Product == (int)ProductType.Salidomo && f.Id == installationConnection.Key);
|
Installation installation = Db.Installations.FirstOrDefault(f => f.Product == (int)ProductType.Salidomo && f.Id == installationConnection.Key);
|
||||||
installation.Status = (int)StatusType.Offline;
|
installation.Status = (int)StatusType.Offline;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,6 @@ INNOVENERGY_PROTOCOL_VERSION = '48TL200V3'
|
||||||
|
|
||||||
|
|
||||||
# S3 Credentials
|
# S3 Credentials
|
||||||
S3BUCKET = "158-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e"
|
S3BUCKET = "436-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e"
|
||||||
S3KEY = "EXOf4d6d68a9ce062f25541fe4a"
|
S3KEY = "EXO6bb2b06f3cebfdbbc8a9b240"
|
||||||
S3SECRET = "4zTQBvwIWnFYajRhoZW0F7k_6rdhnPiSqdvw9cMAZw8"
|
S3SECRET = "m6bEzM8z9t2lCQ13OptMcZcNf80p_TSjaMDtZTNdEjo"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,393 @@
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Box,
|
||||||
|
CardContent,
|
||||||
|
CircularProgress,
|
||||||
|
Container,
|
||||||
|
Grid,
|
||||||
|
IconButton,
|
||||||
|
Modal,
|
||||||
|
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_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 InformationSodioHomeProps {
|
||||||
|
values: I_Installation;
|
||||||
|
type?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function InformationSodioHome(props: InformationSodioHomeProps) {
|
||||||
|
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 = ['Cerbo', 'Venus'];
|
||||||
|
|
||||||
|
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="information"
|
||||||
|
defaultMessage="Information"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="information"
|
||||||
|
value={formValues.information}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{currentUser.userType == UserType.admin && (
|
||||||
|
<>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label="BitWatt Cloud Access Key"
|
||||||
|
name="s3WriteKey"
|
||||||
|
value={formValues.s3WriteKey}
|
||||||
|
onChange={handleChange}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label="BitWatt Cloud Secret Key"
|
||||||
|
name="s3WriteSecret"
|
||||||
|
onChange={handleChange}
|
||||||
|
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 InformationSodioHome;
|
||||||
|
|
@ -115,11 +115,11 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{sortedInstallations.map((installation) => {
|
{sortedInstallations.map((installation) => {
|
||||||
const isInstallationSelected =
|
const isInstallationSelected =
|
||||||
installation.s3BucketId === selectedInstallation;
|
installation.id === selectedInstallation;
|
||||||
|
|
||||||
const status = installation.status;
|
const status = installation.status;
|
||||||
const rowStyles =
|
const rowStyles =
|
||||||
isRowHovered === installation.s3BucketId
|
isRowHovered === installation.id
|
||||||
? {
|
? {
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
backgroundColor: theme.colors.primary.lighter
|
backgroundColor: theme.colors.primary.lighter
|
||||||
|
|
@ -129,15 +129,13 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
hover
|
hover
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
selected={isInstallationSelected}
|
selected={isInstallationSelected}
|
||||||
style={rowStyles}
|
style={rowStyles}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleSelectOneInstallation(installation.s3BucketId)
|
handleSelectOneInstallation(installation.id)
|
||||||
}
|
|
||||||
onMouseEnter={() =>
|
|
||||||
handleRowMouseEnter(installation.s3BucketId)
|
|
||||||
}
|
}
|
||||||
|
onMouseEnter={() => handleRowMouseEnter(installation.id)}
|
||||||
onMouseLeave={() => handleRowMouseLeave()}
|
onMouseLeave={() => handleRowMouseLeave()}
|
||||||
>
|
>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,11 @@ function InstallationSearch(props: installationSearchProps) {
|
||||||
{filteredData.map((installation) => {
|
{filteredData.map((installation) => {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Route
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
path={routes.installation + installation.s3BucketId + '*'}
|
path={routes.installation + installation.id + '*'}
|
||||||
element={
|
element={
|
||||||
<Installation
|
<Installation
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
current_installation={installation}
|
current_installation={installation}
|
||||||
type="installation"
|
type="installation"
|
||||||
></Installation>
|
></Installation>
|
||||||
|
|
|
||||||
|
|
@ -137,15 +137,15 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
// )
|
// )
|
||||||
.map((installation) => {
|
.map((installation) => {
|
||||||
const isInstallationSelected =
|
const isInstallationSelected =
|
||||||
installation.s3BucketId === selectedInstallation;
|
installation.id === selectedInstallation;
|
||||||
|
|
||||||
const status = installation.status;
|
const status = installation.status;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HoverableTableRow
|
<HoverableTableRow
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleSelectOneInstallation(installation.s3BucketId)
|
handleSelectOneInstallation(installation.id)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,11 @@ function InstallationSearch(props: installationSearchProps) {
|
||||||
{filteredData.map((installation) => {
|
{filteredData.map((installation) => {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Route
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
path={routes.installation + installation.s3BucketId + '*'}
|
path={routes.installation + installation.id + '*'}
|
||||||
element={
|
element={
|
||||||
<SalidomoInstallation
|
<SalidomoInstallation
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
current_installation={installation}
|
current_installation={installation}
|
||||||
type="installation"
|
type="installation"
|
||||||
></SalidomoInstallation>
|
></SalidomoInstallation>
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
routes.installation +
|
routes.installation +
|
||||||
`${installationID}` +
|
`${installationID}` +
|
||||||
'/' +
|
'/' +
|
||||||
routes.batteryview,
|
routes.information,
|
||||||
{
|
{
|
||||||
replace: true
|
replace: true
|
||||||
}
|
}
|
||||||
|
|
@ -107,12 +107,6 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<FormattedMessage id="country" defaultMessage="Country" />
|
<FormattedMessage id="country" defaultMessage="Country" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
|
||||||
<FormattedMessage id="VRM Link" defaultMessage="VRM Link" />
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<FormattedMessage id="Device" defaultMessage="Device" />
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<FormattedMessage id="status" defaultMessage="Status" />
|
<FormattedMessage id="status" defaultMessage="Status" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
@ -127,15 +121,15 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
// )
|
// )
|
||||||
.map((installation) => {
|
.map((installation) => {
|
||||||
const isInstallationSelected =
|
const isInstallationSelected =
|
||||||
installation.s3BucketId === selectedInstallation;
|
installation.id === selectedInstallation;
|
||||||
|
|
||||||
const status = installation.status;
|
const status = installation.status;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HoverableTableRow
|
<HoverableTableRow
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleSelectOneInstallation(installation.s3BucketId)
|
handleSelectOneInstallation(installation.id)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
|
@ -190,79 +184,6 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
</Typography>
|
</Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell>
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
fontWeight="bold"
|
|
||||||
color="text.primary"
|
|
||||||
gutterBottom
|
|
||||||
noWrap
|
|
||||||
sx={{ marginTop: '10px', fontSize: 'small' }}
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href={
|
|
||||||
'https://vrm.victronenergy.com/installation/' +
|
|
||||||
installation.vrmLink +
|
|
||||||
'/dashboard'
|
|
||||||
}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
style={{
|
|
||||||
display: 'inline-block',
|
|
||||||
padding: '0'
|
|
||||||
}} // Style the link
|
|
||||||
onClick={(e) => e.stopPropagation()} // Prevent the click event from bubbling up to the table row
|
|
||||||
>
|
|
||||||
VRM link
|
|
||||||
</a>
|
|
||||||
</Typography>
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
marginLeft: '5px'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{installation.device === 1 ? (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
fontWeight="bold"
|
|
||||||
color="text.primary"
|
|
||||||
gutterBottom
|
|
||||||
noWrap
|
|
||||||
sx={{ marginTop: '10px', fontSize: 'small' }}
|
|
||||||
>
|
|
||||||
Cerbo
|
|
||||||
</Typography>
|
|
||||||
) : installation.device === 2 ? (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
fontWeight="bold"
|
|
||||||
color="text.primary"
|
|
||||||
gutterBottom
|
|
||||||
noWrap
|
|
||||||
sx={{ marginTop: '10px', fontSize: 'small' }}
|
|
||||||
>
|
|
||||||
Venus
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
fontWeight="bold"
|
|
||||||
color="text.primary"
|
|
||||||
gutterBottom
|
|
||||||
noWrap
|
|
||||||
sx={{ marginTop: '10px', fontSize: 'small' }}
|
|
||||||
>
|
|
||||||
Device not specified
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,25 @@
|
||||||
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CircularProgress,
|
||||||
|
Container,
|
||||||
|
Grid,
|
||||||
|
Typography
|
||||||
|
} from '@mui/material';
|
||||||
import { I_Installation } from 'src/interfaces/InstallationTypes';
|
import { I_Installation } from 'src/interfaces/InstallationTypes';
|
||||||
import React from 'react';
|
import { UserContext } from 'src/contexts/userContext';
|
||||||
import { Grid } from '@mui/material';
|
import { TopologyValues } from 'src/content/dashboards/Log/graph.util';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
|
||||||
|
import routes from '../../../Resources/routes.json';
|
||||||
|
import Log from '../Log/Log';
|
||||||
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
|
import { UserType } from '../../../interfaces/UserTypes';
|
||||||
|
import HistoryOfActions from '../History/History';
|
||||||
|
import BuildIcon from '@mui/icons-material/Build';
|
||||||
|
import AccessContextProvider from '../../../contexts/AccessContextProvider';
|
||||||
|
import Access from '../ManageAccess/Access';
|
||||||
|
import InformationSodioHome from '../Information/InformationSodioHome';
|
||||||
|
|
||||||
interface singleInstallationProps {
|
interface singleInstallationProps {
|
||||||
current_installation?: I_Installation;
|
current_installation?: I_Installation;
|
||||||
|
|
@ -8,383 +27,266 @@ interface singleInstallationProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
function SodioHomeInstallation(props: singleInstallationProps) {
|
function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
// const context = useContext(UserContext);
|
const context = useContext(UserContext);
|
||||||
// const { currentUser } = context;
|
const { currentUser } = context;
|
||||||
// const location = useLocation().pathname;
|
const location = useLocation().pathname;
|
||||||
// const [errorLoadingS3Data, setErrorLoadingS3Data] = useState(false);
|
const [errorLoadingS3Data, setErrorLoadingS3Data] = useState(false);
|
||||||
// const [currentTab, setCurrentTab] = useState<string>(undefined);
|
const [currentTab, setCurrentTab] = useState<string>(undefined);
|
||||||
// const [values, setValues] = useState<TopologyValues | null>(null);
|
const [values, setValues] = useState<TopologyValues | null>(null);
|
||||||
// const status = props.current_installation.status;
|
const status = props.current_installation.status;
|
||||||
// const [
|
const [
|
||||||
// failedToCommunicateWithInstallation,
|
failedToCommunicateWithInstallation,
|
||||||
// setFailedToCommunicateWithInstallation
|
setFailedToCommunicateWithInstallation
|
||||||
// ] = useState(0);
|
] = useState(0);
|
||||||
// const [connected, setConnected] = useState(true);
|
const [connected, setConnected] = useState(true);
|
||||||
// const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
//
|
|
||||||
// if (props.current_installation == undefined) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// const S3data = {
|
|
||||||
// s3Region: props.current_installation.s3Region,
|
|
||||||
// s3Provider: props.current_installation.s3Provider,
|
|
||||||
// s3Key: props.current_installation.s3Key,
|
|
||||||
// s3Secret: props.current_installation.s3Secret,
|
|
||||||
// s3BucketId: props.current_installation.s3BucketId
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// const s3Bucket =
|
|
||||||
// props.current_installation.s3BucketId.toString() +
|
|
||||||
// '-' +
|
|
||||||
// 'c0436b6a-d276-4cd8-9c44-1eae86cf5d0e';
|
|
||||||
//
|
|
||||||
// const [fetchFunctionCalled, setFetchFunctionCalled] = useState(false);
|
|
||||||
// const s3Credentials = { s3Bucket, ...S3data };
|
|
||||||
//
|
|
||||||
// function timeout(delay: number) {
|
|
||||||
// return new Promise((res) => setTimeout(res, delay));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// const continueFetching = useRef(false);
|
|
||||||
//
|
|
||||||
// const fetchDataPeriodically = async () => {
|
|
||||||
// var timeperiodToSearch = 30;
|
|
||||||
// let res;
|
|
||||||
// let timestampToFetch;
|
|
||||||
//
|
|
||||||
// for (var i = 0; i < timeperiodToSearch; i += 1) {
|
|
||||||
// if (!continueFetching.current) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// timestampToFetch = UnixTime.now().earlier(TimeSpan.fromMinutes(i));
|
|
||||||
// console.log('timestamp to fetch is ' + timestampToFetch);
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// res = await fetchData(timestampToFetch, s3Credentials, true);
|
|
||||||
// if (res !== FetchResult.notAvailable && res !== FetchResult.tryLater) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// } catch (err) {
|
|
||||||
// console.error('Error fetching data:', err);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (i >= timeperiodToSearch) {
|
|
||||||
// setConnected(false);
|
|
||||||
// setLoading(false);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// setConnected(true);
|
|
||||||
// setLoading(false);
|
|
||||||
// console.log('NUMBER OF FILES=' + Object.keys(res).length);
|
|
||||||
//
|
|
||||||
// while (continueFetching.current) {
|
|
||||||
// for (const timestamp of Object.keys(res)) {
|
|
||||||
// if (!continueFetching.current) {
|
|
||||||
// setFetchFunctionCalled(false);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// console.log(`Timestamp: ${timestamp}`);
|
|
||||||
// console.log(res[timestamp]);
|
|
||||||
//
|
|
||||||
// // Set values asynchronously with delay
|
|
||||||
// setValues(
|
|
||||||
// extractValues({
|
|
||||||
// time: UnixTime.fromTicks(parseInt(timestamp, 10)),
|
|
||||||
// value: res[timestamp]
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
// // Wait for 2 seconds before processing next timestamp
|
|
||||||
// await timeout(2000);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// timestampToFetch = timestampToFetch.later(TimeSpan.fromMinutes(20));
|
|
||||||
// console.log('NEW TIMESTAMP TO FETCH IS ' + timestampToFetch);
|
|
||||||
//
|
|
||||||
// for (i = 0; i < 10; i++) {
|
|
||||||
// if (!continueFetching.current) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// console.log('Trying to fetch timestamp ' + timestampToFetch);
|
|
||||||
// res = await fetchData(timestampToFetch, s3Credentials, true);
|
|
||||||
// if (
|
|
||||||
// res !== FetchResult.notAvailable &&
|
|
||||||
// res !== FetchResult.tryLater
|
|
||||||
// ) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// } catch (err) {
|
|
||||||
// console.error('Error fetching data:', err);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// timestampToFetch = timestampToFetch.later(TimeSpan.fromMinutes(1));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// useEffect(() => {
|
|
||||||
// let path = location.split('/');
|
|
||||||
// setCurrentTab(path[path.length - 1]);
|
|
||||||
// }, [location]);
|
|
||||||
//
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (location.includes('batteryview')) {
|
|
||||||
// if (location.includes('batteryview') && !location.includes('mainstats')) {
|
|
||||||
// if (!continueFetching.current) {
|
|
||||||
// continueFetching.current = true;
|
|
||||||
// if (!fetchFunctionCalled) {
|
|
||||||
// setFetchFunctionCalled(true);
|
|
||||||
// fetchDataPeriodically();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return () => {
|
|
||||||
// continueFetching.current = false;
|
|
||||||
// };
|
|
||||||
// } else {
|
|
||||||
// continueFetching.current = false;
|
|
||||||
// }
|
|
||||||
// }, [currentTab, location]);
|
|
||||||
//
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (status === null) {
|
|
||||||
// setConnected(false);
|
|
||||||
// }
|
|
||||||
// }, [status]);
|
|
||||||
//
|
|
||||||
|
|
||||||
return <Grid item xs={12} md={12}></Grid>;
|
if (props.current_installation == undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// return (
|
const [fetchFunctionCalled, setFetchFunctionCalled] = useState(false);
|
||||||
// <>
|
|
||||||
// <Grid item xs={12} md={12}>
|
function timeout(delay: number) {
|
||||||
// <div style={{ display: 'flex', alignItems: 'center' }}>
|
return new Promise((res) => setTimeout(res, delay));
|
||||||
// <Typography
|
}
|
||||||
// fontWeight="bold"
|
|
||||||
// color="text.primary"
|
useEffect(() => {
|
||||||
// noWrap
|
let path = location.split('/');
|
||||||
// sx={{
|
setCurrentTab(path[path.length - 1]);
|
||||||
// marginTop: '-20px',
|
}, [location]);
|
||||||
// marginBottom: '10px',
|
|
||||||
// fontSize: '14px'
|
useEffect(() => {
|
||||||
// }}
|
if (status === null) {
|
||||||
// >
|
setConnected(false);
|
||||||
// <FormattedMessage
|
}
|
||||||
// id="installation_name_simple"
|
}, [status]);
|
||||||
// defaultMessage="Installation Name:"
|
|
||||||
// />
|
return (
|
||||||
// </Typography>
|
<>
|
||||||
// <Typography
|
<Grid item xs={12} md={12}>
|
||||||
// fontWeight="bold"
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||||
// color="orange"
|
<Typography
|
||||||
// noWrap
|
fontWeight="bold"
|
||||||
// sx={{
|
color="text.primary"
|
||||||
// marginTop: '-20px',
|
noWrap
|
||||||
// marginBottom: '10px',
|
sx={{
|
||||||
// marginLeft: '5px',
|
marginTop: '-20px',
|
||||||
// fontSize: '14px'
|
marginBottom: '10px',
|
||||||
// }}
|
fontSize: '14px'
|
||||||
// >
|
}}
|
||||||
// {props.current_installation.name}
|
>
|
||||||
// </Typography>
|
<FormattedMessage
|
||||||
// </div>
|
id="installation_name_simple"
|
||||||
// <div style={{ display: 'flex', alignItems: 'center' }}>
|
defaultMessage="Installation Name:"
|
||||||
// <Typography
|
/>
|
||||||
// fontWeight="bold"
|
</Typography>
|
||||||
// color="text.primary"
|
<Typography
|
||||||
// noWrap
|
fontWeight="bold"
|
||||||
// sx={{
|
color="orange"
|
||||||
// marginTop: '0px',
|
noWrap
|
||||||
// marginBottom: '10px',
|
sx={{
|
||||||
// fontSize: '14px'
|
marginTop: '-20px',
|
||||||
// }}
|
marginBottom: '10px',
|
||||||
// >
|
marginLeft: '5px',
|
||||||
// Status:
|
fontSize: '14px'
|
||||||
// </Typography>
|
}}
|
||||||
// <div
|
>
|
||||||
// style={{
|
{props.current_installation.name}
|
||||||
// display: 'flex',
|
</Typography>
|
||||||
// alignItems: 'center',
|
</div>
|
||||||
// marginLeft: '75px',
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||||
// marginTop: '-10px'
|
<Typography
|
||||||
// }}
|
fontWeight="bold"
|
||||||
// >
|
color="text.primary"
|
||||||
// {status === -1 ? (
|
noWrap
|
||||||
// <CancelIcon
|
sx={{
|
||||||
// style={{
|
marginTop: '0px',
|
||||||
// width: '23px',
|
marginBottom: '10px',
|
||||||
// height: '23px',
|
fontSize: '14px'
|
||||||
// color: 'red',
|
}}
|
||||||
// borderRadius: '50%'
|
>
|
||||||
// }}
|
Status:
|
||||||
// />
|
</Typography>
|
||||||
// ) : (
|
<div
|
||||||
// ''
|
style={{
|
||||||
// )}
|
display: 'flex',
|
||||||
//
|
alignItems: 'center',
|
||||||
// {status === -2 ? (
|
marginLeft: '75px',
|
||||||
// <CircularProgress
|
marginTop: '-10px'
|
||||||
// size={20}
|
}}
|
||||||
// sx={{
|
>
|
||||||
// color: '#f7b34d'
|
{status === -1 ? (
|
||||||
// }}
|
<CancelIcon
|
||||||
// />
|
style={{
|
||||||
// ) : (
|
width: '23px',
|
||||||
// ''
|
height: '23px',
|
||||||
// )}
|
color: 'red',
|
||||||
//
|
borderRadius: '50%'
|
||||||
// <div
|
}}
|
||||||
// style={{
|
/>
|
||||||
// width: '20px',
|
) : (
|
||||||
// height: '20px',
|
''
|
||||||
// marginLeft: '2px',
|
)}
|
||||||
// borderRadius: '50%',
|
|
||||||
// backgroundColor:
|
{status === -2 ? (
|
||||||
// status === 2
|
<CircularProgress
|
||||||
// ? 'red'
|
size={20}
|
||||||
// : status === 1
|
sx={{
|
||||||
// ? 'orange'
|
color: '#f7b34d'
|
||||||
// : status === -1 || status === -2
|
}}
|
||||||
// ? 'transparent'
|
/>
|
||||||
// : 'green'
|
) : (
|
||||||
// }}
|
''
|
||||||
// />
|
)}
|
||||||
//
|
|
||||||
// {props.current_installation.testingMode && (
|
<div
|
||||||
// <BuildIcon
|
style={{
|
||||||
// style={{
|
width: '20px',
|
||||||
// width: '23px',
|
height: '20px',
|
||||||
// height: '23px',
|
marginLeft: '2px',
|
||||||
// color: 'purple',
|
borderRadius: '50%',
|
||||||
// borderRadius: '50%',
|
backgroundColor:
|
||||||
// position: 'relative',
|
status === 2
|
||||||
// zIndex: 1,
|
? 'red'
|
||||||
// marginLeft: '15px'
|
: status === 1
|
||||||
// }}
|
? 'orange'
|
||||||
// />
|
: status === -1 || status === -2
|
||||||
// )}
|
? 'transparent'
|
||||||
// </div>
|
: 'green'
|
||||||
// </div>
|
}}
|
||||||
// {loading &&
|
/>
|
||||||
// currentTab != 'information' &&
|
|
||||||
// currentTab != 'overview' &&
|
{props.current_installation.testingMode && (
|
||||||
// currentTab != 'manage' &&
|
<BuildIcon
|
||||||
// currentTab != 'history' &&
|
style={{
|
||||||
// currentTab != 'log' && (
|
width: '23px',
|
||||||
// <Container
|
height: '23px',
|
||||||
// maxWidth="xl"
|
color: 'purple',
|
||||||
// sx={{
|
borderRadius: '50%',
|
||||||
// display: 'flex',
|
position: 'relative',
|
||||||
// flexDirection: 'column',
|
zIndex: 1,
|
||||||
// justifyContent: 'center',
|
marginLeft: '15px'
|
||||||
// alignItems: 'center',
|
}}
|
||||||
// height: '70vh'
|
/>
|
||||||
// }}
|
)}
|
||||||
// >
|
</div>
|
||||||
// <CircularProgress size={60} style={{ color: '#ffc04d' }} />
|
</div>
|
||||||
// <Typography
|
{loading &&
|
||||||
// variant="body2"
|
currentTab != 'information' &&
|
||||||
// style={{ color: 'black', fontWeight: 'bold' }}
|
currentTab != 'overview' &&
|
||||||
// mt={2}
|
currentTab != 'manage' &&
|
||||||
// >
|
currentTab != 'history' &&
|
||||||
// Connecting to the device...
|
currentTab != 'log' && (
|
||||||
// </Typography>
|
<Container
|
||||||
// </Container>
|
maxWidth="xl"
|
||||||
// )}
|
sx={{
|
||||||
//
|
display: 'flex',
|
||||||
// <Card variant="outlined">
|
flexDirection: 'column',
|
||||||
// <Grid
|
justifyContent: 'center',
|
||||||
// container
|
alignItems: 'center',
|
||||||
// direction="row"
|
height: '70vh'
|
||||||
// justifyContent="center"
|
}}
|
||||||
// alignItems="stretch"
|
>
|
||||||
// spacing={0}
|
<CircularProgress size={60} style={{ color: '#ffc04d' }} />
|
||||||
// >
|
<Typography
|
||||||
// <Routes>
|
variant="body2"
|
||||||
// <Route
|
style={{ color: 'black', fontWeight: 'bold' }}
|
||||||
// path={routes.information}
|
mt={2}
|
||||||
// element={
|
>
|
||||||
// <InformationSalidomo
|
Connecting to the device...
|
||||||
// values={props.current_installation}
|
</Typography>
|
||||||
// s3Credentials={s3Credentials}
|
</Container>
|
||||||
// type={props.type}
|
)}
|
||||||
// ></InformationSalidomo>
|
|
||||||
// }
|
<Card variant="outlined">
|
||||||
// />
|
<Grid
|
||||||
//
|
container
|
||||||
// <Route
|
direction="row"
|
||||||
// path={routes.log}
|
justifyContent="center"
|
||||||
// element={
|
alignItems="stretch"
|
||||||
// <Log
|
spacing={0}
|
||||||
// errorLoadingS3Data={errorLoadingS3Data}
|
>
|
||||||
// id={props.current_installation.id}
|
<Routes>
|
||||||
// ></Log>
|
<Route
|
||||||
// }
|
path={routes.information}
|
||||||
// />
|
element={
|
||||||
//
|
<InformationSodioHome
|
||||||
// <Route
|
values={props.current_installation}
|
||||||
// path={routes.overview}
|
type={props.type}
|
||||||
// element={
|
></InformationSodioHome>
|
||||||
// <SalidomoOverview
|
}
|
||||||
// s3Credentials={s3Credentials}
|
/>
|
||||||
// id={props.current_installation.id}
|
|
||||||
// ></SalidomoOverview>
|
<Route
|
||||||
// }
|
path={routes.log}
|
||||||
// />
|
element={
|
||||||
//
|
<Log
|
||||||
// <Route
|
errorLoadingS3Data={errorLoadingS3Data}
|
||||||
// path={routes.batteryview + '*'}
|
id={props.current_installation.id}
|
||||||
// element={
|
></Log>
|
||||||
// <BatteryView
|
}
|
||||||
// values={values}
|
/>
|
||||||
// s3Credentials={s3Credentials}
|
|
||||||
// installationId={props.current_installation.id}
|
{/*<Route*/}
|
||||||
// productNum={props.current_installation.product}
|
{/* path={routes.overview}*/}
|
||||||
// connected={connected}
|
{/* element={*/}
|
||||||
// ></BatteryView>
|
{/* <SalidomoOverview*/}
|
||||||
// }
|
{/* s3Credentials={s3Credentials}*/}
|
||||||
// ></Route>
|
{/* id={props.current_installation.id}*/}
|
||||||
//
|
{/* ></SalidomoOverview>*/}
|
||||||
// {currentUser.userType == UserType.admin && (
|
{/* }*/}
|
||||||
// <Route
|
{/*/>*/}
|
||||||
// path={routes.history}
|
|
||||||
// element={
|
{/*<Route*/}
|
||||||
// <HistoryOfActions
|
{/* path={routes.batteryview + '*'}*/}
|
||||||
// errorLoadingS3Data={errorLoadingS3Data}
|
{/* element={*/}
|
||||||
// id={props.current_installation.id}
|
{/* <BatteryView*/}
|
||||||
// ></HistoryOfActions>
|
{/* values={values}*/}
|
||||||
// }
|
{/* s3Credentials={s3Credentials}*/}
|
||||||
// />
|
{/* installationId={props.current_installation.id}*/}
|
||||||
// )}
|
{/* productNum={props.current_installation.product}*/}
|
||||||
//
|
{/* connected={connected}*/}
|
||||||
// {currentUser.userType == UserType.admin && (
|
{/* ></BatteryView>*/}
|
||||||
// <Route
|
{/* }*/}
|
||||||
// path={routes.manage}
|
{/*></Route>*/}
|
||||||
// element={
|
|
||||||
// <AccessContextProvider>
|
{currentUser.userType == UserType.admin && (
|
||||||
// <Access
|
<Route
|
||||||
// currentResource={props.current_installation}
|
path={routes.history}
|
||||||
// resourceType={props.type}
|
element={
|
||||||
// ></Access>
|
<HistoryOfActions
|
||||||
// </AccessContextProvider>
|
errorLoadingS3Data={errorLoadingS3Data}
|
||||||
// }
|
id={props.current_installation.id}
|
||||||
// />
|
></HistoryOfActions>
|
||||||
// )}
|
}
|
||||||
//
|
/>
|
||||||
// <Route
|
)}
|
||||||
// path={'*'}
|
|
||||||
// element={<Navigate to={routes.batteryview}></Navigate>}
|
{currentUser.userType == UserType.admin && (
|
||||||
// />
|
<Route
|
||||||
// </Routes>
|
path={routes.manage}
|
||||||
// </Grid>
|
element={
|
||||||
// </Card>
|
<AccessContextProvider>
|
||||||
// </Grid>
|
<Access
|
||||||
// </>
|
currentResource={props.current_installation}
|
||||||
// );
|
resourceType={props.type}
|
||||||
|
></Access>
|
||||||
|
</AccessContextProvider>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path={'*'}
|
||||||
|
element={<Navigate to={routes.information}></Navigate>}
|
||||||
|
/>
|
||||||
|
</Routes>
|
||||||
|
</Grid>
|
||||||
|
</Card>
|
||||||
|
</Grid>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SodioHomeInstallation;
|
export default SodioHomeInstallation;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useMemo, useState } from 'react';
|
||||||
import { FormControl, Grid, InputAdornment, TextField } from '@mui/material';
|
import { FormControl, Grid, InputAdornment, TextField } from '@mui/material';
|
||||||
import SearchTwoToneIcon from '@mui/icons-material/SearchTwoTone';
|
import SearchTwoToneIcon from '@mui/icons-material/SearchTwoTone';
|
||||||
import { I_Installation } from '../../../interfaces/InstallationTypes';
|
import { I_Installation } from '../../../interfaces/InstallationTypes';
|
||||||
import { Route, Routes,useLocation } from 'react-router-dom';
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
||||||
import routes from '../../../Resources/routes.json';
|
import routes from '../../../Resources/routes.json';
|
||||||
import FlatInstallationView from './FlatInstallationView';
|
import FlatInstallationView from './FlatInstallationView';
|
||||||
import SodioHomeInstallation from './Installation';
|
import SodioHomeInstallation from './Installation';
|
||||||
|
|
@ -82,11 +82,11 @@ function InstallationSearch(props: installationSearchProps) {
|
||||||
{filteredData.map((installation) => {
|
{filteredData.map((installation) => {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Route
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
path={routes.installation + installation.s3BucketId + '*'}
|
path={routes.installation + installation.id + '*'}
|
||||||
element={
|
element={
|
||||||
<SodioHomeInstallation
|
<SodioHomeInstallation
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
current_installation={installation}
|
current_installation={installation}
|
||||||
type="installation"
|
type="installation"
|
||||||
></SodioHomeInstallation>
|
></SodioHomeInstallation>
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,8 @@ import {
|
||||||
Alert,
|
Alert,
|
||||||
Box,
|
Box,
|
||||||
CircularProgress,
|
CircularProgress,
|
||||||
FormControl,
|
|
||||||
IconButton,
|
IconButton,
|
||||||
InputLabel,
|
|
||||||
MenuItem,
|
|
||||||
Modal,
|
Modal,
|
||||||
Select,
|
|
||||||
TextField,
|
TextField,
|
||||||
useTheme
|
useTheme
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
@ -32,7 +28,9 @@ function SodiohomeInstallationForm(props: SodiohomeInstallationFormProps) {
|
||||||
region: '',
|
region: '',
|
||||||
location: '',
|
location: '',
|
||||||
country: '',
|
country: '',
|
||||||
serialNumber: ''
|
serialNumber: '',
|
||||||
|
s3WriteSecret: '',
|
||||||
|
s3WriteKey: ''
|
||||||
});
|
});
|
||||||
const requiredFields = ['name', 'location', 'country', 'serialNumber'];
|
const requiredFields = ['name', 'location', 'country', 'serialNumber'];
|
||||||
|
|
||||||
|
|
@ -159,7 +157,10 @@ function SodiohomeInstallationForm(props: SodiohomeInstallationFormProps) {
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
label={
|
label={
|
||||||
<FormattedMessage id="serialNumber" defaultMessage="Serial Number" />
|
<FormattedMessage
|
||||||
|
id="serialNumber"
|
||||||
|
defaultMessage="Serial Number"
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
name="serialNumber"
|
name="serialNumber"
|
||||||
value={formValues.serialNumber}
|
value={formValues.serialNumber}
|
||||||
|
|
@ -169,6 +170,38 @@ function SodiohomeInstallationForm(props: SodiohomeInstallationFormProps) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="s3WriteKey"
|
||||||
|
defaultMessage="BitWatt Cloud Access Key"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="s3WriteKey"
|
||||||
|
value={formValues.s3WriteKey}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
error={formValues.s3WriteKey === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="s3WriteSecret"
|
||||||
|
defaultMessage="BitWatt Cloud Secret Key"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
name="s3WriteSecret"
|
||||||
|
value={formValues.s3WriteSecret}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
error={formValues.s3WriteSecret === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
label={
|
label={
|
||||||
|
|
|
||||||
|
|
@ -66,16 +66,16 @@ function SodioHomeInstallationTabs() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sodiohomeInstallations && sodiohomeInstallations.length > 0) {
|
if (sodiohomeInstallations && sodiohomeInstallations.length > 0) {
|
||||||
if (!socket) {
|
if (!socket) {
|
||||||
openSocket(1);
|
openSocket(2);
|
||||||
} else if (currentProduct == 0) {
|
} else if (currentProduct != 2) {
|
||||||
closeSocket();
|
closeSocket();
|
||||||
openSocket(1);
|
openSocket(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [sodiohomeInstallations]);
|
}, [sodiohomeInstallations]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setProduct(1);
|
setProduct(2);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleTabsChange = (_event: ChangeEvent<{}>, value: string): void => {
|
const handleTabsChange = (_event: ChangeEvent<{}>, value: string): void => {
|
||||||
|
|
|
||||||
|
|
@ -42,18 +42,30 @@ function CustomTreeItem(props: CustomTreeItemProps) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [selected, setSelected] = useState(false);
|
const [selected, setSelected] = useState(false);
|
||||||
const currentLocation = useLocation();
|
const currentLocation = useLocation();
|
||||||
const { product, setProduct } = useContext(ProductIdContext);
|
const { product } = useContext(ProductIdContext);
|
||||||
|
|
||||||
const handleSelectOneInstallation = (): void => {
|
const handleSelectOneInstallation = (): void => {
|
||||||
let installation = props.node;
|
let installation = props.node;
|
||||||
let path =
|
let installation_path =
|
||||||
product == 0 ? routes.installations : routes.salidomo_installations;
|
installation.product == 0
|
||||||
|
? routes.installations
|
||||||
|
: installation.product == 1
|
||||||
|
? routes.salidomo_installations
|
||||||
|
: routes.sodiohome_installations;
|
||||||
|
|
||||||
|
let folder_path =
|
||||||
|
product == 0
|
||||||
|
? routes.installations
|
||||||
|
: product == 1
|
||||||
|
? routes.salidomo_installations
|
||||||
|
: routes.sodiohome_installations;
|
||||||
|
|
||||||
if (installation.type != 'Folder') {
|
if (installation.type != 'Folder') {
|
||||||
navigate(
|
navigate(
|
||||||
path +
|
installation_path +
|
||||||
routes.tree +
|
routes.tree +
|
||||||
routes.installation +
|
routes.installation +
|
||||||
installation.s3BucketId +
|
installation.id +
|
||||||
'/' +
|
'/' +
|
||||||
routes.live,
|
routes.live,
|
||||||
{
|
{
|
||||||
|
|
@ -63,7 +75,7 @@ function CustomTreeItem(props: CustomTreeItemProps) {
|
||||||
setSelected(!selected);
|
setSelected(!selected);
|
||||||
} else {
|
} else {
|
||||||
navigate(
|
navigate(
|
||||||
path +
|
folder_path +
|
||||||
routes.tree +
|
routes.tree +
|
||||||
routes.folder +
|
routes.folder +
|
||||||
installation.id +
|
installation.id +
|
||||||
|
|
@ -164,6 +176,8 @@ function CustomTreeItem(props: CustomTreeItemProps) {
|
||||||
currentLocation.pathname ===
|
currentLocation.pathname ===
|
||||||
routes.salidomo_installations + routes.tree ||
|
routes.salidomo_installations + routes.tree ||
|
||||||
currentLocation.pathname === routes.installations + routes.tree ||
|
currentLocation.pathname === routes.installations + routes.tree ||
|
||||||
|
currentLocation.pathname ===
|
||||||
|
routes.sodiohome_installations + routes.tree ||
|
||||||
currentLocation.pathname.includes('folder')
|
currentLocation.pathname.includes('folder')
|
||||||
? 'block'
|
? 'block'
|
||||||
: 'none',
|
: 'none',
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
deleteFolder
|
deleteFolder
|
||||||
} = installationContext;
|
} = installationContext;
|
||||||
|
|
||||||
//const { product, setProduct } = useContext(ProductIdContext);
|
|
||||||
const [product, setProduct] = useState('Salimax');
|
const [product, setProduct] = useState('Salimax');
|
||||||
|
|
||||||
const handleChangeInstallationChoice = (e) => {
|
const handleChangeInstallationChoice = (e) => {
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ import { InstallationsContext } from 'src/contexts/InstallationsContextProvider'
|
||||||
import { Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import routes from '../../../Resources/routes.json';
|
import routes from '../../../Resources/routes.json';
|
||||||
import SalidomoInstallation from '../SalidomoInstallations/Installation';
|
import SalidomoInstallation from '../SalidomoInstallations/Installation';
|
||||||
import { ProductIdContext } from '../../../contexts/ProductIdContextProvider';
|
|
||||||
import Folder from './Folder';
|
import Folder from './Folder';
|
||||||
|
import SodioHomeInstallation from '../SodiohomeInstallations/Installation';
|
||||||
|
import { ProductIdContext } from '../../../contexts/ProductIdContextProvider';
|
||||||
|
|
||||||
function InstallationTree() {
|
function InstallationTree() {
|
||||||
const { foldersAndInstallations, fetchAllFoldersAndInstallations } =
|
const { foldersAndInstallations, fetchAllFoldersAndInstallations } =
|
||||||
useContext(InstallationsContext);
|
useContext(InstallationsContext);
|
||||||
const { product, setProduct } = useContext(ProductIdContext);
|
|
||||||
|
|
||||||
const sortedInstallations = [...foldersAndInstallations].sort((a, b) => {
|
const sortedInstallations = [...foldersAndInstallations].sort((a, b) => {
|
||||||
// Compare the status field of each installation and sort them based on the status.
|
// Compare the status field of each installation and sort them based on the status.
|
||||||
|
|
@ -36,8 +36,10 @@ function InstallationTree() {
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { product } = useContext(ProductIdContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchAllFoldersAndInstallations(product);
|
fetchAllFoldersAndInstallations();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const TreeNode = ({ node, parent_id }) => {
|
const TreeNode = ({ node, parent_id }) => {
|
||||||
|
|
@ -50,11 +52,7 @@ function InstallationTree() {
|
||||||
subnode != node &&
|
subnode != node &&
|
||||||
subnode.parentId == node.id && (
|
subnode.parentId == node.id && (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
key={
|
key={subnode.id.toString() + subnode.type}
|
||||||
subnode.type == 'Installation'
|
|
||||||
? subnode.s3BucketId.toString() + subnode.type
|
|
||||||
: subnode.id.toString() + subnode.type
|
|
||||||
}
|
|
||||||
node={subnode}
|
node={subnode}
|
||||||
parent_id={node.id}
|
parent_id={node.id}
|
||||||
/>
|
/>
|
||||||
|
|
@ -82,21 +80,27 @@ function InstallationTree() {
|
||||||
if (installation.type == 'Installation') {
|
if (installation.type == 'Installation') {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Route
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
path={routes.installation + installation.s3BucketId + '*'}
|
path={routes.installation + installation.id + '*'}
|
||||||
element={
|
element={
|
||||||
product == 0 ? (
|
installation.product == 0 ? (
|
||||||
<Installation
|
<Installation
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
current_installation={installation}
|
current_installation={installation}
|
||||||
type="installation"
|
type="installation"
|
||||||
></Installation>
|
></Installation>
|
||||||
) : (
|
) : installation.product == 1 ? (
|
||||||
<SalidomoInstallation
|
<SalidomoInstallation
|
||||||
key={installation.s3BucketId}
|
key={installation.id}
|
||||||
current_installation={installation}
|
current_installation={installation}
|
||||||
type="installation"
|
type="installation"
|
||||||
></SalidomoInstallation>
|
></SalidomoInstallation>
|
||||||
|
) : (
|
||||||
|
<SodioHomeInstallation
|
||||||
|
key={installation.id}
|
||||||
|
current_installation={installation}
|
||||||
|
type="installation"
|
||||||
|
></SodioHomeInstallation>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -126,11 +130,7 @@ function InstallationTree() {
|
||||||
{foldersAndInstallations.map((node, index) => {
|
{foldersAndInstallations.map((node, index) => {
|
||||||
return (
|
return (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
key={
|
key={node.id.toString() + node.type}
|
||||||
node.type == 'Installation'
|
|
||||||
? node.s3BucketId.toString() + node.type
|
|
||||||
: node.id.toString() + node.type
|
|
||||||
}
|
|
||||||
node={node}
|
node={node}
|
||||||
parent_id={'0'}
|
parent_id={'0'}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,7 @@ const InstallationsContextProvider = ({
|
||||||
.put('/UpdateInstallation', formValues)
|
.put('/UpdateInstallation', formValues)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setUpdated(true);
|
setUpdated(true);
|
||||||
|
setLoading(false);
|
||||||
if (formValues.product === 0 && view === 'installation')
|
if (formValues.product === 0 && view === 'installation')
|
||||||
fetchAllInstallations();
|
fetchAllInstallations();
|
||||||
else if (formValues.product === 1 && view === 'installation')
|
else if (formValues.product === 1 && view === 'installation')
|
||||||
|
|
@ -286,6 +287,7 @@ const InstallationsContextProvider = ({
|
||||||
.delete(`/DeleteInstallation?installationId=${formValues.id}`)
|
.delete(`/DeleteInstallation?installationId=${formValues.id}`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setUpdated(true);
|
setUpdated(true);
|
||||||
|
setLoading(false);
|
||||||
if (formValues.product === 0 && view === 'installation')
|
if (formValues.product === 0 && view === 'installation')
|
||||||
fetchAllInstallations();
|
fetchAllInstallations();
|
||||||
else if (formValues.product === 1 && view === 'installation')
|
else if (formValues.product === 1 && view === 'installation')
|
||||||
|
|
@ -317,7 +319,10 @@ const InstallationsContextProvider = ({
|
||||||
async (formValues: Partial<I_Folder>, product: number) => {
|
async (formValues: Partial<I_Folder>, product: number) => {
|
||||||
axiosConfig
|
axiosConfig
|
||||||
.post('/CreateFolder', formValues)
|
.post('/CreateFolder', formValues)
|
||||||
.then(() => fetchAllFoldersAndInstallations(product))
|
.then(() => {
|
||||||
|
setLoading(false);
|
||||||
|
fetchAllFoldersAndInstallations(product);
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(true);
|
setError(true);
|
||||||
if (error.response?.status === 401) {
|
if (error.response?.status === 401) {
|
||||||
|
|
@ -334,6 +339,7 @@ const InstallationsContextProvider = ({
|
||||||
axiosConfig
|
axiosConfig
|
||||||
.put('/UpdateFolder', formValues)
|
.put('/UpdateFolder', formValues)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
setLoading(false);
|
||||||
setUpdated(true);
|
setUpdated(true);
|
||||||
|
|
||||||
fetchAllFoldersAndInstallations(product);
|
fetchAllFoldersAndInstallations(product);
|
||||||
|
|
@ -357,6 +363,7 @@ const InstallationsContextProvider = ({
|
||||||
.delete(`/DeleteFolder?folderId=${formValues.id}`)
|
.delete(`/DeleteFolder?folderId=${formValues.id}`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setUpdated(true);
|
setUpdated(true);
|
||||||
|
setLoading(false);
|
||||||
fetchAllFoldersAndInstallations(product);
|
fetchAllFoldersAndInstallations(product);
|
||||||
setTimeout(() => setUpdated(false), 3000);
|
setTimeout(() => setUpdated(false), 3000);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,6 @@ export const ProductIdContext = createContext<ProductIdContextType | undefined>(
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
// Define the product mapping for dynamic assignment
|
|
||||||
// const productMapping: { [key: string]: number } = {
|
|
||||||
// salimax: 0,
|
|
||||||
// salidomo: 1,
|
|
||||||
// sodiohome: 2,
|
|
||||||
// // Additional mappings can be added here
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Create a UserContextProvider component
|
// Create a UserContextProvider component
|
||||||
export const ProductIdContextProvider = ({
|
export const ProductIdContextProvider = ({
|
||||||
children
|
children
|
||||||
|
|
@ -60,6 +52,7 @@ export const ProductIdContextProvider = ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const changeProductId = (new_product: number) => {
|
const changeProductId = (new_product: number) => {
|
||||||
|
// console.log('from provider' + new_product);
|
||||||
setProduct(new_product);
|
setProduct(new_product);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ export interface I_Folder {
|
||||||
name: string;
|
name: string;
|
||||||
information: string;
|
information: string;
|
||||||
parentId: number;
|
parentId: number;
|
||||||
|
product: number;
|
||||||
type: string;
|
type: string;
|
||||||
s3BucketId: number;
|
s3BucketId: number;
|
||||||
status?: number;
|
status?: number;
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,8 @@ function SidebarMenu() {
|
||||||
const { closeSidebar } = useContext(SidebarContext);
|
const { closeSidebar } = useContext(SidebarContext);
|
||||||
const context = useContext(UserContext);
|
const context = useContext(UserContext);
|
||||||
const { currentUser, setUser } = context;
|
const { currentUser, setUser } = context;
|
||||||
const { accessToSalimax, accessToSalidomo,accessToSodiohome } = useContext(ProductIdContext);
|
const { accessToSalimax, accessToSalidomo, accessToSodiohome } =
|
||||||
|
useContext(ProductIdContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -228,7 +229,10 @@ function SidebarMenu() {
|
||||||
startIcon={<BrightnessLowTwoToneIcon />}
|
startIcon={<BrightnessLowTwoToneIcon />}
|
||||||
>
|
>
|
||||||
<Box sx={{ marginTop: '3px' }}>
|
<Box sx={{ marginTop: '3px' }}>
|
||||||
<FormattedMessage id="sodiohome" defaultMessage="Sodiohome" />
|
<FormattedMessage
|
||||||
|
id="sodiohome"
|
||||||
|
defaultMessage="Sodiohome"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Button>
|
</Button>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue