Merge branch 'main' of https://git.innov.energy/Innovenergy/git_trunk
This commit is contained in:
commit
c7bf3d3444
|
@ -1,12 +1,7 @@
|
||||||
import useToken from "./hooks/useToken";
|
import useToken from "./hooks/useToken";
|
||||||
import Login from "./Login";
|
import Login from "./Login";
|
||||||
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
||||||
import { Box, Grid, Divider } from "@mui/material";
|
import { Grid } from "@mui/material";
|
||||||
import BasicTable from "./components/Table";
|
|
||||||
import InstallationTabs from "./components/InstallationTabs";
|
|
||||||
import Alarms from "./routes/Alarms";
|
|
||||||
import InstallationDetail from "./routes/Installation";
|
|
||||||
import Log from "./routes/Log";
|
|
||||||
import routes from "./routes.json";
|
import routes from "./routes.json";
|
||||||
import { IntlProvider } from "react-intl";
|
import { IntlProvider } from "react-intl";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
@ -14,14 +9,13 @@ import en from "./lang/en.json";
|
||||||
import de from "./lang/de.json";
|
import de from "./lang/de.json";
|
||||||
import LanguageSelect from "./components/LanguageSelect";
|
import LanguageSelect from "./components/LanguageSelect";
|
||||||
import LogoutButton from "./components/LogoutButton";
|
import LogoutButton from "./components/LogoutButton";
|
||||||
import NavigationButtons from "./components/NavigationButtons";
|
import Installations from "./routes/Installations";
|
||||||
import UserList from "./components/UserTree";
|
|
||||||
import Sidebar from "./components/Sidebar";
|
import Users from "./routes/Users";
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const { token, setToken, removeToken } = useToken();
|
const { token, setToken, removeToken } = useToken();
|
||||||
const [language, setLanguage] = useState("en");
|
const [language, setLanguage] = useState("en");
|
||||||
const [currentView, setCurrentView] = useState("installations");
|
|
||||||
|
|
||||||
const getTranslations = () => {
|
const getTranslations = () => {
|
||||||
if (language === "de") {
|
if (language === "de") {
|
||||||
|
@ -45,43 +39,13 @@ const App = () => {
|
||||||
<LanguageSelect language={language} setLanguage={setLanguage} />
|
<LanguageSelect language={language} setLanguage={setLanguage} />
|
||||||
<LogoutButton removeToken={removeToken} />
|
<LogoutButton removeToken={removeToken} />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box sx={{ p: 1 }}>
|
|
||||||
<Grid container spacing={2}>
|
|
||||||
<Grid item xs={3}>
|
|
||||||
<NavigationButtons
|
|
||||||
currentView={currentView}
|
|
||||||
setCurrentView={setCurrentView}
|
|
||||||
/>
|
|
||||||
{currentView === "installations" ? <Sidebar /> : <UserList />}
|
|
||||||
</Grid>
|
|
||||||
<Grid
|
|
||||||
item
|
|
||||||
xs={1}
|
|
||||||
container
|
|
||||||
direction="row"
|
|
||||||
justifyContent="center"
|
|
||||||
alignItems="center"
|
|
||||||
>
|
|
||||||
<Divider orientation="vertical" variant="middle" />
|
|
||||||
</Grid>
|
|
||||||
<Grid item xs={8}>
|
|
||||||
{currentView === "installations" && (
|
|
||||||
<>
|
|
||||||
<InstallationTabs />
|
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route
|
<Route
|
||||||
path={routes.installationWithId}
|
path={routes.installations + "*"}
|
||||||
element={<InstallationDetail />}
|
element={<Installations />}
|
||||||
/>
|
/>
|
||||||
<Route path={routes.alarmsWithId} element={<Alarms />} />
|
<Route path={routes.tree} element={<Users />} />
|
||||||
<Route path={routes.usersWithId} element={<BasicTable />} />
|
|
||||||
<Route path={routes.logWithId} element={<Log />} />
|
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Box>
|
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
|
|
|
@ -41,10 +41,10 @@ const InstallationList = (props: InstallationListProps) => {
|
||||||
const filteredData = filterData(props.searchQuery, data);
|
const filteredData = filterData(props.searchQuery, data);
|
||||||
|
|
||||||
const routeMatch = useRouteMatch([
|
const routeMatch = useRouteMatch([
|
||||||
routes.installationWithId,
|
routes.installations + routes.installation + ":id",
|
||||||
routes.alarmsWithId,
|
routes.installations + routes.alarms + ":id",
|
||||||
routes.usersWithId,
|
routes.installations + routes.users + ":id",
|
||||||
routes.logWithId,
|
routes.installations + routes.log + ":id",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -76,11 +76,14 @@ const InstallationList = (props: InstallationListProps) => {
|
||||||
component="nav"
|
component="nav"
|
||||||
aria-labelledby="nested-list-subheader"
|
aria-labelledby="nested-list-subheader"
|
||||||
>
|
>
|
||||||
{filteredData?.map((installation) => (
|
{filteredData?.map((installation) => {
|
||||||
|
console.log(routeMatch);
|
||||||
|
return (
|
||||||
<Fragment key={installation.id}>
|
<Fragment key={installation.id}>
|
||||||
<Link
|
<Link
|
||||||
to={
|
to={
|
||||||
getPathWithoutId(routeMatch?.pattern?.path) + installation.id
|
getPathWithoutId(routeMatch?.pattern?.path) +
|
||||||
|
installation.id
|
||||||
}
|
}
|
||||||
style={{ textDecoration: "none", color: "black" }}
|
style={{ textDecoration: "none", color: "black" }}
|
||||||
>
|
>
|
||||||
|
@ -88,13 +91,16 @@ const InstallationList = (props: InstallationListProps) => {
|
||||||
selected={installation.id === Number(routeMatch?.params.id)}
|
selected={installation.id === Number(routeMatch?.params.id)}
|
||||||
>
|
>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={installation.location + " | " + installation.name}
|
primary={
|
||||||
|
installation.location + " | " + installation.name
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</Link>
|
</Link>
|
||||||
<Divider />
|
<Divider />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</List>
|
</List>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -9,10 +9,10 @@ import { useIntl } from "react-intl";
|
||||||
|
|
||||||
const InstallationTabs = () => {
|
const InstallationTabs = () => {
|
||||||
const routeMatch = useRouteMatch([
|
const routeMatch = useRouteMatch([
|
||||||
routes.installationWithId,
|
routes.installations + routes.installation + ":id",
|
||||||
routes.alarmsWithId,
|
routes.installations + routes.alarms + ":id",
|
||||||
routes.usersWithId,
|
routes.installations + routes.users + ":id",
|
||||||
routes.logWithId,
|
routes.installations + routes.log + ":id",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const id = routeMatch?.params?.id;
|
const id = routeMatch?.params?.id;
|
||||||
|
@ -23,7 +23,7 @@ const InstallationTabs = () => {
|
||||||
<Box sx={{ width: "100%" }}>
|
<Box sx={{ width: "100%" }}>
|
||||||
<Box sx={{ borderBottom: 1, borderColor: "divider" }}>
|
<Box sx={{ borderBottom: 1, borderColor: "divider" }}>
|
||||||
<Tabs
|
<Tabs
|
||||||
value={routeMatch?.pattern?.path ?? routes.installationWithId}
|
value={routeMatch?.pattern?.path ?? routes.installation + ":id"}
|
||||||
aria-label="basic tabs example"
|
aria-label="basic tabs example"
|
||||||
>
|
>
|
||||||
<Tab
|
<Tab
|
||||||
|
@ -31,7 +31,9 @@ const InstallationTabs = () => {
|
||||||
id: "installation",
|
id: "installation",
|
||||||
defaultMessage: "Installation",
|
defaultMessage: "Installation",
|
||||||
})}
|
})}
|
||||||
value={routes.installationWithId}
|
value={
|
||||||
|
routes.installations + routes.installation + ":id"
|
||||||
|
}
|
||||||
component={Link}
|
component={Link}
|
||||||
to={routes.installation + id}
|
to={routes.installation + id}
|
||||||
/>
|
/>
|
||||||
|
@ -40,7 +42,7 @@ const InstallationTabs = () => {
|
||||||
id: "alarms",
|
id: "alarms",
|
||||||
defaultMessage: "Alarms",
|
defaultMessage: "Alarms",
|
||||||
})}
|
})}
|
||||||
value={routes.alarmsWithId}
|
value={routes.installations + routes.alarms + ":id"}
|
||||||
component={Link}
|
component={Link}
|
||||||
to={routes.alarms + id}
|
to={routes.alarms + id}
|
||||||
/>
|
/>
|
||||||
|
@ -49,7 +51,7 @@ const InstallationTabs = () => {
|
||||||
id: "users",
|
id: "users",
|
||||||
defaultMessage: "Users",
|
defaultMessage: "Users",
|
||||||
})}
|
})}
|
||||||
value={routes.usersWithId}
|
value={routes.installations + routes.users + ":id"}
|
||||||
component={Link}
|
component={Link}
|
||||||
to={routes.users + id}
|
to={routes.users + id}
|
||||||
/>
|
/>
|
||||||
|
@ -58,7 +60,7 @@ const InstallationTabs = () => {
|
||||||
id: "log",
|
id: "log",
|
||||||
defaultMessage: "Log",
|
defaultMessage: "Log",
|
||||||
})}
|
})}
|
||||||
value={routes.logWithId}
|
value={routes.installations + routes.log + ":id"}
|
||||||
component={Link}
|
component={Link}
|
||||||
to={routes.log + id}
|
to={routes.log + id}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
import { ToggleButton, ToggleButtonGroup } from "@mui/material";
|
import { ToggleButton, ToggleButtonGroup } from "@mui/material";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import useRouteMatch from "../hooks/useRouteMatch";
|
||||||
|
import routes from "../routes.json";
|
||||||
|
|
||||||
interface NavigationButtonsProps {
|
const NavigationButtons = () => {
|
||||||
currentView: string;
|
const routeMatch = useRouteMatch([
|
||||||
setCurrentView: (value: string) => void;
|
routes.installations + "*",
|
||||||
}
|
routes.tree + "*",
|
||||||
const NavigationButtons = (props: NavigationButtonsProps) => {
|
]);
|
||||||
const handleChange = (
|
|
||||||
event: React.MouseEvent<HTMLElement>,
|
|
||||||
newAlignment: string
|
|
||||||
) => {
|
|
||||||
props.setCurrentView(newAlignment);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
color="primary"
|
color="primary"
|
||||||
value={props.currentView}
|
value={routeMatch?.pattern?.path}
|
||||||
exclusive
|
exclusive
|
||||||
onChange={handleChange}
|
|
||||||
sx={{ mb: 1 }}
|
sx={{ mb: 1 }}
|
||||||
>
|
>
|
||||||
<ToggleButton value="installations">
|
<ToggleButton
|
||||||
|
value={routes.installations + "*"}
|
||||||
|
component={Link}
|
||||||
|
to={routes.installations}
|
||||||
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id="allInstallations"
|
id="allInstallations"
|
||||||
defaultMessage="All installations"
|
defaultMessage="All installations"
|
||||||
/>
|
/>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
<ToggleButton value="users">
|
<ToggleButton value={routes.tree + "*"} component={Link} to={routes.tree}>
|
||||||
<FormattedMessage id="users" defaultMessage="Users" />
|
<FormattedMessage id="users" defaultMessage="Users" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</ToggleButtonGroup>
|
</ToggleButtonGroup>
|
||||||
|
|
|
@ -1,102 +1,23 @@
|
||||||
import TreeView from "@mui/lab/TreeView";
|
import TreeView from "@mui/lab/TreeView";
|
||||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||||
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode, useEffect, useState } from "react";
|
||||||
import { TreeItem } from "@mui/lab";
|
import { TreeItem } from "@mui/lab";
|
||||||
import { I_Folder, I_Installation } from "../util/types";
|
import { I_Folder, I_Installation } from "../util/types";
|
||||||
|
import axiosConfig from "../config/axiosConfig";
|
||||||
const UserList = () => {
|
const UserList = () => {
|
||||||
const data: I_Folder[] = [
|
const [data, setData] = useState<I_Folder[]>();
|
||||||
{
|
|
||||||
id: 107,
|
useEffect(() => {
|
||||||
name: "Bruen-Tromp",
|
axiosConfig.get("/GetTree").then((res) => {
|
||||||
information: "05 Burrows Terrace",
|
setData(res.data);
|
||||||
parentId: 75,
|
});
|
||||||
type: "Folder",
|
}, []);
|
||||||
children: [
|
|
||||||
{
|
const handleClick = (e: any, nodes: any) => {
|
||||||
id: 100,
|
console.log(e);
|
||||||
name: "Sporer and Sons",
|
console.log(nodes);
|
||||||
information: "820 Helena Terrace",
|
};
|
||||||
parentId: 107,
|
|
||||||
type: "Folder",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 101,
|
|
||||||
name: "Hahn-Heaney",
|
|
||||||
information: "144 Di Loreto Center",
|
|
||||||
parentId: 107,
|
|
||||||
type: "Folder",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 125,
|
|
||||||
name: "Sporer and Sons",
|
|
||||||
information: "820 Helena Terrace",
|
|
||||||
parentId: 107,
|
|
||||||
type: "Folder",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
location: "Säffle",
|
|
||||||
region: "SG",
|
|
||||||
country: "SE",
|
|
||||||
orderNumbers: "1LWDGmdXCLmCRFJHTKwcmpoP7bcNeaWJuj",
|
|
||||||
lat: 0,
|
|
||||||
long: 0,
|
|
||||||
s3Bucket: "",
|
|
||||||
id: 632,
|
|
||||||
name: "Nikolas Scholz",
|
|
||||||
information: "",
|
|
||||||
parentId: 125,
|
|
||||||
type: "Installation",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
location: "Krasnoye",
|
|
||||||
region: "ZH",
|
|
||||||
country: "RU",
|
|
||||||
orderNumbers: "1M4Rw8toMSJn3d8ULouDd1gYKzANFXeMWh",
|
|
||||||
lat: 0,
|
|
||||||
long: 0,
|
|
||||||
s3Bucket: "",
|
|
||||||
id: 248,
|
|
||||||
name: "Judye Goldson",
|
|
||||||
information: "",
|
|
||||||
parentId: 125,
|
|
||||||
type: "Installation",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 103,
|
|
||||||
name: "Bruen-Tromp",
|
|
||||||
information: "05 Burrows Terrace",
|
|
||||||
parentId: 75,
|
|
||||||
type: "Folder",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
id: 100,
|
|
||||||
name: "Sporer and Sons",
|
|
||||||
information: "820 Helena Terrace",
|
|
||||||
parentId: 107,
|
|
||||||
type: "Folder",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 101,
|
|
||||||
name: "Hahn-Heaney",
|
|
||||||
information: "144 Di Loreto Center",
|
|
||||||
parentId: 107,
|
|
||||||
type: "Folder",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 135,
|
|
||||||
name: "Hahn-Heaney",
|
|
||||||
information: "144 Di Loreto Center",
|
|
||||||
parentId: 107,
|
|
||||||
type: "Folder",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const instanceOfFolder = (object: any): object is I_Folder => {
|
const instanceOfFolder = (object: any): object is I_Folder => {
|
||||||
return "children" in object;
|
return "children" in object;
|
||||||
|
@ -122,14 +43,15 @@ const UserList = () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TreeView
|
<TreeView
|
||||||
aria-label="rich object"
|
|
||||||
defaultCollapseIcon={<ExpandMoreIcon />}
|
defaultCollapseIcon={<ExpandMoreIcon />}
|
||||||
defaultExpandIcon={<ChevronRightIcon />}
|
defaultExpandIcon={<ChevronRightIcon />}
|
||||||
sx={{ height: 300, flexGrow: 1, maxWidth: 400 }}
|
sx={{ height: 300, flexGrow: 1, maxWidth: 400 }}
|
||||||
|
onNodeToggle={handleClick}
|
||||||
>
|
>
|
||||||
{renderTree(data)}
|
{data && renderTree(data)}
|
||||||
</TreeView>
|
</TreeView>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
{
|
{
|
||||||
"installationWithId": "/installation/:id",
|
"installation": "installation/",
|
||||||
"installation": "/installation/",
|
"alarms": "alarms/",
|
||||||
"alarmsWithId": "/alarms/:id",
|
"users": "users/",
|
||||||
"alarms": "/alarms/",
|
"log": "log/",
|
||||||
"usersWithId": "/users/:id",
|
"installations": "/installations/",
|
||||||
"users": "/users/",
|
"tree": "/users/*"
|
||||||
"logWithId": "/log/:id",
|
|
||||||
"log": "/log/",
|
|
||||||
"installations": "/installations"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ const InstallationDetail = () => {
|
||||||
|
|
||||||
if (values && values.id && values.id.toString() === id) {
|
if (values && values.id && values.id.toString() === id) {
|
||||||
return (
|
return (
|
||||||
<Box sx={{ py: 3, width: 1 / 2 }}>
|
<Box sx={{ py: 3 }}>
|
||||||
<CustomerForm values={values} id={id} />
|
<CustomerForm values={values} id={id} />
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { Grid, Divider } from "@mui/material";
|
||||||
|
import { Container } from "@mui/system";
|
||||||
|
import { Routes, Route } from "react-router";
|
||||||
|
import InstallationTabs from "../components/InstallationTabs";
|
||||||
|
import NavigationButtons from "../components/NavigationButtons";
|
||||||
|
import BasicTable from "../components/Table";
|
||||||
|
import Alarms from "./Alarms";
|
||||||
|
import InstallationDetail from "./Installation";
|
||||||
|
import Log from "./Log";
|
||||||
|
import routes from "../routes.json";
|
||||||
|
import Sidebar from "../components/Sidebar";
|
||||||
|
|
||||||
|
const Installations = () => {
|
||||||
|
return (
|
||||||
|
<Container maxWidth="xl">
|
||||||
|
<Grid container spacing={2}>
|
||||||
|
<Grid item xs={3}>
|
||||||
|
<NavigationButtons />
|
||||||
|
<Sidebar />
|
||||||
|
</Grid>
|
||||||
|
<Grid
|
||||||
|
item
|
||||||
|
xs={1}
|
||||||
|
container
|
||||||
|
direction="row"
|
||||||
|
justifyContent="center"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<Divider orientation="vertical" variant="middle" />
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={8}>
|
||||||
|
<InstallationTabs />
|
||||||
|
<Routes>
|
||||||
|
<Route
|
||||||
|
path={routes.installation + ":id"}
|
||||||
|
element={<InstallationDetail />}
|
||||||
|
index
|
||||||
|
/>
|
||||||
|
<Route path={routes.alarms + ":id"} element={<Alarms />} />
|
||||||
|
<Route path={routes.users + ":id"} element={<BasicTable />} />
|
||||||
|
<Route path={routes.log + ":id"} element={<Log />} />
|
||||||
|
</Routes>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Installations;
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { Grid, Divider } from "@mui/material";
|
||||||
|
import { Container } from "@mui/system";
|
||||||
|
import NavigationButtons from "../components/NavigationButtons";
|
||||||
|
import UserTree from "../components/UserTree";
|
||||||
|
|
||||||
|
const Users = () => {
|
||||||
|
return (
|
||||||
|
<Container maxWidth="xl">
|
||||||
|
<Grid container spacing={2}>
|
||||||
|
<Grid item xs={3}>
|
||||||
|
<NavigationButtons />
|
||||||
|
<UserTree />
|
||||||
|
</Grid>
|
||||||
|
<Grid
|
||||||
|
item
|
||||||
|
xs={1}
|
||||||
|
container
|
||||||
|
direction="row"
|
||||||
|
justifyContent="center"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<Divider orientation="vertical" variant="middle" />
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={8}></Grid>
|
||||||
|
</Grid>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Users;
|
Loading…
Reference in New Issue