fix: compile errors for assembleDebug
Исправлены generic-типы в списках и import mutableStateOf в MainActivity. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableStateOf as composeMutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
|
||||
@@ -76,7 +76,10 @@ fun DashboardScreen(repo: SacRepository) {
|
||||
d.recentEvents.take(8).forEach { e ->
|
||||
Text("${e.severity} · ${e.title}", style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
} ?: if (loading) CircularProgressIndicator()
|
||||
}
|
||||
if (data == null && loading) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,9 +100,10 @@ fun EventsScreen(repo: SacRepository, onOpen: (Long) -> Unit) {
|
||||
PagedListScreen(
|
||||
title = "События",
|
||||
loadPage = { page, severity ->
|
||||
repo.withAuth { it.listEvents(page = page, pageSize = 30, severity = severity) }
|
||||
val res = repo.withAuth { it.listEvents(page = page, pageSize = 30, severity = severity) }
|
||||
res.items to res.total
|
||||
},
|
||||
itemKey = { it.id },
|
||||
itemKey = EventSummary::id,
|
||||
itemLabel = { "${it.severity} · ${it.title}" },
|
||||
itemSub = { "${it.hostname} · ${it.occurredAt}" },
|
||||
onOpen = onOpen,
|
||||
@@ -113,11 +117,12 @@ fun ProblemsScreen(repo: SacRepository, onOpen: (Long) -> Unit) {
|
||||
PagedListScreen(
|
||||
title = "Проблемы",
|
||||
loadPage = { page, filter ->
|
||||
repo.withAuth {
|
||||
val res = repo.withAuth {
|
||||
it.listProblems(page = page, pageSize = 30, status = filter ?: "open")
|
||||
}
|
||||
res.items to res.total
|
||||
},
|
||||
itemKey = { it.id },
|
||||
itemKey = ProblemSummary::id,
|
||||
itemLabel = { "${it.severity} · ${it.title}" },
|
||||
itemSub = { "${it.status} · ${it.hostname ?: "—"}" },
|
||||
onOpen = onOpen,
|
||||
@@ -131,9 +136,10 @@ fun HostsScreen(repo: SacRepository, onOpen: (Long) -> Unit) {
|
||||
PagedListScreen(
|
||||
title = "Хосты",
|
||||
loadPage = { page, _ ->
|
||||
repo.withAuth { it.listHosts(page = page, pageSize = 30) }
|
||||
val res = repo.withAuth { it.listHosts(page = page, pageSize = 30) }
|
||||
res.items to res.total
|
||||
},
|
||||
itemKey = { it.id },
|
||||
itemKey = HostSummary::id,
|
||||
itemLabel = { it.hostname },
|
||||
itemSub = { "${it.agentStatus} · ${it.product}" },
|
||||
onOpen = onOpen,
|
||||
@@ -208,7 +214,7 @@ fun ReportsScreen(repo: SacRepository, onOpen: (Long) -> Unit) {
|
||||
@Composable
|
||||
private fun <T> PagedListScreen(
|
||||
title: String,
|
||||
loadPage: suspend (Int, String?) -> Any,
|
||||
loadPage: suspend (Int, String?) -> Pair<List<T>, Int>,
|
||||
itemKey: (T) -> Long,
|
||||
itemLabel: (T) -> String,
|
||||
itemSub: (T) -> String,
|
||||
@@ -228,21 +234,9 @@ private fun <T> PagedListScreen(
|
||||
scope.launch {
|
||||
loading = true
|
||||
try {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
when (val res = loadPage(page, filter)) {
|
||||
is EventListResponse -> {
|
||||
items = res.items as List<T>
|
||||
total = res.total
|
||||
}
|
||||
is ProblemListResponse -> {
|
||||
items = res.items as List<T>
|
||||
total = res.total
|
||||
}
|
||||
is HostListResponse -> {
|
||||
items = res.items as List<T>
|
||||
total = res.total
|
||||
}
|
||||
}
|
||||
val (pageItems, pageTotal) = loadPage(page, filter)
|
||||
items = pageItems
|
||||
total = pageTotal
|
||||
} catch (e: Exception) {
|
||||
error = e.message
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user