frontend ready to implement index.tsx for Sodiohome

This commit is contained in:
Noe 2025-01-20 10:54:33 +01:00
parent 4e28d56346
commit 3ea01e3df0
4 changed files with 24 additions and 14 deletions

View File

@ -41,6 +41,7 @@ public class Installation : TreeNode
public int Status { get; set; } = -1;
public int Product { get; set; } = (int)ProductType.Salimax;
public int Device { get; set; } = 0;
public string SerialNumber { get; set; } = "";
[Ignore]
public String OrderNumbers { get; set; }

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

@ -122,11 +122,13 @@ function TreeInformation(props: TreeInformationProps) {
const handleFolderFormSubmit = () => {
setOpenModalFolder(false);
setOpenModalInstallation(false);
setLoading(false);
};
const handleInstallationFormSubmit = () => {
setOpenModalFolder(false);
setOpenModalInstallation(false);
setLoading(false);
};
const handleFormCancel = () => {

View File

@ -82,10 +82,10 @@ const InstallationsContextProvider = ({
const update = pendingUpdates.current[installation.id];
return update
? {
...installation,
status: update.status,
testingMode: update.testingMode
}
...installation,
status: update.status,
testingMode: update.testingMode
}
: installation;
});
@ -95,7 +95,7 @@ const InstallationsContextProvider = ({
// Clear the pending updates after applying
pendingUpdates.current = {};
}, [salidomoInstallations, salimaxInstallations,sodiohomeInstallations]);
}, [salidomoInstallations, salimaxInstallations, sodiohomeInstallations]);
useEffect(() => {
const timer = setInterval(() => {
@ -109,7 +109,7 @@ const InstallationsContextProvider = ({
setcurrentProduct(product);
const tokenString = localStorage.getItem('token');
const token = tokenString !== null ? tokenString : '';
const urlWithToken = `wss://monitor.innov.energy/api/CreateWebSocket?authToken=${token}`;
const urlWithToken = `wss://stage.innov.energy/api/CreateWebSocket?authToken=${token}`;
const socket = new WebSocket(urlWithToken);
@ -126,7 +126,9 @@ const InstallationsContextProvider = ({
// Send the corresponding installation IDs
socket.send(
JSON.stringify(installationsToSend.map((installation) => installation.id))
JSON.stringify(
installationsToSend.map((installation) => installation.id)
)
);
});
@ -199,7 +201,7 @@ const InstallationsContextProvider = ({
const fetchAllSodiohomeInstallations = useCallback(async () => {
axiosConfig
.get('/GetAllSodiohomeInstallations')
.get('/GetAllSodioHomeInstallations')
.then((res: AxiosResponse<I_Installation[]>) =>
setSodiohomeInstallations(res.data)
)
@ -230,7 +232,10 @@ const InstallationsContextProvider = ({
async (formValues: Partial<I_Installation>) => {
axiosConfig
.post('/CreateInstallation', formValues)
.then(() => fetchAllFoldersAndInstallations(formValues.product))
.then(() => {
setLoading(false);
fetchAllFoldersAndInstallations(formValues.product);
})
.catch((error) => {
setError(true);
if (error.response?.status === 401) {
@ -330,8 +335,10 @@ const InstallationsContextProvider = ({
.put('/UpdateFolder', formValues)
.then(() => {
setUpdated(true);
fetchAllFoldersAndInstallations(product);
setTimeout(() => setUpdated(false), 3000);
setLoading(false);
})
.catch((error) => {
setError(true);