Fixed login route bug
This commit is contained in:
parent
984455e815
commit
38afc5b003
|
@ -119,6 +119,10 @@ function App() {
|
|||
path={routes.forgotPassword}
|
||||
element={<ForgotPassword />}
|
||||
></Route>
|
||||
<Route
|
||||
path={'*'}
|
||||
element={<Navigate to={routes.login}></Navigate>}
|
||||
></Route>
|
||||
</Routes>
|
||||
</ThemeProvider>
|
||||
);
|
||||
|
@ -147,6 +151,10 @@ function App() {
|
|||
path={''}
|
||||
element={<Navigate to={routes.installations}></Navigate>}
|
||||
></Route>
|
||||
<Route
|
||||
path={'login'}
|
||||
element={<Navigate to={routes.installations}></Navigate>}
|
||||
></Route>
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
|
@ -168,7 +176,10 @@ function App() {
|
|||
/>
|
||||
|
||||
<Route path={routes.users + '*'} element={<Users />} />
|
||||
|
||||
<Route
|
||||
path={'*'}
|
||||
element={<Navigate to={routes.installations}></Navigate>}
|
||||
></Route>
|
||||
<Route path="ResetPassword" element={<ResetPassword />}></Route>
|
||||
</Route>
|
||||
</Routes>
|
||||
|
|
|
@ -91,7 +91,7 @@ function Login() {
|
|||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{ userSelect: 'none' }}>
|
||||
<Container maxWidth="xl" sx={{ pt: 2 }} className="login">
|
||||
<Grid container>
|
||||
<Grid item xs={3} container justifyContent="flex-start" mb={2}>
|
||||
|
@ -263,7 +263,7 @@ function Login() {
|
|||
</Grid>
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ export const getChartOptions = (
|
|||
: chartInfo.max <= 0
|
||||
? Math.ceil(chartInfo.min / findPower(chartInfo.min).value) *
|
||||
findPower(chartInfo.min).value
|
||||
: Math.abs(chartInfo.min) < 1
|
||||
: Math.abs(chartInfo.min) < 1 || Math.abs(chartInfo.max) < 1
|
||||
? -Math.max(
|
||||
Math.abs(
|
||||
Math.ceil(chartInfo.min / findPower(chartInfo.min).value) *
|
||||
|
@ -278,7 +278,7 @@ export const getChartOptions = (
|
|||
).toFixed(2)
|
||||
: chartInfo.max <= 0
|
||||
? 0
|
||||
: Math.abs(chartInfo.min) < 1
|
||||
: Math.abs(chartInfo.min) < 1 || Math.abs(chartInfo.max) < 1
|
||||
? +Math.max(
|
||||
Math.abs(
|
||||
Math.ceil(chartInfo.min / findPower(chartInfo.min).value) *
|
||||
|
|
|
@ -444,20 +444,20 @@ function Overview(props: OverviewProps) {
|
|||
>
|
||||
<FormattedMessage id="lastweek" defaultMessage="Last week" />
|
||||
</Button>
|
||||
{/*<Button*/}
|
||||
{/* variant="contained"*/}
|
||||
{/* onClick={handleMonthData}*/}
|
||||
{/* disabled={loading}*/}
|
||||
{/* sx={{*/}
|
||||
{/* marginTop: '20px',*/}
|
||||
{/* marginLeft: '10px',*/}
|
||||
{/* backgroundColor: monthlyData ? '#808080' : '#ffc04d',*/}
|
||||
{/* color: '#000000',*/}
|
||||
{/* '&:hover': { bgcolor: '#f7b34d' }*/}
|
||||
{/* }}*/}
|
||||
{/*>*/}
|
||||
{/* <FormattedMessage id="lastmonth" defaultMessage="Last Month" />*/}
|
||||
{/*</Button>*/}
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={handleMonthData}
|
||||
disabled={loading}
|
||||
sx={{
|
||||
marginTop: '20px',
|
||||
marginLeft: '10px',
|
||||
backgroundColor: monthlyData ? '#808080' : '#ffc04d',
|
||||
color: '#000000',
|
||||
'&:hover': { bgcolor: '#f7b34d' }
|
||||
}}
|
||||
>
|
||||
<FormattedMessage id="lastmonth" defaultMessage="Last Month" />
|
||||
</Button>
|
||||
{dailyData && (
|
||||
<>
|
||||
<Button
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState } from 'react';
|
||||
import { Container, Grid, Switch } from '@mui/material';
|
||||
import { Container, Grid, Switch, Typography } from '@mui/material';
|
||||
import TopologyColumn from './topologyColumn';
|
||||
import {
|
||||
getAmount,
|
||||
|
@ -41,16 +41,33 @@ function Topology(props: TopologyProps) {
|
|||
justifyContent: 'right'
|
||||
}}
|
||||
>
|
||||
<Switch
|
||||
edge="start"
|
||||
color="secondary"
|
||||
onChange={handleSwitch()}
|
||||
sx={{
|
||||
'& .MuiSwitch-thumb': {
|
||||
backgroundColor: 'orange'
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div>
|
||||
<Typography sx={{ marginTop: '5px', marginRight: '20px' }}>
|
||||
Display Values
|
||||
</Typography>
|
||||
<Switch
|
||||
edge="start"
|
||||
color="secondary"
|
||||
onChange={handleSwitch()}
|
||||
sx={{
|
||||
'& .MuiSwitch-thumb': {
|
||||
backgroundColor: 'orange'
|
||||
},
|
||||
marginLeft: '20px'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/*<Switch*/}
|
||||
{/* edge="start"*/}
|
||||
{/* color="secondary"*/}
|
||||
{/* onChange={handleSwitch()}*/}
|
||||
{/* sx={{*/}
|
||||
{/* '& .MuiSwitch-thumb': {*/}
|
||||
{/* backgroundColor: 'orange'*/}
|
||||
{/* }*/}
|
||||
{/* }}*/}
|
||||
{/*/>*/}
|
||||
</Grid>
|
||||
|
||||
<Grid
|
||||
|
|
|
@ -29,7 +29,7 @@ const isInt = (value: number) => {
|
|||
return value % 1 === 0;
|
||||
};
|
||||
|
||||
function formatPower(value) {
|
||||
function formatPower(value, unit) {
|
||||
if (isNaN(value)) {
|
||||
return 'Invalid';
|
||||
}
|
||||
|
@ -47,7 +47,12 @@ function formatPower(value) {
|
|||
magnitude++;
|
||||
}
|
||||
|
||||
const roundedValue = value.toFixed(1);
|
||||
const roundedValue = Math.round(value);
|
||||
|
||||
//Filter all values less than 100 Watts
|
||||
if (magnitude === 0 && value < 100 && unit === 'W') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return negative === false
|
||||
? `${roundedValue} ${prefixes[magnitude]}`
|
||||
|
@ -243,8 +248,12 @@ function TopologyBox(props: TopologyBoxProps) {
|
|||
{props.data.values.map((boxData, index) => {
|
||||
return (
|
||||
<Typography key={index}>
|
||||
{formatPower(boxData.value)}
|
||||
{boxData.unit}
|
||||
{formatPower(boxData.value, boxData.unit) === 0
|
||||
? null
|
||||
: formatPower(boxData.value, boxData.unit)}
|
||||
{formatPower(boxData.value, boxData.unit) === 0
|
||||
? null
|
||||
: boxData.unit}
|
||||
</Typography>
|
||||
);
|
||||
})}
|
||||
|
|
|
@ -45,7 +45,12 @@ function formatPower(value) {
|
|||
magnitude++;
|
||||
}
|
||||
|
||||
const roundedValue = value.toFixed(1);
|
||||
const roundedValue = Math.round(value);
|
||||
|
||||
//Filter all values less than 100 Watts
|
||||
if (magnitude === 0 && value < 100) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return negative === false
|
||||
? `${roundedValue} ${prefixes[magnitude]}`
|
||||
|
@ -113,8 +118,12 @@ function TopologyFlow(props: TopologyFlowProps) {
|
|||
zIndex: 1
|
||||
}}
|
||||
>
|
||||
{formatPower(props.data.values[0].value)}
|
||||
{props.data.values[0].unit}
|
||||
{formatPower(props.data.values[0].value) === 0
|
||||
? null
|
||||
: formatPower(props.data.values[0].value)}
|
||||
{formatPower(props.data.values[0].value) === 0
|
||||
? null
|
||||
: props.data.values[0].unit}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
Grid,
|
||||
IconButton,
|
||||
Modal,
|
||||
Switch,
|
||||
Tab,
|
||||
Tabs,
|
||||
TextField,
|
||||
|
@ -22,6 +23,7 @@ import { InnovEnergyUser } from 'src/interfaces/UserTypes';
|
|||
import { TokenContext } from 'src/contexts/tokenContext';
|
||||
import { TabsContainerWrapper } from 'src/layouts/TabsContainerWrapper';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import FormControlLabel from '@mui/material/FormControlLabel';
|
||||
|
||||
interface singleUserProps {
|
||||
current_user: InnovEnergyUser;
|
||||
|
@ -80,6 +82,14 @@ function User(props: singleUserProps) {
|
|||
[name]: value
|
||||
});
|
||||
};
|
||||
|
||||
const handleAdminChange = (event) => {
|
||||
setFormValues({
|
||||
...formValues,
|
||||
['hasWriteAccess']: event.target.checked
|
||||
});
|
||||
};
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
setLoading(true);
|
||||
setError(false);
|
||||
|
@ -94,8 +104,13 @@ function User(props: singleUserProps) {
|
|||
});
|
||||
|
||||
if (res) {
|
||||
setUpdated(true);
|
||||
props.fetchDataAgain();
|
||||
setLoading(false);
|
||||
setUpdated(true);
|
||||
|
||||
setTimeout(() => {
|
||||
setUpdated(false);
|
||||
}, 3000);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -278,6 +293,34 @@ function User(props: singleUserProps) {
|
|||
fullWidth
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<FormControlLabel
|
||||
labelPlacement="start"
|
||||
control={
|
||||
<Switch
|
||||
checked={
|
||||
formValues.hasWriteAccess ? true : false
|
||||
}
|
||||
color="primary"
|
||||
name="hasWriteAccess"
|
||||
onChange={handleAdminChange}
|
||||
sx={{
|
||||
marginLeft: '8px',
|
||||
marginTop: '2px'
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<Typography sx={{ marginTop: '4px' }}>
|
||||
Admin
|
||||
</Typography>
|
||||
}
|
||||
sx={{
|
||||
marginLeft: '10px'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
|
|
|
@ -8,7 +8,7 @@ function Users() {
|
|||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{ userSelect: 'none' }}>
|
||||
<AccessContextProvider>
|
||||
<Container maxWidth="xl" sx={{ marginTop: '20px' }}>
|
||||
<Grid item xs={12}>
|
||||
|
@ -19,7 +19,7 @@ function Users() {
|
|||
</Container>
|
||||
<Footer />
|
||||
</AccessContextProvider>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@ import {
|
|||
MenuItem,
|
||||
Modal,
|
||||
Select,
|
||||
Switch,
|
||||
TextField,
|
||||
Typography,
|
||||
useTheme
|
||||
} from '@mui/material';
|
||||
import Button from '@mui/material/Button';
|
||||
|
@ -17,10 +19,9 @@ import { Close as CloseIcon } from '@mui/icons-material';
|
|||
import { InnovEnergyUser } from 'src/interfaces/UserTypes';
|
||||
import axiosConfig from 'src/Resources/axiosConfig';
|
||||
import { TokenContext } from 'src/contexts/tokenContext';
|
||||
import FormControlLabel from '@mui/material/FormControlLabel';
|
||||
import Checkbox from '@mui/material/Checkbox';
|
||||
import { I_Folder, I_Installation } from 'src/interfaces/InstallationTypes';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import FormControlLabel from '@mui/material/FormControlLabel';
|
||||
|
||||
interface userFormProps {
|
||||
cancel: () => void;
|
||||
|
@ -385,16 +386,22 @@ function userForm(props: userFormProps) {
|
|||
|
||||
<div>
|
||||
<FormControlLabel
|
||||
labelPlacement="start"
|
||||
control={
|
||||
<Checkbox
|
||||
<Switch
|
||||
color="primary"
|
||||
onChange={handleAdminChange}
|
||||
sx={{
|
||||
marginLeft: '11px'
|
||||
marginLeft: '8px',
|
||||
marginTop: '2px'
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label="Admin"
|
||||
sx={{ marginTop: 1 }}
|
||||
label={<Typography sx={{ marginTop: '6px' }}>Admin</Typography>}
|
||||
sx={{
|
||||
marginLeft: '10px',
|
||||
marginTop: '9px'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
import {
|
||||
Box,
|
||||
Card,
|
||||
Typography,
|
||||
Container,
|
||||
Divider,
|
||||
Button,
|
||||
FormControl,
|
||||
Container,
|
||||
OutlinedInput,
|
||||
InputAdornment,
|
||||
styled
|
||||
styled,
|
||||
Typography
|
||||
} from '@mui/material';
|
||||
import { Helmet } from 'react-helmet-async';
|
||||
import SearchTwoToneIcon from '@mui/icons-material/SearchTwoTone';
|
||||
|
||||
const MainContent = styled(Box)(
|
||||
({ theme }) => `
|
||||
|
@ -50,42 +45,14 @@ function Status404() {
|
|||
<Typography variant="h2" sx={{ my: 2 }}>
|
||||
The page you were looking for doesn't exist.
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="h4"
|
||||
color="text.secondary"
|
||||
fontWeight="normal"
|
||||
sx={{ mb: 4 }}
|
||||
<Button
|
||||
href="/login"
|
||||
variant="outlined"
|
||||
sx={{ backgroundColor: 'white' }}
|
||||
>
|
||||
It's on us, we moved the content to a different page. The search
|
||||
below should help!
|
||||
</Typography>
|
||||
Go to homepage
|
||||
</Button>
|
||||
</Box>
|
||||
<Container maxWidth="sm">
|
||||
<Card sx={{ textAlign: 'center', mt: 3, p: 4 }}>
|
||||
<FormControl variant="outlined" fullWidth>
|
||||
<OutlinedInputWrapper
|
||||
type="text"
|
||||
placeholder="Search terms here..."
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<ButtonSearch variant="contained" size="small">
|
||||
Search
|
||||
</ButtonSearch>
|
||||
</InputAdornment>
|
||||
}
|
||||
startAdornment={
|
||||
<InputAdornment position="start">
|
||||
<SearchTwoToneIcon />
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<Divider sx={{ my: 4 }}>OR</Divider>
|
||||
<Button href="/overview" variant="outlined">
|
||||
Go to homepage
|
||||
</Button>
|
||||
</Card>
|
||||
</Container>
|
||||
</Container>
|
||||
</MainContent>
|
||||
</>
|
||||
|
|
|
@ -110,7 +110,7 @@ export const transformInputToDailyData = async (
|
|||
while (startUnixTime < endTimestamp) {
|
||||
timestampPromises.push(fetchData(startUnixTime, s3Credentials));
|
||||
|
||||
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + diff / 200);
|
||||
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + diff / 100);
|
||||
if (startUnixTime.ticks % 2 !== 0) {
|
||||
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + 1);
|
||||
}
|
||||
|
@ -436,12 +436,8 @@ export const transformInputToAggregatedData = async (
|
|||
overviewData['/GridExportPower'].magnitude
|
||||
),
|
||||
unit: '(kWh)',
|
||||
min:
|
||||
overviewData['/GridImportPower'].min +
|
||||
overviewData['/GridExportPower'].min,
|
||||
max:
|
||||
overviewData['/GridImportPower'].max +
|
||||
overviewData['/GridExportPower'].max
|
||||
min: overviewData['/GridExportPower'].min,
|
||||
max: overviewData['/GridImportPower'].max
|
||||
};
|
||||
|
||||
chartOverview.overview = {
|
||||
|
|
|
@ -11,6 +11,7 @@ import { styled } from '@mui/material/styles';
|
|||
import ExpandMoreTwoToneIcon from '@mui/icons-material/ExpandMoreTwoTone';
|
||||
import { ThemeContext } from '../../../../theme/ThemeProvider';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import '../../../../App.css';
|
||||
|
||||
interface HeaderButtonsProps {
|
||||
language: string;
|
||||
|
@ -106,7 +107,7 @@ function HeaderMenu(props: HeaderButtonsProps) {
|
|||
const isMobile = window.innerWidth <= 1280;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{ userSelect: 'none' }}>
|
||||
<ListWrapper
|
||||
sx={{
|
||||
color: isMobile ? 'white' : ''
|
||||
|
@ -132,18 +133,22 @@ function HeaderMenu(props: HeaderButtonsProps) {
|
|||
</ListItem>
|
||||
</List>
|
||||
</ListWrapper>
|
||||
<Menu anchorEl={ref.current} onClose={handleClose} open={isOpen}>
|
||||
<MenuItem value="en" onClick={() => handleLanguageSelect('en')}>
|
||||
English
|
||||
</MenuItem>
|
||||
<MenuItem value="de" onClick={() => handleLanguageSelect('de')}>
|
||||
German
|
||||
</MenuItem>
|
||||
<MenuItem value="fr" onClick={() => handleLanguageSelect('fr')}>
|
||||
French
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</>
|
||||
<div
|
||||
style={{ userSelect: 'none', pointerEvents: 'none', cursor: 'default' }}
|
||||
>
|
||||
<Menu anchorEl={ref.current} onClose={handleClose} open={isOpen}>
|
||||
<MenuItem value="en" onClick={() => handleLanguageSelect('en')}>
|
||||
English
|
||||
</MenuItem>
|
||||
<MenuItem value="de" onClick={() => handleLanguageSelect('de')}>
|
||||
German
|
||||
</MenuItem>
|
||||
<MenuItem value="fr" onClick={() => handleLanguageSelect('fr')}>
|
||||
French
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import { TokenContext } from 'src/contexts/tokenContext';
|
|||
import { useNavigate } from 'react-router-dom';
|
||||
import routes from 'src/Resources/routes.json';
|
||||
import { WebSocketContext } from '../../../../contexts/WebSocketContextProvider';
|
||||
import '../../../../App.css';
|
||||
|
||||
const UserBoxButton = styled(Button)(
|
||||
({ theme }) => `
|
||||
|
@ -86,8 +87,13 @@ function HeaderUserbox() {
|
|||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<UserBoxButton color="secondary" ref={ref} onClick={handleOpen}>
|
||||
<div style={{ userSelect: 'none' }}>
|
||||
<UserBoxButton
|
||||
color="secondary"
|
||||
ref={ref}
|
||||
onClick={handleOpen}
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
<Hidden mdDown>
|
||||
<UserBoxText>
|
||||
<UserBoxLabel variant="body1">{currentUser?.name}</UserBoxLabel>
|
||||
|
@ -113,14 +119,16 @@ function HeaderUserbox() {
|
|||
horizontal: 'right'
|
||||
}}
|
||||
>
|
||||
<MenuUserBox sx={{ minWidth: 210 }} display="flex">
|
||||
<UserBoxText>
|
||||
<UserBoxLabel variant="body1">{currentUser?.name}</UserBoxLabel>
|
||||
<UserBoxDescription variant="body2">
|
||||
{currentUser?.email}
|
||||
</UserBoxDescription>
|
||||
</UserBoxText>
|
||||
</MenuUserBox>
|
||||
<div style={{ userSelect: 'none', cursor: 'none' }}>
|
||||
<MenuUserBox sx={{ minWidth: 210 }} display="flex">
|
||||
<UserBoxText>
|
||||
<UserBoxLabel variant="body1">{currentUser?.name}</UserBoxLabel>
|
||||
<UserBoxDescription variant="body2">
|
||||
{currentUser?.email}
|
||||
</UserBoxDescription>
|
||||
</UserBoxText>
|
||||
</MenuUserBox>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
<Box sx={{ m: 1 }}>
|
||||
|
@ -130,7 +138,7 @@ function HeaderUserbox() {
|
|||
</Button>
|
||||
</Box>
|
||||
</Popover>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,10 +43,12 @@ const SidebarLayout = (props: SidebarLayoutProps) => {
|
|||
}
|
||||
}}
|
||||
>
|
||||
<Header
|
||||
language={props.language}
|
||||
onSelectLanguage={props.onSelectLanguage}
|
||||
/>
|
||||
<div style={{ userSelect: 'none' }}>
|
||||
<Header
|
||||
language={props.language}
|
||||
onSelectLanguage={props.onSelectLanguage}
|
||||
/>
|
||||
</div>
|
||||
<Sidebar />
|
||||
<Box
|
||||
sx={{
|
||||
|
|
Loading…
Reference in New Issue