Fix CronJob model API compatibility and register BackHandler in SettingsScreen
This commit is contained in:
1 parent
9b2aeae836
commit
3ff148f6d0
3 files changed
+28
-5
No files matched your search
@@ -3,8 +3,25 @@ package com.m57.hermescontrol.data.model
|
||||
data class CronJob(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val schedule: String?,
|
||||
val schedule: Any?,
|
||||
val state: String?,
|
||||
val last_run_status: String?,
|
||||
val next_run: String?,
|
||||
)
|
||||
val schedule_display: String? = null,
|
||||
val last_status: String? = null,
|
||||
val next_run_at: String? = null,
|
||||
) {
|
||||
val scheduleText: String
|
||||
get() =
|
||||
when (schedule) {
|
||||
is String -> schedule
|
||||
is Map<*, *> -> (schedule["display"] as? String) ?: schedule_display ?: ""
|
||||
else -> schedule_display ?: ""
|
||||
}
|
||||
|
||||
val lastRunStatus: String
|
||||
get() = last_run_status ?: last_status ?: ""
|
||||
|
||||
val nextRunTime: String
|
||||
get() = next_run ?: next_run_at ?: ""
|
||||
}
|
||||
@@ -108,14 +108,17 @@ fun CronJobsScreen(
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(text = job.name, style = MaterialTheme.typography.titleMedium)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(text = "Schedule: ${job.schedule}", style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
text = "Schedule: ${job.scheduleText}",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
Text(text = "Status: ${job.state}", style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
text = "Last Run: ${job.last_run_status ?: "Never"}",
|
||||
text = "Last Run: ${job.lastRunStatus.ifBlank { "Never" }}",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
Text(
|
||||
text = "Next Run: ${job.next_run ?: "N/A"}",
|
||||
text = "Next Run: ${job.nextRunTime.ifBlank { "N/A" }}",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.m57.hermescontrol.ui.settings
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
@@ -66,6 +67,8 @@ fun SettingsScreen(
|
||||
val state by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
var passwordVisible by remember { mutableStateOf(false) }
|
||||
|
||||
BackHandler(onBack = onBack)
|
||||
|
||||
Scaffold(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
topBar = {
|
||||
|
||||
Reference in new issue
Block a user