frontend ready to implement index.tsx for Sodiohome
This commit is contained in:
parent
4e28d56346
commit
3ea01e3df0
|
@ -41,6 +41,7 @@ public class Installation : TreeNode
|
||||||
public int Status { get; set; } = -1;
|
public int Status { get; set; } = -1;
|
||||||
public int Product { get; set; } = (int)ProductType.Salimax;
|
public int Product { get; set; } = (int)ProductType.Salimax;
|
||||||
public int Device { get; set; } = 0;
|
public int Device { get; set; } = 0;
|
||||||
|
public string SerialNumber { get; set; } = "";
|
||||||
|
|
||||||
[Ignore]
|
[Ignore]
|
||||||
public String OrderNumbers { get; set; }
|
public String OrderNumbers { get; set; }
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -122,11 +122,13 @@ function TreeInformation(props: TreeInformationProps) {
|
||||||
const handleFolderFormSubmit = () => {
|
const handleFolderFormSubmit = () => {
|
||||||
setOpenModalFolder(false);
|
setOpenModalFolder(false);
|
||||||
setOpenModalInstallation(false);
|
setOpenModalInstallation(false);
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInstallationFormSubmit = () => {
|
const handleInstallationFormSubmit = () => {
|
||||||
setOpenModalFolder(false);
|
setOpenModalFolder(false);
|
||||||
setOpenModalInstallation(false);
|
setOpenModalInstallation(false);
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFormCancel = () => {
|
const handleFormCancel = () => {
|
||||||
|
|
|
@ -95,7 +95,7 @@ const InstallationsContextProvider = ({
|
||||||
|
|
||||||
// Clear the pending updates after applying
|
// Clear the pending updates after applying
|
||||||
pendingUpdates.current = {};
|
pendingUpdates.current = {};
|
||||||
}, [salidomoInstallations, salimaxInstallations,sodiohomeInstallations]);
|
}, [salidomoInstallations, salimaxInstallations, sodiohomeInstallations]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
|
@ -109,7 +109,7 @@ const InstallationsContextProvider = ({
|
||||||
setcurrentProduct(product);
|
setcurrentProduct(product);
|
||||||
const tokenString = localStorage.getItem('token');
|
const tokenString = localStorage.getItem('token');
|
||||||
const token = tokenString !== null ? tokenString : '';
|
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);
|
const socket = new WebSocket(urlWithToken);
|
||||||
|
|
||||||
|
@ -126,7 +126,9 @@ const InstallationsContextProvider = ({
|
||||||
|
|
||||||
// Send the corresponding installation IDs
|
// Send the corresponding installation IDs
|
||||||
socket.send(
|
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 () => {
|
const fetchAllSodiohomeInstallations = useCallback(async () => {
|
||||||
axiosConfig
|
axiosConfig
|
||||||
.get('/GetAllSodiohomeInstallations')
|
.get('/GetAllSodioHomeInstallations')
|
||||||
.then((res: AxiosResponse<I_Installation[]>) =>
|
.then((res: AxiosResponse<I_Installation[]>) =>
|
||||||
setSodiohomeInstallations(res.data)
|
setSodiohomeInstallations(res.data)
|
||||||
)
|
)
|
||||||
|
@ -230,7 +232,10 @@ const InstallationsContextProvider = ({
|
||||||
async (formValues: Partial<I_Installation>) => {
|
async (formValues: Partial<I_Installation>) => {
|
||||||
axiosConfig
|
axiosConfig
|
||||||
.post('/CreateInstallation', formValues)
|
.post('/CreateInstallation', formValues)
|
||||||
.then(() => fetchAllFoldersAndInstallations(formValues.product))
|
.then(() => {
|
||||||
|
setLoading(false);
|
||||||
|
fetchAllFoldersAndInstallations(formValues.product);
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(true);
|
setError(true);
|
||||||
if (error.response?.status === 401) {
|
if (error.response?.status === 401) {
|
||||||
|
@ -330,8 +335,10 @@ const InstallationsContextProvider = ({
|
||||||
.put('/UpdateFolder', formValues)
|
.put('/UpdateFolder', formValues)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setUpdated(true);
|
setUpdated(true);
|
||||||
|
|
||||||
fetchAllFoldersAndInstallations(product);
|
fetchAllFoldersAndInstallations(product);
|
||||||
setTimeout(() => setUpdated(false), 3000);
|
setTimeout(() => setUpdated(false), 3000);
|
||||||
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(true);
|
setError(true);
|
||||||
|
|
Loading…
Reference in New Issue