From 4e28d56346059f65238aa29c0931f980734e5b37 Mon Sep 17 00:00:00 2001 From: Noe Date: Mon, 20 Jan 2025 08:33:24 +0100 Subject: [PATCH] Fixed create installation tab (do not depend on product id) --- csharp/App/Backend/DataTypes/Installation.cs | 3 +- csharp/App/Backend/Relations/Session.cs | 2 + csharp/App/Backend/deploy.sh | 4 +- .../dbus-fzsonick-48tl/config.py | 6 +- .../src/Resources/axiosConfig.tsx | 4 +- .../FlatInstallationView.tsx | 10 +- .../content/dashboards/Tree/Information.tsx | 133 +++++++++++++++++- 7 files changed, 143 insertions(+), 19 deletions(-) diff --git a/csharp/App/Backend/DataTypes/Installation.cs b/csharp/App/Backend/DataTypes/Installation.cs index f67c0c921..a5af9b9e0 100644 --- a/csharp/App/Backend/DataTypes/Installation.cs +++ b/csharp/App/Backend/DataTypes/Installation.cs @@ -5,7 +5,8 @@ namespace InnovEnergy.App.Backend.DataTypes; public enum ProductType { Salimax = 0, - Salidomo = 1 + Salidomo = 1, + SodioHome =2 } public enum StatusType diff --git a/csharp/App/Backend/Relations/Session.cs b/csharp/App/Backend/Relations/Session.cs index 9f7b037ea..e87b762e4 100644 --- a/csharp/App/Backend/Relations/Session.cs +++ b/csharp/App/Backend/Relations/Session.cs @@ -14,6 +14,7 @@ public class Session : Relation [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 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() diff --git a/csharp/App/Backend/deploy.sh b/csharp/App/Backend/deploy.sh index ff3675a7d..52b6913db 100755 --- a/csharp/App/Backend/deploy.sh +++ b/csharp/App/Backend/deploy.sh @@ -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' diff --git a/firmware/Venus_Release/VenusReleaseFiles/dbus-fzsonick-48tl/config.py b/firmware/Venus_Release/VenusReleaseFiles/dbus-fzsonick-48tl/config.py index 595ed1bcb..02e178bdf 100755 --- a/firmware/Venus_Release/VenusReleaseFiles/dbus-fzsonick-48tl/config.py +++ b/firmware/Venus_Release/VenusReleaseFiles/dbus-fzsonick-48tl/config.py @@ -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" diff --git a/typescript/frontend-marios2/src/Resources/axiosConfig.tsx b/typescript/frontend-marios2/src/Resources/axiosConfig.tsx index 0d4606588..9f230ab85 100644 --- a/typescript/frontend-marios2/src/Resources/axiosConfig.tsx +++ b/typescript/frontend-marios2/src/Resources/axiosConfig.tsx @@ -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' }); diff --git a/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/FlatInstallationView.tsx b/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/FlatInstallationView.tsx index 84ac01509..cf43e6912 100644 --- a/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/FlatInstallationView.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/FlatInstallationView.tsx @@ -130,11 +130,11 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => { {sortedInstallations - // .filter( - // (installation) => - // installation.status === -1 && - // installation.testingMode == false - // ) + .filter( + (installation) => + installation.status === -1 && + installation.testingMode == false + ) .map((installation) => { const isInstallationSelected = installation.s3BucketId === selectedInstallation; diff --git a/typescript/frontend-marios2/src/content/dashboards/Tree/Information.tsx b/typescript/frontend-marios2/src/content/dashboards/Tree/Information.tsx index 0f698d296..c33c456b2 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Tree/Information.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Tree/Information.tsx @@ -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 && ( + {}} + aria-labelledby="error-modal" + aria-describedby="error-modal-description" + > + + +
+ + + + + + +
+
+
+ + + +
+
+
+ )} + {openModalInstallation && product == 'Salimax' && ( )} - {openModalInstallation && product == 1 && ( + {openModalInstallation && product == 'Salidomo' && ( )} - {openModalInstallation && product == 2 && ( + {openModalInstallation && product == 'Sodiohome' && (