This commit is contained in:
2026-04-22 08:21:49 +02:00
parent e754cb63bf
commit a9d26750fa
7 changed files with 235 additions and 59 deletions

View File

@@ -43,9 +43,14 @@
<h2 class="h5 mb-3">Connexion</h2>
<div class="mb-3">
<label for="demoWsEndpointSelect" class="form-label">Endpoint</label>
<select id="demoWsEndpointSelect" class="form-select"></select>
</div>
<label for="demoWsEndpointSelect" class="form-label">Endpoint WS activé</label>
<select id="demoWsEndpointSelect" class="form-select"></select>
<div class="form-text">
Seuls les endpoints définis dans <code>config.solana.ws_endpoints</code> et marqués
<code>enabled: true</code> apparaissent ici. Les endpoints HTTP ne sont pas utilisés
par cette fenêtre.
</div>
</div>
<div class="d-flex flex-wrap gap-2 mb-3">
<button id="demoWsConnectButton" type="button" class="btn btn-success">Connect</button>
@@ -56,6 +61,14 @@
<div><strong>State:</strong> <span id="demoWsStateText">Disconnected</span></div>
<div><strong>Endpoint:</strong> <span id="demoWsEndpointText">-</span></div>
</div>
<div class="small text-body-secondary mt-2">
<div><strong>Events:</strong> <span id="demoWsEventCountText">0</span></div>
<div><strong>Notifications:</strong> <span id="demoWsNotificationCountText">0</span></div>
<div><strong>UI logs:</strong> <span id="demoWsUiLogCountText">0</span></div>
<div><strong>Suppressed:</strong> <span id="demoWsSuppressedLogCountText">0</span></div>
<div><strong>Last event:</strong> <span id="demoWsLastEventKindText">-</span></div>
</div>
<hr />

View File

@@ -26,6 +26,11 @@ interface DemoWsStatusPayload {
currentSubscribeMethod: string | null;
currentUnsubscribeMethod: string | null;
currentNotificationMethod: string | null;
eventCountTotal: number;
notificationCountTotal: number;
uiLogCount: number;
suppressedLogCount: number;
lastEventKind: string | null;
}
interface DemoWsSubscribeRequest {
@@ -195,6 +200,11 @@ function applyStatusToUi(
stateText: HTMLSpanElement,
endpointText: HTMLSpanElement,
subscriptionText: HTMLSpanElement,
eventCountText: HTMLSpanElement,
notificationCountText: HTMLSpanElement,
uiLogCountText: HTMLSpanElement,
suppressedLogCountText: HTMLSpanElement,
lastEventKindText: HTMLSpanElement,
connectButton: HTMLButtonElement,
disconnectButton: HTMLButtonElement,
subscribeButton: HTMLButtonElement,
@@ -213,6 +223,12 @@ function applyStatusToUi(
subscriptionText.textContent = "-";
}
eventCountText.textContent = String(status.eventCountTotal);
notificationCountText.textContent = String(status.notificationCountTotal);
uiLogCountText.textContent = String(status.uiLogCount);
suppressedLogCountText.textContent = String(status.suppressedLogCount);
lastEventKindText.textContent = status.lastEventKind ?? "-";
const isConnected = status.connectionState === "Connected";
const isBusy = status.connectionState === "Connecting" || status.connectionState === "Disconnecting";
@@ -273,6 +289,11 @@ document.addEventListener("DOMContentLoaded", async () => {
const endpointText = document.querySelector<HTMLSpanElement>("#demoWsEndpointText");
const subscriptionText = document.querySelector<HTMLSpanElement>("#demoWsSubscriptionText");
const requestText = document.querySelector<HTMLSpanElement>("#demoWsRequestText");
const eventCountText = document.querySelector<HTMLSpanElement>("#demoWsEventCountText");
const notificationCountText = document.querySelector<HTMLSpanElement>("#demoWsNotificationCountText");
const uiLogCountText = document.querySelector<HTMLSpanElement>("#demoWsUiLogCountText");
const suppressedLogCountText = document.querySelector<HTMLSpanElement>("#demoWsSuppressedLogCountText");
const lastEventKindText = document.querySelector<HTMLSpanElement>("#demoWsLastEventKindText");
const connectButton = document.querySelector<HTMLButtonElement>("#demoWsConnectButton");
const disconnectButton = document.querySelector<HTMLButtonElement>("#demoWsDisconnectButton");
const subscribeButton = document.querySelector<HTMLButtonElement>("#demoWsSubscribeButton");
@@ -281,6 +302,7 @@ document.addEventListener("DOMContentLoaded", async () => {
const logTextarea = document.querySelector<HTMLTextAreaElement>("#demoWsLogTextarea");
if (
!eventCountText || !notificationCountText || !uiLogCountText || !suppressedLogCountText || !lastEventKindText ||
!endpointSelect || !methodSelect || !modeSelect || !targetGroup || !targetLabel || !targetInput ||
!filterGroup || !filterTextarea || !configGroup || !configTextarea || !statusBadge ||
!stateText || !endpointText || !subscriptionText || !requestText || !connectButton ||
@@ -299,18 +321,23 @@ document.addEventListener("DOMContentLoaded", async () => {
});
unlistenStatusEvent = await listen<DemoWsStatusPayload>("demo-ws-status", (event) => {
applyStatusToUi(
event.payload,
statusBadge,
stateText,
endpointText,
subscriptionText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
});
applyStatusToUi(
event.payload,
statusBadge,
stateText,
endpointText,
subscriptionText,
eventCountText,
notificationCountText,
uiLogCountText,
suppressedLogCountText,
lastEventKindText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
});
} catch (error) {
appendLogLine(logTextarea, `[ui] event listen error: ${String(error)}`);
}
@@ -373,16 +400,21 @@ document.addEventListener("DOMContentLoaded", async () => {
try {
const status = await invoke<DemoWsStatusPayload>("demo_ws_get_status");
applyStatusToUi(
status,
statusBadge,
stateText,
endpointText,
subscriptionText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
status,
statusBadge,
stateText,
endpointText,
subscriptionText,
eventCountText,
notificationCountText,
uiLogCountText,
suppressedLogCountText,
lastEventKindText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
} catch (error) {
appendLogLine(logTextarea, `[ui] initial status error: ${String(error)}`);
}
@@ -396,16 +428,21 @@ document.addEventListener("DOMContentLoaded", async () => {
});
applyStatusToUi(
status,
statusBadge,
stateText,
endpointText,
subscriptionText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
status,
statusBadge,
stateText,
endpointText,
subscriptionText,
eventCountText,
notificationCountText,
uiLogCountText,
suppressedLogCountText,
lastEventKindText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
} catch (error) {
appendLogLine(logTextarea, `[ui] connect error: ${String(error)}`);
}
@@ -416,16 +453,21 @@ document.addEventListener("DOMContentLoaded", async () => {
const status = await invoke<DemoWsStatusPayload>("demo_ws_disconnect");
applyStatusToUi(
status,
statusBadge,
stateText,
endpointText,
subscriptionText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
status,
statusBadge,
stateText,
endpointText,
subscriptionText,
eventCountText,
notificationCountText,
uiLogCountText,
suppressedLogCountText,
lastEventKindText,
connectButton,
disconnectButton,
subscribeButton,
unsubscribeButton,
);
} catch (error) {
appendLogLine(logTextarea, `[ui] disconnect error: ${String(error)}`);
}