aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-16 18:28:29 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-16 18:28:29 -0600
commitfdfca6f31cd019c8d5492eeba1b1698a5f2bf556 (patch)
treeddfbb207ef9d9db7e79f0718f3ea8a2f2a14e5ae /shared
parentc7b28c25b032a1b82b782ef5ff8dd5e703d5a8ad (diff)
parentf133dc96d4072c3bf4f9794b000b1e0ab946f96b (diff)
downloadetbsa-trackermap-mobile-fdfca6f31cd019c8d5492eeba1b1698a5f2bf556.tar.gz
etbsa-trackermap-mobile-fdfca6f31cd019c8d5492eeba1b1698a5f2bf556.tar.bz2
etbsa-trackermap-mobile-fdfca6f31cd019c8d5492eeba1b1698a5f2bf556.zip
Merge branch 'main' of https://git.sr.ht/~avalos/trackermap-mobile
Diffstat (limited to 'shared')
-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
3 files changed, 13 insertions, 13 deletions
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")