Fixed create installation tab (do not depend on product id)

This commit is contained in:
Noe 2025-01-20 08:33:24 +01:00
parent 63f60bdb3e
commit 4e28d56346
7 changed files with 143 additions and 19 deletions

View File

@ -5,7 +5,8 @@ namespace InnovEnergy.App.Backend.DataTypes;
public enum ProductType
{
Salimax = 0,
Salidomo = 1
Salidomo = 1,
SodioHome =2
}
public enum StatusType

View File

@ -14,6 +14,7 @@ public class Session : Relation<String, Int64>
[Indexed] public DateTime LastSeen { get; set; }
public Boolean AccessToSalimax { get; set; } = false;
public Boolean AccessToSalidomo { get; set; } = false;
public Boolean AccessToSodioHome { get; set; } = false;
[Ignore] public Boolean Valid => DateTime.Now - LastSeen <=MaxAge ;
// Private backing field
@ -45,6 +46,7 @@ public class Session : Relation<String, Int64>
LastSeen = DateTime.Now;
AccessToSalimax = user.AccessibleInstallations(product: (int)ProductType.Salimax).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()

View File

@ -1,5 +1,5 @@
#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
#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'

View File

@ -54,6 +54,6 @@ INNOVENERGY_PROTOCOL_VERSION = '48TL200V3'
# S3 Credentials
S3BUCKET = "140-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e"
S3KEY = "EXOa947c7fc5990a7a6f6c40860"
S3SECRET = "J1yOTLbYEO6cMxQ2wgIwe__ru9-_RH5BBtKzx_2JJHk"
S3BUCKET = "158-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e"
S3KEY = "EXOf4d6d68a9ce062f25541fe4a"
S3SECRET = "4zTQBvwIWnFYajRhoZW0F7k_6rdhnPiSqdvw9cMAZw8"

View File

@ -1,12 +1,12 @@
import axios from 'axios';
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'
});
const axiosConfig = axios.create({
baseURL: 'https://monitor.innov.energy/api'
baseURL: 'https://stage.innov.energy/api'
//baseURL: 'http://127.0.0.1:7087/api'
});

View File

@ -130,11 +130,11 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
</TableHead>
<TableBody>
{sortedInstallations
// .filter(
// (installation) =>
// installation.status === -1 &&
// installation.testingMode == false
// )
.filter(
(installation) =>
installation.status === -1 &&
installation.testingMode == false
)
.map((installation) => {
const isInstallationSelected =
installation.s3BucketId === selectedInstallation;

View File

@ -4,9 +4,13 @@ import {
CardContent,
CircularProgress,
Container,
FormControl,
Grid,
IconButton,
InputLabel,
MenuItem,
Modal,
Select,
TextField,
Typography,
useTheme
@ -18,11 +22,10 @@ import React, { useContext, useState } from 'react';
import { I_Folder } from '../../../interfaces/InstallationTypes';
import { UserContext } from '../../../contexts/userContext';
import FolderForm from './folderForm';
import InstallationForm from '../Installations/installationForm';
import { InstallationsContext } from '../../../contexts/InstallationsContextProvider';
import { UserType } from '../../../interfaces/UserTypes';
import InstallationForm from '../Installations/installationForm';
import SalidomoInstallationForm from '../SalidomoInstallations/SalidomoInstallationForm';
import { ProductIdContext } from '../../../contexts/ProductIdContextProvider';
import SodiohomeInstallationForm from '../SodiohomeInstallations/SodiohomeInstallationForm';
interface TreeInformationProps {
@ -38,6 +41,8 @@ function TreeInformation(props: TreeInformationProps) {
const { currentUser } = context;
const [formValues, setFormValues] = useState(props.folder);
const [openModalFolder, setOpenModalFolder] = useState(false);
const [openModalInstallationChoice, setOpenModalInstallationChoice] =
useState(false);
const [openModalInstallation, setOpenModalInstallation] = useState(false);
const requiredFields = ['name'];
const [openModalDeleteFolder, setOpenModalDeleteFolder] = useState(false);
@ -53,7 +58,17 @@ function TreeInformation(props: TreeInformationProps) {
deleteFolder
} = 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 { name, value } = e.target;
@ -70,6 +85,16 @@ function TreeInformation(props: TreeInformationProps) {
};
const handleNewInstallationInsertion = () => {
setOpenModalInstallationChoice(true);
//setOpenModalInstallation(true);
};
const handleCancelSubmitInstallationChoice = () => {
setOpenModalInstallationChoice(false);
};
const handleSubmitInstallationChoice = () => {
setOpenModalInstallationChoice(false);
setOpenModalInstallation(true);
};
@ -200,21 +225,117 @@ function TreeInformation(props: TreeInformationProps) {
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
cancel={handleFormCancel}
submit={handleInstallationFormSubmit}
parentid={props.folder.id}
/>
)}
{openModalInstallation && product == 1 && (
{openModalInstallation && product == 'Salidomo' && (
<SalidomoInstallationForm
cancel={handleFormCancel}
submit={handleInstallationFormSubmit}
parentid={props.folder.id}
/>
)}
{openModalInstallation && product == 2 && (
{openModalInstallation && product == 'Sodiohome' && (
<SodiohomeInstallationForm
cancel={handleFormCancel}
submit={handleInstallationFormSubmit}