diff --git a/typescript/frontend-marios2/src/Resources/routes.json b/typescript/frontend-marios2/src/Resources/routes.json index 760e7d4aa..b14a0b8ce 100644 --- a/typescript/frontend-marios2/src/Resources/routes.json +++ b/typescript/frontend-marios2/src/Resources/routes.json @@ -1,24 +1,19 @@ { - "installation": "installation/", - "live": "live", "users": "/users/", - "log": "log/", "installations": "/installations/", - "groups": "/groups/", - "group": "group/", + "installation": "installation/", + "login": "/login/", + "forgotPassword": "/forgotPassword/", "folder": "folder/", - "manageAccess": "manageAccess/", - "user": "user/", "tree": "tree/", "list": "list/", "overview": "overview", "manage": "manage", "batteryview": "batteryview", "log": "log", + "live": "live", "information": "information", "configuration": "configuration", - "login": "/login/", - "forgotPassword": "/forgotPassword/", "mainstats": "mainstats", - "general": "general" + "detailed_view": "detailed_view/" } diff --git a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx index 321f7819e..6fdfeeee5 100644 --- a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import { Container, Grid, @@ -23,6 +23,7 @@ import { FormattedMessage } from 'react-intl'; import { I_S3Credentials } from '../../../interfaces/S3Types'; import routes from '../../../Resources/routes.json'; import MainStats from './MainStats'; +import DetailedBatteryView from './DetailedBatteryView'; interface BatteryViewProps { values: TopologyValues; @@ -33,261 +34,263 @@ function BatteryView(props: BatteryViewProps) { if (props.values === null) { return null; } - const currentPath = useLocation(); + const currentLocation = useLocation(); const navigate = useNavigate(); - const [currentTab, setCurrentTab] = useState(undefined); - const numOfBatteries = props.values.batteryView.values[0].value - .toString() - .split(',').length; - - const batteryData = []; - let batteryId = 1; - // Use a for loop to generate battery data - for (let index = 1; index <= numOfBatteries * 7; index += 7) { - const battery = { - BatteryId: 'Battery ' + batteryId.toString(), - FwVersion: props.values.batteryView.values[index].value, - Power: - Number(props.values.batteryView.values[index + 1].value).toFixed(2) + - ' ' + - props.values.batteryView.values[index + 1].unit, - Voltage: - Number(props.values.batteryView.values[index + 2].value).toFixed(2) + - ' ' + - props.values.batteryView.values[index + 2].unit, - Soc: - props.values.batteryView.values[index + 3].value + - ' ' + - props.values.batteryView.values[index + 3].unit, - AverageTemperature: - props.values.batteryView.values[index + 4].value + - ' ' + - props.values.batteryView.values[index + 4].unit, - - Warnings: props.values.batteryView.values[index + 5].value, - Alarms: props.values.batteryView.values[index + 6].value - }; - batteryId++; - batteryData.push(battery); - } + const numOfBatteries = props.values.batteryView.length; const handleMainStatsButton = () => { navigate(routes.mainstats); }; - useEffect(() => { - let path = currentPath.pathname.split('/'); - - setCurrentTab(path[path.length - 1]); - }, [currentPath]); - return ( <> + + + + + + + + } /> + {Array.from({ length: numOfBatteries }).map((_, i) => ( + + } + /> + ))} - {currentTab === 'batteryview' && ( - - - - - - )} - {currentTab === 'batteryview' && ( - - - - - Battery - Firmware - Power - Voltage - SoC - Temperature - Warnings - Alarms - - - - {batteryData.map((battery) => ( - +
+ + + Battery + Firmware + Power + Voltage + SoC + Temperature + Warnings + Alarms + + + + {props.values.batteryView.map((battery) => ( + + + + {'Battery ' + battery.BatteryId} + + + - - {battery.BatteryId} - - - {battery.FwVersion} - - - {battery.Power} - - + + {battery.Power.value + ' ' + battery.Power.unit} + + 57 - ? '#FF033E' - : '#32CD32', - color: battery.Voltage === '' ? 'white' : 'inherit' - }} - > - {battery.Voltage} - - - {battery.Soc} - - 270 - ? '#FF033E' - : '#32CD32 ' - }} - > - {battery.AverageTemperature} - + backgroundColor: + battery.Voltage.value < 44 || battery.Voltage.value > 57 + ? '#FF033E' + : '#32CD32', + color: battery.Voltage.value === '' ? 'white' : 'inherit' + }} + > + {battery.Voltage.value + ' ' + battery.Voltage.unit} + + + {battery.Soc.value + ' ' + battery.Soc.unit} + + 270 + ? '#FF033E' + : '#32CD32 ' + }} + > + {battery.AverageTemperature.value + + ' ' + + battery.AverageTemperature.unit} + - - {battery.Warnings === '' ? ( - 'None' - ) : battery.Warnings.split(';').length > 1 ? ( - - Multiple Warnings - - ) : ( - battery.Warnings - )} - - - {battery.Alarms === '' ? ( - 'None' - ) : battery.Alarms.split(';').length > 1 ? ( - - Multiple Alarms - - ) : ( - battery.Alarms - )} - - - ))} - -
-
- )} + + {battery.Warnings.value === '' ? ( + 'None' + ) : battery.Warnings.value.toString().split(';').length > + 1 ? ( + + Multiple Warnings + + ) : ( + battery.Warnings.value + )} + + + {battery.Alarms.value === '' ? ( + 'None' + ) : battery.Alarms.value.toString().split(';').length > + 1 ? ( + + Multiple Alarms + + ) : ( + battery.Alarms.value + )} + + + ))} + + +
); diff --git a/typescript/frontend-marios2/src/content/dashboards/BatteryView/DetailedBatteryView.tsx b/typescript/frontend-marios2/src/content/dashboards/BatteryView/DetailedBatteryView.tsx new file mode 100644 index 000000000..bacb3ff88 --- /dev/null +++ b/typescript/frontend-marios2/src/content/dashboards/BatteryView/DetailedBatteryView.tsx @@ -0,0 +1,971 @@ +import React from 'react'; +import { I_S3Credentials } from '../../../interfaces/S3Types'; +import { + Card, + Grid, + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableRow +} from '@mui/material'; +import { Battery } from '../Log/graph.util'; +import Button from '@mui/material/Button'; +import { FormattedMessage } from 'react-intl'; +import { useNavigate } from 'react-router-dom'; +import routes from '../../../Resources/routes.json'; + +interface DetailedBatteryViewProps { + s3Credentials: I_S3Credentials; + batteryData: Battery; +} + +function DetailedBatteryView(props: DetailedBatteryViewProps) { + if (props.batteryData === null) { + return null; + } + const navigate = useNavigate(); + + const handleBatteryViewButton = () => { + navigate(location.pathname.split('/').slice(0, -2).join('/')); + }; + const handleMainStatsButton = () => { + navigate( + location.pathname.split('/').slice(0, -2).join('/') + + '/' + + routes.mainstats + ); + }; + + return ( + <> + + + + + + + + + + + + + + + Voltage + + + {props.batteryData.Voltage.value + + ' ' + + props.batteryData.Voltage.unit} + + + + + Current + + + {props.batteryData.Current.value + + ' ' + + props.batteryData.Current.unit} + + + + + Power + + + {props.batteryData.Power.value + + ' ' + + props.batteryData.Power.unit} + + + + + Bus Current + + + {props.batteryData.BusCurrent.value + + ' ' + + props.batteryData.BusCurrent.unit} + + + + + Cells Current + + + {props.batteryData.CellsCurrent.value + + ' ' + + props.batteryData.CellsCurrent.unit} + + + + + Heating Current + + + {props.batteryData.HeatingCurrent.value + + ' ' + + props.batteryData.HeatingCurrent.unit} + + + + + Heating Power + + + {props.batteryData.HeatingPower.value + + ' ' + + props.batteryData.HeatingPower.unit} + + + + + Soc + + + {props.batteryData.Soc.value + + ' ' + + props.batteryData.Soc.unit} + + + + + SOCAh + + + {props.batteryData.SOCAh.value + + ' ' + + props.batteryData.SOCAh.unit} + + + +
+
+
+
+ {/*----------------------------------------------------------------------------------------------------------------------------------*/} + + + + + + + + Heating + + + {props.batteryData.HeatingTemperature.value + + ' ' + + props.batteryData.HeatingTemperature.unit} + + + + + Board Temperature + + + {props.batteryData.BoardTemperature.value + + ' ' + + props.batteryData.BoardTemperature.unit} + + + + + Center Cells Temperature + + + {props.batteryData.AverageTemperature.value + + ' ' + + props.batteryData.AverageTemperature.unit} + + + + + Left Cells Temperature + + + {props.batteryData.LeftCellsTemperature.value + + ' ' + + props.batteryData.LeftCellsTemperature.unit} + + + + + Right Cells Temperature + + + {props.batteryData.RightCellsTemperature.value + + ' ' + + props.batteryData.RightCellsTemperature.unit} + + + + + Average Temperature + + + {props.batteryData.AverageTemperature.value + + ' ' + + props.batteryData.AverageTemperature.unit} + + + + + State + + + {props.batteryData.StateTemperature.value + + ' ' + + props.batteryData.StateTemperature.unit} + + + +
+
+
+
+ + {/*----------------------------------------------------------------------------------------------------------------------------------*/} + + + + + + + + Connected To Dc Bus + + + {props.batteryData.ConnectedToDcBus.value + + ' ' + + props.batteryData.ConnectedToDcBus.unit} + + + + + Alarm Out Active + + + {props.batteryData.AlarmOutActive.value + + ' ' + + props.batteryData.AlarmOutActive.unit} + + + + + Internal Fan Active + + + {props.batteryData.InternalFanActive.value + + ' ' + + props.batteryData.InternalFanActive.unit} + + + + + Volt Measurement Allowed + + + {props.batteryData.VoltMeasurementAllowed.value + + ' ' + + props.batteryData.VoltMeasurementAllowed.unit} + + + + + Aux Relay Bus + + + {props.batteryData.AuxRelayBus.value + + ' ' + + props.batteryData.AuxRelayBus.unit} + + + + + Remote State Active + + + {props.batteryData.RemoteStateActive.value + + ' ' + + props.batteryData.RemoteStateActive.unit} + + + + + RiscActive + + + {props.batteryData.RiscActive.value + + ' ' + + props.batteryData.RiscActive.unit} + + + +
+
+
+
+ + {/*----------------------------------------------------------------------------------------------------------------------------------*/} + + + + + + + + Eoc + + + {props.batteryData.Eoc.value + + ' ' + + props.batteryData.Eoc.unit} + + + + + Serial Number + + + {props.batteryData.SerialNumber.value + + ' ' + + props.batteryData.SerialNumber.unit} + + + + + Firmware Version + + + {props.batteryData.FwVersion.value + + ' ' + + props.batteryData.FwVersion.unit} + + + + + Time Since TOC + + + {props.batteryData.TimeSinceTOC.value + + ' ' + + props.batteryData.TimeSinceTOC.unit} + + + + + Calibration Charge Requested + + + {props.batteryData.CalibrationChargeRequested.value + + ' ' + + props.batteryData.CalibrationChargeRequested.unit} + + + + + Max Charge Power + + + {props.batteryData.MaxChargePower.value + + ' ' + + props.batteryData.MaxChargePower.unit} + + + + + Max Discharge Power + + + {props.batteryData.MaxDischargePower.value + + ' ' + + props.batteryData.MaxDischargePower.unit} + + + +
+
+
+
+ {/*----------------------------------------------------------------------------------------------------------------------------------*/} + + + + + + + + Blue Led + + +
+ + + + + Green Led + + +
+ + + + + Red Led + + +
+ + + + + Amber Led + + +
+ + + +
+
+
+
+ + ); +} + +export default DetailedBatteryView; diff --git a/typescript/frontend-marios2/src/content/dashboards/BatteryView/MainStats.tsx b/typescript/frontend-marios2/src/content/dashboards/BatteryView/MainStats.tsx index 5d3352a44..1a4c6dbf1 100644 --- a/typescript/frontend-marios2/src/content/dashboards/BatteryView/MainStats.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/BatteryView/MainStats.tsx @@ -384,7 +384,6 @@ function MainStats(props: MainStatsProps) { {!loading && ( <> - {' '}