Update SodistoreMax battery view in frontend
Also, fixed sessions for SodistoreMax
This commit is contained in:
parent
2cb15d6478
commit
8db16313e9
|
|
@ -30,8 +30,12 @@ function App() {
|
|||
const navigate = useNavigate();
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
const username = searchParams.get('username');
|
||||
const { setAccessToSalimax, setAccessToSalidomo, setAccessToSodiohome } =
|
||||
useContext(ProductIdContext);
|
||||
const {
|
||||
setAccessToSalimax,
|
||||
setAccessToSalidomo,
|
||||
setAccessToSodiohome,
|
||||
setAccessToSodistore
|
||||
} = useContext(ProductIdContext);
|
||||
|
||||
const [language, setLanguage] = useState('en');
|
||||
const getTranslations = () => {
|
||||
|
|
@ -73,10 +77,13 @@ function App() {
|
|||
setAccessToSalimax(response.data.accessToSalimax);
|
||||
setAccessToSalidomo(response.data.accessToSalidomo);
|
||||
setAccessToSodiohome(response.data.accessToSodiohome);
|
||||
setAccessToSodistore(response.data.accessToSodistoreMax);
|
||||
if (response.data.accessToSalimax) {
|
||||
navigate(routes.installations);
|
||||
} else if (response.data.accessToSalidomo) {
|
||||
navigate(routes.salidomo_installations);
|
||||
} else if (response.data.accessToSodistoreMax) {
|
||||
navigate(routes.sodistore_installations);
|
||||
} else {
|
||||
navigate(routes.sodiohome_installations);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,12 @@ function Login() {
|
|||
|
||||
const theme = useTheme();
|
||||
const context = useContext(UserContext);
|
||||
const { setAccessToSalimax, setAccessToSalidomo,setAccessToSodiohome } =
|
||||
useContext(ProductIdContext);
|
||||
const {
|
||||
setAccessToSalimax,
|
||||
setAccessToSalidomo,
|
||||
setAccessToSodiohome,
|
||||
setAccessToSodistore
|
||||
} = useContext(ProductIdContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
if (!context) {
|
||||
|
|
@ -79,6 +83,7 @@ function Login() {
|
|||
setAccessToSalimax(response.data.accessToSalimax);
|
||||
setAccessToSalidomo(response.data.accessToSalidomo);
|
||||
setAccessToSodiohome(response.data.accessToSodioHome);
|
||||
setAccessToSodistore(response.data.accessToSodistoreMax);
|
||||
|
||||
if (rememberMe) {
|
||||
cookies.set('rememberedUsername', username, { path: '/' });
|
||||
|
|
@ -86,9 +91,9 @@ function Login() {
|
|||
}
|
||||
if (response.data.accessToSalimax) {
|
||||
navigate(routes.installations);
|
||||
} else if(response.data.accessToSalidomo){
|
||||
} else if (response.data.accessToSalidomo) {
|
||||
navigate(routes.salidomo_installations);
|
||||
} else{
|
||||
} else {
|
||||
navigate(routes.sodiohome_installations);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ function BatteryView(props: BatteryViewProps) {
|
|||
if (props.values === null && props.connected == true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentLocation = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const sortedBatteryView =
|
||||
|
|
@ -215,8 +216,16 @@ function BatteryView(props: BatteryViewProps) {
|
|||
<TableCell align="center">Voltage</TableCell>
|
||||
<TableCell align="center">SoC</TableCell>
|
||||
<TableCell align="center">Temperature</TableCell>
|
||||
<TableCell align="center">Warnings</TableCell>
|
||||
<TableCell align="center">Alarms</TableCell>
|
||||
{product === 0 ? (
|
||||
<TableCell align="center">Warnings</TableCell>
|
||||
) : (
|
||||
<TableCell align="center">Min Cell Voltage</TableCell>
|
||||
)}
|
||||
{product === 0 ? (
|
||||
<TableCell align="center">Alarms</TableCell>
|
||||
) : (
|
||||
<TableCell align="center">Max Cell Voltage</TableCell>
|
||||
)}
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
|
|
@ -248,7 +257,7 @@ function BatteryView(props: BatteryViewProps) {
|
|||
>
|
||||
{product == 0
|
||||
? battery.FwVersion
|
||||
: battery.BatteryDeligreenDataRecord.FwVersion}
|
||||
: battery.BatteryDeligreenDataRecord.FwVersion + '.0'}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
sx={{
|
||||
|
|
@ -271,9 +280,9 @@ function BatteryView(props: BatteryViewProps) {
|
|||
? '#FF033E'
|
||||
: '#32CD32'
|
||||
: battery.BatteryDeligreenDataRecord
|
||||
.TotalBatteryVoltage < 44 ||
|
||||
.TotalBatteryVoltage < 32 ||
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TotalBatteryVoltage > 57
|
||||
.TotalBatteryVoltage > 63
|
||||
? '#FF033E'
|
||||
: '#32CD32',
|
||||
color:
|
||||
|
|
@ -305,7 +314,7 @@ function BatteryView(props: BatteryViewProps) {
|
|||
: battery.Soc < 50
|
||||
? '#ffbf00'
|
||||
: '#32CD32'
|
||||
: battery.BatteryDeligreenDataRecord.Soc < 20
|
||||
: battery.BatteryDeligreenDataRecord.Soc <= 10
|
||||
? '#FF033E'
|
||||
: battery.BatteryDeligreenDataRecord.Soc < 50
|
||||
? '#ffbf00'
|
||||
|
|
@ -341,27 +350,15 @@ function BatteryView(props: BatteryViewProps) {
|
|||
: '#32CD32'
|
||||
};
|
||||
} else {
|
||||
const avg =
|
||||
(battery.BatteryDeligreenDataRecord.TemperaturesList
|
||||
.CellTemperature1 +
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.CellTemperature2 +
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.CellTemperature3 +
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.CellTemperature4) /
|
||||
4;
|
||||
|
||||
return {
|
||||
width: '10%',
|
||||
textAlign: 'center',
|
||||
backgroundColor:
|
||||
avg > 300
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.EnvironmentTemperature > 50 ||
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.EnvironmentTemperature < 0
|
||||
? '#FF033E'
|
||||
: avg > 280
|
||||
? '#ffbf00'
|
||||
: avg < 245
|
||||
? '#008FFB'
|
||||
: '#32CD32'
|
||||
};
|
||||
}
|
||||
|
|
@ -369,17 +366,8 @@ function BatteryView(props: BatteryViewProps) {
|
|||
>
|
||||
{product === 0
|
||||
? battery.Temperatures.Cells.Average + ' °C'
|
||||
: (
|
||||
(battery.BatteryDeligreenDataRecord.TemperaturesList
|
||||
.CellTemperature1 +
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.CellTemperature2 +
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.CellTemperature3 +
|
||||
battery.BatteryDeligreenDataRecord
|
||||
.TemperaturesList.CellTemperature4) /
|
||||
4
|
||||
).toFixed(1) + ' °C'}
|
||||
: battery.BatteryDeligreenDataRecord.TemperaturesList
|
||||
.EnvironmentTemperature + ' °C'}
|
||||
</TableCell>
|
||||
|
||||
{product === 0 && (
|
||||
|
|
@ -452,6 +440,61 @@ function BatteryView(props: BatteryViewProps) {
|
|||
</TableCell>
|
||||
</>
|
||||
)}
|
||||
{product === 3 && (
|
||||
<>
|
||||
{(() => {
|
||||
const cellVoltagesString =
|
||||
battery.BatteryDeligreenDataRecord.CellVoltage ||
|
||||
'';
|
||||
|
||||
const cellVoltagesArray: number[] = cellVoltagesString
|
||||
.split(',')
|
||||
.map((v) => parseFloat(v.trim()))
|
||||
.filter((v) => !isNaN(v)); // Filter invalid numbers
|
||||
|
||||
const minVoltage = Math.min(...cellVoltagesArray);
|
||||
const maxVoltage = Math.max(...cellVoltagesArray);
|
||||
|
||||
return (
|
||||
<>
|
||||
<TableCell
|
||||
sx={{
|
||||
width: '20%',
|
||||
textAlign: 'center',
|
||||
padding: '8px',
|
||||
backgroundColor:
|
||||
minVoltage < 1.82 || minVoltage > 3.94
|
||||
? '#FF033E'
|
||||
: minVoltage < 2 || minVoltage > 3.8
|
||||
? '#ffbf00'
|
||||
: '#32CD32',
|
||||
color: minVoltage != 0 ? 'black' : 'white'
|
||||
}}
|
||||
>
|
||||
{minVoltage.toFixed(3)} V{' '}
|
||||
</TableCell>
|
||||
|
||||
<TableCell
|
||||
sx={{
|
||||
width: '20%',
|
||||
textAlign: 'center',
|
||||
padding: '8px',
|
||||
backgroundColor:
|
||||
maxVoltage < 1.82 || maxVoltage > 3.94
|
||||
? '#FF033E'
|
||||
: maxVoltage < 2 || maxVoltage > 3.8
|
||||
? '#ffbf00'
|
||||
: '#32CD32',
|
||||
color: maxVoltage != 0 ? 'black' : 'white'
|
||||
}}
|
||||
>
|
||||
{maxVoltage.toFixed(3)} V{' '}
|
||||
</TableCell>
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</>
|
||||
)}
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
|
|
|
|||
|
|
@ -148,14 +148,6 @@ function Installation(props: singleInstallationProps) {
|
|||
console.log(res[timestamp]);
|
||||
|
||||
setValues(res[timestamp]);
|
||||
// Set values asynchronously with delay
|
||||
// setValues(
|
||||
// extractValues({
|
||||
// time: UnixTime.fromTicks(parseInt(timestamp, 10)),
|
||||
// value: res[timestamp]
|
||||
// })
|
||||
// );
|
||||
// Wait for 2 seconds before processing next timestamp
|
||||
await timeout(2000);
|
||||
}
|
||||
|
||||
|
|
@ -182,6 +174,9 @@ function Installation(props: singleInstallationProps) {
|
|||
}
|
||||
timestampToFetch = timestampToFetch.later(TimeSpan.fromSeconds(1));
|
||||
}
|
||||
if (i == 30) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -200,25 +200,26 @@ function SidebarMenu() {
|
|||
</ListItem>
|
||||
</List>
|
||||
)}
|
||||
|
||||
<List component="div">
|
||||
<ListItem component="div">
|
||||
<Button
|
||||
disableRipple
|
||||
component={RouterLink}
|
||||
onClick={closeSidebar}
|
||||
to="/sodistore_installations"
|
||||
startIcon={<BrightnessLowTwoToneIcon />}
|
||||
>
|
||||
<Box sx={{ marginTop: '3px' }}>
|
||||
<FormattedMessage
|
||||
id="sodistore"
|
||||
defaultMessage="Sodistore"
|
||||
/>
|
||||
</Box>
|
||||
</Button>
|
||||
</ListItem>
|
||||
</List>
|
||||
{accessToSodistore && (
|
||||
<List component="div">
|
||||
<ListItem component="div">
|
||||
<Button
|
||||
disableRipple
|
||||
component={RouterLink}
|
||||
onClick={closeSidebar}
|
||||
to="/sodistore_installations"
|
||||
startIcon={<BrightnessLowTwoToneIcon />}
|
||||
>
|
||||
<Box sx={{ marginTop: '3px' }}>
|
||||
<FormattedMessage
|
||||
id="sodistore"
|
||||
defaultMessage="Sodistore"
|
||||
/>
|
||||
</Box>
|
||||
</Button>
|
||||
</ListItem>
|
||||
</List>
|
||||
)}
|
||||
|
||||
{accessToSalidomo && (
|
||||
<List component="div">
|
||||
|
|
|
|||
Loading…
Reference in New Issue