mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Bugfix: Refactor date and time initialization in Export.jsx (#6794)
* Refactor date and time initialization in Export.jsx to use local timezone * Update error message to include specific reason for failure in Export.jsx
This commit is contained in:
parent
7e5abe7a65
commit
a8f282515f
@ -1,5 +1,5 @@
|
|||||||
import Heading from '../components/Heading';
|
import Heading from '../components/Heading';
|
||||||
import { useState, useEffect } from 'preact/hooks';
|
import { useState } from 'preact/hooks';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import Button from '../components/Button';
|
import Button from '../components/Button';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
@ -10,21 +10,17 @@ export default function Export() {
|
|||||||
const [camera, setCamera] = useState('select');
|
const [camera, setCamera] = useState('select');
|
||||||
const [playback, setPlayback] = useState('select');
|
const [playback, setPlayback] = useState('select');
|
||||||
const [message, setMessage] = useState({ text: '', error: false });
|
const [message, setMessage] = useState({ text: '', error: false });
|
||||||
const [startDate, setStartDate] = useState('input');
|
|
||||||
const [startTime, setStartTime] = useState('input');
|
|
||||||
const [endDate, setEndDate] = useState('input');
|
|
||||||
const [endTime, setEndTime] = useState('input');
|
|
||||||
|
|
||||||
useEffect(() => {
|
const currentDate = new Date();
|
||||||
const currentDate = new Date();
|
currentDate.setHours(0, 0, 0, 0);
|
||||||
currentDate.setHours(0, 0, 0, 0);
|
const offsetMs = currentDate.getTimezoneOffset() * 60 * 1000;
|
||||||
const offsetMs = currentDate.getTimezoneOffset() * 60 * 1000;
|
const localDate = new Date(currentDate.getTime() - offsetMs);
|
||||||
const localISOTime = (new Date(currentDate.getTime() - offsetMs)).toISOString().slice(0,16);
|
const localISODate = localDate.toISOString().split('T')[0];
|
||||||
setStartDate(localISOTime);
|
|
||||||
setStartTime("00:00");
|
const [startDate, setStartDate] = useState(localISODate);
|
||||||
setEndDate(localISOTime);
|
const [startTime, setStartTime] = useState("00:00");
|
||||||
setEndTime("23:59");
|
const [endDate, setEndDate] = useState(localISODate);
|
||||||
}, []);
|
const [endTime, setEndTime] = useState("23:59");
|
||||||
|
|
||||||
const onHandleExport = () => {
|
const onHandleExport = () => {
|
||||||
if (camera == 'select') {
|
if (camera == 'select') {
|
||||||
@ -52,8 +48,13 @@ export default function Export() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setMessage({ text: 'Successfully started export. View the file in the /exports folder.', error: false });
|
axios.post(`export/${camera}/start/${start}/end/${end}`, { playback })
|
||||||
axios.post(`export/${camera}/start/${start}/end/${end}`, { playback });
|
.then(() => {
|
||||||
|
setMessage({ text: 'Successfully started export. View the file in the /exports folder.', error: false });
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setMessage({ text: 'Failed to start export: '+error.response.data.message, error: true });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user