aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt14
1 files changed, 10 insertions, 4 deletions
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<EventInformation.Type> = 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<EventInformation.Type>,
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<EventInformation>()
@@ -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)