diff --git a/csharp/App/Backend/Program.cs b/csharp/App/Backend/Program.cs index 89d449465..aef349777 100644 --- a/csharp/App/Backend/Program.cs +++ b/csharp/App/Backend/Program.cs @@ -18,9 +18,11 @@ public static class Program public static void Main(String[] args) { //Db.CreateFakeRelations(); + Watchdog.NotifyReady(); Db.Init(); var builder = WebApplication.CreateBuilder(args); + string vpnServerIp = "194.182.190.208"; //string vpnServerIp = "127.0.0.1"; WebsocketManager.Factory = new ConnectionFactory { HostName = vpnServerIp}; diff --git a/csharp/App/Backend/Relations/Session.cs b/csharp/App/Backend/Relations/Session.cs index 34cbff4f0..c86cb3c38 100644 --- a/csharp/App/Backend/Relations/Session.cs +++ b/csharp/App/Backend/Relations/Session.cs @@ -34,9 +34,10 @@ public class Session : Relation private static String CreateToken() { - var token = new Byte[24]; - Random.Shared.NextBytes(token); - return Convert.ToBase64String(token).Replace("/",""); + //var token = new Byte[24]; + //Random.Shared.NextBytes(token); + //return Convert.ToBase64String(token).Replace("/",""); + return Guid.NewGuid().ToString("N"); } } \ No newline at end of file diff --git a/csharp/App/Backend/Websockets/WebsockerManager.cs b/csharp/App/Backend/Websockets/WebsockerManager.cs index 00ef1b1e0..b2a1f2924 100644 --- a/csharp/App/Backend/Websockets/WebsockerManager.cs +++ b/csharp/App/Backend/Websockets/WebsockerManager.cs @@ -190,7 +190,7 @@ public static class WebsocketManager Console.WriteLine("Create new empty list for installation id " + installationId); InstallationConnections[installationId] = new InstallationInfo { - Status = -2 + Status = -1 }; } diff --git a/typescript/frontend-marios2/src/App.tsx b/typescript/frontend-marios2/src/App.tsx index df14a337a..29ee0324f 100644 --- a/typescript/frontend-marios2/src/App.tsx +++ b/typescript/frontend-marios2/src/App.tsx @@ -140,39 +140,39 @@ function App() { locale={language} defaultLocale="en" > - - - } - > - + + + + } + > + - - } - > - - - - - } - /> + > + + + + + + } + /> - } /> + } /> - }> - - + }> + + + ); diff --git a/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx b/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx index 9ab18fb6a..c6cda3cca 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx @@ -17,7 +17,6 @@ interface installationSearchProps { function InstallationSearch(props: installationSearchProps) { const theme = useTheme(); const [searchTerm, setSearchTerm] = useState(''); - const searchParams = new URLSearchParams(location.search); const installationId = parseInt(searchParams.get('installation')); diff --git a/typescript/frontend-marios2/src/contexts/InstallationsContextProvider.tsx b/typescript/frontend-marios2/src/contexts/InstallationsContextProvider.tsx index 03dd3c6bf..5b130d761 100644 --- a/typescript/frontend-marios2/src/contexts/InstallationsContextProvider.tsx +++ b/typescript/frontend-marios2/src/contexts/InstallationsContextProvider.tsx @@ -9,6 +9,8 @@ import { import axiosConfig from 'src/Resources/axiosConfig'; import { I_Folder, I_Installation } from 'src/interfaces/InstallationTypes'; import { TokenContext } from './tokenContext'; +import routes from '../Resources/routes.json'; +import { useNavigate } from 'react-router-dom'; interface I_InstallationContextProviderProps { installations: I_Installation[]; @@ -59,7 +61,7 @@ const InstallationsContextProvider = ({ const [loading, setLoading] = useState(false); const [error, setError] = useState(false); const [updated, setUpdated] = useState(false); - + const navigate = useNavigate(); const tokencontext = useContext(TokenContext); const { removeToken } = tokencontext; @@ -73,6 +75,7 @@ const InstallationsContextProvider = ({ .catch((err: AxiosError) => { if (err.response && err.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, []); @@ -86,6 +89,7 @@ const InstallationsContextProvider = ({ .catch((err) => { if (err.response && err.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, []); @@ -104,6 +108,7 @@ const InstallationsContextProvider = ({ setError(true); if (error.response && error.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, @@ -134,6 +139,7 @@ const InstallationsContextProvider = ({ setError(true); if (error.response && error.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, @@ -164,6 +170,7 @@ const InstallationsContextProvider = ({ setError(true); if (error.response && error.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, @@ -183,6 +190,7 @@ const InstallationsContextProvider = ({ setError(true); if (error.response && error.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, []); @@ -206,6 +214,7 @@ const InstallationsContextProvider = ({ setError(true); if (error.response && error.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, []); @@ -229,6 +238,7 @@ const InstallationsContextProvider = ({ setError(true); if (error.response && error.response.status == 401) { removeToken(); + navigate(routes.login); } }); }, []); diff --git a/typescript/frontend-marios2/src/contexts/WebSocketContextProvider.tsx b/typescript/frontend-marios2/src/contexts/WebSocketContextProvider.tsx index 0c3998c96..5820f6479 100644 --- a/typescript/frontend-marios2/src/contexts/WebSocketContextProvider.tsx +++ b/typescript/frontend-marios2/src/contexts/WebSocketContextProvider.tsx @@ -54,7 +54,7 @@ const WebSocketContextProvider = ({ children }: { children: ReactNode }) => { const installation_id = message.id; const status = message.status; - //console.log('Message from server ', installation_id, status); + console.log('Message from server ', installation_id, status); setInstallationStatus((prevStatus) => { // Create a new object by spreading the previous state @@ -90,32 +90,7 @@ const WebSocketContextProvider = ({ children }: { children: ReactNode }) => { if (!installationStatus.hasOwnProperty(installationId)) { status = -2; } else { - let i = 0; - //If at least one status value shows an error, then show error - for (i; i < installationStatus[installationId].length; i++) { - if (installationStatus[installationId][i] === 2) { - status = 2; - return status; - } - if (installationStatus[installationId][i] === 1) { - status = 1; - return status; - } - } - - if (installationStatus[installationId][0] == -1) { - let i = 0; - for (i; i < installationStatus[installationId].length; i++) { - if (installationStatus[installationId][i] != -1) { - break; - } - } - if (i === installationStatus[installationId].length) { - status = -1; - } - } else { - status = installationStatus[installationId][0]; - } + status = installationStatus[installationId][0]; } return status; };