Fixed create installation tab (do not depend on product id)
This commit is contained in:
parent
63f60bdb3e
commit
4e28d56346
|
@ -5,7 +5,8 @@ namespace InnovEnergy.App.Backend.DataTypes;
|
||||||
public enum ProductType
|
public enum ProductType
|
||||||
{
|
{
|
||||||
Salimax = 0,
|
Salimax = 0,
|
||||||
Salidomo = 1
|
Salidomo = 1,
|
||||||
|
SodioHome =2
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum StatusType
|
public enum StatusType
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class Session : Relation<String, Int64>
|
||||||
[Indexed] public DateTime LastSeen { get; set; }
|
[Indexed] public DateTime LastSeen { get; set; }
|
||||||
public Boolean AccessToSalimax { get; set; } = false;
|
public Boolean AccessToSalimax { get; set; } = false;
|
||||||
public Boolean AccessToSalidomo { get; set; } = false;
|
public Boolean AccessToSalidomo { get; set; } = false;
|
||||||
|
public Boolean AccessToSodioHome { get; set; } = false;
|
||||||
[Ignore] public Boolean Valid => DateTime.Now - LastSeen <=MaxAge ;
|
[Ignore] public Boolean Valid => DateTime.Now - LastSeen <=MaxAge ;
|
||||||
|
|
||||||
// Private backing field
|
// Private backing field
|
||||||
|
@ -45,6 +46,7 @@ public class Session : Relation<String, Int64>
|
||||||
LastSeen = DateTime.Now;
|
LastSeen = DateTime.Now;
|
||||||
AccessToSalimax = user.AccessibleInstallations(product: (int)ProductType.Salimax).ToList().Count > 0;
|
AccessToSalimax = user.AccessibleInstallations(product: (int)ProductType.Salimax).ToList().Count > 0;
|
||||||
AccessToSalidomo = user.AccessibleInstallations(product: (int)ProductType.Salidomo).ToList().Count > 0;
|
AccessToSalidomo = user.AccessibleInstallations(product: (int)ProductType.Salidomo).ToList().Count > 0;
|
||||||
|
AccessToSodioHome = user.AccessibleInstallations(product: (int)ProductType.SodioHome).ToList().Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String CreateToken()
|
private static String CreateToken()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#To deploy to the monitor server, uncomment the following line
|
#To deploy to the monitor server, uncomment the following line
|
||||||
dotnet publish Backend.csproj -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=false && rsync -av bin/Release/net6.0/linux-x64/publish/ ubuntu@194.182.190.208:~/backend && ssh ubuntu@194.182.190.208 'sudo systemctl restart backend'
|
#dotnet publish Backend.csproj -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=false && rsync -av bin/Release/net6.0/linux-x64/publish/ ubuntu@194.182.190.208:~/backend && ssh ubuntu@194.182.190.208 'sudo systemctl restart backend'
|
||||||
|
|
||||||
#To deploy to the stage server, uncomment the following line
|
#To deploy to the stage server, uncomment the following line
|
||||||
#dotnet publish Backend.csproj -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=false && rsync -av bin/Release/net6.0/linux-x64/publish/ ubuntu@91.92.154.141:~/backend && ssh ubuntu@91.92.154.141 'sudo systemctl restart backend'
|
dotnet publish Backend.csproj -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=false && rsync -av bin/Release/net6.0/linux-x64/publish/ ubuntu@91.92.154.141:~/backend && ssh ubuntu@91.92.154.141 'sudo systemctl restart backend'
|
||||||
|
|
|
@ -54,6 +54,6 @@ INNOVENERGY_PROTOCOL_VERSION = '48TL200V3'
|
||||||
|
|
||||||
|
|
||||||
# S3 Credentials
|
# S3 Credentials
|
||||||
S3BUCKET = "140-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e"
|
S3BUCKET = "158-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e"
|
||||||
S3KEY = "EXOa947c7fc5990a7a6f6c40860"
|
S3KEY = "EXOf4d6d68a9ce062f25541fe4a"
|
||||||
S3SECRET = "J1yOTLbYEO6cMxQ2wgIwe__ru9-_RH5BBtKzx_2JJHk"
|
S3SECRET = "4zTQBvwIWnFYajRhoZW0F7k_6rdhnPiSqdvw9cMAZw8"
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
export const axiosConfigWithoutToken = axios.create({
|
export const axiosConfigWithoutToken = axios.create({
|
||||||
baseURL: 'https://monitor.innov.energy/api'
|
baseURL: 'https://stage.innov.energy/api'
|
||||||
//baseURL: 'http://127.0.0.1:7087/api'
|
//baseURL: 'http://127.0.0.1:7087/api'
|
||||||
});
|
});
|
||||||
|
|
||||||
const axiosConfig = axios.create({
|
const axiosConfig = axios.create({
|
||||||
baseURL: 'https://monitor.innov.energy/api'
|
baseURL: 'https://stage.innov.energy/api'
|
||||||
//baseURL: 'http://127.0.0.1:7087/api'
|
//baseURL: 'http://127.0.0.1:7087/api'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -130,11 +130,11 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{sortedInstallations
|
{sortedInstallations
|
||||||
// .filter(
|
.filter(
|
||||||
// (installation) =>
|
(installation) =>
|
||||||
// installation.status === -1 &&
|
installation.status === -1 &&
|
||||||
// installation.testingMode == false
|
installation.testingMode == false
|
||||||
// )
|
)
|
||||||
.map((installation) => {
|
.map((installation) => {
|
||||||
const isInstallationSelected =
|
const isInstallationSelected =
|
||||||
installation.s3BucketId === selectedInstallation;
|
installation.s3BucketId === selectedInstallation;
|
||||||
|
|
|
@ -4,9 +4,13 @@ import {
|
||||||
CardContent,
|
CardContent,
|
||||||
CircularProgress,
|
CircularProgress,
|
||||||
Container,
|
Container,
|
||||||
|
FormControl,
|
||||||
Grid,
|
Grid,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
InputLabel,
|
||||||
|
MenuItem,
|
||||||
Modal,
|
Modal,
|
||||||
|
Select,
|
||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
useTheme
|
useTheme
|
||||||
|
@ -18,11 +22,10 @@ import React, { useContext, useState } from 'react';
|
||||||
import { I_Folder } from '../../../interfaces/InstallationTypes';
|
import { I_Folder } from '../../../interfaces/InstallationTypes';
|
||||||
import { UserContext } from '../../../contexts/userContext';
|
import { UserContext } from '../../../contexts/userContext';
|
||||||
import FolderForm from './folderForm';
|
import FolderForm from './folderForm';
|
||||||
import InstallationForm from '../Installations/installationForm';
|
|
||||||
import { InstallationsContext } from '../../../contexts/InstallationsContextProvider';
|
import { InstallationsContext } from '../../../contexts/InstallationsContextProvider';
|
||||||
import { UserType } from '../../../interfaces/UserTypes';
|
import { UserType } from '../../../interfaces/UserTypes';
|
||||||
|
import InstallationForm from '../Installations/installationForm';
|
||||||
import SalidomoInstallationForm from '../SalidomoInstallations/SalidomoInstallationForm';
|
import SalidomoInstallationForm from '../SalidomoInstallations/SalidomoInstallationForm';
|
||||||
import { ProductIdContext } from '../../../contexts/ProductIdContextProvider';
|
|
||||||
import SodiohomeInstallationForm from '../SodiohomeInstallations/SodiohomeInstallationForm';
|
import SodiohomeInstallationForm from '../SodiohomeInstallations/SodiohomeInstallationForm';
|
||||||
|
|
||||||
interface TreeInformationProps {
|
interface TreeInformationProps {
|
||||||
|
@ -38,6 +41,8 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
const { currentUser } = context;
|
const { currentUser } = context;
|
||||||
const [formValues, setFormValues] = useState(props.folder);
|
const [formValues, setFormValues] = useState(props.folder);
|
||||||
const [openModalFolder, setOpenModalFolder] = useState(false);
|
const [openModalFolder, setOpenModalFolder] = useState(false);
|
||||||
|
const [openModalInstallationChoice, setOpenModalInstallationChoice] =
|
||||||
|
useState(false);
|
||||||
const [openModalInstallation, setOpenModalInstallation] = useState(false);
|
const [openModalInstallation, setOpenModalInstallation] = useState(false);
|
||||||
const requiredFields = ['name'];
|
const requiredFields = ['name'];
|
||||||
const [openModalDeleteFolder, setOpenModalDeleteFolder] = useState(false);
|
const [openModalDeleteFolder, setOpenModalDeleteFolder] = useState(false);
|
||||||
|
@ -53,7 +58,17 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
deleteFolder
|
deleteFolder
|
||||||
} = installationContext;
|
} = installationContext;
|
||||||
|
|
||||||
const { product, setProduct } = useContext(ProductIdContext);
|
//const { product, setProduct } = useContext(ProductIdContext);
|
||||||
|
const [product, setProduct] = useState('Salimax');
|
||||||
|
|
||||||
|
const handleChangeInstallationChoice = (e) => {
|
||||||
|
setProduct(e.target.value); // Directly update the product state
|
||||||
|
// console.log('Selected Product:', e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ProductTypes = ['Salimax', 'Salidomo', 'Sodiohome'];
|
||||||
|
|
||||||
|
const isMobile = window.innerWidth <= 1490;
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
|
@ -70,6 +85,16 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNewInstallationInsertion = () => {
|
const handleNewInstallationInsertion = () => {
|
||||||
|
setOpenModalInstallationChoice(true);
|
||||||
|
//setOpenModalInstallation(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancelSubmitInstallationChoice = () => {
|
||||||
|
setOpenModalInstallationChoice(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmitInstallationChoice = () => {
|
||||||
|
setOpenModalInstallationChoice(false);
|
||||||
setOpenModalInstallation(true);
|
setOpenModalInstallation(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -200,21 +225,117 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
parentid={props.folder.id}
|
parentid={props.folder.id}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{openModalInstallation && product == 0 && (
|
{openModalInstallationChoice && (
|
||||||
|
<Modal
|
||||||
|
open={openModalInstallationChoice}
|
||||||
|
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>
|
||||||
|
<FormControl
|
||||||
|
fullWidth
|
||||||
|
sx={{ marginTop: 1, marginBottom: 1, width: 390 }}
|
||||||
|
>
|
||||||
|
<InputLabel
|
||||||
|
sx={{
|
||||||
|
fontSize: 14,
|
||||||
|
backgroundColor: 'white'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="producType"
|
||||||
|
defaultMessage="Select a Product"
|
||||||
|
/>
|
||||||
|
</InputLabel>
|
||||||
|
<Select
|
||||||
|
name="product"
|
||||||
|
value={product}
|
||||||
|
onChange={handleChangeInstallationChoice}
|
||||||
|
>
|
||||||
|
{ProductTypes.map((type) => (
|
||||||
|
<MenuItem key={type} value={type}>
|
||||||
|
{type}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center', // Center horizontally
|
||||||
|
alignItems: 'center', // Center vertically
|
||||||
|
marginTop: 20,
|
||||||
|
gap: '10px' // Space between buttons
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleSubmitInstallationChoice}
|
||||||
|
sx={{
|
||||||
|
marginLeft: '20px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage id="submit" defaultMessage="Submit" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleCancelSubmitInstallationChoice}
|
||||||
|
sx={{
|
||||||
|
marginLeft: '10px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage id="cancel" defaultMessage="Cancel" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
|
{openModalInstallation && product == 'Salimax' && (
|
||||||
<InstallationForm
|
<InstallationForm
|
||||||
cancel={handleFormCancel}
|
cancel={handleFormCancel}
|
||||||
submit={handleInstallationFormSubmit}
|
submit={handleInstallationFormSubmit}
|
||||||
parentid={props.folder.id}
|
parentid={props.folder.id}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{openModalInstallation && product == 1 && (
|
{openModalInstallation && product == 'Salidomo' && (
|
||||||
<SalidomoInstallationForm
|
<SalidomoInstallationForm
|
||||||
cancel={handleFormCancel}
|
cancel={handleFormCancel}
|
||||||
submit={handleInstallationFormSubmit}
|
submit={handleInstallationFormSubmit}
|
||||||
parentid={props.folder.id}
|
parentid={props.folder.id}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{openModalInstallation && product == 2 && (
|
{openModalInstallation && product == 'Sodiohome' && (
|
||||||
<SodiohomeInstallationForm
|
<SodiohomeInstallationForm
|
||||||
cancel={handleFormCancel}
|
cancel={handleFormCancel}
|
||||||
submit={handleInstallationFormSubmit}
|
submit={handleInstallationFormSubmit}
|
||||||
|
|
Loading…
Reference in New Issue