diff --git a/client/.idea/misc.xml b/client/.idea/misc.xml index 773fe0f..9f71c83 100644 --- a/client/.idea/misc.xml +++ b/client/.idea/misc.xml @@ -1,3 +1,4 @@ + diff --git a/client/app/build.gradle b/client/app/build.gradle index 8ae8fdf..a9787c9 100644 --- a/client/app/build.gradle +++ b/client/app/build.gradle @@ -84,7 +84,7 @@ dependencies { - implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' implementation 'androidx.activity:activity-compose:1.7.1' implementation "androidx.compose.ui:ui:$compose_ui_version" diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/HomeActivity.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/HomeActivity.kt index ca795c4..b8a746f 100644 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/HomeActivity.kt +++ b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/HomeActivity.kt @@ -113,8 +113,8 @@ private fun TabPage( } when(uiState.tabIndex){ 0 -> PrometheusServerPage(promViewModel, Modifier) - 1 -> PushProxPage(promViewModel, Modifier) - 2 -> RemoteWritePage(promViewModel, Modifier) + 1 -> PushProxPage(promViewModel) + 2 -> RemoteWritePage(promViewModel) } } } @@ -174,26 +174,9 @@ private fun PrometheusServerPage( } } -//TODO delete this thing -//private fun onCheckedChangePushProx( -// value : Boolean, -// promViewModel: PromViewModel, -// showDialog : MutableState -//) { -// if (value) { -// val result: String? = promViewModel.turnPushProxOn() -// if (result != null) { -// showDialog.value = result -// } -// } else { -// promViewModel.turnPushProxOff() -// } -//} - @Composable private fun PushProxPage( promViewModel: PromViewModel, - modifier: Modifier ){ val uiState : PromUiState by promViewModel.uiState.collectAsState() @@ -201,7 +184,7 @@ private fun PushProxPage( val showDialogText : MutableState = remember { mutableStateOf("") } Column( - modifier = modifier, + modifier = Modifier.fillMaxHeight(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, ) { @@ -269,12 +252,11 @@ private fun PushProxPage( @Composable private fun RemoteWritePage( promViewModel: PromViewModel, - modifier: Modifier, ){ val uiState : PromUiState by promViewModel.uiState.collectAsState() Column ( - modifier = modifier, + modifier = Modifier, ) { //TODO implement this Text("Remote write configuration") diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/configuration.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/configuration.kt index 672dde8..7a2ea36 100644 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/configuration.kt +++ b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/compose/configuration.kt @@ -1,5 +1,9 @@ package com.birdthedeveloper.prometheus.android.prometheus.android.exporter.compose +import androidx.work.Data +import androidx.work.workDataOf + +//@Serializable data class PromConfiguration( // the following are default values for various configuration settings val prometheusServerEnabled : Boolean = true, @@ -19,9 +23,30 @@ data class PromConfiguration( return false } + fun fromWorkData(data : Data) : PromConfiguration{ + //TODO implement this + return PromConfiguration( + prometheusServerEnabled = data.getBoolean("0", true), + //prometheusServerPort = data.getInt("1", ) + ) + } + suspend fun loadFromConfigFile(): PromConfiguration { //TODO open file, parse yaml, throw exception possibly return PromConfiguration() } } + + fun toWorkData() : Data{ + return workDataOf( + "0" to this.prometheusServerEnabled, + "1" to this.prometheusServerPort, + "2" to this.pushproxEnabled, + "3" to this.pushproxFqdn, + "4" to this.pushproxProxyUrl, + "5" to this.remoteWriteEnabled, + "6" to this.remoteWriteScrapeInterval, + "7" to this.remoteWriteEndpoint, + ) + } } diff --git a/client/build.gradle b/client/build.gradle index 1dea762..2902af3 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -7,4 +7,7 @@ plugins { id 'com.android.application' version '8.0.2' apply false id 'com.android.library' version '8.0.2' apply false id 'org.jetbrains.kotlin.android' version '1.7.0' apply false + + // custom for serialization + id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.0' }