diff options
author | Anton Tananaev <anton@traccar.org> | 2023-01-31 07:38:18 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-01-31 07:38:18 -0800 |
commit | dcb1fa21441cb292fd66253a97b083e5d47604e5 (patch) | |
tree | 6ed2170b9737b4cb44293d2b9b3e92395db8ba23 /modern/src/reports/EventReportPage.js | |
parent | ea34943121cab989e5ced540139c4fd39527cbde (diff) | |
download | trackermap-web-dcb1fa21441cb292fd66253a97b083e5d47604e5.tar.gz trackermap-web-dcb1fa21441cb292fd66253a97b083e5d47604e5.tar.bz2 trackermap-web-dcb1fa21441cb292fd66253a97b083e5d47604e5.zip |
Add report scheduling
Diffstat (limited to 'modern/src/reports/EventReportPage.js')
-rw-r--r-- | modern/src/reports/EventReportPage.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js index 67bbd888..10b539ab 100644 --- a/modern/src/reports/EventReportPage.js +++ b/modern/src/reports/EventReportPage.js @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import { FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableCell, TableBody, Link, IconButton, } from '@mui/material'; @@ -21,6 +22,7 @@ import MapView from '../map/core/MapView'; import MapGeofence from '../map/MapGeofence'; import MapPositions from '../map/MapPositions'; import MapCamera from '../map/MapCamera'; +import scheduleReport from './common/scheduleReport'; const columnsArray = [ ['eventTime', 'positionFixTime'], @@ -32,6 +34,7 @@ const columnsArray = [ const columnsMap = new Map(columnsArray); const EventReportPage = () => { + const navigate = useNavigate(); const classes = useReportStyles(); const t = useTranslation(); @@ -103,6 +106,19 @@ const EventReportPage = () => { } }); + const handleSchedule = useCatch(async (deviceIds, groupIds, report) => { + report.type = 'events'; + if (eventTypes[0] !== 'allEvents') { + report.attributes.types = eventTypes.join(','); + } + const error = await scheduleReport(deviceIds, groupIds, report); + if (error) { + throw Error(error); + } else { + navigate('/reports/scheduled'); + } + }); + const formatValue = (item, key) => { switch (key) { case 'eventTime': @@ -151,7 +167,7 @@ const EventReportPage = () => { )} <div className={classes.containerMain}> <div className={classes.header}> - <ReportFilter handleSubmit={handleSubmit}> + <ReportFilter handleSubmit={handleSubmit} handleSchedule={handleSchedule}> <div className={classes.filterItem}> <FormControl fullWidth> <InputLabel>{t('reportEventTypes')}</InputLabel> |