v0.2.12-pre.004

This commit is contained in:
2026-08-27 10:02:46 +02:00
parent afc50c1e48
commit e7c3379f44
17 changed files with 914 additions and 70 deletions

View File

@@ -1,11 +1,12 @@
// file: crates/ksp-app-solprices-desk/frontend/ts/main.ts
// version: 3
// version: 4
import "bootstrap";
import ResizeObserver from "resize-observer-polyfill";
import "simplebar";
import { getCurrentWindow } from "@tauri-apps/api/window";
import type { RuntimeStatusDto } from "./bindings/ksp_app_solprices_desk/dto_common/RuntimeStatusDto.ts";
import type { MarketPriceRuntimeStatusDto } from "./bindings/ksp_app_solprices_desk/dto_common/MarketPriceRuntimeStatusDto.ts";
import type { MarketPriceProviderRowDto } from "./bindings/ksp_app_solprices_desk/market_price_runtime/MarketPriceProviderRowDto.ts";
import { frontendDebug, frontendInfo, frontendTrace, frontendWarn, installFrontendConsoleBridge } from "./frontend_log";
import { invokeKsp } from "./invoke";
@@ -53,13 +54,53 @@ function bindNavigation(): void {
frontendTrace("main", "SOL Prices Desk navigation handlers installed");
}
function renderRuntimeStatus(status: RuntimeStatusDto): void {
function appendMarketPriceCell(row: HTMLTableRowElement, value: string): void {
const cell = document.createElement("td");
cell.textContent = value;
row.append(cell);
}
function renderMarketPriceRows(rows: MarketPriceProviderRowDto[]): void {
const loading = document.querySelector<HTMLElement>("#pricesLoading");
const empty = document.querySelector<HTMLElement>("#pricesEmpty");
const tableContainer = document.querySelector<HTMLElement>("#pricesTableContainer");
const tableBody = document.querySelector<HTMLTableSectionElement>("#marketPriceRows");
if (loading) {
loading.hidden = true;
}
if (!tableBody || !tableContainer || !empty) {
frontendWarn("main", "SOL Prices Desk market-price table elements are missing");
return;
}
tableBody.replaceChildren();
empty.hidden = rows.length !== 0;
tableContainer.hidden = rows.length === 0;
for (const provider of rows) {
const row = document.createElement("tr");
appendMarketPriceCell(row, provider.displayName);
appendMarketPriceCell(row, provider.pair);
appendMarketPriceCell(row, provider.semantics);
appendMarketPriceCell(row, provider.authMode);
appendMarketPriceCell(row, provider.loading ? "loading" : provider.availability);
appendMarketPriceCell(row, provider.price ?? "—");
appendMarketPriceCell(row, provider.providerTimestampUnixMillis ?? "—");
appendMarketPriceCell(row, provider.receivedAtUnixMillis ?? "—");
appendMarketPriceCell(row, provider.retryAtUnixMillis ?? "—");
tableBody.append(row);
}
frontendTrace("main", "SOL Prices Desk market-price registry rows rendered", { rowCount: rows.length });
}
function renderRuntimeStatus(status: MarketPriceRuntimeStatusDto): void {
const values: Record<string, string> = {
runtimeCompositeProfile: status.activeCompositeProfile,
runtimeOffchainProfile: status.activeOffchainProfile,
runtimeVersion: status.applicationVersion,
runtimeShellPhase: status.shellPhase,
runtimeConfigDocuments: status.configDocumentCount.toString(),
runtimeProviderCount: status.providerCount.toString(),
runtimeReadyProviderCount: status.readyProviderCount.toString(),
runtimeUnavailableProviderCount: status.unavailableProviderCount.toString(),
runtimeLoggingProfile: status.activeLoggingProfile ?? "fallback",
runtimeLoggingFallback: status.fallbackLoggingActive ? "oui" : "non",
};
@@ -74,14 +115,24 @@ function renderRuntimeStatus(status: RuntimeStatusDto): void {
diagnostic.hidden = status.startupDiagnostic === null;
diagnostic.textContent = status.startupDiagnostic === null ? "" : `${status.startupDiagnostic.domain}:${status.startupDiagnostic.code}${status.startupDiagnostic.message}`;
}
frontendTrace("main", "SOL Prices Desk scaffold runtime status rendered", {
frontendTrace("main", "SOL Prices Desk market-price runtime status rendered", {
fallbackLoggingActive: status.fallbackLoggingActive,
configDocumentCount: status.configDocumentCount,
providerCount: status.providerCount,
readyProviderCount: status.readyProviderCount,
unavailableProviderCount: status.unavailableProviderCount,
});
}
async function loadMarketPrices(): Promise<void> {
frontendTrace("main", "SOL Prices Desk provider registry load started");
const rows = await invokeKsp<MarketPriceProviderRowDto[]>("main", "list_market_prices");
renderMarketPriceRows(rows);
frontendTrace("main", "SOL Prices Desk provider registry load completed", { rowCount: rows.length });
}
async function loadRuntimeStatus(): Promise<void> {
const status = await invokeKsp<RuntimeStatusDto>("main", "get_runtime_status");
const status = await invokeKsp<MarketPriceRuntimeStatusDto>("main", "get_runtime_status");
renderRuntimeStatus(status);
}
@@ -100,6 +151,20 @@ async function initializeMain(): Promise<void> {
}
frontendWarn("main", "SOL Prices Desk startup runtime status load failed");
}
try {
await loadMarketPrices();
} catch {
const loading = document.querySelector<HTMLElement>("#pricesLoading");
const diagnostic = document.querySelector<HTMLElement>("#pricesDiagnostic");
if (loading) {
loading.hidden = true;
}
if (diagnostic) {
diagnostic.hidden = false;
diagnostic.textContent = "L'inventaire provider-neutral n'a pas pu être chargé.";
}
frontendWarn("main", "SOL Prices Desk provider registry load failed");
}
}
document.addEventListener("DOMContentLoaded", () => {