From dcb1fa21441cb292fd66253a97b083e5d47604e5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 31 Jan 2023 07:38:18 -0800 Subject: Add report scheduling --- modern/src/common/components/SelectField.js | 3 +- modern/src/common/components/SplitButton.js | 11 +- modern/src/reports/EventReportPage.js | 18 ++- modern/src/reports/RouteReportPage.js | 15 +- modern/src/reports/StopReportPage.js | 15 +- modern/src/reports/SummaryReportPage.js | 16 ++- modern/src/reports/TripReportPage.js | 15 +- modern/src/reports/common/scheduleReport.js | 27 ++++ modern/src/reports/components/ReportFilter.js | 198 ++++++++++++++++---------- modern/src/resources/l10n/en.json | 1 + modern/src/store/reports.js | 4 + 11 files changed, 234 insertions(+), 89 deletions(-) create mode 100644 modern/src/reports/common/scheduleReport.js (limited to 'modern') diff --git a/modern/src/common/components/SelectField.js b/modern/src/common/components/SelectField.js index 2ee2f147..35f817a0 100644 --- a/modern/src/common/components/SelectField.js +++ b/modern/src/common/components/SelectField.js @@ -6,6 +6,7 @@ import { useEffectAsync } from '../../reactHelper'; const SelectField = ({ label, + fullWidth, multiple, value, emptyValue = 0, @@ -31,7 +32,7 @@ const SelectField = ({ if (items) { return ( - + {label} dispatch(reportsActions.updatePeriod(e.target.value))}> - {t('reportToday')} - {t('reportYesterday')} - {t('reportThisWeek')} - {t('reportPreviousWeek')} - {t('reportThisMonth')} - {t('reportPreviousMonth')} - {t('reportCustom')} - - - - {period === 'custom' && ( -
- dispatch(reportsActions.updateFrom(e.target.value))} - fullWidth - /> -
- )} - {period === 'custom' && ( -
- dispatch(reportsActions.updateTo(e.target.value))} - fullWidth - /> -
+ {button !== 'schedule' ? ( + <> +
+ + {t('reportPeriod')} + + +
+ {period === 'custom' && ( +
+ dispatch(reportsActions.updateFrom(e.target.value))} + fullWidth + /> +
+ )} + {period === 'custom' && ( +
+ dispatch(reportsActions.updateTo(e.target.value))} + fullWidth + /> +
+ )} + + ) : ( + <> +
+ setDescription(event.target.value)} + label={t('sharedDescription')} + fullWidth + /> +
+
+ setCalendarId(Number(event.target.value))} + endpoint="/api/calendars" + label={t('sharedCalendar')} + fullWidth + /> +
+ )} {children}
@@ -167,10 +206,13 @@ const ReportFilter = ({ children, handleSubmit, showOnly, ignoreDevice, multiDev color="secondary" disabled={disabled} onClick={handleClick} + selected={button} + setSelected={(value) => dispatch(reportsActions.updateButton(value))} options={{ json: t('reportShow'), export: t('reportExport'), mail: t('reportEmail'), + schedule: t('reportSchedule'), }} /> )} diff --git a/modern/src/resources/l10n/en.json b/modern/src/resources/l10n/en.json index d93ad5bf..26530133 100644 --- a/modern/src/resources/l10n/en.json +++ b/modern/src/resources/l10n/en.json @@ -506,6 +506,7 @@ "reportShowMarkers": "Show Markers", "reportExport": "Export", "reportEmail": "Email Report", + "reportSchedule": "Schedule", "reportPeriod": "Period", "reportCustom": "Custom", "reportToday": "Today", diff --git a/modern/src/store/reports.js b/modern/src/store/reports.js index 0c336f7a..540c4d4e 100644 --- a/modern/src/store/reports.js +++ b/modern/src/store/reports.js @@ -10,6 +10,7 @@ const { reducer, actions } = createSlice({ period: 'today', from: moment().subtract(1, 'hour').locale('en').format(moment.HTML5_FMT.DATETIME_LOCAL), to: moment().locale('en').format(moment.HTML5_FMT.DATETIME_LOCAL), + button: 'json', }, reducers: { updateDeviceId(state, action) { @@ -30,6 +31,9 @@ const { reducer, actions } = createSlice({ updateTo(state, action) { state.to = action.payload; }, + updateButton(state, action) { + state.button = action.payload; + }, }, }); -- cgit v1.2.3