From 21e16e27f047053582d8b0c722feedf3c8badebe Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sun, 16 Jan 2022 17:57:14 -0600 Subject: Refactored report types into commonMain, added support for event report types in controller and API --- .../trackermap/TrackerMap/controllers/ReportController.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers') diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt index 2151331..8a7f527 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt @@ -36,7 +36,8 @@ class ReportController( deviceId: Int, reportType: ReportType?, reportPeriod: ReportDates.ReportPeriod?, - xlsx: Boolean = false + xlsx: Boolean = false, + eventTypes: Array = arrayOf() ) { if (reportType == null || reportPeriod == null) { return @@ -54,7 +55,7 @@ class ReportController( GlobalScope.launch { when (reportType) { ReportType.POSITIONS -> fetchPositions(deviceId, previousDate, currentDate, xlsx) - ReportType.EVENTS -> fetchEvents(deviceId, previousDate, currentDate, xlsx) + ReportType.EVENTS -> fetchEvents(deviceId, previousDate, currentDate, eventTypes, xlsx) ReportType.STOPS -> fetchStops(deviceId, previousDate, currentDate, xlsx) } } @@ -84,13 +85,16 @@ class ReportController( deviceId: Int, from: String, to: String, + types: Array, xlsx: Boolean ) { Log.d("UnitReportsVM", "Fetching events") if (!xlsx) { val positionsResult = reportsApi.reportsRouteGet(from, to, deviceId) - val eventsResult = reportsApi.reportsEventsGet(from, to, deviceId) + val eventsResult = reportsApi.reportsEventsGet( + from, to, EventInformation.reportTypesToString(types), deviceId + ) val geofencesResult = geofencesApi.geofencesGet(all = true) val result = mutableListOf() @@ -105,7 +109,9 @@ class ReportController( Log.d("UnitReportsVM", "Events report: $result") reportFlow.value = Report.EventsReport(result.toTypedArray()) } else { - val result = reportsApi.reportsEventsGetXlsx(from, to, deviceId) + val result = reportsApi.reportsEventsGetXlsx( + from, to, EventInformation.reportTypesToString(types), deviceId + ) Log.d("UnitReportsVM", "Events report: $result") reportFlow.value = Report.XlsxReport(result) -- cgit v1.2.3