v0.3.15-pre.008
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<!-- file: crates/ksp-app-raw-transaction-ingest-desk/frontend/main.html -->
|
||||
<!-- version: 4 -->
|
||||
<!-- version: 5 -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
@@ -51,18 +51,25 @@
|
||||
<div class="d-flex align-items-start justify-content-between gap-3 flex-wrap mb-4">
|
||||
<div>
|
||||
<h1 class="h3 mb-1">Routes live</h1>
|
||||
<p class="text-body-secondary mb-0">Inventaire déterministe depuis Config, sans probe réseau ni démarrage de Worker.</p>
|
||||
<p class="text-body-secondary mb-0">Inventaire Config et runtime mono-route Store + Worker avec Start/Stop backend-owned.</p>
|
||||
</div>
|
||||
<button id="refreshRouteInventory" class="btn btn-outline-primary btn-sm" type="button">
|
||||
<i class="fa-solid fa-rotate me-2" aria-hidden="true"></i>Refresh
|
||||
</button>
|
||||
</div>
|
||||
<div class="row g-3 align-items-end mb-4">
|
||||
<div class="col-12 col-md-6">
|
||||
<div class="col-12 col-md-4">
|
||||
<label class="form-label" for="routeProfile">Réseau logique</label>
|
||||
<select id="routeProfile" class="form-select" aria-label="Réseau Raw Transaction Ingest Desk"></select>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="col-12 col-md-3">
|
||||
<label class="form-label" for="routeCommitment">Commitment</label>
|
||||
<select id="routeCommitment" class="form-select" aria-label="Commitment Raw Transaction Ingest Desk">
|
||||
<option value="confirmed" selected>confirmed</option>
|
||||
<option value="finalized">finalized</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 col-md-2">
|
||||
<div class="small text-body-secondary">Réseau</div>
|
||||
<div id="routeNetwork" class="fw-semibold app-route-code">—</div>
|
||||
</div>
|
||||
@@ -72,7 +79,21 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info" role="status">
|
||||
<strong>Configured</strong> signifie uniquement que Config prouve la composabilité. Les connexions, le Store et le Worker seront revalidés au Start dans les tranches suivantes.
|
||||
<strong>Configured</strong> signifie que Config prouve la composabilité. Start revalide Config, ouvre le Store puis lance exactement un Worker. pre.008 reste volontairement mono-route.
|
||||
</div>
|
||||
<div class="card border-primary-subtle mb-4">
|
||||
<div class="card-body d-flex align-items-center justify-content-between gap-3 flex-wrap">
|
||||
<div>
|
||||
<div class="small text-body-secondary">Runtime mono-route</div>
|
||||
<div class="d-flex flex-wrap gap-2 mt-1">
|
||||
<span id="routeRuntimeState" class="badge text-bg-secondary">idle</span>
|
||||
<span id="routeRuntimeIdentity" class="app-route-code small text-body-secondary">aucun Worker actif</span>
|
||||
</div>
|
||||
</div>
|
||||
<button id="stopRoute" class="btn btn-outline-danger btn-sm" type="button" disabled>
|
||||
<i class="fa-solid fa-stop me-2" aria-hidden="true"></i>Stop
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small text-body-secondary mb-3">Réseau affiché : <span id="routeSelectedProfile" class="app-route-code">—</span></div>
|
||||
<div id="routeFoundation" class="row g-3 app-route-grid" aria-live="polite"></div>
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
// file: crates/ksp-app-raw-transaction-ingest-desk/frontend/ts/main.ts
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
import "bootstrap";
|
||||
import ResizeObserver from "resize-observer-polyfill";
|
||||
import "simplebar";
|
||||
import type { ShellStatusDto } from "./bindings/ksp_app_raw_transaction_ingest_desk/dto_common/ShellStatusDto.ts";
|
||||
import type { RawIngestCommitment } from "./bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestCommitment.ts";
|
||||
import type { RawIngestRouteId } from "./bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteId.ts";
|
||||
import type { RawIngestRouteInventoryDto } from "./bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteInventoryDto.ts";
|
||||
import type { RawIngestRouteRuntimeDto } from "./bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteRuntimeDto.ts";
|
||||
import type { RawIngestRouteStartRequestDto } from "./bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteStartRequestDto.ts";
|
||||
import { frontendDebug, frontendInfo, frontendTrace, frontendWarn, installFrontendConsoleBridge } from "./frontend_log";
|
||||
import { invokeKsp } from "./invoke";
|
||||
|
||||
@@ -19,6 +23,8 @@ const viewTitles: Record<ViewId, string> = {
|
||||
diagnostics: "Diagnostics",
|
||||
};
|
||||
|
||||
let activeRuntime: RawIngestRouteRuntimeDto | null = null;
|
||||
let lastRuntime: RawIngestRouteRuntimeDto | null = null;
|
||||
let routeInventory: RawIngestRouteInventoryDto | null = null;
|
||||
let selectedProfileId: string | null = null;
|
||||
|
||||
@@ -137,6 +143,21 @@ function renderSelectedProfile(): void {
|
||||
reason.textContent = reasonLabel(route.reason);
|
||||
meta.append(state, network, reason);
|
||||
body.append(title, code, meta);
|
||||
if (route.selectable) {
|
||||
const actions = document.createElement("div");
|
||||
actions.className = "mt-3";
|
||||
const start = document.createElement("button");
|
||||
start.className = "btn btn-primary btn-sm";
|
||||
start.type = "button";
|
||||
start.textContent = "Start";
|
||||
start.disabled = activeRuntime !== null;
|
||||
start.dataset.routeId = route.routeId;
|
||||
start.addEventListener("click", () => {
|
||||
void startRoute(route.routeId).catch(() => frontendWarn("main", "Raw Transaction Ingest Desk route Start failed"));
|
||||
});
|
||||
actions.append(start);
|
||||
body.append(actions);
|
||||
}
|
||||
card.append(body);
|
||||
column.append(card);
|
||||
routeRoot.append(column);
|
||||
@@ -149,6 +170,87 @@ function renderSelectedProfile(): void {
|
||||
});
|
||||
}
|
||||
|
||||
function selectedCommitment(): RawIngestCommitment {
|
||||
const selector = document.querySelector<HTMLSelectElement>("#routeCommitment");
|
||||
return selector?.value === "finalized" ? "finalized" : "confirmed";
|
||||
}
|
||||
|
||||
function runtimeIsActive(runtime: RawIngestRouteRuntimeDto): boolean {
|
||||
return runtime.state === "starting" || runtime.state === "running" || runtime.state === "stopping";
|
||||
}
|
||||
|
||||
function renderMonoRouteRuntime(): void {
|
||||
const projected = activeRuntime ?? lastRuntime;
|
||||
const state = document.querySelector<HTMLElement>("#routeRuntimeState");
|
||||
if (state) {
|
||||
state.textContent = projected?.state ?? "idle";
|
||||
state.className = projected?.state === "faulted" ? "badge text-bg-danger" : activeRuntime ? "badge text-bg-primary" : "badge text-bg-secondary";
|
||||
}
|
||||
text(
|
||||
"#routeRuntimeIdentity",
|
||||
projected ? `${projected.profileId} / ${projected.routeId} / ${projected.commitment}` : "aucun Worker actif",
|
||||
);
|
||||
const stop = document.querySelector<HTMLButtonElement>("#stopRoute");
|
||||
if (stop) {
|
||||
stop.disabled = activeRuntime === null || activeRuntime.state === "stopping";
|
||||
}
|
||||
const profile = document.querySelector<HTMLSelectElement>("#routeProfile");
|
||||
if (profile) {
|
||||
profile.disabled = activeRuntime !== null;
|
||||
}
|
||||
const commitment = document.querySelector<HTMLSelectElement>("#routeCommitment");
|
||||
if (commitment) {
|
||||
commitment.disabled = activeRuntime !== null;
|
||||
}
|
||||
}
|
||||
|
||||
async function startRoute(routeId: RawIngestRouteId): Promise<void> {
|
||||
if (routeInventory === null || selectedProfileId === null || activeRuntime !== null) {
|
||||
return;
|
||||
}
|
||||
const request: RawIngestRouteStartRequestDto = {
|
||||
commitment: selectedCommitment(),
|
||||
inventoryGeneration: routeInventory.generation,
|
||||
profileId: selectedProfileId,
|
||||
routeId,
|
||||
};
|
||||
frontendDebug("main", "Raw Transaction Ingest Desk mono-route Start requested", {
|
||||
commitment: request.commitment,
|
||||
profileId: request.profileId,
|
||||
routeId: request.routeId,
|
||||
});
|
||||
const response = await invokeKsp<RawIngestRouteRuntimeDto>("main", "start_route", { request });
|
||||
lastRuntime = response;
|
||||
activeRuntime = runtimeIsActive(response) ? response : null;
|
||||
renderMonoRouteRuntime();
|
||||
renderSelectedProfile();
|
||||
frontendInfo("main", "Raw Transaction Ingest Desk mono-route Start acknowledged", {
|
||||
profileId: response.profileId,
|
||||
routeId: response.routeId,
|
||||
state: response.state,
|
||||
});
|
||||
}
|
||||
|
||||
async function stopRoute(): Promise<void> {
|
||||
if (activeRuntime === null) {
|
||||
return;
|
||||
}
|
||||
frontendDebug("main", "Raw Transaction Ingest Desk mono-route Stop requested", {
|
||||
profileId: activeRuntime.profileId,
|
||||
routeId: activeRuntime.routeId,
|
||||
});
|
||||
const response = await invokeKsp<RawIngestRouteRuntimeDto>("main", "stop_route");
|
||||
lastRuntime = response;
|
||||
activeRuntime = runtimeIsActive(response) ? response : null;
|
||||
renderMonoRouteRuntime();
|
||||
renderSelectedProfile();
|
||||
frontendInfo("main", "Raw Transaction Ingest Desk mono-route Stop completed", {
|
||||
profileId: response.profileId,
|
||||
routeId: response.routeId,
|
||||
state: response.state,
|
||||
});
|
||||
}
|
||||
|
||||
function renderRouteInventory(inventory: RawIngestRouteInventoryDto): void {
|
||||
routeInventory = inventory;
|
||||
const requestedProfile = selectedProfileId;
|
||||
@@ -169,6 +271,7 @@ function renderRouteInventory(inventory: RawIngestRouteInventoryDto): void {
|
||||
text("#runtimeInventoryGeneration", inventory.generation.toString());
|
||||
text("#runtimeInventoryDefaultProfile", inventory.defaultProfile);
|
||||
renderSelectedProfile();
|
||||
renderMonoRouteRuntime();
|
||||
frontendTrace("main", "Raw Transaction Ingest Desk Config route inventory rendered", {
|
||||
generation: inventory.generation,
|
||||
profileCount: inventory.profiles.length,
|
||||
@@ -220,6 +323,9 @@ function bindRefreshControls(): void {
|
||||
document.querySelector<HTMLButtonElement>("#refreshRuntimeStatus")?.addEventListener("click", () => {
|
||||
void refreshRuntimeStatus().catch(() => frontendWarn("main", "Raw Transaction Ingest Desk runtime status refresh failed"));
|
||||
});
|
||||
document.querySelector<HTMLButtonElement>("#stopRoute")?.addEventListener("click", () => {
|
||||
void stopRoute().catch(() => frontendWarn("main", "Raw Transaction Ingest Desk route Stop failed"));
|
||||
});
|
||||
document.querySelector<HTMLSelectElement>("#routeProfile")?.addEventListener("change", event => {
|
||||
const selector = event.currentTarget;
|
||||
if (!(selector instanceof HTMLSelectElement)) {
|
||||
@@ -239,7 +345,7 @@ async function initializeMain(): Promise<void> {
|
||||
activateView("routes", "startup");
|
||||
await refreshRouteInventory();
|
||||
await refreshRuntimeStatus();
|
||||
frontendInfo("main", "Raw Transaction Ingest Desk Config inventory frontend ready");
|
||||
frontendInfo("main", "Raw Transaction Ingest Desk mono-route runtime frontend ready");
|
||||
}
|
||||
|
||||
void initializeMain().catch(() => frontendWarn("main", "Raw Transaction Ingest Desk frontend initialization failed"));
|
||||
|
||||
Reference in New Issue
Block a user