mirror of
https://github.com/mii443/prometheus-android-exporter.git
synced 2025-12-04 11:38:18 +00:00
add serializable package to gradle
This commit is contained in:
1
client/.idea/misc.xml
generated
1
client/.idea/misc.xml
generated
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
|
|||||||
@@ -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.lifecycle:lifecycle-runtime-ktx:2.6.1'
|
||||||
implementation 'androidx.activity:activity-compose:1.7.1'
|
implementation 'androidx.activity:activity-compose:1.7.1'
|
||||||
implementation "androidx.compose.ui:ui:$compose_ui_version"
|
implementation "androidx.compose.ui:ui:$compose_ui_version"
|
||||||
|
|||||||
@@ -113,8 +113,8 @@ private fun TabPage(
|
|||||||
}
|
}
|
||||||
when(uiState.tabIndex){
|
when(uiState.tabIndex){
|
||||||
0 -> PrometheusServerPage(promViewModel, Modifier)
|
0 -> PrometheusServerPage(promViewModel, Modifier)
|
||||||
1 -> PushProxPage(promViewModel, Modifier)
|
1 -> PushProxPage(promViewModel)
|
||||||
2 -> RemoteWritePage(promViewModel, Modifier)
|
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
|
@Composable
|
||||||
private fun PushProxPage(
|
private fun PushProxPage(
|
||||||
promViewModel: PromViewModel,
|
promViewModel: PromViewModel,
|
||||||
modifier: Modifier
|
|
||||||
){
|
){
|
||||||
val uiState : PromUiState by promViewModel.uiState.collectAsState()
|
val uiState : PromUiState by promViewModel.uiState.collectAsState()
|
||||||
|
|
||||||
@@ -201,7 +184,7 @@ private fun PushProxPage(
|
|||||||
val showDialogText : MutableState<String> = remember { mutableStateOf("") }
|
val showDialogText : MutableState<String> = remember { mutableStateOf("") }
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier,
|
modifier = Modifier.fillMaxHeight(),
|
||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
@@ -269,12 +252,11 @@ private fun PushProxPage(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun RemoteWritePage(
|
private fun RemoteWritePage(
|
||||||
promViewModel: PromViewModel,
|
promViewModel: PromViewModel,
|
||||||
modifier: Modifier,
|
|
||||||
){
|
){
|
||||||
val uiState : PromUiState by promViewModel.uiState.collectAsState()
|
val uiState : PromUiState by promViewModel.uiState.collectAsState()
|
||||||
|
|
||||||
Column (
|
Column (
|
||||||
modifier = modifier,
|
modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
//TODO implement this
|
//TODO implement this
|
||||||
Text("Remote write configuration")
|
Text("Remote write configuration")
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.birdthedeveloper.prometheus.android.prometheus.android.exporter.compose
|
package com.birdthedeveloper.prometheus.android.prometheus.android.exporter.compose
|
||||||
|
|
||||||
|
import androidx.work.Data
|
||||||
|
import androidx.work.workDataOf
|
||||||
|
|
||||||
|
//@Serializable
|
||||||
data class PromConfiguration(
|
data class PromConfiguration(
|
||||||
// the following are default values for various configuration settings
|
// the following are default values for various configuration settings
|
||||||
val prometheusServerEnabled : Boolean = true,
|
val prometheusServerEnabled : Boolean = true,
|
||||||
@@ -19,9 +23,30 @@ data class PromConfiguration(
|
|||||||
return false
|
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 {
|
suspend fun loadFromConfigFile(): PromConfiguration {
|
||||||
//TODO open file, parse yaml, throw exception possibly
|
//TODO open file, parse yaml, throw exception possibly
|
||||||
return PromConfiguration()
|
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,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,7 @@ plugins {
|
|||||||
id 'com.android.application' version '8.0.2' apply false
|
id 'com.android.application' version '8.0.2' apply false
|
||||||
id 'com.android.library' 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
|
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
|
||||||
|
|
||||||
|
// custom for serialization
|
||||||
|
id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.0'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user