JS-spezifische Module und Dateien entfernt, Multiplattform-Targets korrigiert
Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
@@ -15,15 +15,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
@@ -81,9 +72,5 @@ kotlin {
|
||||
implementation(libs.kotlin.stdlib.wasm.js)
|
||||
implementation(libs.ktor.client.js)
|
||||
}
|
||||
|
||||
jsMain.dependencies {
|
||||
implementation(libs.ktor.client.js)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
package at.mocode.frontend.core.auth.data
|
||||
|
||||
import kotlinx.browser.window
|
||||
|
||||
/**
|
||||
* JS-Implementierung: leitet die gesamte Seite zu Keycloak weiter.
|
||||
* Die Funktion kehrt nicht zurück —
|
||||
* der Callback wird beim nächsten App-Start via [consumePendingOidcCallback] verarbeitet.
|
||||
*/
|
||||
actual suspend fun launchOidcFlow(
|
||||
authUrl: String,
|
||||
callbackPort: Int // wird im Browser ignoriert (kein lokaler Server)
|
||||
): OidcCallbackResult {
|
||||
window.location.href = authUrl
|
||||
// Diese Zeile wird nie erreicht — der Browser leitet weiter
|
||||
return OidcCallbackResult.Redirecting
|
||||
}
|
||||
|
||||
/**
|
||||
* JS-Implementierung: prüft beim App-Start, ob die aktuelle URL einen
|
||||
* OIDC-Callback enthält (code= und state= Parameter von Keycloak).
|
||||
* Bereinigt nach dem Auslesen die URL via replaceState.
|
||||
*/
|
||||
actual fun consumePendingOidcCallback(): OidcCallbackResult? {
|
||||
val search = window.location.search
|
||||
if (!search.contains("code=")) return null
|
||||
|
||||
val params = parseJsQueryParams(search.removePrefix("?"))
|
||||
val code = params["code"] ?: return null
|
||||
val state = params["state"] ?: return null
|
||||
val error = params["error"]
|
||||
|
||||
// URL bereinigen — Code soll nicht im Browser-Verlauf bleiben
|
||||
try {
|
||||
window.history.replaceState(null, "", window.location.pathname)
|
||||
} catch (_: Throwable) {
|
||||
// ignore — kein kritischer Fehler
|
||||
}
|
||||
|
||||
return if (error != null) {
|
||||
OidcCallbackResult.Error(
|
||||
error = error,
|
||||
description = params["error_description"]
|
||||
)
|
||||
} else {
|
||||
OidcCallbackResult.Success(code = code, state = state)
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseJsQueryParams(query: String): Map<String, String> =
|
||||
query.split("&")
|
||||
.filter { it.contains("=") }
|
||||
.associate {
|
||||
val parts = it.split("=", limit = 2)
|
||||
parts[0] to decodeURIComponent(parts.getOrElse(1) { "" })
|
||||
}
|
||||
|
||||
actual fun getOidcRedirectUri(): String {
|
||||
val origin = try {
|
||||
window.location.origin
|
||||
} catch (_: Throwable) {
|
||||
"http://localhost"
|
||||
}
|
||||
return origin + at.mocode.frontend.core.domain.AppConstants.OIDC_REDIRECT_URI_JS_PATH
|
||||
}
|
||||
|
||||
private fun decodeURIComponent(encoded: String): String =
|
||||
js("decodeURIComponent(encoded)").unsafeCast<String>()
|
||||
@@ -12,15 +12,6 @@ plugins {
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -10,15 +10,6 @@ plugins {
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package at.mocode.frontend.core.domain
|
||||
|
||||
actual fun currentPlatform(): PlatformType = PlatformType.WEB
|
||||
@@ -11,15 +11,6 @@ plugins {
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
@@ -41,19 +32,10 @@ kotlin {
|
||||
implementation(libs.sqldelight.driver.sqlite)
|
||||
}
|
||||
|
||||
jsMain.dependencies {
|
||||
implementation(libs.sqldelight.driver.web)
|
||||
implementation(npm("@sqlite.org/sqlite-wasm", libs.versions.sqliteWasm.get()))
|
||||
}
|
||||
|
||||
jvmTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
}
|
||||
|
||||
jsTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
}
|
||||
|
||||
wasmJsMain.dependencies {
|
||||
implementation(libs.kotlin.stdlib.wasm.js)
|
||||
implementation(libs.sqldelight.driver.web)
|
||||
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
package at.mocode.frontend.core.localdb
|
||||
|
||||
import app.cash.sqldelight.db.SqlCursor
|
||||
import app.cash.sqldelight.db.SqlDriver
|
||||
import app.cash.sqldelight.driver.worker.WebWorkerDriver
|
||||
import org.w3c.dom.Worker
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
actual class DatabaseDriverFactory {
|
||||
actual suspend fun createDriver(): SqlDriver {
|
||||
// Wir nutzen eine Helper-Funktion, um den Worker zu erstellen.
|
||||
val worker = createWorker()
|
||||
val driver = WebWorkerDriver(worker)
|
||||
|
||||
try {
|
||||
val version = getVersion(driver)
|
||||
val schemaVersion = AppDatabase.Schema.version
|
||||
|
||||
console.log("Database version check: Current=$version, Schema=$schemaVersion")
|
||||
|
||||
if (version == 0L) {
|
||||
console.log("Creating Database Schema...")
|
||||
try {
|
||||
AppDatabase.Schema.create(driver).await()
|
||||
setVersion(driver, schemaVersion)
|
||||
console.log("Database Schema created and version set to $schemaVersion")
|
||||
} catch (e: Throwable) {
|
||||
// If tables already exist but a version was 0 (e.g., previous broken run), we might get here.
|
||||
val msg = e.message ?: ""
|
||||
if (msg.contains("already exists", ignoreCase = true)) {
|
||||
console.warn("Tables already exist but version was 0. Assuming DB is initialized. Setting version to $schemaVersion.")
|
||||
setVersion(driver, schemaVersion)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
} else if (version < schemaVersion) {
|
||||
console.log("Migrating Database Schema from $version to $schemaVersion...")
|
||||
AppDatabase.Schema.migrate(driver, version, schemaVersion).await()
|
||||
setVersion(driver, schemaVersion)
|
||||
console.log("Database Schema migrated")
|
||||
} else {
|
||||
console.log("Database Schema is up to date.")
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
console.error("Error initializing database schema:", e)
|
||||
throw e
|
||||
}
|
||||
|
||||
return driver
|
||||
}
|
||||
|
||||
private suspend fun getVersion(driver: SqlDriver): Long {
|
||||
// Workaround for QueryResult issues:
|
||||
// We capture the cursor in a local variable and return the Boolean result from next().
|
||||
// Then we read from the captured cursor.
|
||||
|
||||
var cursorRef: SqlCursor? = null
|
||||
|
||||
// executeQuery returns QueryResult<Boolean> because mapper returns QueryResult<Boolean>
|
||||
val hasNext = driver.executeQuery(
|
||||
identifier = null,
|
||||
sql = "PRAGMA user_version;",
|
||||
mapper = { cursor ->
|
||||
cursorRef = cursor
|
||||
cursor.next()
|
||||
},
|
||||
parameters = 0
|
||||
).await()
|
||||
|
||||
return if (hasNext) {
|
||||
cursorRef?.getLong(0) ?: 0L
|
||||
} else {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun setVersion(driver: SqlDriver, version: Long) {
|
||||
driver.execute(null, "PRAGMA user_version = $version;", 0).await()
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to create the worker
|
||||
private fun createWorker(): Worker {
|
||||
// Try the relative path again, as an absolute path might fail depending on base href
|
||||
return js("new Worker('sqlite.worker.js')")
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// --- State ---
|
||||
let db = null;
|
||||
let isReady = false;
|
||||
let initError = null;
|
||||
const messageQueue = [];
|
||||
|
||||
// --- Message Handler ---
|
||||
self.onmessage = (event) => {
|
||||
if (!isReady) {
|
||||
if (initError) {
|
||||
postMessage({id: event.data?.id, error: `Worker not initialized: ${initError}`});
|
||||
} else {
|
||||
messageQueue.push(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
processMessage(event);
|
||||
};
|
||||
|
||||
self.onerror = (event) => {
|
||||
console.error('[sqlite.worker] Uncaught error:', event.message, `${event.filename}:${event.lineno}`);
|
||||
};
|
||||
|
||||
// --- Message Processor ---
|
||||
function processMessage(event) {
|
||||
const data = event.data;
|
||||
if (!data) return;
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = executeAction(data);
|
||||
} catch (err) {
|
||||
console.error('[sqlite.worker] Error processing message:', err);
|
||||
postMessage({id: data.id, error: err?.message ?? String(err)});
|
||||
return;
|
||||
}
|
||||
postMessage({id: data.id, ...result});
|
||||
}
|
||||
|
||||
function executeAction(data) {
|
||||
switch (data.action) {
|
||||
case 'exec': {
|
||||
if (!data.sql) {
|
||||
postMessage({id: data.id, error: 'exec: Missing sql string'});
|
||||
return null;
|
||||
}
|
||||
const rows = [];
|
||||
db.exec({
|
||||
sql: data.sql,
|
||||
bind: data.params ?? [],
|
||||
rowMode: 'array',
|
||||
callback: (row) => rows.push(row),
|
||||
});
|
||||
return {results: {values: rows}};
|
||||
}
|
||||
case 'begin_transaction':
|
||||
db.exec('BEGIN TRANSACTION;');
|
||||
return {results: []};
|
||||
case 'end_transaction':
|
||||
db.exec('END TRANSACTION;');
|
||||
return {results: []};
|
||||
case 'rollback_transaction':
|
||||
db.exec('ROLLBACK TRANSACTION;');
|
||||
return {results: []};
|
||||
default:
|
||||
postMessage({id: data.id, error: `Unsupported action: ${data.action}`});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Initialization ---
|
||||
async function init() {
|
||||
// Load sqlite3.js via importScripts (avoids Webpack bundling issues)
|
||||
const loadResult = tryImportScripts();
|
||||
if (loadResult !== null) {
|
||||
handleInitError(loadResult);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof self.sqlite3InitModule !== 'function') {
|
||||
handleInitError('sqlite3InitModule not found after importScripts – sqlite3.js may be corrupt or wrong version.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch WASM binary manually so we control the URL and can detect failures early
|
||||
let wasmBinary;
|
||||
try {
|
||||
const wasmResponse = await fetch('sqlite3.wasm');
|
||||
if (!wasmResponse.ok) {
|
||||
handleInitError(`Failed to fetch sqlite3.wasm: ${wasmResponse.status} ${wasmResponse.statusText}`);
|
||||
return;
|
||||
}
|
||||
wasmBinary = await wasmResponse.arrayBuffer();
|
||||
} catch (e) {
|
||||
handleInitError(`Failed to fetch sqlite3.wasm: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const sqlite3 = await self.sqlite3InitModule({
|
||||
print: console.log,
|
||||
printErr: console.error,
|
||||
wasmBinary,
|
||||
});
|
||||
|
||||
const dbName = 'app.db';
|
||||
if ('opfs' in sqlite3) {
|
||||
console.log(`[sqlite.worker] Using persistent OPFS database: ${dbName}`);
|
||||
db = new sqlite3.oo1.OpfsDb(dbName);
|
||||
} else {
|
||||
console.warn('[sqlite.worker] OPFS not available – falling back to in-memory database');
|
||||
db = new sqlite3.oo1.DB(dbName);
|
||||
}
|
||||
|
||||
// Flush buffered messages
|
||||
isReady = true;
|
||||
console.log(`[sqlite.worker] Ready. Flushing ${messageQueue.length} buffered message(s).`);
|
||||
while (messageQueue.length > 0) {
|
||||
processMessage(messageQueue.shift());
|
||||
}
|
||||
} catch (e) {
|
||||
handleInitError(e?.message ?? String(e));
|
||||
}
|
||||
}
|
||||
|
||||
function tryImportScripts() {
|
||||
try {
|
||||
importScripts('sqlite3.js');
|
||||
return null;
|
||||
} catch (e) {
|
||||
return `importScripts('sqlite3.js') failed – is the file served at root? ${e.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
function handleInitError(message) {
|
||||
initError = message;
|
||||
console.error('[sqlite.worker] Initialization failed:', message);
|
||||
while (messageQueue.length > 0) {
|
||||
const queued = messageQueue.shift();
|
||||
postMessage({id: queued.data?.id, error: `Worker initialization failed: ${initError}`});
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
+2
-9
@@ -6,15 +6,8 @@ import app.cash.sqldelight.db.SqlDriver
|
||||
actual class DatabaseDriverFactory {
|
||||
actual suspend fun createDriver(): SqlDriver {
|
||||
// Provisorische Implementierung für den Build-Erfolg
|
||||
// In einer echten Umgebung müsste hier der WebWorkerDriver konfiguriert werden,
|
||||
// sobald die org.w3c.dom Abhängigkeiten korrekt aufgelöst werden können.
|
||||
// WebWorkerDriver für WasmJs erfordert org.w3c.dom (DOM-Library),
|
||||
// welche in diesem Projekt für WasmJs noch nicht vollständig konfiguriert ist.
|
||||
throw UnsupportedOperationException("Database on Wasm is not yet fully implemented due to missing org.w3c.dom")
|
||||
}
|
||||
|
||||
private suspend fun getVersion(driver: SqlDriver): Long {
|
||||
return 0L
|
||||
}
|
||||
|
||||
private suspend fun setVersion(driver: SqlDriver, version: Long) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -10,15 +10,6 @@ plugins {
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
@@ -57,9 +48,5 @@ kotlin {
|
||||
implementation(libs.ktor.client.js)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
}
|
||||
|
||||
jsMain.dependencies {
|
||||
implementation(libs.ktor.client.js)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package at.mocode.frontend.core.network
|
||||
|
||||
import kotlinx.browser.window
|
||||
|
||||
@Suppress("UnsafeCastFromDynamic", "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
actual object PlatformConfig {
|
||||
|
||||
private val globalScope: dynamic
|
||||
get() = js("typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}))")
|
||||
|
||||
actual fun resolveApiBaseUrl(): String {
|
||||
// 1) Prefer a global JS variable (injected by main.kt via AppConfig)
|
||||
val fromGlobal = try {
|
||||
(globalScope.API_BASE_URL as? String)?.trim().orEmpty()
|
||||
} catch (_: dynamic) {
|
||||
""
|
||||
}
|
||||
if (fromGlobal.isNotEmpty()) {
|
||||
console.log("[PlatformConfig] Resolved API_BASE_URL from global: $fromGlobal")
|
||||
return fromGlobal.removeSuffix("/")
|
||||
}
|
||||
// 2) Try window location origin (same origin gateway/proxy setup)
|
||||
val origin = try {
|
||||
window.location.origin
|
||||
} catch (_: dynamic) {
|
||||
null
|
||||
}
|
||||
if (!origin.isNullOrBlank()) {
|
||||
val resolvedUrl = origin.removeSuffix("/") + "/api"
|
||||
console.log("[PlatformConfig] Resolved API_BASE_URL from window.location.origin: $resolvedUrl")
|
||||
return resolvedUrl
|
||||
}
|
||||
// 3) Fallback to the local gateway directly (e.g., for tests without a window)
|
||||
val fallbackUrl = "http://localhost:8081/api"
|
||||
console.log("[PlatformConfig] Fallback API_BASE_URL: $fallbackUrl")
|
||||
return fallbackUrl
|
||||
}
|
||||
|
||||
actual fun resolveMailServiceUrl(): String {
|
||||
val fromGlobal = try {
|
||||
(globalScope.MAIL_SERVICE_URL as? String)?.trim().orEmpty()
|
||||
} catch (_: dynamic) {
|
||||
""
|
||||
}
|
||||
if (fromGlobal.isNotEmpty()) {
|
||||
return fromGlobal.removeSuffix("/")
|
||||
}
|
||||
return "http://localhost:8085"
|
||||
}
|
||||
|
||||
actual fun resolveKeycloakUrl(): String {
|
||||
// 1) Prefer a global JS variable (injected by main.kt via AppConfig)
|
||||
val fromGlobal = try {
|
||||
(globalScope.KEYCLOAK_URL as? String)?.trim().orEmpty()
|
||||
} catch (_: dynamic) {
|
||||
""
|
||||
}
|
||||
if (fromGlobal.isNotEmpty()) {
|
||||
console.log("[PlatformConfig] Resolved KEYCLOAK_URL from global: $fromGlobal")
|
||||
return fromGlobal.removeSuffix("/")
|
||||
}
|
||||
// 2) Derive from window.location.hostname with default Keycloak port
|
||||
val hostname = try {
|
||||
window.location.hostname
|
||||
} catch (_: dynamic) {
|
||||
null
|
||||
}
|
||||
if (!hostname.isNullOrBlank()) {
|
||||
val resolvedUrl = "http://$hostname:8180"
|
||||
console.log("[PlatformConfig] Resolved KEYCLOAK_URL from window.location.hostname: $resolvedUrl")
|
||||
return resolvedUrl
|
||||
}
|
||||
// 3) Fallback for local development
|
||||
val fallbackUrl = "http://localhost:8180"
|
||||
console.log("[PlatformConfig] Fallback KEYCLOAK_URL: $fallbackUrl")
|
||||
return fallbackUrl
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package at.mocode.frontend.core.network.discovery
|
||||
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.dsl.module
|
||||
|
||||
/**
|
||||
* JS-spezifische Implementierung (vorerst No-op, da mDNS im Browser nicht nativ möglich).
|
||||
*/
|
||||
actual val discoveryModule: Module = module {
|
||||
single<NetworkDiscoveryService> { NoOpDiscoveryService() }
|
||||
}
|
||||
|
||||
class NoOpDiscoveryService : NetworkDiscoveryService {
|
||||
override fun startDiscovery() {}
|
||||
override fun stopDiscovery() {}
|
||||
override fun registerService(port: Int) {}
|
||||
override fun getDiscoveredServices(): List<DiscoveredService> = emptyList()
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package at.mocode.frontend.core.network.sync
|
||||
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.dsl.module
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
|
||||
/**
|
||||
* JS-spezifische Implementierung (vorerst No-op).
|
||||
*/
|
||||
actual val syncModule: Module = module {
|
||||
single<P2pSyncService> { NoOpP2pSyncService() }
|
||||
single { SyncManager(get(), get()) }
|
||||
}
|
||||
|
||||
class NoOpP2pSyncService : P2pSyncService {
|
||||
override fun startServer(port: Int) {}
|
||||
override fun stopServer() {}
|
||||
override suspend fun connectToPeer(host: String, port: Int) {}
|
||||
override suspend fun broadcastEvent(event: SyncEvent) {}
|
||||
override val incomingEvents: Flow<SyncEvent> = emptyFlow()
|
||||
override val connectedPeers: Flow<List<String>> = emptyFlow()
|
||||
}
|
||||
+5
@@ -1,5 +1,8 @@
|
||||
package at.mocode.frontend.core.network.discovery
|
||||
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.dsl.module
|
||||
|
||||
@@ -11,6 +14,8 @@ actual val discoveryModule: Module = module {
|
||||
}
|
||||
|
||||
class NoOpDiscoveryService : NetworkDiscoveryService {
|
||||
override val discoveredServices: StateFlow<List<DiscoveredService>> =
|
||||
MutableStateFlow<List<DiscoveredService>>(emptyList()).asStateFlow()
|
||||
override fun startDiscovery() {}
|
||||
override fun stopDiscovery() {}
|
||||
override fun registerService(port: Int) {}
|
||||
|
||||
@@ -10,15 +10,6 @@ plugins {
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
@@ -32,7 +23,7 @@ kotlin {
|
||||
commonMain.dependencies {
|
||||
// Correct dependency: Syncable interface is in shared core domain
|
||||
implementation(projects.core.coreDomain)
|
||||
// Also include frontend domain if needed (e.g. for frontend specific models)
|
||||
// Also include frontend domain if needed (e.g., for frontend-specific models)
|
||||
implementation(projects.frontend.core.domain)
|
||||
|
||||
// Networking
|
||||
|
||||
@@ -18,15 +18,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
@file:OptIn(ExperimentalWasmDsl::class)
|
||||
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
|
||||
/**
|
||||
* Dieses Modul kapselt die Geräte-Initialisierung (Onboarding).
|
||||
*/
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.composeMultiplatform)
|
||||
alias(libs.plugins.composeCompiler)
|
||||
alias(libs.plugins.kotlinSerialization)
|
||||
}
|
||||
|
||||
group = "at.mocode.clients"
|
||||
version = "1.0.0"
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
implementation(projects.frontend.core.designSystem)
|
||||
implementation(projects.frontend.core.auth)
|
||||
implementation(projects.frontend.core.domain)
|
||||
implementation(projects.frontend.core.network)
|
||||
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.materialIconsExtended)
|
||||
|
||||
implementation(libs.bundles.kmp.common)
|
||||
implementation(libs.bundles.compose.common)
|
||||
|
||||
implementation(libs.koin.core)
|
||||
implementation(libs.koin.compose)
|
||||
}
|
||||
|
||||
jvmMain.dependencies {
|
||||
implementation(compose.uiTooling)
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.di
|
||||
|
||||
import at.mocode.frontend.features.deviceinitialization.presentation.DeviceInitializationViewModel
|
||||
import org.koin.dsl.module
|
||||
|
||||
val deviceInitializationModule = module {
|
||||
factory { (onComplete: (at.mocode.frontend.features.deviceinitialization.domain.DeviceInitializationSettings) -> Unit) ->
|
||||
DeviceInitializationViewModel(get(), onComplete)
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.domain
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class NetworkRole {
|
||||
MASTER,
|
||||
CLIENT,
|
||||
RICHTER,
|
||||
ZEITNEHMER,
|
||||
STALLMEISTER,
|
||||
ANZEIGE,
|
||||
PARCOURS_CHEF
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ExpectedClient(
|
||||
val name: String,
|
||||
val role: NetworkRole,
|
||||
val isOnline: Boolean = false,
|
||||
val isSynchronized: Boolean = true
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class DeviceInitializationSettings(
|
||||
val deviceName: String = "",
|
||||
val sharedKey: String = "",
|
||||
val backupPath: String = "",
|
||||
val networkRole: NetworkRole = NetworkRole.CLIENT,
|
||||
val expectedClients: List<ExpectedClient> = emptyList(),
|
||||
val syncInterval: Int = 30, // in Minuten
|
||||
val defaultPrinter: String = ""
|
||||
) {
|
||||
val isConfigured: Boolean get() = deviceName.isNotBlank() && sharedKey.isNotBlank()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.domain
|
||||
|
||||
expect object DeviceInitializationSettingsManager {
|
||||
fun saveSettings(settings: DeviceInitializationSettings)
|
||||
fun loadSettings(): DeviceInitializationSettings?
|
||||
fun isConfigured(): Boolean
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.domain
|
||||
|
||||
/**
|
||||
* Validierungslogik für den Geräte-Initialisierungs-Wizard.
|
||||
*/
|
||||
object DeviceInitializationValidator {
|
||||
|
||||
/** Mindestlänge für den Gerätenamen. */
|
||||
const val MIN_NAME_LENGTH = 3
|
||||
|
||||
/** Mindestlänge für den Sicherheitsschlüssel. */
|
||||
const val MIN_KEY_LENGTH = 8
|
||||
|
||||
/** Gibt `true` zurück, wenn der Gerätename gültig ist. */
|
||||
fun isNameValid(name: String): Boolean = name.trim().length >= MIN_NAME_LENGTH
|
||||
|
||||
/** Gibt `true` zurück, wenn der Sicherheitsschlüssel gültig ist. */
|
||||
fun isKeyValid(key: String): Boolean = key.trim().length >= MIN_KEY_LENGTH
|
||||
|
||||
/** Gibt `true` zurück, wenn der Backup-Pfad gültig ist. */
|
||||
fun isBackupPathValid(path: String): Boolean = path.isNotBlank()
|
||||
|
||||
/** Gibt `true` zurück, wenn das Sync-Intervall gültig ist. */
|
||||
fun isSyncIntervalValid(interval: Int): Boolean = interval in 1..60
|
||||
|
||||
/**
|
||||
* Gibt `true` zurück, wenn alle Pflichtfelder gültig sind.
|
||||
*/
|
||||
fun canContinue(settings: DeviceInitializationSettings): Boolean {
|
||||
val basicValid = isNameValid(settings.deviceName) &&
|
||||
isKeyValid(settings.sharedKey) &&
|
||||
(if (settings.networkRole == NetworkRole.MASTER) isBackupPathValid(settings.backupPath) else true) &&
|
||||
isSyncIntervalValid(settings.syncInterval)
|
||||
|
||||
if (!basicValid) return false
|
||||
|
||||
// Falls Master, müssen alle erwarteten Clients einen Namen haben
|
||||
if (settings.networkRole == NetworkRole.MASTER) {
|
||||
return settings.expectedClients.all { it.name.trim().isNotEmpty() }
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.presentation
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
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.features.deviceinitialization.domain.DeviceInitializationValidator
|
||||
|
||||
@Composable
|
||||
fun DeviceInitializationScreen(
|
||||
viewModel: DeviceInitializationViewModel
|
||||
) {
|
||||
val uiState by viewModel.uiState.collectAsState()
|
||||
|
||||
// Automatische Discovery starten, wenn wir auf Schritt 0 sind
|
||||
LaunchedEffect(uiState.currentStep) {
|
||||
if (uiState.currentStep == 0) viewModel.startDiscovery()
|
||||
}
|
||||
|
||||
Surface(color = MaterialTheme.colorScheme.background) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(24.dp).verticalScroll(rememberScrollState()),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Text(
|
||||
"Willkommen bei der Meldestelle",
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
Text(
|
||||
if (uiState.currentStep == 0) "Schritt 1: Netzwerk-Rolle festlegen" else "Schritt 2: Rollenspezifische Konfiguration",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
|
||||
if (uiState.currentStep == 0) {
|
||||
// PHASE 1: NETZWERK-ROLLE
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
Text("🌐 Netzwerk-Rolle wählen", style = MaterialTheme.typography.titleMedium)
|
||||
Text(
|
||||
"Wähle aus, ob dieses Gerät als Master (zentrale Datenbank) oder als Client fungiert.",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
|
||||
NetworkRoleSelector(
|
||||
selectedRole = uiState.settings.networkRole,
|
||||
onRoleSelected = { viewModel.setNetworkRole(it) }
|
||||
)
|
||||
|
||||
Button(
|
||||
onClick = { viewModel.nextStep() },
|
||||
modifier = Modifier.align(Alignment.End)
|
||||
) {
|
||||
Text("Weiter")
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowForward, contentDescription = null)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// PHASE 2: ROLLENSPEZIFISCH (JVM spezifische Implementierung folgt)
|
||||
DeviceInitializationConfig(
|
||||
uiState = uiState,
|
||||
viewModel = viewModel
|
||||
)
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
TextButton(onClick = { viewModel.previousStep() }) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Zurück zur Rollenauswahl")
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { viewModel.completeInitialization() },
|
||||
enabled = DeviceInitializationValidator.canContinue(uiState.settings)
|
||||
) {
|
||||
Text("Konfiguration abschließen")
|
||||
Icon(Icons.Default.Check, null, Modifier.padding(start = 8.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
expect fun DeviceInitializationConfig(
|
||||
uiState: DeviceInitializationUiState,
|
||||
viewModel: DeviceInitializationViewModel
|
||||
)
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.presentation
|
||||
|
||||
import at.mocode.frontend.core.network.discovery.DiscoveredService
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.DeviceInitializationSettings
|
||||
|
||||
data class DeviceInitializationUiState(
|
||||
val currentStep: Int = 0,
|
||||
val settings: DeviceInitializationSettings = DeviceInitializationSettings(),
|
||||
val discoveredMasters: List<DiscoveredService> = emptyList(),
|
||||
val isProcessing: Boolean = false,
|
||||
val error: String? = null
|
||||
)
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.presentation
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import at.mocode.frontend.core.network.discovery.NetworkDiscoveryService
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.DeviceInitializationSettings
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.ExpectedClient
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.NetworkRole
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class DeviceInitializationViewModel(
|
||||
private val discoveryService: NetworkDiscoveryService,
|
||||
private val onInitializationComplete: (DeviceInitializationSettings) -> Unit
|
||||
) : ViewModel() {
|
||||
private val _uiState = MutableStateFlow(DeviceInitializationUiState())
|
||||
val uiState: StateFlow<DeviceInitializationUiState> = _uiState.asStateFlow()
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
discoveryService.discoveredServices.collect { services ->
|
||||
_uiState.update { it.copy(discoveredMasters = services) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun startDiscovery() {
|
||||
discoveryService.startDiscovery()
|
||||
}
|
||||
|
||||
fun nextStep() {
|
||||
_uiState.update { it.copy(currentStep = it.currentStep + 1) }
|
||||
}
|
||||
|
||||
fun previousStep() {
|
||||
_uiState.update { it.copy(currentStep = (it.currentStep - 1).coerceAtLeast(0)) }
|
||||
}
|
||||
|
||||
fun updateSettings(update: (DeviceInitializationSettings) -> DeviceInitializationSettings) {
|
||||
_uiState.update { it.copy(settings = update(it.settings)) }
|
||||
}
|
||||
|
||||
fun setNetworkRole(role: NetworkRole) {
|
||||
updateSettings { it.copy(networkRole = role) }
|
||||
}
|
||||
|
||||
fun addExpectedClient(name: String, role: NetworkRole) {
|
||||
updateSettings {
|
||||
it.copy(expectedClients = it.expectedClients + ExpectedClient(name, role))
|
||||
}
|
||||
}
|
||||
|
||||
fun removeExpectedClient(index: Int) {
|
||||
updateSettings {
|
||||
val newList = it.expectedClients.toMutableList().apply { removeAt(index) }
|
||||
it.copy(expectedClients = newList)
|
||||
}
|
||||
}
|
||||
|
||||
fun completeInitialization() {
|
||||
onInitializationComplete(_uiState.value.settings)
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.presentation
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.RadioButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.NetworkRole
|
||||
|
||||
@Composable
|
||||
fun NetworkRoleSelector(
|
||||
selectedRole: NetworkRole,
|
||||
onRoleSelected: (NetworkRole) -> Unit
|
||||
) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
NetworkRoleCard(
|
||||
title = "Master (Host)",
|
||||
description = "Verwaltet die zentrale Datenbank und koordiniert den Sync.",
|
||||
isSelected = selectedRole == NetworkRole.MASTER,
|
||||
onClick = { onRoleSelected(NetworkRole.MASTER) }
|
||||
)
|
||||
|
||||
NetworkRoleCard(
|
||||
title = "Client",
|
||||
description = "Verbindet sich mit einem Master-Gerät im lokalen Netzwerk.",
|
||||
isSelected = selectedRole == NetworkRole.CLIENT,
|
||||
onClick = { onRoleSelected(NetworkRole.CLIENT) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun NetworkRoleCard(
|
||||
title: String,
|
||||
description: String,
|
||||
isSelected: Boolean,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
color = if (isSelected) MaterialTheme.colorScheme.primaryContainer else MaterialTheme.colorScheme.surfaceVariant,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Row(Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
RadioButton(
|
||||
selected = isSelected,
|
||||
onClick = onClick
|
||||
)
|
||||
Column {
|
||||
Text(title, style = MaterialTheme.typography.labelLarge)
|
||||
Text(
|
||||
description,
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.domain
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.io.File
|
||||
|
||||
actual object DeviceInitializationSettingsManager {
|
||||
private val settingsFile = File("settings.json")
|
||||
private val json = Json { prettyPrint = true; ignoreUnknownKeys = true }
|
||||
|
||||
actual fun saveSettings(settings: DeviceInitializationSettings) {
|
||||
try {
|
||||
val content = json.encodeToString(settings)
|
||||
settingsFile.writeText(content)
|
||||
} catch (e: Exception) {
|
||||
println("Fehler beim Speichern der Einstellungen: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
actual fun loadSettings(): DeviceInitializationSettings? {
|
||||
if (!settingsFile.exists()) return null
|
||||
return try {
|
||||
val content = settingsFile.readText()
|
||||
json.decodeFromString<DeviceInitializationSettings>(content)
|
||||
} catch (e: Exception) {
|
||||
println("Fehler beim Laden der Einstellungen: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
actual fun isConfigured(): Boolean {
|
||||
val settings = loadSettings() ?: return false
|
||||
return DeviceInitializationValidator.canContinue(settings)
|
||||
}
|
||||
}
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.presentation
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.outlined.FolderOpen
|
||||
import androidx.compose.material.icons.outlined.Visibility
|
||||
import androidx.compose.material.icons.outlined.VisibilityOff
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.compose.ui.unit.dp
|
||||
import at.mocode.frontend.core.designsystem.components.MsEnumDropdown
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.DeviceInitializationValidator
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.NetworkRole
|
||||
import java.io.File
|
||||
import javax.swing.JFileChooser
|
||||
import javax.swing.UIManager
|
||||
|
||||
@Composable
|
||||
actual fun DeviceInitializationConfig(
|
||||
uiState: DeviceInitializationUiState,
|
||||
viewModel: DeviceInitializationViewModel
|
||||
) {
|
||||
val settings = uiState.settings
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
Text("⚙️ Geräte-Konfiguration (${settings.networkRole})", style = MaterialTheme.typography.titleMedium)
|
||||
|
||||
MsSettingsField(
|
||||
value = settings.deviceName,
|
||||
onValueChange = { viewModel.updateSettings { s -> s.copy(deviceName = it) } },
|
||||
label = "Gerätename",
|
||||
placeholder = "z.B. Meldestelle-PC-1",
|
||||
isError = settings.deviceName.isNotEmpty() && !DeviceInitializationValidator.isNameValid(settings.deviceName),
|
||||
errorText = "Mindestens ${DeviceInitializationValidator.MIN_NAME_LENGTH} Zeichen erforderlich."
|
||||
)
|
||||
|
||||
var passwordVisible by remember { mutableStateOf(false) }
|
||||
MsSettingsField(
|
||||
value = settings.sharedKey,
|
||||
onValueChange = { viewModel.updateSettings { s -> s.copy(sharedKey = it) } },
|
||||
label = "Sicherheitsschlüssel (Sync-Key)",
|
||||
placeholder = "Mindestens 8 Zeichen",
|
||||
isError = settings.sharedKey.isNotEmpty() && !DeviceInitializationValidator.isKeyValid(settings.sharedKey),
|
||||
errorText = "Mindestens ${DeviceInitializationValidator.MIN_KEY_LENGTH} Zeichen erforderlich.",
|
||||
visualTransformation = if (passwordVisible) VisualTransformation.None else PasswordVisualTransformation(),
|
||||
trailingIcon = {
|
||||
IconButton(onClick = { passwordVisible = !passwordVisible }) {
|
||||
Icon(
|
||||
imageVector = if (passwordVisible) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility,
|
||||
contentDescription = if (passwordVisible) "Verbergen" else "Anzeigen"
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (settings.networkRole == NetworkRole.MASTER) {
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
Text("👥 Erwartete Clients (Richter, Zeitnehmer, etc.)", style = MaterialTheme.typography.titleSmall)
|
||||
Text(
|
||||
"Definiere, welche Geräte sich mit diesem Master synchronisieren dürfen.",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
settings.expectedClients.forEachIndexed { index, client ->
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
Text(
|
||||
client.name,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
SuggestionChip(
|
||||
onClick = {},
|
||||
label = { Text(client.role.name) },
|
||||
colors = SuggestionChipDefaults.suggestionChipColors(
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||
labelColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
supportingContent = {
|
||||
Text(
|
||||
if (client.isOnline) "Verbunden" else "Offline",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = if (client.isOnline) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
},
|
||||
trailingContent = {
|
||||
IconButton(onClick = { viewModel.removeExpectedClient(index) }) {
|
||||
Icon(
|
||||
Icons.Default.Delete,
|
||||
contentDescription = "Löschen",
|
||||
tint = MaterialTheme.colorScheme.error,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
},
|
||||
colors = ListItemDefaults.colors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f)
|
||||
),
|
||||
modifier = Modifier.padding(vertical = 4.dp)
|
||||
)
|
||||
}
|
||||
|
||||
var newClientName by remember { mutableStateOf("") }
|
||||
var newClientRole by remember { mutableStateOf(NetworkRole.RICHTER) }
|
||||
var showAddClient by remember { mutableStateOf(false) }
|
||||
|
||||
if (showAddClient) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = newClientName,
|
||||
onValueChange = { newClientName = it },
|
||||
label = { Text("Gerätename des Clients") },
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
|
||||
MsEnumDropdown(
|
||||
label = "Rolle",
|
||||
options = NetworkRole.entries.filter { it != NetworkRole.MASTER }.toTypedArray(),
|
||||
selectedOption = newClientRole,
|
||||
onOptionSelected = { newClientRole = it },
|
||||
modifier = Modifier.weight(0.5f)
|
||||
)
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
if (newClientName.isNotBlank()) {
|
||||
viewModel.addExpectedClient(newClientName, newClientRole)
|
||||
newClientName = ""
|
||||
showAddClient = false
|
||||
}
|
||||
},
|
||||
enabled = newClientName.isNotBlank()
|
||||
) {
|
||||
Icon(Icons.Default.Add, null)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TextButton(onClick = { showAddClient = true }) {
|
||||
Icon(Icons.Default.Add, null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Client hinzufügen")
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
OutlinedTextField(
|
||||
value = settings.backupPath,
|
||||
onValueChange = { viewModel.updateSettings { s -> s.copy(backupPath = it) } },
|
||||
label = { Text("Backup-Verzeichnis (Pfad)") },
|
||||
placeholder = { Text("/pfad/zu/den/backups") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
trailingIcon = {
|
||||
IconButton(onClick = {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
|
||||
val chooser = JFileChooser().apply {
|
||||
fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
|
||||
dialogTitle = "Backup-Verzeichnis wählen"
|
||||
if (settings.backupPath.isNotEmpty()) {
|
||||
val currentDir = File(settings.backupPath)
|
||||
if (currentDir.exists()) currentDirectory = currentDir
|
||||
}
|
||||
}
|
||||
val result = chooser.showOpenDialog(null)
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
viewModel.updateSettings { s -> s.copy(backupPath = chooser.selectedFile.absolutePath) }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("[Error] Fehler beim Öffnen des Verzeichnis-Wählers: ${e.message}")
|
||||
}
|
||||
}) {
|
||||
Icon(Icons.Outlined.FolderOpen, contentDescription = "Verzeichnis wählen")
|
||||
}
|
||||
},
|
||||
isError = settings.backupPath.isNotEmpty() && !DeviceInitializationValidator.isBackupPathValid(settings.backupPath)
|
||||
)
|
||||
|
||||
Text("Sync-Intervall: ${settings.syncInterval} Min.", style = MaterialTheme.typography.labelMedium)
|
||||
Slider(
|
||||
value = settings.syncInterval.toFloat(),
|
||||
onValueChange = { viewModel.updateSettings { s -> s.copy(syncInterval = it.toInt()) } },
|
||||
valueRange = 1f..60f,
|
||||
steps = 59
|
||||
)
|
||||
} else {
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
Text("🔍 Verfügbare Master im Netzwerk", style = MaterialTheme.typography.titleSmall)
|
||||
|
||||
if (uiState.discoveredMasters.isEmpty()) {
|
||||
Box(Modifier.fillMaxWidth().padding(16.dp), contentAlignment = Alignment.Center) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(24.dp))
|
||||
Text("Suche nach Master...", modifier = Modifier.padding(start = 40.dp))
|
||||
}
|
||||
}
|
||||
|
||||
uiState.discoveredMasters.forEach { service ->
|
||||
ListItem(
|
||||
headlineContent = { Text(service.name) },
|
||||
supportingContent = { Text("${service.host}:${service.port}") },
|
||||
trailingContent = {
|
||||
Button(onClick = {
|
||||
viewModel.updateSettings { s -> s.copy(sharedKey = service.metadata["key"] ?: s.sharedKey) }
|
||||
}) {
|
||||
Text("Verbinden")
|
||||
}
|
||||
},
|
||||
colors = ListItemDefaults.colors(containerColor = MaterialTheme.colorScheme.primaryContainer)
|
||||
)
|
||||
}
|
||||
|
||||
Text(
|
||||
"Hinweis: Als Client wird dieses Gerät automatisch versuchen, den Master im Netzwerk zu finden.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MsSettingsField(
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
label: String,
|
||||
placeholder: String,
|
||||
isError: Boolean,
|
||||
errorText: String,
|
||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||
trailingIcon: @Composable (() -> Unit)? = null
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
label = { Text(label) },
|
||||
placeholder = { Text(placeholder) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
isError = isError,
|
||||
visualTransformation = visualTransformation,
|
||||
trailingIcon = trailingIcon,
|
||||
supportingText = {
|
||||
if (isError) {
|
||||
Text(errorText)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.domain
|
||||
|
||||
actual object DeviceInitializationSettingsManager {
|
||||
actual fun saveSettings(settings: DeviceInitializationSettings) {
|
||||
// Nicht implementiert für WasmJS
|
||||
}
|
||||
|
||||
actual fun loadSettings(): DeviceInitializationSettings? = null
|
||||
|
||||
actual fun isConfigured(): Boolean = false
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package at.mocode.frontend.features.deviceinitialization.presentation
|
||||
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun DeviceInitializationConfig(
|
||||
uiState: DeviceInitializationUiState,
|
||||
viewModel: DeviceInitializationViewModel
|
||||
) {
|
||||
Text("Konfiguration für Web (WasmJS) ist nicht implementiert.")
|
||||
}
|
||||
@@ -17,15 +17,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -19,15 +19,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -17,15 +17,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -18,15 +18,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
@@ -78,8 +69,5 @@ kotlin {
|
||||
implementation(compose.uiTooling)
|
||||
}
|
||||
|
||||
jsMain.dependencies {
|
||||
implementation(libs.ktor.client.js)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -15,15 +15,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -17,15 +17,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package at.mocode.turnier.feature.di
|
||||
|
||||
import org.koin.dsl.module
|
||||
|
||||
actual val turnierFeatureModule = module {
|
||||
// No-op or minimal for JS/Web
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
|
||||
/**
|
||||
* Feature-Modul: Veranstalter-Verwaltung (Desktop-only)
|
||||
* Kapselt alle Screens und Logik für Veranstalter-Auswahl, -Detail und -Neuanlage.
|
||||
* kapselt alle Screens und Logik für Veranstalter-Auswahl, -Detail und -Neuanlage.
|
||||
*/
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
@@ -16,15 +16,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -16,15 +16,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -17,15 +17,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
|
||||
/**
|
||||
* Feature-Modul: ZNS-Stammdaten-Import (Desktop-only)
|
||||
* Kapselt ViewModel, State, API-Kommunikation und UI-Screen für den ZNS-Import.
|
||||
* kapselt ViewModel, State, API-Kommunikation und UI-Screen für den ZNS-Import.
|
||||
*/
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
@@ -18,15 +18,6 @@ version = "1.0.0"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
||||
@@ -10,13 +10,13 @@ import java.util.*
|
||||
* Setzt alle Core- und Feature-Module zu einer lauffähigen Desktop-Anwendung zusammen.
|
||||
*
|
||||
* Packaging:
|
||||
* ./gradlew :frontend:shells:meldestelle-desktop:packageDeb → Linux .deb
|
||||
* ./gradlew :frontend:shells:meldestelle-desktop:packageMsi → Windows .msi
|
||||
* ./gradlew :frontend:shells:meldestelle-desktop:packageDmg → macOS .dmg
|
||||
* ./gradlew :frontend:shells:meldestelle-desktop:packageDeb → Linux .deb
|
||||
* ./gradlew :frontend:shells:meldestelle-desktop:packageMsi → Windows .msi
|
||||
* ./gradlew :frontend:shells:meldestelle-desktop:packageDmg → macOS .dmg
|
||||
* ./gradlew :frontend:shells:meldestelle-desktop:packageReleaseDistributables → alle Plattformen
|
||||
*
|
||||
* Version: wird automatisch aus version.properties im Root-Projekt gelesen (SemVer).
|
||||
* Icons: src/jvmMain/resources/icon.png / icon.ico / icon.icns
|
||||
* Version: Wird automatisch aus version.properties im Root-Projekt gelesen (SemVer).
|
||||
* Icons: src/jvmMain/resources/icon.png / icon.ico / icon.icns
|
||||
* → siehe ICONS_PLACEHOLDER.md für Anforderungen
|
||||
*/
|
||||
plugins {
|
||||
@@ -42,15 +42,6 @@ val packageVer = "$vMajor.$vMinor.$vPatch"
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
binaries.library()
|
||||
browser {
|
||||
@@ -86,6 +77,7 @@ kotlin {
|
||||
implementation(projects.frontend.features.vereinFeature)
|
||||
implementation(projects.frontend.features.turnierFeature)
|
||||
implementation(projects.frontend.features.billingFeature)
|
||||
implementation(projects.frontend.features.deviceInitialization)
|
||||
|
||||
// Compose Desktop
|
||||
implementation(compose.desktop.currentOs)
|
||||
|
||||
+2
-2
@@ -10,12 +10,12 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import at.mocode.desktop.navigation.DesktopNavigationPort
|
||||
import at.mocode.desktop.screens.layout.DesktopMainLayout
|
||||
import at.mocode.desktop.screens.onboarding.SettingsManager
|
||||
import at.mocode.frontend.core.auth.data.AuthTokenManager
|
||||
import at.mocode.frontend.core.auth.presentation.LoginScreen
|
||||
import at.mocode.frontend.core.auth.presentation.LoginViewModel
|
||||
import at.mocode.frontend.core.designsystem.theme.AppTheme
|
||||
import at.mocode.frontend.core.navigation.AppScreen
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.DeviceInitializationSettingsManager
|
||||
import org.koin.compose.koinInject
|
||||
import org.koin.compose.viewmodel.koinViewModel
|
||||
|
||||
@@ -37,7 +37,7 @@ fun DesktopApp() {
|
||||
|
||||
// DeviceInitialization-Check beim Start
|
||||
LaunchedEffect(Unit) {
|
||||
if (!SettingsManager.isConfigured()) {
|
||||
if (!DeviceInitializationSettingsManager.isConfigured()) {
|
||||
nav.navigateToScreen(AppScreen.DeviceInitialization)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import at.mocode.frontend.core.localdb.localDbModule
|
||||
import at.mocode.frontend.core.network.networkModule
|
||||
import at.mocode.frontend.core.sync.di.syncModule
|
||||
import at.mocode.frontend.features.billing.di.billingModule
|
||||
import at.mocode.frontend.features.deviceinitialization.di.deviceInitializationModule
|
||||
import at.mocode.frontend.features.nennung.di.nennungFeatureModule
|
||||
import at.mocode.frontend.features.pferde.di.pferdeModule
|
||||
import at.mocode.frontend.features.profile.di.profileModule
|
||||
@@ -43,6 +44,7 @@ fun main() = application {
|
||||
reiterModule,
|
||||
vereinFeatureModule,
|
||||
turnierFeatureModule,
|
||||
deviceInitializationModule,
|
||||
desktopModule,
|
||||
)
|
||||
}
|
||||
|
||||
+21
-16
@@ -24,9 +24,6 @@ import at.mocode.desktop.screens.management.VeranstalterAuswahl
|
||||
import at.mocode.desktop.screens.management.VeranstalterDetail
|
||||
import at.mocode.desktop.screens.management.VeranstalterVerwaltungScreen
|
||||
import at.mocode.desktop.screens.nennung.NennungsEingangScreen
|
||||
import at.mocode.desktop.screens.onboarding.OnboardingScreen
|
||||
import at.mocode.desktop.screens.onboarding.OnboardingSettings
|
||||
import at.mocode.desktop.screens.onboarding.SettingsManager
|
||||
import at.mocode.desktop.screens.profile.FunktionaerProfil
|
||||
import at.mocode.desktop.screens.veranstaltung.*
|
||||
import at.mocode.frontend.core.designsystem.theme.AppColors
|
||||
@@ -37,6 +34,10 @@ import at.mocode.frontend.core.network.ConnectivityTracker
|
||||
import at.mocode.frontend.core.network.discovery.NetworkDiscoveryService
|
||||
import at.mocode.frontend.features.billing.presentation.BillingScreen
|
||||
import at.mocode.frontend.features.billing.presentation.BillingViewModel
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.DeviceInitializationSettings
|
||||
import at.mocode.frontend.features.deviceinitialization.domain.DeviceInitializationSettingsManager
|
||||
import at.mocode.frontend.features.deviceinitialization.presentation.DeviceInitializationScreen
|
||||
import at.mocode.frontend.features.deviceinitialization.presentation.DeviceInitializationViewModel
|
||||
import at.mocode.frontend.features.nennung.presentation.NennungViewModel
|
||||
import at.mocode.frontend.features.nennung.presentation.NennungsMaske
|
||||
import at.mocode.frontend.features.pferde.presentation.PferdeScreen
|
||||
@@ -79,7 +80,11 @@ fun DesktopMainLayout(
|
||||
) {
|
||||
println("[Navigation] Rendering Screen: ${currentScreen::class.simpleName} (Details: $currentScreen)")
|
||||
// DeviceInitialization-Daten (On-the-fly geladen oder Default)
|
||||
var onboardingSettings by remember { mutableStateOf(SettingsManager.loadSettings() ?: OnboardingSettings()) }
|
||||
var onboardingSettings by remember {
|
||||
mutableStateOf(
|
||||
DeviceInitializationSettingsManager.loadSettings() ?: DeviceInitializationSettings()
|
||||
)
|
||||
}
|
||||
|
||||
// Automatische Umleitung zum DeviceInitialization, wenn Setup fehlt (außer wir sind bereits dort)
|
||||
LaunchedEffect(onboardingSettings) {
|
||||
@@ -111,7 +116,7 @@ fun DesktopMainLayout(
|
||||
onBack = onBack,
|
||||
onSettingsChange = {
|
||||
onboardingSettings = it
|
||||
SettingsManager.saveSettings(it)
|
||||
DeviceInitializationSettingsManager.saveSettings(it)
|
||||
},
|
||||
settings = onboardingSettings,
|
||||
)
|
||||
@@ -518,25 +523,25 @@ private fun DesktopContentArea(
|
||||
currentScreen: AppScreen,
|
||||
onNavigate: (AppScreen) -> Unit,
|
||||
onBack: () -> Unit,
|
||||
settings: OnboardingSettings,
|
||||
onSettingsChange: (OnboardingSettings) -> Unit,
|
||||
settings: DeviceInitializationSettings,
|
||||
onSettingsChange: (DeviceInitializationSettings) -> Unit,
|
||||
) {
|
||||
when (currentScreen) {
|
||||
// DeviceInitialization (Geräte-Setup)
|
||||
is AppScreen.DeviceInitialization -> {
|
||||
println("[Screen] Rendering DeviceInitialization")
|
||||
OnboardingScreen(
|
||||
settings = settings,
|
||||
onSettingsChange = onSettingsChange,
|
||||
onContinue = { finalSettings: OnboardingSettings ->
|
||||
SettingsManager.saveSettings(finalSettings)
|
||||
val viewModel = koinViewModel<DeviceInitializationViewModel> {
|
||||
org.koin.core.parameter.parametersOf({ finalSettings: DeviceInitializationSettings ->
|
||||
DeviceInitializationSettingsManager.saveSettings(finalSettings)
|
||||
// Vision_04: Sicherheitsschlüssel als Token setzen, damit Cloud-Suche funktioniert
|
||||
val authTokenManager =
|
||||
org.koin.core.context.GlobalContext.get().get<at.mocode.frontend.core.auth.data.AuthTokenManager>()
|
||||
authTokenManager.setToken(finalSettings.sharedKey)
|
||||
onSettingsChange(finalSettings)
|
||||
onNavigate(AppScreen.VeranstaltungVerwaltung)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
DeviceInitializationScreen(viewModel = viewModel)
|
||||
}
|
||||
|
||||
// Haupt-Zentrale: Veranstaltung-Verwaltung
|
||||
@@ -871,7 +876,7 @@ private fun DesktopContentArea(
|
||||
|
||||
@Composable
|
||||
private fun DesktopFooterBar(
|
||||
settings: OnboardingSettings,
|
||||
settings: DeviceInitializationSettings,
|
||||
onSetupClick: () -> Unit = {}
|
||||
) {
|
||||
val connectivityTracker = koinInject<ConnectivityTracker>()
|
||||
@@ -881,7 +886,7 @@ private fun DesktopFooterBar(
|
||||
val online by connectivityTracker.isOnline.collectAsState()
|
||||
val znsState = znsImporter.state
|
||||
val discoveredServices = remember { mutableStateOf(discoveryService.getDiscoveredServices()) }
|
||||
val deviceName = settings.geraetName.ifBlank { "Unbekannt" }
|
||||
val deviceName = settings.deviceName.ifBlank { "Unbekannt" }
|
||||
|
||||
// Periodisches Update der LAN-Geräte (mDNS)
|
||||
LaunchedEffect(Unit) {
|
||||
|
||||
@@ -15,15 +15,6 @@ kotlin {
|
||||
jvm()
|
||||
|
||||
if (isWasmEnabled) {
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmJs {
|
||||
browser {
|
||||
testTask {
|
||||
|
||||
Reference in New Issue
Block a user