diff --git a/.fslckout b/.fslckout deleted file mode 100644 index b04b2616f..000000000 Binary files a/.fslckout and /dev/null differ diff --git a/.gitignore b/.gitignore index 06f03ae8b..49f881c74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -/typescript/Frontend/node_modules -/typescript/Frontend/node_modules/* -*/Debug/* -*/Release/* -*/db.sqlite -*.fossil +**/node_modules +**/bin +**/obj +*.DotSettings.user +**/.idea/workspace.xml +**/.idea/tasks.xml diff --git a/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.local.xml b/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.local.xml index a62517f8c..b4bb05128 100644 --- a/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.local.xml +++ b/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.local.xml @@ -14,17 +14,5 @@ - - - " - - - no-auth - - - - - - \ No newline at end of file diff --git a/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.xml b/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.xml index 4813994e8..05388d9aa 100644 --- a/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.xml +++ b/csharp/.idea/.idea.InnovEnergy/.idea/dataSources.xml @@ -8,17 +8,5 @@ jdbc:sqlite:$PROJECT_DIR$/app/Backend/db.sqlite $ProjectFileDir$ - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/app/Backend/db.sqlite-original - $ProjectFileDir$ - - - file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.39.2/sqlite-jdbc-3.39.2.jar - - - \ No newline at end of file diff --git a/csharp/.idea/.idea.InnovEnergy/.idea/vcs.xml b/csharp/.idea/.idea.InnovEnergy/.idea/vcs.xml index 64713b81f..6c0b86358 100644 --- a/csharp/.idea/.idea.InnovEnergy/.idea/vcs.xml +++ b/csharp/.idea/.idea.InnovEnergy/.idea/vcs.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/csharp/.idea/.idea.InnovEnergy/.idea/workspace.xml b/csharp/.idea/.idea.InnovEnergy/.idea/workspace.xml deleted file mode 100644 index 8fb0ad86f..000000000 --- a/csharp/.idea/.idea.InnovEnergy/.idea/workspace.xml +++ /dev/null @@ -1,1056 +0,0 @@ - - - - BmsTunnel/BmsTunnel.csproj - Meiringen/Meiringen.csproj - RemoteSupportConsole/RemoteSupportConsole.csproj - S3/S3.csproj - app/Backend/Backend.csproj - app/CsController/CsController.csproj - app/EmuMeterDriver/EmuMeterDriver.csproj - app/FossilTui/FossilTui.csproj - app/GuiFeeder/GuiFeeder.csproj - app/TestBatteryDbus/TestBatteryDbus.csproj - app/Trumpf/SaliMax.csproj - app/Trumpf/Trumpf.Client.csproj - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - "keyToString": { - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "WebServerToolWindowFactoryState": "false", - "XThreadsFramesViewSplitterKey": "0.030162413", - "last_opened_file_path": "/home/kim/code/innovenergy/new/csharp/app/Backend/Backend.csproj", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "preferences.pluginManager", - "vue.rearranger.settings.migration": "true" - }, - "keyToStringList": { - "DatabaseDriversLRU": [ - "sqlite" - ], - "rider.external.source.directories": [ - "/home/kim/.config/JetBrains/Rider2022.3/resharper-host/DecompilerCache", - "/home/kim/.config/JetBrains/Rider2022.3/resharper-host/SourcesCache", - "/home/kim/.local/share/Symbols/src" - ] - } -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1664959681659 - - - - - - - - - - - - - - file://$PROJECT_DIR$/app/TestBatteryDbus/Program.cs - 160 - - - - - - - - - - file://$PROJECT_DIR$/lib/DBus/Transport/BufferedSocketReader.cs - 35 - - - - - file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/db53ae57c8bf4a54b9178b6941e53ac288c00/ac/4b4abb9e/Socket.cs - 1543 - - - - - - - - - - file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/db53ae57c8bf4a54b9178b6941e53ac288c00/3d/798f3797/SocketPal.cs - 1161 - - - - - - - - - - file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/db53ae57c8bf4a54b9178b6941e53ac288c00/ac/4b4abb9e/Socket.cs - 1556 - - - - - - - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/Message.cs - 176 - - - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/Message.cs - 158 - - - - - file://$PROJECT_DIR$/lib/DBus/WireFormat/DBusWriter.cs - 91 - - - - - file://$PROJECT_DIR$/app/TestBatteryDbus/Program.cs - 154 - - - - - - - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/DataTypes/Signatures/Specialized/ArraySignature.cs - 41 - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/DataTypes/Signatures/Specialized/CompositeSignature.cs - 33 - - - - - - file://$PROJECT_DIR$/lib/DBus/WireFormat/DBusReader.cs - 93 - - - - - file://$PROJECT_DIR$/lib/DBus/WireFormat/DBusReader.cs - 101 - - - - - file://$PROJECT_DIR$/lib/DBus/WireFormat/DBusReader.cs - 99 - - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/DataTypes/Signatures/Specialized/ArraySignature.cs - 38 - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/Replies.cs - 29 - - - - file://$PROJECT_DIR$/lib/DBus/Transport/DBusSocket.cs - 72 - - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/DataTypes/Convert/TypeToSignature.cs - 20 - - - - file://$PROJECT_DIR$/lib/DBus/Protocol/Replies.cs - 19 - - - - file://$PROJECT_DIR$/app/BmsTunnel/Program.cs - 39 - - - - - - - - - file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/f6b53e22cc3b47ae9298001b4e574299166000/3e/715ef200/JsonDocument.cs - 897 - - - - - - - - - file:///tmp/JetBrainsPerUserTemp-1000-1/Duponil.cs - 16 - - - - file://$PROJECT_DIR$/app/Backend/Database/User.cs - 87 - - - - - - - - - - - - - - - - - - - - - - setLanguage(e.target.value)} - > - - - - - - - { - + { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); + const [error, setError] = useState(); - const handleSubmit = async (e: any) => { + const handleSubmit = (e: any) => { setLoading(true); - loginUser(username, password).then((res) => { - setToken(res.data); + loginUser(username, password).then(({ data }) => { + if (typeof data === "string") { + setToken(data); + setLoading(false); + } + setError(data); setLoading(false); }); }; @@ -41,6 +46,7 @@ const Login = ({ setToken }: { setToken: any }) => { value={password} handleChange={(e) => setPassword(e.target.value)} /> + {error && Incorrect username or password}
+ + + + + ); }; diff --git a/typescript/Frontend/src/components/LanguageSelect.tsx b/typescript/Frontend/src/components/LanguageSelect.tsx new file mode 100644 index 000000000..a90217bc4 --- /dev/null +++ b/typescript/Frontend/src/components/LanguageSelect.tsx @@ -0,0 +1,28 @@ +import { MenuItem, Select } from "@mui/material"; +import { FormattedMessage } from "react-intl"; + +interface LanguageSelectProps { + language: string; + setLanguage: (language: string) => void; +} +const LanguageSelect = (props: LanguageSelectProps) => { + return ( + + ); +}; + +export default LanguageSelect; diff --git a/typescript/Frontend/src/components/LogoutButton.tsx b/typescript/Frontend/src/components/LogoutButton.tsx new file mode 100644 index 000000000..fe773519e --- /dev/null +++ b/typescript/Frontend/src/components/LogoutButton.tsx @@ -0,0 +1,28 @@ +import { Button } from "@mui/material"; +import { FormattedMessage } from "react-intl"; +import axiosConfig from "../config/axiosConfig"; +import { useNavigate } from "react-router-dom"; + +interface LogoutButtonProps { + removeToken: () => void; +} +const LogoutButton = (props: LogoutButtonProps) => { + const navigate = useNavigate(); + + return ( + + ); +}; + +export default LogoutButton; diff --git a/typescript/Frontend/src/components/NavigationButtons.tsx b/typescript/Frontend/src/components/NavigationButtons.tsx new file mode 100644 index 000000000..9175a7410 --- /dev/null +++ b/typescript/Frontend/src/components/NavigationButtons.tsx @@ -0,0 +1,24 @@ +import { Button, ButtonGroup } from "@mui/material"; +import { FormattedMessage } from "react-intl"; + +const NavigationButtons = () => { + return ( + + + + + ); +}; + +export default NavigationButtons; diff --git a/typescript/Frontend/src/components/NestedList.tsx b/typescript/Frontend/src/components/NestedList.tsx index 02759877c..d9d25b62c 100644 --- a/typescript/Frontend/src/components/NestedList.tsx +++ b/typescript/Frontend/src/components/NestedList.tsx @@ -5,7 +5,7 @@ import { Divider, TextField } from "@mui/material"; import { Link } from "react-router-dom"; import useRouteMatch from "../hooks/useRouteMatch"; import routes from "../routes.json"; -import { useEffect, useState } from "react"; +import { Fragment, useEffect, useState } from "react"; import { I_Installation } from "../util/installation.util"; import axiosConfig from "../config/axiosConfig"; import { useIntl } from "react-intl"; @@ -46,11 +46,10 @@ const NestedList = () => { ]); useEffect(() => { - axiosConfig - .get("https://localhost:7087/api/GetAllInstallations", {}) - .then((res) => { - setData(res.data); - }); + console.log("useeffect"); + axiosConfig.get("/GetAllInstallations", {}).then((res) => { + setData(res.data); + }); }, []); return ( @@ -72,9 +71,8 @@ const NestedList = () => { aria-labelledby="nested-list-subheader" > {filteredData?.map((installation) => ( - <> + @@ -87,7 +85,7 @@ const NestedList = () => { - + ))} diff --git a/typescript/Frontend/src/components/Tabs.tsx b/typescript/Frontend/src/components/Tabs.tsx index a1eee2a9d..5d3cadeb0 100644 --- a/typescript/Frontend/src/components/Tabs.tsx +++ b/typescript/Frontend/src/components/Tabs.tsx @@ -6,8 +6,15 @@ import { Link } from "react-router-dom"; import routes from "../routes.json"; import useRouteMatch from "../hooks/useRouteMatch"; import { useIntl } from "react-intl"; +import LogoutButton from "./LogoutButton"; +import LanguageSelect from "./LanguageSelect"; -const BasicTabs = () => { +interface BasicTabsProps { + removeToken: () => void; + language: string; + setLanguage: (language: string) => void; +} +const BasicTabs = (props: BasicTabsProps) => { const routeMatch = useRouteMatch([ routes.installationWithId, routes.alarmsWithId, @@ -21,7 +28,10 @@ const BasicTabs = () => { return ( - + { component={Link} to={routes.log + id} /> + + diff --git a/typescript/Frontend/src/hooks/useToken.tsx b/typescript/Frontend/src/hooks/useToken.tsx index 3182dc672..e20c7198b 100644 --- a/typescript/Frontend/src/hooks/useToken.tsx +++ b/typescript/Frontend/src/hooks/useToken.tsx @@ -1,5 +1,4 @@ import { useState } from "react"; -import axiosConfig from "../config/axiosConfig"; const useToken = () => { const getToken = () => { @@ -11,12 +10,17 @@ const useToken = () => { const saveToken = (userToken: any) => { sessionStorage.setItem("token", JSON.stringify(userToken)); setToken(userToken); - axiosConfig.defaults.headers.common["auth"] = userToken; + }; + + const removeToken = () => { + sessionStorage.removeItem("token"); + setToken(null); }; return { setToken: saveToken, token, + removeToken, }; }; diff --git a/typescript/Frontend/src/lang/de.json b/typescript/Frontend/src/lang/de.json new file mode 100644 index 000000000..21a9804f7 --- /dev/null +++ b/typescript/Frontend/src/lang/de.json @@ -0,0 +1,18 @@ +{ + "alarms": "Alarme", + "allInstallations": "Alle Installationen", + "applyChanges": "Änderungen übernehmen", + "country": "Land", + "customerName": "Kundenname", + "english": "Englisch", + "german": "Deutsch", + "installation": "Installation", + "location": "Ort", + "log": "Log", + "orderNumbers": "Bestellnummern", + "region": "Region", + "search": "Suche", + "users": "Benutzer", + "logout": "Logout", + "updatedSuccessfully": "Erfolgreich aktualisiert" +} diff --git a/typescript/Frontend/src/lang/en.json b/typescript/Frontend/src/lang/en.json new file mode 100644 index 000000000..3197f95b6 --- /dev/null +++ b/typescript/Frontend/src/lang/en.json @@ -0,0 +1,18 @@ +{ + "alarms": "Alarms", + "allInstallations": "All installations", + "applyChanges": "Apply changes", + "country": "country", + "customerName": "Customer name", + "english": "English", + "german": "German", + "installation": "Installation", + "location": "Location", + "log": "Log", + "orderNumbers": "Order numbers", + "region": "Region", + "search": "Search", + "users": "Users", + "logout": "Logout", + "updatedSuccessfully": "Updated successfully" +} \ No newline at end of file diff --git a/typescript/Frontend/src/routes/Home.tsx b/typescript/Frontend/src/routes/Home.tsx deleted file mode 100644 index 74ed8bc0b..000000000 --- a/typescript/Frontend/src/routes/Home.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { Box, Button, ButtonGroup, Grid, TextField } from "@mui/material"; -import Divider from "@mui/material/Divider"; -import { Route, Routes } from "react-router-dom"; -import NestedList from "../components/NestedList"; -import BasicTable from "../components/Table"; -import BasicTabs from "../components/Tabs"; -import routes from "../routes.json"; -import InstallationDetail from "./Installation"; - -const Home = () => { - - return ( - - - - - - - - - - - - - - - - - } - /> - alarms
} /> - } /> - log} /> -
-
- - - ); -}; - -export default Home; diff --git a/typescript/Frontend/src/routes/Installation.tsx b/typescript/Frontend/src/routes/Installation.tsx index 612d71002..9e856abf5 100644 --- a/typescript/Frontend/src/routes/Installation.tsx +++ b/typescript/Frontend/src/routes/Installation.tsx @@ -1,4 +1,5 @@ -import { Box, CircularProgress } from "@mui/material"; +import { Alert, Box, CircularProgress } from "@mui/material"; +import { AxiosError } from "axios"; import { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import CustomerForm from "../components/CustomerForm"; @@ -9,23 +10,36 @@ const InstallationDetail = () => { const { id } = useParams(); const [values, setValues] = useState(); const [loading, setLoading] = useState(false); + const [error, setError] = useState(); useEffect(() => { setLoading(true); - axiosConfig.get("/GetInstallationById?id=" + id).then((res) => { - setValues(res.data); - setLoading(false); - }); + axiosConfig + .get("/GetInstallationById?id=" + id) + .then((res) => { + setValues(res.data); + setLoading(false); + }) + .catch((err: AxiosError) => { + setError(err); + setLoading(false); + }); }, [id]); - if (values && values.id.toString() === id) { + if (error) { + return ( + + {error.message} + + ); + } else if (values && values.id.toString() === id) { return ( ); } else if (loading) { - return ; + return ; } return null; }; diff --git a/typescript/Frontend/src/util/installation.util.tsx b/typescript/Frontend/src/util/installation.util.tsx index 94e106b6f..7f35e1ebd 100644 --- a/typescript/Frontend/src/util/installation.util.tsx +++ b/typescript/Frontend/src/util/installation.util.tsx @@ -8,7 +8,7 @@ export interface I_Installation { location: string; region: string; country: string; - orderNumber: string; + orderNumbers: string; lat: number; long: number; s3Bucket: string; @@ -17,5 +17,3 @@ export interface I_Installation { information: string; parentId: number; } - -