refactor(desktop, core): Onboarding zu DeviceInitialization umbenannt, Navigation und Screens angepasst
Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
+2
-2
@@ -3,8 +3,8 @@ package at.mocode.frontend.core.auth.di
|
||||
import at.mocode.frontend.core.auth.data.AuthApiClient
|
||||
import at.mocode.frontend.core.auth.data.AuthTokenManager
|
||||
import at.mocode.frontend.core.auth.presentation.LoginViewModel
|
||||
import at.mocode.frontend.core.network.TokenProvider
|
||||
import at.mocode.frontend.core.domain.AppConstants
|
||||
import at.mocode.frontend.core.network.TokenProvider
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
@@ -24,7 +24,7 @@ val authModule = module {
|
||||
}
|
||||
|
||||
// LoginViewModel
|
||||
factory { LoginViewModel(get(), get(), get(named("apiClient"))) }
|
||||
factory { LoginViewModel(get(), get()) }
|
||||
|
||||
// Brücke zum TokenProvider des Kernnetzwerks, ohne dort eine harte Abhängigkeit hinzuzufügen
|
||||
single<TokenProvider> {
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package at.mocode.frontend.core.auth.presentation
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.Login
|
||||
import androidx.compose.material.icons.automirrored.filled.Logout
|
||||
import androidx.compose.material.icons.filled.AccountCircle
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import at.mocode.frontend.core.designsystem.components.MsCard
|
||||
|
||||
/**
|
||||
* Eine Plug-and-Play Komponente zur Anzeige des aktuellen Authentifizierungs-Status.
|
||||
* Kann überall (Sidebar, Header, Screens) eingesetzt werden.
|
||||
*/
|
||||
@Composable
|
||||
fun AuthStatusCard(
|
||||
viewModel: LoginViewModel,
|
||||
modifier: Modifier = Modifier,
|
||||
onLoginClick: () -> Unit = {}
|
||||
) {
|
||||
val authState by viewModel.authState.collectAsState()
|
||||
val uiState by viewModel.uiState.collectAsState()
|
||||
|
||||
MsCard(modifier = modifier.fillMaxWidth()) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.AccountCircle,
|
||||
contentDescription = null,
|
||||
tint = if (authState.isAuthenticated) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.outline,
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
Spacer(Modifier.width(12.dp))
|
||||
Column {
|
||||
Text(
|
||||
text = if (authState.isAuthenticated) "Angemeldet als" else "Nicht angemeldet",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Text(
|
||||
text = if (authState.isAuthenticated) (authState.username ?: "Unbekannt") else "Gast",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (authState.isAuthenticated) {
|
||||
Button(
|
||||
onClick = { viewModel.logout() },
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||
)
|
||||
) {
|
||||
Icon(Icons.AutoMirrored.Filled.Logout, contentDescription = null, modifier = Modifier.size(18.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Abmelden")
|
||||
}
|
||||
} else {
|
||||
Button(
|
||||
onClick = onLoginClick,
|
||||
enabled = !uiState.isOidcLoading
|
||||
) {
|
||||
if (uiState.isOidcLoading) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(18.dp), strokeWidth = 2.dp)
|
||||
} else {
|
||||
Icon(Icons.AutoMirrored.Filled.Login, contentDescription = null, modifier = Modifier.size(18.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Anmelden")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (authState.isAuthenticated && authState.roles.isNotEmpty()) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
authState.roles.forEach { role ->
|
||||
SuggestionChip(
|
||||
onClick = {},
|
||||
label = { Text(role, style = MaterialTheme.typography.labelSmall) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-6
@@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import at.mocode.frontend.core.auth.data.*
|
||||
import at.mocode.frontend.core.domain.AppConstants
|
||||
import io.ktor.client.*
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
@@ -34,13 +33,15 @@ data class LoginUiState(
|
||||
*/
|
||||
class LoginViewModel(
|
||||
private val authTokenManager: AuthTokenManager,
|
||||
private val authApiClient: AuthApiClient,
|
||||
private val apiClient: HttpClient
|
||||
private val authApiClient: AuthApiClient
|
||||
) : ViewModel() {
|
||||
|
||||
private val _uiState = MutableStateFlow(LoginUiState())
|
||||
val uiState: StateFlow<LoginUiState> = _uiState.asStateFlow()
|
||||
|
||||
private val _authState = MutableStateFlow(AuthState())
|
||||
val authState: StateFlow<AuthState> = _authState.asStateFlow()
|
||||
|
||||
// PKCE-State für den laufenden OIDC-Flow (in-memory)
|
||||
private var pendingCodeVerifier: String? = null
|
||||
private var pendingState: String? = null
|
||||
@@ -48,9 +49,10 @@ class LoginViewModel(
|
||||
init {
|
||||
// AuthTokenManager-State beobachten → UI synchron halten
|
||||
viewModelScope.launch {
|
||||
authTokenManager.authState.collect { authState ->
|
||||
_uiState.value = _uiState.value.copy(isAuthenticated = authState.isAuthenticated)
|
||||
if (!authState.isAuthenticated) {
|
||||
authTokenManager.authState.collect { auth ->
|
||||
_authState.value = auth
|
||||
_uiState.value = _uiState.value.copy(isAuthenticated = auth.isAuthenticated)
|
||||
if (!auth.isAuthenticated) {
|
||||
_uiState.value = LoginUiState()
|
||||
}
|
||||
}
|
||||
@@ -223,4 +225,11 @@ class LoginViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Abmelden. */
|
||||
fun logout() {
|
||||
viewModelScope.launch {
|
||||
authTokenManager.clearToken()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,9 +1,9 @@
|
||||
package at.mocode.frontend.core.navigation
|
||||
|
||||
sealed class AppScreen(val route: String) {
|
||||
// Onboarding (Desktop: Gerätename/Schlüssel/ZNS)
|
||||
data object Onboarding : AppScreen("/onboarding")
|
||||
data object Landing : AppScreen(Routes.HOME)
|
||||
// DeviceInitialization (Desktop: Gerätename/Schlüssel/ZNS)
|
||||
data object DeviceInitialization : AppScreen("/onboarding")
|
||||
data object PortalDashboard : AppScreen(Routes.HOME)
|
||||
data object Home : AppScreen("/home")
|
||||
data object Dashboard : AppScreen("/dashboard")
|
||||
data object CreateTournament : AppScreen("/tournament/create") // Neuer Screen
|
||||
@@ -11,11 +11,11 @@ sealed class AppScreen(val route: String) {
|
||||
// Login now accepts an optional returnTo screen to determine where to go after success
|
||||
data class Login(val returnTo: AppScreen? = null) : AppScreen(Routes.LOGIN)
|
||||
|
||||
data object Ping : AppScreen("/ping")
|
||||
data object ConnectivityCheck : AppScreen("/ping")
|
||||
data object Profile : AppScreen("/profile")
|
||||
data object OrganizerProfile : AppScreen("/organizer/profile")
|
||||
data object AuthCallback : AppScreen("/auth/callback")
|
||||
data object Nennung : AppScreen("/nennung")
|
||||
data object EntryManagement : AppScreen("/nennung")
|
||||
|
||||
// --- Desktop-Navigation (Vision_03) ---
|
||||
data object VeranstaltungVerwaltung : AppScreen("/verwaltung") // Gesamtübersicht
|
||||
@@ -38,7 +38,7 @@ sealed class AppScreen(val route: String) {
|
||||
|
||||
// data class VeranstaltungProfil(val id: Long) : AppScreen("/veranstaltung/profil/$id")
|
||||
|
||||
// Neuer Flow: + Neue Veranstaltung → Veranstalter auswählen → Veranstalter-Detail → Veranstaltung-Übersicht
|
||||
// Neuer Flow: + neue Veranstaltung → Veranstalter auswählen → Veranstalter-Detail → Veranstaltung-Übersicht
|
||||
data object VeranstalterAuswahl : AppScreen("/veranstalter/auswahl")
|
||||
data object VeranstalterNeu : AppScreen("/veranstalter/neu")
|
||||
data class VeranstalterDetail(val veranstalterId: Long) : AppScreen("/veranstalter/$veranstalterId")
|
||||
@@ -46,6 +46,7 @@ sealed class AppScreen(val route: String) {
|
||||
// Neue Veranstaltungs-Konfig-Seite (aus Veranstalter-Detail oder direkt aus Cockpit)
|
||||
data class VeranstaltungKonfig(val veranstalterId: Long = 0) :
|
||||
AppScreen("/veranstalter/$veranstalterId/veranstaltung/neu")
|
||||
|
||||
data class VeranstaltungProfil(val veranstalterId: Long, val veranstaltungId: Long) :
|
||||
AppScreen("/veranstalter/$veranstalterId/veranstaltung/$veranstaltungId")
|
||||
|
||||
@@ -61,7 +62,6 @@ sealed class AppScreen(val route: String) {
|
||||
data object Reiter : AppScreen("/reiter")
|
||||
data object Pferde : AppScreen("/pferde")
|
||||
data object Vereine : AppScreen("/vereine")
|
||||
data object Funktionaere : AppScreen("/funktionaere")
|
||||
data object Meisterschaften : AppScreen("/meisterschaften")
|
||||
data object Cups : AppScreen("/cups")
|
||||
data object StammdatenImport : AppScreen("/stammdaten/import")
|
||||
@@ -85,17 +85,17 @@ sealed class AppScreen(val route: String) {
|
||||
|
||||
fun fromRoute(route: String): AppScreen {
|
||||
return when (route) {
|
||||
"/onboarding" -> Onboarding
|
||||
Routes.HOME -> Landing
|
||||
"/onboarding" -> DeviceInitialization
|
||||
Routes.HOME -> PortalDashboard
|
||||
"/home" -> Home
|
||||
"/dashboard" -> Dashboard
|
||||
"/tournament/create" -> CreateTournament
|
||||
Routes.LOGIN, Routes.Auth.LOGIN -> Login()
|
||||
"/ping" -> Ping
|
||||
"/ping" -> ConnectivityCheck
|
||||
"/profile" -> Profile
|
||||
"/organizer/profile" -> OrganizerProfile
|
||||
"/auth/callback" -> AuthCallback
|
||||
"/nennung" -> Nennung
|
||||
"/nennung" -> EntryManagement
|
||||
"/verwaltung" -> VeranstaltungVerwaltung
|
||||
"/pferde/verwaltung" -> PferdVerwaltung
|
||||
"/reiter/verwaltung" -> ReiterVerwaltung
|
||||
@@ -139,7 +139,7 @@ sealed class AppScreen(val route: String) {
|
||||
VERANSTALTUNG_PROFIL.matchEntire(route)?.destructured?.let { (verId, vId) ->
|
||||
return VeranstaltungProfil(verId.toLong(), vId.toLong())
|
||||
}
|
||||
Landing // Default fallback
|
||||
PortalDashboard // Default fallback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -10,13 +10,15 @@ import kotlin.test.assertTrue
|
||||
|
||||
private class FakeNav : NavigationPort {
|
||||
var last: String? = null
|
||||
override val currentScreen: StateFlow<AppScreen> = MutableStateFlow(AppScreen.Landing)
|
||||
override val currentScreen: StateFlow<AppScreen> = MutableStateFlow(AppScreen.PortalDashboard)
|
||||
override fun navigateTo(route: String) {
|
||||
last = route
|
||||
}
|
||||
|
||||
override fun navigateToScreen(screen: AppScreen) {
|
||||
last = screen.route
|
||||
}
|
||||
|
||||
override fun navigateBack() {
|
||||
// no-op for tests
|
||||
}
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package at.mocode.ping.feature.presentation
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.HealthAndSafety
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material.icons.filled.NetworkCheck
|
||||
import androidx.compose.material.icons.filled.Sync
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import at.mocode.frontend.core.designsystem.theme.Dimens
|
||||
|
||||
/**
|
||||
* Eine modulare Gruppe von Test-Buttons für die Konnektivitäts-Diagnose.
|
||||
* Plug-and-Play fähig für Ping-Screen oder Sidebar.
|
||||
*/
|
||||
@Composable
|
||||
fun PingActionGroup(
|
||||
viewModel: PingViewModel,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val uiState = viewModel.uiState
|
||||
|
||||
Column(
|
||||
modifier = modifier,
|
||||
verticalArrangement = Arrangement.spacedBy(Dimens.SpacingS)
|
||||
) {
|
||||
Text(
|
||||
text = "DIAGNOSE-TESTS",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
fontWeight = androidx.compose.ui.text.font.FontWeight.Bold,
|
||||
modifier = Modifier.padding(bottom = Dimens.SpacingXS)
|
||||
)
|
||||
|
||||
// Grid-ähnliches Layout für die Buttons
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(Dimens.SpacingS)) {
|
||||
PingTestButton(
|
||||
text = "Simple Ping",
|
||||
icon = Icons.Default.NetworkCheck,
|
||||
onClick = { viewModel.performSimplePing() },
|
||||
isLoading = uiState.isLoading,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
PingTestButton(
|
||||
text = "Secure Ping",
|
||||
icon = Icons.Default.Lock,
|
||||
onClick = { viewModel.performSecurePing() },
|
||||
isLoading = uiState.isLoading,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(Dimens.SpacingS)) {
|
||||
PingTestButton(
|
||||
text = "Health Check",
|
||||
icon = Icons.Default.HealthAndSafety,
|
||||
onClick = { viewModel.performHealthCheck() },
|
||||
isLoading = uiState.isLoading,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
PingTestButton(
|
||||
text = "Delta Sync",
|
||||
icon = Icons.Default.Sync,
|
||||
onClick = { viewModel.triggerSync() },
|
||||
isLoading = uiState.isSyncing,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
|
||||
// Zusätzlicher Button für Enhanced Ping (Circuit Breaker Test)
|
||||
OutlinedButton(
|
||||
onClick = { viewModel.performEnhancedPing() },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = !uiState.isLoading
|
||||
) {
|
||||
Text("Enhanced Ping (Simulation)", fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PingTestButton(
|
||||
text: String,
|
||||
icon: androidx.compose.ui.graphics.vector.ImageVector,
|
||||
onClick: () -> Unit,
|
||||
isLoading: Boolean,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Button(
|
||||
onClick = onClick,
|
||||
modifier = modifier.height(48.dp),
|
||||
enabled = !isLoading,
|
||||
contentPadding = PaddingValues(horizontal = Dimens.SpacingS)
|
||||
) {
|
||||
Icon(icon, contentDescription = null, modifier = Modifier.size(18.dp))
|
||||
Spacer(Modifier.width(Dimens.SpacingXS))
|
||||
Text(text, fontSize = 12.sp, maxLines = 1)
|
||||
}
|
||||
}
|
||||
+22
-82
@@ -2,8 +2,6 @@ package at.mocode.ping.feature.presentation
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.*
|
||||
@@ -11,21 +9,22 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import at.mocode.frontend.core.designsystem.components.ButtonSize
|
||||
import at.mocode.frontend.core.designsystem.components.MsButton
|
||||
import at.mocode.frontend.core.auth.presentation.AuthStatusCard
|
||||
import at.mocode.frontend.core.auth.presentation.LoginViewModel
|
||||
import at.mocode.frontend.core.designsystem.components.MsCard
|
||||
import at.mocode.frontend.core.designsystem.theme.Dimens
|
||||
import org.koin.compose.koinInject
|
||||
|
||||
@Composable
|
||||
fun PingScreen(
|
||||
viewModel: PingViewModel,
|
||||
onBack: () -> Unit = {}
|
||||
onBack: () -> Unit = {},
|
||||
onNavigateToLogin: () -> Unit = {}
|
||||
) {
|
||||
val uiState = viewModel.uiState
|
||||
val authViewModel: LoginViewModel = koinInject()
|
||||
|
||||
// Wir nutzen jetzt das globale Theme (Hintergrund kommt vom Theme)
|
||||
Column(
|
||||
@@ -43,7 +42,15 @@ fun PingScreen(
|
||||
|
||||
Spacer(Modifier.height(Dimens.SpacingS))
|
||||
|
||||
// 2. Main Dashboard Area (Split View)
|
||||
// 2. Auth Status Area (Plug-and-Play)
|
||||
AuthStatusCard(
|
||||
viewModel = authViewModel,
|
||||
onLoginClick = onNavigateToLogin
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(Dimens.SpacingS))
|
||||
|
||||
// 3. Main Dashboard Area (Split View)
|
||||
Row(modifier = Modifier.weight(1f)) {
|
||||
// Left Panel: Controls & Status Grid (60%)
|
||||
Column(
|
||||
@@ -52,26 +59,24 @@ fun PingScreen(
|
||||
.fillMaxHeight()
|
||||
.padding(end = Dimens.SpacingS)
|
||||
) {
|
||||
ActionToolbar(viewModel)
|
||||
PingActionGroup(viewModel)
|
||||
Spacer(Modifier.height(Dimens.SpacingS))
|
||||
StatusGrid(uiState)
|
||||
}
|
||||
|
||||
// Right Panel: Terminal Log (40%)
|
||||
// Hier nutzen wir bewusst einen dunklen "Terminal"-Look, unabhängig vom Theme
|
||||
MsCard(
|
||||
TerminalConsole(
|
||||
logs = uiState.logs,
|
||||
onClear = { viewModel.clearLogs() },
|
||||
modifier = Modifier
|
||||
.weight(0.4f)
|
||||
.fillMaxHeight()
|
||||
) {
|
||||
LogHeader(onClear = { viewModel.clearLogs() })
|
||||
LogConsole(uiState.logs)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(Dimens.SpacingXS))
|
||||
|
||||
// 3. Footer
|
||||
// 4. Footer
|
||||
PingStatusBar(uiState.lastSyncResult)
|
||||
}
|
||||
}
|
||||
@@ -90,7 +95,7 @@ private fun PingHeader(
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, "Back", tint = MaterialTheme.colorScheme.onBackground)
|
||||
}
|
||||
Text(
|
||||
"PING SERVICE // DASHBOARD",
|
||||
"KONNEKTIVITÄTS-DIAGNOSE // DASHBOARD",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
modifier = Modifier.weight(1f).padding(start = Dimens.SpacingS)
|
||||
@@ -131,27 +136,6 @@ private fun StatusBadge(text: String, color: Color) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ActionToolbar(viewModel: PingViewModel) {
|
||||
// Wrap buttons to avoid overflow on small screens
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
FlowRow(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(Dimens.SpacingXS),
|
||||
verticalArrangement = Arrangement.spacedBy(Dimens.SpacingXS)
|
||||
) {
|
||||
MsButton(text = "Simple", size = ButtonSize.SMALL, onClick = { viewModel.performSimplePing() })
|
||||
MsButton(text = "Enhanced", size = ButtonSize.SMALL, onClick = { viewModel.performEnhancedPing() })
|
||||
MsButton(text = "Secure", size = ButtonSize.SMALL, onClick = { viewModel.performSecurePing() })
|
||||
MsButton(text = "Health", size = ButtonSize.SMALL, onClick = { viewModel.performHealthCheck() })
|
||||
MsButton(
|
||||
text = "Sync",
|
||||
size = ButtonSize.SMALL,
|
||||
onClick = { viewModel.triggerSync() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StatusGrid(uiState: PingUiState) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(Dimens.SpacingS)) {
|
||||
@@ -237,50 +221,6 @@ private fun KeyValueRow(key: String, value: String) {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Log Components (Terminal Style - intentionally distinct) ---
|
||||
|
||||
@Composable
|
||||
private fun LogHeader(onClear: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = Dimens.SpacingXS),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text("EVENT LOG", style = MaterialTheme.typography.labelSmall, fontWeight = FontWeight.Bold)
|
||||
TextButton(
|
||||
onClick = onClear,
|
||||
contentPadding = PaddingValues(0.dp),
|
||||
modifier = Modifier.height(24.dp)
|
||||
) {
|
||||
Text("CLEAR", style = MaterialTheme.typography.labelSmall)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LogConsole(logs: List<LogEntry>) {
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color(0xFF1E1E1E)) // Always dark for terminal
|
||||
.padding(Dimens.SpacingXS),
|
||||
reverseLayout = false
|
||||
) {
|
||||
items(logs) { log ->
|
||||
val color = if (log.isError) Color(0xFFFF5555) else Color(0xFF55FF55)
|
||||
Text(
|
||||
text = "[${log.timestamp}] [${log.source}] ${log.message}",
|
||||
color = color,
|
||||
fontSize = 11.sp,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
lineHeight = 14.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PingStatusBar(lastSync: String?) {
|
||||
Surface(
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package at.mocode.ping.feature.presentation
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import at.mocode.frontend.core.designsystem.theme.Dimens
|
||||
|
||||
/**
|
||||
* Eine universelle Terminal-Konsole zur Anzeige von Log-Einträgen.
|
||||
* Plug-and-Play ist fähig für verschiedene Features (Ping, Sync, Auth-Logs).
|
||||
*/
|
||||
@Composable
|
||||
fun TerminalConsole(
|
||||
logs: List<LogEntry>,
|
||||
modifier: Modifier = Modifier,
|
||||
onClear: () -> Unit = {}
|
||||
) {
|
||||
Column(modifier = modifier) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = Dimens.SpacingXS),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text("EVENT LOG", style = MaterialTheme.typography.labelSmall, fontWeight = FontWeight.Bold)
|
||||
TextButton(
|
||||
onClick = onClear,
|
||||
contentPadding = PaddingValues(0.dp),
|
||||
modifier = Modifier.height(24.dp)
|
||||
) {
|
||||
Text("CLEAR", style = MaterialTheme.typography.labelSmall)
|
||||
}
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color(0xFF1E1E1E)) // Terminallook (Dunkel)
|
||||
.padding(Dimens.SpacingXS)
|
||||
) {
|
||||
items(logs) { log ->
|
||||
val color = if (log.isError) Color(0xFFFF5555) else Color(0xFF55FF55)
|
||||
Text(
|
||||
text = "[${log.timestamp}] [${log.source}] ${log.message}",
|
||||
color = color,
|
||||
fontSize = 11.sp,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
lineHeight = 14.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+65
-37
@@ -1,11 +1,13 @@
|
||||
package at.mocode.turnier.feature.presentation
|
||||
|
||||
import at.mocode.frontend.core.network.discovery.DiscoveredService
|
||||
import at.mocode.frontend.core.network.sync.DataChangedEvent
|
||||
import at.mocode.frontend.core.network.sync.PingEvent
|
||||
import at.mocode.frontend.core.network.sync.SyncManager
|
||||
import at.mocode.frontend.core.network.sync.*
|
||||
import at.mocode.turnier.feature.domain.Bewerb
|
||||
import at.mocode.turnier.feature.domain.BewerbRepository
|
||||
import at.mocode.turnier.feature.domain.StartlistenRepository
|
||||
import at.mocode.turnier.feature.domain.model.StartlistenZeile
|
||||
import at.mocode.zns.parser.ZnsBewerb
|
||||
import at.mocode.zns.parser.ZnsBewerbParser
|
||||
import at.mocode.zns.parser.ZnsNennung
|
||||
@@ -17,7 +19,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import at.mocode.turnier.feature.domain.model.StartlistenZeile
|
||||
|
||||
typealias BewerbListItem = Bewerb
|
||||
|
||||
@@ -112,9 +113,11 @@ class BewerbViewModel(
|
||||
load() // Bei relevanten Änderungen neu laden
|
||||
}
|
||||
}
|
||||
|
||||
is PingEvent -> {
|
||||
// Optional: Heartbeat loggen oder Status anzeigen
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -123,9 +126,11 @@ class BewerbViewModel(
|
||||
// Auch verbundene Peers beobachten
|
||||
scope.launch {
|
||||
manager.getConnectedPeers().collect { peers ->
|
||||
reduce { it.copy(discoveredNodes = peers.map { p ->
|
||||
DiscoveredService("P2P", p, 0)
|
||||
}) }
|
||||
reduce {
|
||||
it.copy(discoveredNodes = peers.map { p ->
|
||||
DiscoveredService("P2P", p, 0)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,38 +143,46 @@ class BewerbViewModel(
|
||||
is BewerbIntent.Select -> {
|
||||
reduce { it.copy(selectedId = intent.id) }
|
||||
if (intent.id != null) {
|
||||
loadErgebnisse()
|
||||
loadErgebnisse()
|
||||
}
|
||||
}
|
||||
|
||||
is BewerbIntent.ClearError -> reduce { it.copy(errorMessage = null) }
|
||||
|
||||
is BewerbIntent.OpenDialog -> {
|
||||
dialogVm.send(BewerbAnlegenIntent.Open)
|
||||
syncDialogState()
|
||||
}
|
||||
|
||||
is BewerbIntent.CloseDialog -> {
|
||||
dialogVm.send(BewerbAnlegenIntent.Close)
|
||||
syncDialogState()
|
||||
}
|
||||
|
||||
is BewerbIntent.SetBewerbsTyp -> {
|
||||
dialogVm.send(BewerbAnlegenIntent.SetBewerbsTyp(intent.typ))
|
||||
syncDialogState()
|
||||
}
|
||||
|
||||
is BewerbIntent.SetAbteilungsTyp -> {
|
||||
dialogVm.send(BewerbAnlegenIntent.SetAbteilungsTyp(intent.typ))
|
||||
syncDialogState()
|
||||
}
|
||||
|
||||
is BewerbIntent.OpenImportDialog -> _state.value = _state.value.copy(showImportDialog = true)
|
||||
is BewerbIntent.CloseImportDialog -> _state.value = _state.value.copy(showImportDialog = false, importPreview = emptyList(), nennungenPreview = emptyList())
|
||||
is BewerbIntent.CloseImportDialog -> _state.value =
|
||||
_state.value.copy(showImportDialog = false, importPreview = emptyList(), nennungenPreview = emptyList())
|
||||
|
||||
is BewerbIntent.ProcessImportFile -> {
|
||||
val bewerbe = intent.lines.mapNotNull { ZnsBewerbParser.parse(it) }
|
||||
val nennungen = intent.lines.mapNotNull { ZnsNennungParser.parse(it) }
|
||||
_state.value = _state.value.copy(importPreview = bewerbe, nennungenPreview = nennungen)
|
||||
}
|
||||
|
||||
is BewerbIntent.ConfirmImport -> {
|
||||
confirmImport()
|
||||
}
|
||||
|
||||
is BewerbIntent.GenerateStartliste -> generateStartliste()
|
||||
is BewerbIntent.CloseStartlistePreview -> reduce { it.copy(showStartlistePreview = false) }
|
||||
is BewerbIntent.StartNetworkScan -> startScan()
|
||||
@@ -183,38 +196,41 @@ class BewerbViewModel(
|
||||
is BewerbIntent.OpenErgebnisEdit -> {
|
||||
val bewerbId = state.value.selectedId?.toString() ?: ""
|
||||
reduce {
|
||||
it.copy(
|
||||
selectedZeile = intent.zeile,
|
||||
editingErgebnis = at.mocode.turnier.feature.domain.Ergebnis(
|
||||
nennungId = intent.zeile.nennungId,
|
||||
bewerbId = bewerbId
|
||||
)
|
||||
it.copy(
|
||||
selectedZeile = intent.zeile,
|
||||
editingErgebnis = at.mocode.turnier.feature.domain.Ergebnis(
|
||||
nennungId = intent.zeile.nennungId,
|
||||
bewerbId = bewerbId
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is BewerbIntent.CloseErgebnisEdit -> reduce { it.copy(editingErgebnis = null, selectedZeile = null) }
|
||||
is BewerbIntent.SaveErgebnis -> {
|
||||
scope.launch {
|
||||
ergebnisRepo.save(intent.ergebnis).onSuccess {
|
||||
reduce { it.copy(editingErgebnis = null, selectedZeile = null) }
|
||||
loadErgebnisse()
|
||||
}
|
||||
ergebnisRepo.save(intent.ergebnis).onSuccess {
|
||||
reduce { it.copy(editingErgebnis = null, selectedZeile = null) }
|
||||
loadErgebnisse()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is BewerbIntent.CalculatePlatzierung -> {
|
||||
val selectedId = state.value.selectedId ?: return@send
|
||||
val selectedId = state.value.selectedId ?: return
|
||||
scope.launch {
|
||||
ergebnisRepo.calculatePlatzierung(selectedId.toString()).onSuccess {
|
||||
loadErgebnisse()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is BewerbIntent.ExportErgebnislistePdf -> {
|
||||
val selectedId = state.value.selectedId ?: return@send
|
||||
val selectedId = state.value.selectedId ?: return
|
||||
scope.launch {
|
||||
ergebnisRepo.exportPdf(selectedId.toString()).onSuccess { bytes ->
|
||||
// In einer echten Desktop-App würde man hier einen File-Saver öffnen
|
||||
// Für den MVP loggen wir nur den Erfolg.
|
||||
// In einer echten Desktop-App würde man hier einen File-Saver öffnen.
|
||||
// Für den MVP loggen wir nur den Erfolg ein.
|
||||
println("PDF Export erfolgreich: ${bytes.size} bytes")
|
||||
}
|
||||
}
|
||||
@@ -225,9 +241,9 @@ class BewerbViewModel(
|
||||
private fun loadErgebnisse() {
|
||||
val bewerbId = state.value.selectedId ?: return
|
||||
scope.launch {
|
||||
ergebnisRepo.getForBewerb(bewerbId.toString()).onSuccess { list ->
|
||||
reduce { it.copy(ergebnisse = list) }
|
||||
}
|
||||
ergebnisRepo.getForBewerb(bewerbId.toString()).onSuccess { list ->
|
||||
reduce { it.copy(ergebnisse = list) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +264,12 @@ class BewerbViewModel(
|
||||
repo.getAuditLog(id).onSuccess { log ->
|
||||
_state.update { it.copy(auditLog = log, isAuditLoading = false) }
|
||||
}.onFailure { t ->
|
||||
_state.update { it.copy(isAuditLoading = false, errorMessage = "Audit-Log konnte nicht geladen werden: ${t.message}") }
|
||||
_state.update {
|
||||
it.copy(
|
||||
isAuditLoading = false,
|
||||
errorMessage = "Audit-Log konnte nicht geladen werden: ${t.message}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +277,7 @@ class BewerbViewModel(
|
||||
private fun updateZeitplan(id: Long, beginn: String?) {
|
||||
scope.launch {
|
||||
repo.updateZeitplan(id, null, beginn, null).onSuccess {
|
||||
load() // Neu laden um Konsistenz zu prüfen
|
||||
load() // Neu laden, um Konsistenz zu prüfen
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,13 +285,15 @@ class BewerbViewModel(
|
||||
private fun startScan() {
|
||||
syncManager?.start(8080)
|
||||
_state.update { it.copy(isScanning = true) }
|
||||
// Nach dem Start des Servers ein Ping-Event broadcasten um Präsenz zu zeigen
|
||||
syncManager?.broadcastEvent(PingEvent(
|
||||
eventId = turnierId.toString(),
|
||||
sequenceNumber = 0,
|
||||
originNodeId = "Client-${(1000..9999).random()}",
|
||||
createdAt = 0 // In commonMain ohne Clock-Lib erst mal 0
|
||||
))
|
||||
// Nach dem Start des Servers ein ConnectivityCheck-Event Broadcasting, um Präsenz zu zeigen
|
||||
syncManager?.broadcastEvent(
|
||||
PingEvent(
|
||||
eventId = turnierId.toString(),
|
||||
sequenceNumber = 0,
|
||||
originNodeId = "Client-${(1000..9999).random()}",
|
||||
createdAt = 0 // In commonMain ohne Clock-Lib erst mal 0
|
||||
)
|
||||
)
|
||||
refreshNodes()
|
||||
}
|
||||
|
||||
@@ -318,7 +341,12 @@ class BewerbViewModel(
|
||||
reduce { it.copy(showImportDialog = false, importPreview = emptyList()) }
|
||||
load()
|
||||
} else {
|
||||
reduce { it.copy(isLoading = false, errorMessage = "Import fehlgeschlagen: ${result.exceptionOrNull()?.message}") }
|
||||
reduce {
|
||||
it.copy(
|
||||
isLoading = false,
|
||||
errorMessage = "Import fehlgeschlagen: ${result.exceptionOrNull()?.message}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,9 +376,9 @@ class BewerbViewModel(
|
||||
val q = query.trim()
|
||||
return list.filter {
|
||||
it.name.contains(q, ignoreCase = true) ||
|
||||
it.sparte.contains(q, ignoreCase = true) ||
|
||||
it.klasse.contains(q, ignoreCase = true) ||
|
||||
it.tag.contains(q, ignoreCase = true)
|
||||
it.sparte.contains(q, ignoreCase = true) ||
|
||||
it.klasse.contains(q, ignoreCase = true) ||
|
||||
it.tag.contains(q, ignoreCase = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-9
@@ -26,13 +26,13 @@ private val NennSelectedBg = Color(0xFFEFF6FF)
|
||||
* NENNUNGEN-Tab gemäß Vision_03.
|
||||
*
|
||||
* Layout: 2-spaltig
|
||||
* - Links (flex): Pferd+Reiter-Suche + Nennungs-Tabelle
|
||||
* - Rechts (360dp): Verkauf/Buchungen + Bewerbsübersicht
|
||||
* - Links (flex): Pferd+Reiter-Suche + Nennungs-Tabelle
|
||||
* - Rechts (360dp): Verkauf/Buchungen + Bewerbsübersicht
|
||||
*/
|
||||
@Composable
|
||||
fun NennungenTabContent(
|
||||
viewModel: TurnierNennungViewModel,
|
||||
onAbrechnungClick: () -> Unit = {}
|
||||
viewModel: TurnierNennungViewModel,
|
||||
onAbrechnungClick: () -> Unit = {}
|
||||
) {
|
||||
val state by viewModel.state.collectAsState()
|
||||
|
||||
@@ -55,7 +55,7 @@ fun NennungenTabContent(
|
||||
Row(modifier = Modifier.fillMaxSize()) {
|
||||
// ── Linke Spalte: Suche + Tabelle ─────────────────────────────────────
|
||||
Column(modifier = Modifier.weight(1f).fillMaxHeight()) {
|
||||
NennungenSuchePanel(viewModel, state)
|
||||
NennungenSuchePanel(viewModel)
|
||||
HorizontalDivider()
|
||||
NennungenTabelle(viewModel, state)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ fun NennungenTabContent(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun NennungenSuchePanel(viewModel: TurnierNennungViewModel, state: NennungenState) {
|
||||
private fun NennungenSuchePanel(viewModel: TurnierNennungViewModel) {
|
||||
var pferdQuery by remember { mutableStateOf("") }
|
||||
var reiterQuery by remember { mutableStateOf("") }
|
||||
|
||||
@@ -146,7 +146,7 @@ private fun NennungenTabelle(viewModel: TurnierNennungViewModel, state: Nennunge
|
||||
Text("Keine Nennungen vorhanden", fontSize = 14.sp, color = Color(0xFF6B7280))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
"Suchen Sie nach Pferd und Reiter, um eine Nennung hinzuzufügen.",
|
||||
"Suchen Sie nach Pferd und Reiter, um eine EntryManagement hinzuzufügen.",
|
||||
fontSize = 12.sp,
|
||||
color = Color(0xFF9CA3AF)
|
||||
)
|
||||
@@ -287,5 +287,3 @@ private data class NennungUiModel(
|
||||
val bewerb: String,
|
||||
val status: String,
|
||||
)
|
||||
|
||||
private fun sampleNennungen(): List<NennungUiModel> = emptyList()
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"geraetName": "Meldestelle",
|
||||
"sharedKey": "Meldestelle",
|
||||
"backupPath": "/mocode/Meldestelle/docs/temp",
|
||||
"backupPath": "/home/stefan/WsMeldestelle/Meldestelle/meldestelle/docs/temp",
|
||||
"networkRole": "MASTER",
|
||||
"expectedClients": [
|
||||
{
|
||||
"name": "Zeithnehmer",
|
||||
"role": "ZEITNEHMER"
|
||||
"name": "Richter-Turm",
|
||||
"role": "RICHTER"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+9
-8
@@ -35,18 +35,18 @@ fun DesktopApp() {
|
||||
val currentScreen by nav.currentScreen.collectAsState()
|
||||
val loginViewModel: LoginViewModel = koinViewModel()
|
||||
|
||||
// Onboarding-Check beim Start
|
||||
// DeviceInitialization-Check beim Start
|
||||
LaunchedEffect(Unit) {
|
||||
if (!SettingsManager.isConfigured()) {
|
||||
nav.navigateToScreen(AppScreen.Onboarding)
|
||||
nav.navigateToScreen(AppScreen.DeviceInitialization)
|
||||
}
|
||||
}
|
||||
|
||||
val authState by authTokenManager.authState.collectAsState()
|
||||
|
||||
// Login-Gate: Nicht-authentifizierte Screens → Login, außer Onboarding ist erlaubt
|
||||
// Vision_03 Update: Wir starten mit Onboarding
|
||||
if (!authState.isAuthenticated && currentScreen !is AppScreen.Login && currentScreen !is AppScreen.Onboarding
|
||||
// Login-Gate: Nicht-authentifizierte Screens → Login, außer DeviceInitialization ist erlaubt
|
||||
// Vision_03 Update: Wir starten mit DeviceInitialization
|
||||
if (!authState.isAuthenticated && currentScreen !is AppScreen.Login && currentScreen !is AppScreen.DeviceInitialization
|
||||
&& currentScreen !is AppScreen.VeranstaltungVerwaltung
|
||||
&& currentScreen !is AppScreen.VeranstalterAuswahl && currentScreen !is AppScreen.VeranstalterNeu
|
||||
&& currentScreen !is AppScreen.VeranstalterDetail && currentScreen !is AppScreen.VeranstaltungKonfig
|
||||
@@ -57,10 +57,11 @@ fun DesktopApp() {
|
||||
&& currentScreen !is AppScreen.VereinVerwaltung
|
||||
&& currentScreen !is AppScreen.StammdatenImport
|
||||
&& currentScreen !is AppScreen.NennungsEingang
|
||||
&& currentScreen !is AppScreen.ConnectivityCheck
|
||||
) {
|
||||
LaunchedEffect(Unit) {
|
||||
// Standard: Start im Onboarding
|
||||
nav.navigateToScreen(AppScreen.Onboarding)
|
||||
// Standard: Start im DeviceInitialization
|
||||
nav.navigateToScreen(AppScreen.DeviceInitialization)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ fun DesktopApp() {
|
||||
val returnTo = screen.returnTo ?: AppScreen.VeranstaltungVerwaltung
|
||||
nav.navigateToScreen(returnTo)
|
||||
},
|
||||
onBack = { /* Desktop hat keine Landing-Page */ },
|
||||
onBack = { /* Desktop hat keine PortalDashboard-Page */ },
|
||||
)
|
||||
|
||||
else -> {
|
||||
|
||||
+4
-4
@@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.asStateFlow
|
||||
* Hält den aktuellen Screen als StateFlow, den DesktopApp beobachtet.
|
||||
*/
|
||||
class DesktopNavigationPort : NavigationPort {
|
||||
private val _currentScreen = MutableStateFlow<AppScreen>(AppScreen.Onboarding)
|
||||
private val _currentScreen = MutableStateFlow<AppScreen>(AppScreen.DeviceInitialization)
|
||||
override val currentScreen: StateFlow<AppScreen> = _currentScreen.asStateFlow()
|
||||
|
||||
// Backstack zur Speicherung des Verlaufs
|
||||
@@ -29,7 +29,7 @@ class DesktopNavigationPort : NavigationPort {
|
||||
val current = _currentScreen.value
|
||||
if (current != screen) {
|
||||
backStack.add(current)
|
||||
// Begrenzung des Backstacks auf z.B. 50 Einträge
|
||||
// Begrenzung des Backstacks auf z. B. 50 Einträge
|
||||
if (backStack.size > 50) backStack.removeAt(0)
|
||||
}
|
||||
_currentScreen.value = screen
|
||||
@@ -41,8 +41,8 @@ class DesktopNavigationPort : NavigationPort {
|
||||
println("[DesktopNav] navigateBack -> $previousScreen")
|
||||
_currentScreen.value = previousScreen
|
||||
} else {
|
||||
println("[DesktopNav] navigateBack -> Stack leer, bleibe bei Onboarding")
|
||||
_currentScreen.value = AppScreen.Onboarding
|
||||
println("[DesktopNav] navigateBack -> Stack leer, bleibe bei DeviceInitialization")
|
||||
_currentScreen.value = AppScreen.DeviceInitialization
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-46
@@ -60,7 +60,6 @@ import org.koin.compose.viewmodel.koinViewModel
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
// Primärfarbe der TopBar (kann später ins Theme ausgelagert werden)
|
||||
private val TopBarColor = Color(0xFF1E3A8A)
|
||||
private val TopBarTextColor = Color.White
|
||||
|
||||
/**
|
||||
@@ -79,14 +78,14 @@ fun DesktopMainLayout(
|
||||
onLogout: () -> Unit,
|
||||
) {
|
||||
println("[Navigation] Rendering Screen: ${currentScreen::class.simpleName} (Details: $currentScreen)")
|
||||
// Onboarding-Daten (On-the-fly geladen oder Default)
|
||||
// DeviceInitialization-Daten (On-the-fly geladen oder Default)
|
||||
var onboardingSettings by remember { mutableStateOf(SettingsManager.loadSettings() ?: OnboardingSettings()) }
|
||||
|
||||
// Automatische Umleitung zum Onboarding, wenn Setup fehlt (außer wir sind bereits dort)
|
||||
// Automatische Umleitung zum DeviceInitialization, wenn Setup fehlt (außer wir sind bereits dort)
|
||||
LaunchedEffect(onboardingSettings) {
|
||||
if (!onboardingSettings.isConfigured && currentScreen !is AppScreen.Onboarding) {
|
||||
println("[DesktopNav] Setup fehlt -> Umleitung zum Onboarding")
|
||||
onNavigate(AppScreen.Onboarding)
|
||||
if (!onboardingSettings.isConfigured && currentScreen !is AppScreen.DeviceInitialization) {
|
||||
println("[DesktopNav] Setup fehlt -> Umleitung zum DeviceInitialization")
|
||||
onNavigate(AppScreen.DeviceInitialization)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ fun DesktopMainLayout(
|
||||
HorizontalDivider(thickness = Dimens.BorderThin, color = MaterialTheme.colorScheme.outlineVariant)
|
||||
DesktopFooterBar(
|
||||
settings = onboardingSettings,
|
||||
onSetupClick = { onNavigate(AppScreen.Onboarding) }
|
||||
onSetupClick = { onNavigate(AppScreen.DeviceInitialization) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -182,9 +181,9 @@ private fun DesktopNavRail(
|
||||
|
||||
NavRailItem(
|
||||
icon = Icons.Default.WifiTethering,
|
||||
label = "Sync",
|
||||
selected = currentScreen is AppScreen.Ping,
|
||||
onClick = { onNavigate(AppScreen.Ping) }
|
||||
label = "ConnectivityCheck",
|
||||
selected = currentScreen is AppScreen.ConnectivityCheck,
|
||||
onClick = { onNavigate(AppScreen.ConnectivityCheck) }
|
||||
)
|
||||
|
||||
Spacer(Modifier.weight(1f))
|
||||
@@ -192,8 +191,8 @@ private fun DesktopNavRail(
|
||||
NavRailItem(
|
||||
icon = Icons.Default.AppRegistration,
|
||||
label = "Setup",
|
||||
selected = currentScreen is AppScreen.Onboarding,
|
||||
onClick = { onNavigate(AppScreen.Onboarding) }
|
||||
selected = currentScreen is AppScreen.DeviceInitialization,
|
||||
onClick = { onNavigate(AppScreen.DeviceInitialization) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -264,7 +263,7 @@ private fun DesktopTopHeader(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
if (currentScreen !is AppScreen.Onboarding) {
|
||||
if (currentScreen !is AppScreen.DeviceInitialization) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
@@ -439,10 +438,10 @@ private fun BreadcrumbContent(
|
||||
)
|
||||
}
|
||||
|
||||
is AppScreen.Ping -> {
|
||||
is AppScreen.ConnectivityCheck -> {
|
||||
BreadcrumbSeparator()
|
||||
Text(
|
||||
text = "Ping Service",
|
||||
text = "Konnektivitäts-Diagnose",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
@@ -511,27 +510,6 @@ private fun InvalidContextNotice(message: String, onBack: () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PlaceholderScreen(
|
||||
title: String,
|
||||
onBack: () -> Unit,
|
||||
onAction: (() -> Unit)? = null,
|
||||
actionLabel: String = "Aktion ausführen"
|
||||
) {
|
||||
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
Text(title, style = MaterialTheme.typography.headlineMedium)
|
||||
Text("Dieser Screen ist noch in Arbeit (Placeholder)", color = Color.Gray)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = onBack) { Text("Zurück") }
|
||||
if (onAction != null) {
|
||||
Button(onClick = onAction) { Text(actionLabel) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Content-Bereich: rendert den passenden Screen je nach aktuellem AppScreen.
|
||||
*/
|
||||
@@ -544,9 +522,9 @@ private fun DesktopContentArea(
|
||||
onSettingsChange: (OnboardingSettings) -> Unit,
|
||||
) {
|
||||
when (currentScreen) {
|
||||
// Onboarding (Geräte-Setup)
|
||||
is AppScreen.Onboarding -> {
|
||||
println("[Screen] Rendering Onboarding")
|
||||
// DeviceInitialization (Geräte-Setup)
|
||||
is AppScreen.DeviceInitialization -> {
|
||||
println("[Screen] Rendering DeviceInitialization")
|
||||
OnboardingScreen(
|
||||
settings = settings,
|
||||
onSettingsChange = onSettingsChange,
|
||||
@@ -656,9 +634,8 @@ private fun DesktopContentArea(
|
||||
)
|
||||
|
||||
/*
|
||||
is AppScreen.VeranstaltungProfil -> PlaceholderScreen("Veranstaltung-Profil #${currentScreen.id}",
|
||||
onBack = { onNavigate(AppScreen.VeranstaltungVerwaltung) }
|
||||
)
|
||||
is AppScreen.VeranstaltungProfil -> VeranstaltungProfilScreen(id = currentScreen.id,
|
||||
onBack = onBack)
|
||||
*/
|
||||
|
||||
// Neuer Flow: Veranstalter auswählen → Detail → Veranstaltung-Übersicht
|
||||
@@ -812,13 +789,25 @@ private fun DesktopContentArea(
|
||||
}
|
||||
}
|
||||
|
||||
// Ping-Screen
|
||||
is AppScreen.Ping -> {
|
||||
println("[Screen] Rendering Ping")
|
||||
// ConnectivityCheck-Screen
|
||||
is AppScreen.ConnectivityCheck -> {
|
||||
println("[Screen] Rendering ConnectivityCheck")
|
||||
val pingViewModel: PingViewModel = koinInject()
|
||||
PingScreen(
|
||||
viewModel = pingViewModel,
|
||||
onBack = onBack,
|
||||
onNavigateToLogin = { onNavigate(AppScreen.Login(returnTo = AppScreen.ConnectivityCheck)) }
|
||||
)
|
||||
}
|
||||
|
||||
// Login-Screen (Integration)
|
||||
is AppScreen.Login -> {
|
||||
println("[Screen] Rendering Login")
|
||||
val loginViewModel: at.mocode.frontend.core.auth.presentation.LoginViewModel = koinInject()
|
||||
at.mocode.frontend.core.auth.presentation.LoginScreen(
|
||||
viewModel = loginViewModel,
|
||||
onLoginSuccess = onBack,
|
||||
onBack = onBack
|
||||
)
|
||||
}
|
||||
|
||||
@@ -856,7 +845,7 @@ private fun DesktopContentArea(
|
||||
SeriesScreen(title = "Cups", onBack = onBack)
|
||||
}
|
||||
|
||||
is AppScreen.Nennung -> {
|
||||
is AppScreen.EntryManagement -> {
|
||||
val nennungViewModel: NennungViewModel = koinViewModel()
|
||||
NennungsMaske(
|
||||
viewModel = nennungViewModel,
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ fun NennungsEingangScreen(onBack: () -> Unit) {
|
||||
fun NennungDetailDialog(mail: OnlineNennungMail, onDismiss: () -> Unit, onMarkProcessed: () -> Unit) {
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text("Details zur Online-Nennung") },
|
||||
title = { Text("Details zur Online-EntryManagement") },
|
||||
text = {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
DetailRow("Absender", mail.sender)
|
||||
|
||||
+4
-7
@@ -1,13 +1,13 @@
|
||||
package at.mocode.desktop.screens.onboarding
|
||||
|
||||
/**
|
||||
* Validierungslogik für den Onboarding-Wizard.
|
||||
* Validierungslogik für den DeviceInitialization-Wizard.
|
||||
*
|
||||
* Extrahiert aus `OnboardingScreen` für isolierte Unit-Tests (B-2).
|
||||
* Regeln gemäß Onboarding-Spezifikation:
|
||||
* Regeln gemäß DeviceInitialization-Spezifikation:
|
||||
* - Gerätename: mindestens 3 Zeichen (nach trim)
|
||||
* - Sicherheitsschlüssel: mindestens 8 Zeichen (nach trim)
|
||||
* - Backup-Pfad: darf nicht leer sein und muss existieren (Prüfung optional hier)
|
||||
* - Backup-Pfad: Darf nicht leer sein und muss existieren (Prüfung optional hier)
|
||||
* - Sync-Intervall: zwischen 1 und 60 Minuten
|
||||
*/
|
||||
object OnboardingValidator {
|
||||
@@ -18,9 +18,6 @@ object OnboardingValidator {
|
||||
/** Mindestlänge für den Sicherheitsschlüssel. */
|
||||
const val MIN_KEY_LENGTH = 8
|
||||
|
||||
/** Standard-Sync-Intervall in Minuten. */
|
||||
const val DEFAULT_SYNC_INTERVAL = 30
|
||||
|
||||
/** Gibt `true` zurück, wenn der Gerätename gültig ist. */
|
||||
fun isNameValid(name: String): Boolean = name.trim().length >= MIN_NAME_LENGTH
|
||||
|
||||
@@ -35,7 +32,7 @@ object OnboardingValidator {
|
||||
|
||||
/**
|
||||
* Gibt `true` zurück, wenn alle Pflichtfelder gültig sind und
|
||||
* der „Weiter"-Button aktiviert werden darf.
|
||||
* der „Weiter“-Button aktiviert werden darf.
|
||||
*/
|
||||
fun canContinue(settings: OnboardingSettings): Boolean {
|
||||
val basicValid = isNameValid(settings.geraetName) &&
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
/**
|
||||
* B-2 Test-Suite: Onboarding-Wizard Edge-Cases
|
||||
* B-2 Test-Suite: DeviceInitialization-Wizard Edge-Cases
|
||||
*
|
||||
* Testet die Validierungslogik des Onboarding-Wizards isoliert via [OnboardingValidator].
|
||||
* Testet die Validierungslogik des DeviceInitialization-Wizards isoliert via [OnboardingValidator].
|
||||
* Die `rememberSaveable`-Regression (Zurück-Navigation behält Felder) ist durch den
|
||||
* Fix in OnboardingScreen.kt (remember → rememberSaveable) abgesichert; ein
|
||||
* Compose-UI-Test dafür ist auf JVM-Desktop ohne Instrumentation nicht möglich.
|
||||
@@ -144,7 +144,7 @@ class OnboardingValidatorTest {
|
||||
assertTrue(second)
|
||||
}
|
||||
|
||||
// ─── rememberSaveable Regressions-Dokumentation ─────────────────────────────
|
||||
// ─── rememberSavable Regressions-Dokumentation ─────────────────────────────
|
||||
|
||||
@Test
|
||||
fun `B2 Regression rememberSaveable - Validator akzeptiert vorausgefüllte Werte nach Ruecknavigation`() {
|
||||
|
||||
Reference in New Issue
Block a user