aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-16 18:28:14 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-16 18:28:14 -0600
commitf133dc96d4072c3bf4f9794b000b1e0ab946f96b (patch)
treeb4210a6abeed10b1bf6c8486462495d46e4a9566
parent21e16e27f047053582d8b0c722feedf3c8badebe (diff)
downloadetbsa-trackermap-mobile-f133dc96d4072c3bf4f9794b000b1e0ab946f96b.tar.gz
etbsa-trackermap-mobile-f133dc96d4072c3bf4f9794b000b1e0ab946f96b.tar.bz2
etbsa-trackermap-mobile-f133dc96d4072c3bf4f9794b000b1e0ab946f96b.zip
Fixed event report types on API
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt2
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt12
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt6
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt8
4 files changed, 14 insertions, 14 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt
index 62ac4f2..7749b54 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsViewModel.kt
@@ -86,7 +86,7 @@ class UnitReportsViewModel(
reportType = _reportType.value,
reportPeriod = _reportPeriod.value,
xlsx = xlsx,
- eventTypes = arrayOf(
+ eventTypes = listOf(
EventInformation.Type.DEVICE_INACTIVE,
EventInformation.Type.DEVICE_MOVING,
EventInformation.Type.DEVICE_STOPPED,
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
index 3765207..d77064e 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
@@ -36,14 +36,14 @@ class ReportsApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(
from: String,
to: String,
deviceId: Int,
- type: String = "%",
+ types: List<String> = listOf("%"),
xlsx: Boolean = false
): Any {
val localVariableQuery: MultiValueMap = mapOf(
"deviceId" to toMultiValue(listOf(deviceId), "multi"),
"from" to listOf(from),
"to" to listOf(to),
- "type" to listOf(type)
+ "type" to types
)
val localVariableHeaders = mutableMapOf<String, String>()
if (xlsx) {
@@ -81,20 +81,20 @@ class ReportsApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(
suspend fun reportsEventsGet(
from: String,
to: String,
- type: String = "%",
+ types: List<String> = listOf("%"),
deviceId: Int,
): Array<Event> {
- return reportsEventsGetBase(from, to, deviceId, type, false) as Array<Event>
+ return reportsEventsGetBase(from, to, deviceId, types, false) as Array<Event>
}
@Suppress("UNCHECKED_CAST")
suspend fun reportsEventsGetXlsx(
from: String,
to: String,
- type: String = "%",
+ types: List<String> = listOf("%"),
deviceId: Int,
): ByteArray {
- return reportsEventsGetBase(from, to, deviceId, type, true) as ByteArray
+ return reportsEventsGetBase(from, to, deviceId, types, true) as ByteArray
}
/**
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt
index befd8f1..5e4b2d5 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt
@@ -51,11 +51,11 @@ data class EventInformation(
Type.UNKNOWN -> "unknown"
}
- fun reportTypesToString(t: Array<Type>) =
+ fun reportTypesToStrings(t: List<Type>) =
if (t.isEmpty() || t.contains(Type.ALL)) {
- reportTypeToString(Type.ALL)
+ listOf(reportTypeToString(Type.ALL))
} else {
- t.joinToString(",", transform = this::reportTypeToString)
+ t.map(this::reportTypeToString)
}
fun stringToReportType(s: String) =
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 8a7f527..78f0173 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt
@@ -37,7 +37,7 @@ class ReportController(
reportType: ReportType?,
reportPeriod: ReportDates.ReportPeriod?,
xlsx: Boolean = false,
- eventTypes: Array<EventInformation.Type> = arrayOf()
+ eventTypes: List<EventInformation.Type> = listOf()
) {
if (reportType == null || reportPeriod == null) {
return
@@ -85,7 +85,7 @@ class ReportController(
deviceId: Int,
from: String,
to: String,
- types: Array<EventInformation.Type>,
+ types: List<EventInformation.Type>,
xlsx: Boolean
) {
Log.d("UnitReportsVM", "Fetching events")
@@ -93,7 +93,7 @@ class ReportController(
if (!xlsx) {
val positionsResult = reportsApi.reportsRouteGet(from, to, deviceId)
val eventsResult = reportsApi.reportsEventsGet(
- from, to, EventInformation.reportTypesToString(types), deviceId
+ from, to, EventInformation.reportTypesToStrings(types), deviceId
)
val geofencesResult = geofencesApi.geofencesGet(all = true)
@@ -110,7 +110,7 @@ class ReportController(
reportFlow.value = Report.EventsReport(result.toTypedArray())
} else {
val result = reportsApi.reportsEventsGetXlsx(
- from, to, EventInformation.reportTypesToString(types), deviceId
+ from, to, EventInformation.reportTypesToStrings(types), deviceId
)
Log.d("UnitReportsVM", "Events report: $result")