add serializable package to gradle

This commit is contained in:
Martin Ptáček
2023-05-29 22:37:08 +02:00
parent 89b448d351
commit eeffff1046
5 changed files with 34 additions and 23 deletions

1
client/.idea/misc.xml generated
View File

@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">

View File

@@ -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"

View File

@@ -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<String>
//) {
// 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<String> = 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")

View File

@@ -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,
)
}
}

View File

@@ -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'
}