fix: correct log response key to 'lines' and convert refresh text to icon button in LogsScreen
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.m57.hermescontrol.data.model
|
package com.m57.hermescontrol.data.model
|
||||||
|
|
||||||
data class LogResponse(
|
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.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Menu
|
import androidx.compose.material.icons.filled.Menu
|
||||||
|
import androidx.compose.material.icons.filled.Refresh
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -79,7 +80,10 @@ fun LogsScreen(
|
|||||||
title = { Text("System Logs") },
|
title = { Text("System Logs") },
|
||||||
actions = {
|
actions = {
|
||||||
IconButton(onClick = { viewModel.loadLogs() }) {
|
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()
|
ApiClient.hermesApi.getLogs()
|
||||||
}
|
}
|
||||||
if (response.isSuccessful) {
|
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 {
|
} else {
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
|
|||||||
Reference in New Issue
Block a user