fix: correct log response key to 'lines' and convert refresh text to icon button in LogsScreen
This commit is contained in:
1 parent
69f36b1606
commit
edc2d45966
3 files changed
+10
-3
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package com.m57.hermescontrol.data.model
|
||||
|
||||
data class LogResponse(
|
||||
val logs: List<String>,
|
||||
val lines: List<String>? = null,
|
||||
val logs: List<String>? = null,
|
||||
)
|
||||
@@ -13,6 +13,7 @@ import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -79,7 +80,10 @@ fun LogsScreen(
|
||||
title = { Text("System Logs") },
|
||||
actions = {
|
||||
IconButton(onClick = { viewModel.loadLogs() }) {
|
||||
Text("Refresh", style = MaterialTheme.typography.bodyMedium)
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Refresh,
|
||||
contentDescription = "Refresh",
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -31,7 +31,9 @@ class LogsViewModel : ViewModel() {
|
||||
ApiClient.hermesApi.getLogs()
|
||||
}
|
||||
if (response.isSuccessful) {
|
||||
_uiState.update { it.copy(isLoading = false, logs = response.body()?.logs.orEmpty()) }
|
||||
val body = response.body()
|
||||
val logsList = body?.lines ?: body?.logs ?: emptyList()
|
||||
_uiState.update { it.copy(isLoading = false, logs = logsList) }
|
||||
} else {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
|
||||
Reference in new issue
Block a user