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/RouteReportPage.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/RouteReportPage.js')
-rw-r--r-- | modern/src/reports/RouteReportPage.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 64bf0a59..ebd4547a 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -1,5 +1,6 @@ import React, { Fragment, useCallback, useState } from 'react'; import { useSelector } from 'react-redux'; +import { useNavigate } from 'react-router-dom'; import { IconButton, Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; @@ -22,8 +23,10 @@ import useReportStyles from './common/useReportStyles'; import TableShimmer from '../common/components/TableShimmer'; import MapCamera from '../map/MapCamera'; import MapGeofence from '../map/MapGeofence'; +import scheduleReport from './common/scheduleReport'; const RouteReportPage = () => { + const navigate = useNavigate(); const classes = useReportStyles(); const t = useTranslation(); @@ -67,6 +70,16 @@ const RouteReportPage = () => { } }); + const handleSchedule = useCatch(async (deviceIds, groupIds, report) => { + report.type = 'route'; + const error = await scheduleReport(deviceIds, groupIds, report); + if (error) { + throw Error(error); + } else { + navigate('/reports/scheduled'); + } + }); + return ( <PageLayout menu={<ReportsMenu />} breadcrumbs={['reportTitle', 'reportRoute']}> <div className={classes.container}> @@ -90,7 +103,7 @@ const RouteReportPage = () => { )} <div className={classes.containerMain}> <div className={classes.header}> - <ReportFilter handleSubmit={handleSubmit} multiDevice> + <ReportFilter handleSubmit={handleSubmit} handleSchedule={handleSchedule} multiDevice> <ColumnSelect columns={columns} setColumns={setColumns} |