start on working on s3 access

This commit is contained in:
Sina Blattmann 2023-07-06 09:22:46 +02:00
parent 393b06792a
commit 9884232639
4 changed files with 29 additions and 20 deletions

View File

@ -4,7 +4,7 @@ import { useContext, useState } from "react";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import axiosConfig from "../../config/axiosConfig"; import axiosConfig from "../../config/axiosConfig";
import { I_Installation } from "../../util/types"; import { I_Installation } from "../../util/types";
import { InstallationContext } from "../Context/InstallationContextProvider"; import { InstallationsContext } from "../Context/InstallationsContextProvider";
import MoveDialog from "../Groups/Tree/MoveDialog"; import MoveDialog from "../Groups/Tree/MoveDialog";
import InnovenergyButton from "../Layout/InnovenergyButton"; import InnovenergyButton from "../Layout/InnovenergyButton";
import InnovenergyTextfield from "../Layout/InnovenergyTextfield"; import InnovenergyTextfield from "../Layout/InnovenergyTextfield";
@ -16,11 +16,12 @@ interface I_InstallationFormProps {
id: string | undefined; id: string | undefined;
hasMoveButton?: boolean; hasMoveButton?: boolean;
} }
const InstallationForm = (props: I_InstallationFormProps) => { const InstallationForm = (props: I_InstallationFormProps) => {
const { values, id, hasMoveButton } = props; const { values, id, hasMoveButton } = props;
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const { fetchData } = useContext(InstallationContext); const { fetchData } = useContext(InstallationsContext);
const { getCurrentUser } = useContext(UserContext); const { getCurrentUser } = useContext(UserContext);
const readOnly = !getCurrentUser().hasWriteAccess; const readOnly = !getCurrentUser().hasWriteAccess;

View File

@ -1,13 +1,19 @@
import List from "@mui/material/List"; import List from "@mui/material/List";
import ListItemButton from "@mui/material/ListItemButton"; import ListItemButton from "@mui/material/ListItemButton";
import ListItemText from "@mui/material/ListItemText"; import ListItemText from "@mui/material/ListItemText";
import { Alert, CircularProgress, Divider, Grid, useTheme } from "@mui/material"; import {
Alert,
CircularProgress,
Divider,
Grid,
useTheme,
} from "@mui/material";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import useRouteMatch from "../../hooks/useRouteMatch"; import useRouteMatch from "../../hooks/useRouteMatch";
import routes from "../../routes.json"; import routes from "../../routes.json";
import { Fragment, useContext, useEffect } from "react"; import { Fragment, useContext, useEffect } from "react";
import { I_Installation } from "../../util/types"; import { I_Installation } from "../../util/types";
import { InstallationContext } from "../Context/InstallationContextProvider"; import { InstallationsContext } from "../Context/InstallationsContextProvider";
import { colors } from "../.."; import { colors } from "../..";
interface InstallationListProps { interface InstallationListProps {
@ -37,7 +43,7 @@ const filterData = (
}; };
const InstallationList = (props: InstallationListProps) => { const InstallationList = (props: InstallationListProps) => {
const { fetchData, data, loading, error } = useContext(InstallationContext); const { fetchData, data, loading, error } = useContext(InstallationsContext);
const filteredData = filterData(props.searchQuery, data); const filteredData = filterData(props.searchQuery, data);
@ -45,12 +51,10 @@ const InstallationList = (props: InstallationListProps) => {
routes.installations + routes.list + routes.installation + ":id", routes.installations + routes.list + routes.installation + ":id",
routes.installations + routes.list + routes.liveView + ":id", routes.installations + routes.list + routes.liveView + ":id",
routes.installations + routes.list + routes.log + ":id", routes.installations + routes.list + routes.log + ":id",
]); ]);
const theme = useTheme(); const theme = useTheme();
useEffect(() => { useEffect(() => {
fetchData(); fetchData();
}, [fetchData]); }, [fetchData]);

View File

@ -4,7 +4,7 @@ import LiveView from "./LiveView";
import InstallationTabs from "./InstallationTabs"; import InstallationTabs from "./InstallationTabs";
import Log from "./Log/Log"; import Log from "./Log/Log";
import routes from "../../routes.json"; import routes from "../../routes.json";
import InstallationContextProvider from "../Context/InstallationContextProvider"; import InstallationsContextProvider from "../Context/InstallationsContextProvider";
import SearchSidebar from "../Layout/Search"; import SearchSidebar from "../Layout/Search";
import InstallationList from "./InstallationList"; import InstallationList from "./InstallationList";
import Installation from "./Installation"; import Installation from "./Installation";
@ -19,7 +19,7 @@ const Installations = () => {
routes.installations + routes.list + routes.log + ":id", routes.installations + routes.list + routes.log + ":id",
]); ]);
return ( return (
<InstallationContextProvider> <InstallationsContextProvider>
<LogContextProvider> <LogContextProvider>
<Grid container spacing={2} height="100%"> <Grid container spacing={2} height="100%">
<Grid item xs={3}> <Grid item xs={3}>
@ -44,7 +44,7 @@ const Installations = () => {
</Grid> </Grid>
</Grid> </Grid>
</LogContextProvider> </LogContextProvider>
</InstallationContextProvider> </InstallationsContextProvider>
); );
}; };

View File

@ -59,7 +59,7 @@ export const fetchData = (
const ScalarGraph = () => { const ScalarGraph = () => {
const timeRange = createTimes( const timeRange = createTimes(
UnixTime.now() /* .fromTicks(1682085650) */ UnixTime.now() /* .fromTicks(1682085650) */
.rangeBefore(TimeSpan.fromDays(5)), .rangeBefore(TimeSpan.fromDays(10)),
NUMBER_OF_NODES NUMBER_OF_NODES
); );
const [timeSeries, setTimeSeries] = useState<RecordSeries>([]); const [timeSeries, setTimeSeries] = useState<RecordSeries>([]);
@ -166,7 +166,6 @@ const ScalarGraph = () => {
[getCacheSeries] [getCacheSeries]
); );
const theme = useTheme(); const theme = useTheme();
const renderGraphs = () => { const renderGraphs = () => {
if (checkedToggles.length > 0) { if (checkedToggles.length > 0) {
@ -240,7 +239,6 @@ const ScalarGraph = () => {
</div> </div>
); );
} }
}
return ( return (
<Alert sx={{ mt: 2 }} severity="info"> <Alert sx={{ mt: 2 }} severity="info">
<FormattedMessage <FormattedMessage
@ -249,6 +247,12 @@ const ScalarGraph = () => {
/> />
</Alert> </Alert>
); );
}
return (
<Alert sx={{ mt: 2 }} severity="error">
<FormattedMessage id="error" defaultMessage="There was an error" />
</Alert>
);
}; };
return <>{renderGraphs()}</>; return <>{renderGraphs()}</>;