Fixed Configuration Tab on frontend.
Fixed time axis on overview tab and main-stats (battery view tab).
This commit is contained in:
parent
fcbd85db7f
commit
1338a5ecf3
|
@ -195,6 +195,8 @@ public static class Controller
|
||||||
var mustDoCalibrationCharge = calibrationChargeForced == CalibrationChargeType.ChargePermanently ||
|
var mustDoCalibrationCharge = calibrationChargeForced == CalibrationChargeType.ChargePermanently ||
|
||||||
(calibrationChargeForced == CalibrationChargeType.AdditionallyOnce && additionalCalibrationRequired) ||
|
(calibrationChargeForced == CalibrationChargeType.AdditionallyOnce && additionalCalibrationRequired) ||
|
||||||
(calibrationChargeForced == CalibrationChargeType.RepetitivelyEvery && repetitiveCalibrationRequired);
|
(calibrationChargeForced == CalibrationChargeType.RepetitivelyEvery && repetitiveCalibrationRequired);
|
||||||
|
Console.WriteLine("Next Repetitive calibration charge date is "+statusRecord.Config.DayAndTimeForRepetitiveCalibration);
|
||||||
|
Console.WriteLine("Next Additional calibration charge date is "+statusRecord.Config.DayAndTimeForAdditionalCalibration);
|
||||||
|
|
||||||
if (statusRecord.Battery is not null)
|
if (statusRecord.Battery is not null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,6 @@ import {
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import axiosConfig from '../../../Resources/axiosConfig';
|
|
||||||
import { Close as CloseIcon } from '@mui/icons-material';
|
import { Close as CloseIcon } from '@mui/icons-material';
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
import MenuItem from '@mui/material/MenuItem';
|
||||||
import {
|
import {
|
||||||
|
@ -28,6 +27,8 @@ import {
|
||||||
} from '@mui/x-date-pickers';
|
} from '@mui/x-date-pickers';
|
||||||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import axiosConfig from '../../../Resources/axiosConfig';
|
||||||
|
import utc from 'dayjs/plugin/utc';
|
||||||
|
|
||||||
interface ConfigurationProps {
|
interface ConfigurationProps {
|
||||||
values: TopologyValues;
|
values: TopologyValues;
|
||||||
|
@ -61,6 +62,9 @@ function Configuration(props: ConfigurationProps) {
|
||||||
'Saturday'
|
'Saturday'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
dayjs.extend(utc);
|
||||||
|
const localOffset = dayjs().utcOffset();
|
||||||
|
|
||||||
const [errors, setErrors] = useState({
|
const [errors, setErrors] = useState({
|
||||||
minimumSoC: false,
|
minimumSoC: false,
|
||||||
gridSetPoint: false
|
gridSetPoint: false
|
||||||
|
@ -89,35 +93,43 @@ function Configuration(props: ConfigurationProps) {
|
||||||
CalibrationChargeOptionsController.indexOf(
|
CalibrationChargeOptionsController.indexOf(
|
||||||
props.values.calibrationChargeState[0].value.toString()
|
props.values.calibrationChargeState[0].value.toString()
|
||||||
) == 0
|
) == 0
|
||||||
? dayjs(props.values.repetitiveCalibrationChargeDate[0].value).toDate()
|
? dayjs
|
||||||
: dayjs(props.values.additionalCalibrationChargeDate[0].value).toDate()
|
.utc(props.values.repetitiveCalibrationChargeDate[0].value)
|
||||||
|
.add(localOffset, 'minute')
|
||||||
|
.toDate()
|
||||||
|
: dayjs
|
||||||
|
.utc(props.values.additionalCalibrationChargeDate[0].value)
|
||||||
|
.add(localOffset, 'minute')
|
||||||
|
.toDate()
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
if (
|
if (
|
||||||
props.values.mode[0].value === 'CalibrationCharge' &&
|
CalibrationChargeOptionsController.indexOf(
|
||||||
formValues.CalibrationChargeState == 0
|
props.values.calibrationChargeState[0].value.toString()
|
||||||
|
) != 2 &&
|
||||||
|
props.values.mode[0].value === 'CalibrationCharge'
|
||||||
) {
|
) {
|
||||||
setDateSelectionError(
|
setDateSelectionError(
|
||||||
'You cannot change the date while the installation is in Calibration Charge Mode'
|
'You cannot change the date while the installation is in Calibration Charge Mode'
|
||||||
);
|
);
|
||||||
setErrorDateModalOpen(true);
|
setErrorDateModalOpen(true);
|
||||||
return;
|
return;
|
||||||
} else if (dayjs(formValues.calibrationChargeDate).isBefore(dayjs())) {
|
} else if (
|
||||||
console.log(dayjs());
|
formValues.CalibrationChargeState != 2 &&
|
||||||
console.log('asked for', dayjs(formValues.calibrationChargeDate));
|
dayjs(formValues.calibrationChargeDate).isBefore(dayjs())
|
||||||
|
) {
|
||||||
|
//console.log('asked for', dayjs(formValues.calibrationChargeDate));
|
||||||
setDateSelectionError('You must specify a future date');
|
setDateSelectionError('You must specify a future date');
|
||||||
setErrorDateModalOpen(true);
|
setErrorDateModalOpen(true);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
console.log('asked for', dayjs(formValues.calibrationChargeDate));
|
//console.log('asked for', dayjs(formValues.calibrationChargeDate));
|
||||||
const configurationToSend: ConfigurationValues = {
|
const configurationToSend: ConfigurationValues = {
|
||||||
minimumSoC: formValues.minimumSoC,
|
minimumSoC: formValues.minimumSoC,
|
||||||
gridSetPoint: formValues.gridSetPoint,
|
gridSetPoint: formValues.gridSetPoint,
|
||||||
CalibrationChargeState: formValues.CalibrationChargeState,
|
CalibrationChargeState: formValues.CalibrationChargeState,
|
||||||
calibrationChargeDate: dayjs(formValues.calibrationChargeDate)
|
calibrationChargeDate: dayjs(formValues.calibrationChargeDate).toDate()
|
||||||
.add(2, 'hours')
|
|
||||||
.toDate()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
@ -147,7 +159,7 @@ function Configuration(props: ConfigurationProps) {
|
||||||
const handleConfirm = (newDate) => {
|
const handleConfirm = (newDate) => {
|
||||||
setFormValues({
|
setFormValues({
|
||||||
...formValues,
|
...formValues,
|
||||||
['calibrationChargeDate']: dayjs(newDate).toDate()
|
['calibrationChargeDate']: dayjs.utc(newDate).toDate()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -159,7 +171,6 @@ function Configuration(props: ConfigurationProps) {
|
||||||
difference += 7;
|
difference += 7;
|
||||||
}
|
}
|
||||||
const adjustedDate = currentDate.add(difference, 'day');
|
const adjustedDate = currentDate.add(difference, 'day');
|
||||||
|
|
||||||
setFormValues({
|
setFormValues({
|
||||||
...formValues,
|
...formValues,
|
||||||
['calibrationChargeDate']: adjustedDate.toDate()
|
['calibrationChargeDate']: adjustedDate.toDate()
|
||||||
|
@ -174,12 +185,14 @@ function Configuration(props: ConfigurationProps) {
|
||||||
),
|
),
|
||||||
['calibrationChargeDate']:
|
['calibrationChargeDate']:
|
||||||
CalibrationChargeOptions.indexOf(event.target.value) == 0
|
CalibrationChargeOptions.indexOf(event.target.value) == 0
|
||||||
? dayjs(
|
? dayjs
|
||||||
props.values.repetitiveCalibrationChargeDate[0].value
|
.utc(props.values.repetitiveCalibrationChargeDate[0].value)
|
||||||
).toDate()
|
.add(localOffset, 'minute')
|
||||||
: dayjs(
|
.toDate()
|
||||||
props.values.additionalCalibrationChargeDate[0].value
|
: dayjs
|
||||||
).toDate()
|
.utc(props.values.additionalCalibrationChargeDate[0].value)
|
||||||
|
.add(localOffset, 'minute')
|
||||||
|
.toDate()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -320,9 +333,6 @@ function Configuration(props: ConfigurationProps) {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
onChange={handleSelectedCalibrationChargeChange}
|
onChange={handleSelectedCalibrationChargeChange}
|
||||||
//open={openForcedCalibrationCharge}
|
|
||||||
//onClose={handleCloseForcedCalibrationCharge}
|
|
||||||
//onOpen={handleOpenForcedCalibrationCharge}
|
|
||||||
>
|
>
|
||||||
{CalibrationChargeOptions.map((option) => (
|
{CalibrationChargeOptions.map((option) => (
|
||||||
<MenuItem key={option} value={option}>
|
<MenuItem key={option} value={option}>
|
||||||
|
@ -336,8 +346,10 @@ function Configuration(props: ConfigurationProps) {
|
||||||
<div>
|
<div>
|
||||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
<DateTimePicker
|
<DateTimePicker
|
||||||
|
format="DD/MM/YYYY HH:mm"
|
||||||
|
ampm={false}
|
||||||
label="Select Next Calibration Charge Date"
|
label="Select Next Calibration Charge Date"
|
||||||
value={dayjs(formValues.calibrationChargeDate)}
|
value={dayjs.utc(formValues.calibrationChargeDate)}
|
||||||
onChange={handleConfirm}
|
onChange={handleConfirm}
|
||||||
sx={{
|
sx={{
|
||||||
marginTop: 2
|
marginTop: 2
|
||||||
|
@ -370,9 +382,6 @@ function Configuration(props: ConfigurationProps) {
|
||||||
daysInWeek[formValues.calibrationChargeDate.getDay()]
|
daysInWeek[formValues.calibrationChargeDate.getDay()]
|
||||||
}
|
}
|
||||||
onChange={handleSelectedCalibrationChargeDay}
|
onChange={handleSelectedCalibrationChargeDay}
|
||||||
// open={openForcedCalibrationCharge}
|
|
||||||
// onClose={handleCloseForcedCalibrationCharge}
|
|
||||||
// onOpen={handleOpenForcedCalibrationCharge}
|
|
||||||
>
|
>
|
||||||
{daysInWeek.map((day) => (
|
{daysInWeek.map((day) => (
|
||||||
<MenuItem key={day} value={day}>
|
<MenuItem key={day} value={day}>
|
||||||
|
@ -386,8 +395,9 @@ function Configuration(props: ConfigurationProps) {
|
||||||
<div style={{ marginBottom: '5px', marginTop: '10px' }}>
|
<div style={{ marginBottom: '5px', marginTop: '10px' }}>
|
||||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
<TimePicker
|
<TimePicker
|
||||||
|
ampm={false}
|
||||||
label="Calibration Charge Hour"
|
label="Calibration Charge Hour"
|
||||||
value={dayjs(formValues.calibrationChargeDate)}
|
value={dayjs.utc(formValues.calibrationChargeDate)}
|
||||||
onChange={handleConfirm}
|
onChange={handleConfirm}
|
||||||
/>
|
/>
|
||||||
</LocalizationProvider>
|
</LocalizationProvider>
|
||||||
|
|
|
@ -282,25 +282,25 @@ function Information(props: InformationProps) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
{/*<div>*/}
|
||||||
<TextField
|
{/* <TextField*/}
|
||||||
label="S3 Write Key"
|
{/* label="S3 Write Key"*/}
|
||||||
name="s3writekey"
|
{/* name="s3writekey"*/}
|
||||||
value={formValues.s3WriteKey}
|
{/* value={formValues.s3WriteKey}*/}
|
||||||
variant="outlined"
|
{/* variant="outlined"*/}
|
||||||
fullWidth
|
{/* fullWidth*/}
|
||||||
/>
|
{/* />*/}
|
||||||
</div>
|
{/*</div>*/}
|
||||||
|
|
||||||
<div>
|
{/*<div>*/}
|
||||||
<TextField
|
{/* <TextField*/}
|
||||||
label="S3 Write Secret Key"
|
{/* label="S3 Write Secret Key"*/}
|
||||||
name="s3writesecretkey"
|
{/* name="s3writesecretkey"*/}
|
||||||
value={formValues.s3WriteSecret}
|
{/* value={formValues.s3WriteSecret}*/}
|
||||||
variant="outlined"
|
{/* variant="outlined"*/}
|
||||||
fullWidth
|
{/* fullWidth*/}
|
||||||
/>
|
{/* />*/}
|
||||||
</div>
|
{/*</div>*/}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
|
@ -143,7 +143,9 @@ export const transformInputToBatteryViewData = async (
|
||||||
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + 1);
|
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + 1);
|
||||||
}
|
}
|
||||||
const adjustedTimestamp = new Date(startUnixTime.ticks * 1000);
|
const adjustedTimestamp = new Date(startUnixTime.ticks * 1000);
|
||||||
adjustedTimestamp.setHours(adjustedTimestamp.getHours() + 1);
|
adjustedTimestamp.setHours(
|
||||||
|
adjustedTimestamp.getHours() - adjustedTimestamp.getTimezoneOffset() / 60
|
||||||
|
);
|
||||||
adjustedTimestampArray.push(adjustedTimestamp);
|
adjustedTimestampArray.push(adjustedTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +328,11 @@ export const transformInputToDailyData = async (
|
||||||
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + 1);
|
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + 1);
|
||||||
}
|
}
|
||||||
const adjustedTimestamp = new Date(startUnixTime.ticks * 1000);
|
const adjustedTimestamp = new Date(startUnixTime.ticks * 1000);
|
||||||
adjustedTimestamp.setHours(adjustedTimestamp.getHours() + 1);
|
//Timezone offset is negative, so we convert the timestamp to the current zone by subtracting the corresponding offset
|
||||||
|
adjustedTimestamp.setHours(
|
||||||
|
adjustedTimestamp.getHours() - adjustedTimestamp.getTimezoneOffset() / 60
|
||||||
|
);
|
||||||
|
|
||||||
adjustedTimestampArray.push(adjustedTimestamp);
|
adjustedTimestampArray.push(adjustedTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue