diff options
Diffstat (limited to 'shared/src/commonMain/kotlin')
23 files changed, 47 insertions, 22 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Injectable.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Injectable.kt new file mode 100644 index 0000000..a7467d6 --- /dev/null +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Injectable.kt @@ -0,0 +1,3 @@ +package mx.trackermap.TrackerMap + +interface Injectable
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt index c324f4c..1da9831 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Attribute import mx.trackermap.TrackerMap.client.infrastructure.* -class AttributesApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class AttributesApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Attributes diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt index 7a9bd38..c666dc3 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Calendar import mx.trackermap.TrackerMap.client.infrastructure.* -class CalendarsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class CalendarsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Calendars diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt index ffdb699..eb1718c 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt @@ -11,12 +11,13 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Command import mx.trackermap.TrackerMap.client.models.CommandType import mx.trackermap.TrackerMap.client.infrastructure.* -class CommandsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class CommandsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Saved Commands diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt index eff69bd..8b839aa 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt @@ -11,12 +11,13 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Device import mx.trackermap.TrackerMap.client.models.DeviceAccumulators import mx.trackermap.TrackerMap.client.infrastructure.* -class DevicesApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class DevicesApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Devices diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt index f050bbe..bff61c2 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Driver import mx.trackermap.TrackerMap.client.infrastructure.* -class DriversApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class DriversApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Drivers diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt index 572fdd0..87f8dce 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Event import mx.trackermap.TrackerMap.client.infrastructure.* -class EventsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class EventsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt index 25996fe..049aee9 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Geofence import mx.trackermap.TrackerMap.client.infrastructure.* -class GeofencesApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class GeofencesApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Geofences diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt index 032b7fc..07b3b05 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Group import mx.trackermap.TrackerMap.client.infrastructure.* -class GroupsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class GroupsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Groups diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt index 6dd10ec..e28a728 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Maintenance import mx.trackermap.TrackerMap.client.infrastructure.* -class MaintenanceApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class MaintenanceApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Maintenance diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt index c27a532..f311fdb 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt @@ -11,12 +11,13 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Notification import mx.trackermap.TrackerMap.client.models.NotificationType import mx.trackermap.TrackerMap.client.infrastructure.* -class NotificationsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class NotificationsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Notifications diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt index 0fb7651..76fd4a8 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Permission import mx.trackermap.TrackerMap.client.infrastructure.* -class PermissionsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class PermissionsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Unlink an Object from another Object diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt index 3373448..6ad74cb 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Position import mx.trackermap.TrackerMap.client.infrastructure.* -class PositionsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class PositionsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetches a list of Positions 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 67bff68..64ef8ea 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 @@ -13,6 +13,7 @@ package mx.trackermap.TrackerMap.client.apis import io.ktor.content.* import kotlinx.datetime.LocalDateTime +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Event import mx.trackermap.TrackerMap.client.models.Position import mx.trackermap.TrackerMap.client.models.Stop @@ -21,7 +22,7 @@ import mx.trackermap.TrackerMap.client.models.ReportTrips import mx.trackermap.TrackerMap.client.infrastructure.* -class ReportsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class ReportsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Events within the time period for the Devices or Groups diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt index ea7b911..5672543 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Server import mx.trackermap.TrackerMap.client.infrastructure.* -class ServerApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class ServerApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch Server information diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt index 6d9dbea..a22d2d9 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt @@ -11,10 +11,11 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.User import mx.trackermap.TrackerMap.client.infrastructure.* -class SessionApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class SessionApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Close the Session diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt index 1c7c5f5..0b9c766 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt @@ -12,11 +12,12 @@ package mx.trackermap.TrackerMap.client.apis import kotlinx.datetime.LocalDateTime +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.Statistics import mx.trackermap.TrackerMap.client.infrastructure.* -class StatisticsApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class StatisticsApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch server Statistics diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt index 21e4bd3..90dd9f6 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.models.User import mx.trackermap.TrackerMap.client.infrastructure.* -class UsersApi(sessionManager: SessionManager) : ApiClient(sessionManager) { +class UsersApi(sessionManager: SessionManager) : ApiClient(sessionManager), Injectable { /** * Fetch a list of Users diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt index 6287b0c..caf2da1 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/SessionManager.kt @@ -3,10 +3,11 @@ package mx.trackermap.TrackerMap.client.infrastructure import com.russhwolf.settings.Settings import com.russhwolf.settings.get import com.russhwolf.settings.set +import mx.trackermap.TrackerMap.Injectable class SessionManager( private val defaultBaseUrl: String -) { +): Injectable { companion object { const val SERVER_URL_KEY = "server_url" diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt index 0e4c5c9..e16bb72 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt @@ -21,13 +21,14 @@ import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.apis.GeofencesApi import mx.trackermap.TrackerMap.client.models.Geofence @DelicateCoroutinesApi class GeofencesController( private val geofencesApi: GeofencesApi -) { +): Injectable { val geofencesFlow = MutableStateFlow<Map<Int,Geofence>>(emptyMap()) init { 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 b60a034..46bc445 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt @@ -21,6 +21,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.apis.GeofencesApi import mx.trackermap.TrackerMap.client.apis.ReportsApi import mx.trackermap.TrackerMap.client.models.EventInformation @@ -32,7 +33,7 @@ import mx.trackermap.TrackerMap.utils.ReportDates class ReportController( private val reportsApi: ReportsApi, private val geofencesApi: GeofencesApi -) { +): Injectable { sealed class Report { class PositionsReport(val positions: Array<Position>) : Report() diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt index 2f196f1..d3deca1 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt @@ -22,6 +22,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import kotlinx.serialization.json.JsonPrimitive +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.apis.SessionApi import mx.trackermap.TrackerMap.client.apis.UsersApi import mx.trackermap.TrackerMap.client.models.SessionBody @@ -31,7 +32,7 @@ import mx.trackermap.TrackerMap.client.models.User class SessionController( private val sessionApi: SessionApi, private val usersApi: UsersApi -) { +): Injectable { sealed class LoginState { object Nothing: LoginState() object Loading: LoginState() diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt index b282a34..fd1e950 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt @@ -25,6 +25,7 @@ import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch +import mx.trackermap.TrackerMap.Injectable import mx.trackermap.TrackerMap.client.apis.DevicesApi import mx.trackermap.TrackerMap.client.apis.PositionsApi import mx.trackermap.TrackerMap.client.models.Position @@ -38,7 +39,7 @@ import kotlin.time.ExperimentalTime class UnitsController( private val devicesApi: DevicesApi, private val positionsApi: PositionsApi -) { +): Injectable { private companion object { const val UPDATE_TIME = 20 } |