v0.1.0-pre.051
This commit is contained in:
@@ -26,9 +26,10 @@ fs2.workspace = true
|
||||
kb-config = { path = "../kb-config" }
|
||||
kb-core = { path = "../kb-core" }
|
||||
kb-logging = { path = "../kb-logging" }
|
||||
kb-program-ids = { path = "../kb-program-ids" }
|
||||
kb-store = { path = "../kb-store" }
|
||||
kb-pipeline = { path = "../kb-pipeline" }
|
||||
kb-program-ids = { path = "../kb-program-ids" }
|
||||
kb-pipeline-demo-scenarios = { path = "../kb-pipeline-demo-scenarios" }
|
||||
kb-onchain-transport = { path = "../kb-onchain-transport" }
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
"demo_sql_diag",
|
||||
"demo_sql_pg_raw",
|
||||
"demo_sql_pg_core",
|
||||
"demo_sql_replay_candidates"
|
||||
"demo_sql_replay_candidates",
|
||||
"demo_config"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default"
|
||||
"core:default",
|
||||
"tracing:default"
|
||||
]
|
||||
}
|
||||
}
|
||||
93
kb-app-demo-desktop/frontend/demo_config.html
Normal file
93
kb-app-demo-desktop/frontend/demo_config.html
Normal file
@@ -0,0 +1,93 @@
|
||||
<!-- file: kb-app-demo-desktop/frontend/demo_config.html -->
|
||||
<!-- version: 2 -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Khadhroony Bot3 - Configuration</title>
|
||||
<link rel="stylesheet" href="sass/main.scss" />
|
||||
</head>
|
||||
|
||||
<body class="bg-body-tertiary">
|
||||
<header class="app-header">
|
||||
<nav class="navbar navbar-expand-lg h-100 py-0 bg-light text-dark">
|
||||
<div class="container my-0">
|
||||
<div class="navbar-brand d-flex align-items-center" aria-label="Khadhroony Bot3">
|
||||
<img alt="Logo" src="imgs/logo.png" class="app-logo" />
|
||||
<span class="ps-2 fs-4 fw-bold text-primary font-logo">Bot3</span>
|
||||
</div>
|
||||
|
||||
<div class="ms-auto d-flex align-items-center gap-2">
|
||||
<span class="badge text-bg-primary">Configuration</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="app-main">
|
||||
<div class="osb-scrollable pt-1 pb-4" data-simplebar>
|
||||
<div class="container py-4">
|
||||
<div class="row g-4">
|
||||
<div class="col-12">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<h1 class="h3 card-title mb-3">Profil actif</h1>
|
||||
<dl class="row mb-0">
|
||||
<dt class="col-sm-3">Fichier</dt>
|
||||
<dd class="col-sm-9"><code id="configPath">Chargement...</code></dd>
|
||||
<dt class="col-sm-3">Profil</dt>
|
||||
<dd class="col-sm-9"><code id="activeProfileName">Chargement...</code></dd>
|
||||
<dt class="col-sm-3">Environnement</dt>
|
||||
<dd class="col-sm-9"><code id="activeEnvironment">Chargement...</code></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-xl-6">
|
||||
<div class="card shadow-sm border-0 h-100">
|
||||
<div class="card-body">
|
||||
<h2 class="h5 card-title mb-3">Configuration active</h2>
|
||||
<div id="activeProfileJson" class="app-config-box app-json-viewer mb-0">Chargement...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-xl-6">
|
||||
<div class="card shadow-sm border-0 h-100">
|
||||
<div class="card-body">
|
||||
<h2 class="h5 card-title mb-3">Configuration complète</h2>
|
||||
<div id="fullConfigJson" class="app-config-box app-json-viewer mb-0">Chargement...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<h2 class="h5 card-title mb-3">Schéma JSON embarqué</h2>
|
||||
<div id="schemaJson" class="app-config-box app-json-viewer mb-0">Chargement...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="app-footer bg-dark text-light">
|
||||
<div class="container h-100 d-flex align-items-center">
|
||||
<div class="row flex-grow-1 align-items-center">
|
||||
<div class="col-12 text-center text-small my-1 my-md-0">
|
||||
© 2026 SASEDEV
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="module" src="ts/demo_config.ts" defer></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- file: kb-app-demo-desktop/frontend/main.html -->
|
||||
<!-- version: 4 -->
|
||||
<!-- version: 5 -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
@@ -22,6 +22,8 @@
|
||||
Démos
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a id="openDemoConfigLink" class="dropdown-item" href="#">Configuration</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a id="openDemoWsLink" class="dropdown-item" href="#">WebSocket standard</a></li>
|
||||
<li><a id="openDemoHttpLink" class="dropdown-item" href="#">HTTP JSON-RPC</a></li>
|
||||
<li><a id="openDemoBackfillLink" class="dropdown-item" href="#">Backfill HTTP</a></li>
|
||||
|
||||
84
kb-app-demo-desktop/frontend/ts/demo_config.ts
Normal file
84
kb-app-demo-desktop/frontend/ts/demo_config.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
// file: kb_app_demo/frontend/ts/demo_config.ts
|
||||
// version: 5
|
||||
|
||||
import * as bootstrap from "bootstrap";
|
||||
import "simplebar";
|
||||
import "@andypf/json-viewer";
|
||||
import ResizeObserver from "resize-observer-polyfill";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { frontendDebug, frontendError, installFrontendConsoleBridge } from "./frontend_log.ts";
|
||||
import type { DemoConfigPayload } from "./bindings/kb_app_demo_desktop/demo_config/DemoConfigPayload.ts";
|
||||
|
||||
(window as Window & typeof globalThis & { bootstrap?: typeof bootstrap }).bootstrap = bootstrap;
|
||||
(window as Window & typeof globalThis & { ResizeObserver?: typeof ResizeObserver }).ResizeObserver = ResizeObserver;
|
||||
|
||||
function setText(selector: string, value: string): void {
|
||||
const element = document.querySelector<HTMLElement>(selector);
|
||||
if (element) {
|
||||
element.textContent = value;
|
||||
}
|
||||
}
|
||||
|
||||
function renderJsonViewer(selector: string, value: unknown): void {
|
||||
const container = document.querySelector<HTMLElement>(selector);
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
const serialized = JSON.stringify(value, null, 2) ?? "null";
|
||||
const viewer = document.createElement("andypf-json-viewer");
|
||||
viewer.setAttribute("indent", "2");
|
||||
viewer.setAttribute("expanded", "1");
|
||||
viewer.setAttribute("theme", "default-light");
|
||||
viewer.setAttribute("show-data-types", "true");
|
||||
viewer.setAttribute("show-toolbar", "false");
|
||||
viewer.setAttribute("expand-icon-type", "arrow");
|
||||
viewer.setAttribute("show-copy", "true");
|
||||
viewer.setAttribute("show-size", "true");
|
||||
viewer.setAttribute("expand-empty", "false");
|
||||
viewer.setAttribute("data", serialized);
|
||||
container.textContent = "";
|
||||
container.appendChild(viewer);
|
||||
}
|
||||
|
||||
function parseSchemaJson(schemaJson: string): unknown {
|
||||
try {
|
||||
return JSON.parse(schemaJson) as unknown;
|
||||
} catch (caughtError) {
|
||||
const message = caughtError instanceof Error ? caughtError.message : String(caughtError);
|
||||
return {
|
||||
error: `Schema JSON parsing failed: ${message}`,
|
||||
raw: schemaJson,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDemoConfig(): Promise<void> {
|
||||
try {
|
||||
const payload = await invoke<DemoConfigPayload>("load_demo_config");
|
||||
setText("#configPath", payload.config_path);
|
||||
setText("#activeProfileName", payload.active_profile_name);
|
||||
setText("#activeEnvironment", payload.environment);
|
||||
renderJsonViewer("#activeProfileJson", payload.active_profile);
|
||||
renderJsonViewer("#fullConfigJson", payload.app_config);
|
||||
renderJsonViewer("#schemaJson", parseSchemaJson(payload.schema_json));
|
||||
} catch (caughtError) {
|
||||
const message = caughtError instanceof Error ? caughtError.message : String(caughtError);
|
||||
setText("#activeProfileJson", `Erreur pendant le chargement de la configuration : ${message}`);
|
||||
frontendError("kb-app-demo-desktop.frontend.demo_config", `Configuration loading failed: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
installFrontendConsoleBridge("kb-app-demo-desktop.frontend.demo_config");
|
||||
|
||||
frontendDebug("kb-app-demo-desktop.frontend.demo_config", "configuration demo window loaded");
|
||||
|
||||
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
||||
Array.from(tooltipTriggerList).map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
|
||||
const toastElList = document.querySelectorAll('.toast');
|
||||
Array.from(toastElList).map(toastEl => new bootstrap.Toast(toastEl));
|
||||
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]');
|
||||
Array.from(popoverTriggerList).map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl));
|
||||
|
||||
await loadDemoConfig();
|
||||
});
|
||||
@@ -28,8 +28,22 @@ async function loadReadme(readmeContent: HTMLElement): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function openDemoConfigWindow(): Promise<void> {
|
||||
try {
|
||||
await invoke("open_demo_config_window");
|
||||
} catch (caughtError) {
|
||||
const message = caughtError instanceof Error ? caughtError.message : String(caughtError);
|
||||
frontendError("kb-app-demo-desktop.frontend.main", `Cannot open configuration window: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
installFrontendConsoleBridge("kb-app-demo-desktop.frontend.main");
|
||||
|
||||
document.querySelector<HTMLAnchorElement>("#openDemoConfigLink")?.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
void openDemoConfigWindow();
|
||||
});
|
||||
frontendDebug("kb-app-demo-desktop.frontend.main", "main window loaded");
|
||||
const readmeContent = document.querySelector<HTMLElement>("#readmeContent");
|
||||
if (readmeContent) {
|
||||
|
||||
51
kb-app-demo-desktop/src/demo_config.rs
Normal file
51
kb-app-demo-desktop/src/demo_config.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
// file: kb-app-demo-desktop/src/demo_config.rs
|
||||
// version: 1
|
||||
|
||||
//! Configuration demo payload and state projection.
|
||||
|
||||
use ts_rs::TS; // rust-rules: derive-import
|
||||
|
||||
/// Serializable payload shown by the configuration demo page.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[ts(
|
||||
export,
|
||||
export_to = "../frontend/ts/bindings/kb_app_demo_desktop/demo_config/DemoConfigPayload.ts"
|
||||
)]
|
||||
pub(crate) struct DemoConfigPayload {
|
||||
/// Path used to load the configuration file.
|
||||
pub(crate) config_path: std::string::String,
|
||||
/// Active profile name.
|
||||
pub(crate) active_profile_name: std::string::String,
|
||||
/// Active profile environment.
|
||||
pub(crate) environment: std::string::String,
|
||||
/// Entire parsed configuration.
|
||||
pub(crate) app_config: kb_config::AppConfig,
|
||||
/// Active profile configuration.
|
||||
pub(crate) active_profile: kb_config::ProfileConfig,
|
||||
/// Embedded JSON Schema text used during loading.
|
||||
pub(crate) schema_json: std::string::String,
|
||||
}
|
||||
|
||||
/// Builds the configuration payload from shared application state.
|
||||
pub(crate) fn demo_config_payload(state: &crate::AppState) -> crate::DemoConfigPayload {
|
||||
return crate::DemoConfigPayload {
|
||||
config_path: state.config_path().to_owned(),
|
||||
active_profile_name: state.active_profile().name.clone(),
|
||||
environment: state.active_profile().app.environment.clone(),
|
||||
app_config: state.app_config().clone(),
|
||||
active_profile: state.active_profile().clone(),
|
||||
schema_json: kb_config::config_json_schema_text().to_owned(),
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ts_rs::TS; // rust-rules: trait-import
|
||||
|
||||
#[test]
|
||||
fn payload_binding_uses_desktop_path() {
|
||||
let config = ts_rs::Config::default();
|
||||
let declaration = <crate::DemoConfigPayload as TS>::decl(&config);
|
||||
assert!(declaration.contains("DemoConfigPayload"));
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ pub(crate) fn table_snapshots_from_pg(
|
||||
) -> std::vec::Vec<crate::DemoSqlTableSnapshot> {
|
||||
let mut output = std::vec::Vec::new();
|
||||
for value in values {
|
||||
output.push(table_snapshot_from_pg(value));
|
||||
output.push(crate::table_snapshot_from_pg(value));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/lib.rs
|
||||
// version: 5
|
||||
// version: 6
|
||||
|
||||
//! Tauri desktop demo application for `khadhroony-bot3`.
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
mod app_state;
|
||||
mod constants;
|
||||
mod demo_backfill;
|
||||
mod demo_config;
|
||||
mod demo_http;
|
||||
mod demo_ws;
|
||||
mod demo_sql_common;
|
||||
@@ -47,6 +48,10 @@ pub(crate) use self::demo_backfill::build_demo_backfill_pipeline_request;
|
||||
pub(crate) use self::demo_backfill::build_role_options;
|
||||
/// Converts a pipeline summary to the UI-safe summary.
|
||||
pub(crate) use self::demo_backfill::demo_backfill_summary_payload;
|
||||
/// Configuration payload shown by the configuration window.
|
||||
pub(crate) use self::demo_config::DemoConfigPayload;
|
||||
/// Builds the configuration payload from shared application state.
|
||||
pub(crate) use self::demo_config::demo_config_payload;
|
||||
/// HTTP demo response payload.
|
||||
pub(crate) use self::demo_http::DemoHttpExecutionPayload;
|
||||
/// One selectable HTTP JSON-RPC method.
|
||||
@@ -93,8 +98,6 @@ pub(crate) use self::demo_ws::demo_ws_disconnect_inner;
|
||||
pub(crate) use self::demo_ws::demo_ws_status_inner;
|
||||
/// Unsubscribes one active WebSocket subscription.
|
||||
pub(crate) use self::demo_ws::demo_ws_unsubscribe_inner;
|
||||
/// Disconnects the application WebSocket session during shutdown.
|
||||
pub(crate) use self::demo_ws::disconnect_demo_ws_app_state;
|
||||
/// UI-safe SQL table diagnostic snapshot.
|
||||
pub(crate) use self::demo_sql_common::DemoSqlTableSnapshot;
|
||||
/// Connects to the configured PostgreSQL store.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/tauri.rs
|
||||
// version: 7
|
||||
// version: 8
|
||||
|
||||
//! Tauri runtime assembly and private command wrappers.
|
||||
|
||||
@@ -64,21 +64,10 @@ pub fn run() -> kb_core::Result<()> {
|
||||
load_demo_sql_replay_programs,
|
||||
load_demo_sql_replay_entities,
|
||||
export_demo_sql_replay_csv,
|
||||
open_demo_config_window,
|
||||
load_demo_config,
|
||||
]);
|
||||
builder = builder.plugin(tracing_builder.build::<tauri::Wry>());
|
||||
builder = builder.on_window_event(|window, event| {
|
||||
if window.label() != "demo_ws" {
|
||||
return;
|
||||
}
|
||||
if !matches!(event, tauri::WindowEvent::Destroyed) {
|
||||
return;
|
||||
}
|
||||
let app_handle = window.app_handle().clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let state = app_handle.state::<crate::AppState>();
|
||||
crate::disconnect_demo_ws_app_state(&state, false).await;
|
||||
});
|
||||
});
|
||||
builder = builder.setup(|app| {
|
||||
let splash_window = match app.get_webview_window("splash") {
|
||||
std::option::Option::Some(window) => window,
|
||||
@@ -194,6 +183,46 @@ fn install_default_rustls_provider() -> kb_core::Result<()> {
|
||||
};
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn open_demo_config_window(
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> std::result::Result<(), std::string::String> {
|
||||
if let std::option::Option::Some(window) = app_handle.get_webview_window("demo_config") {
|
||||
if let std::result::Result::Err(error) = window.show() {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
}
|
||||
if let std::result::Result::Err(error) = window.set_focus() {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
}
|
||||
return std::result::Result::Ok(());
|
||||
}
|
||||
let builder = tauri::WebviewWindowBuilder::new(
|
||||
&app_handle,
|
||||
"demo_config",
|
||||
tauri::WebviewUrl::App("demo_config.html".into()),
|
||||
)
|
||||
.title("Khadhroony Bot3 - Configuration")
|
||||
.inner_size(1280.0, 820.0)
|
||||
.min_inner_size(960.0, 640.0);
|
||||
let window = match builder.build() {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
},
|
||||
};
|
||||
if let std::result::Result::Err(error) = window.set_focus() {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
}
|
||||
return std::result::Result::Ok(());
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn load_demo_config(
|
||||
state: tauri::State<'_, crate::AppState>,
|
||||
) -> crate::DemoConfigPayload {
|
||||
return crate::demo_config_payload(state.inner());
|
||||
}
|
||||
|
||||
fn into_ipc_result<T>(
|
||||
result: kb_core::Result<T>,
|
||||
) -> std::result::Result<T, std::string::String> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/vite.config.ts
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
import { defineConfig, normalizePath } from "vite";
|
||||
import { NodePackageImporter } from "sass-embedded";
|
||||
@@ -30,6 +30,7 @@ export default defineConfig(() => ({
|
||||
"demo_sql_pg_raw": normalizePath(resolve(__dirname, 'frontend/demo_sql_pg_raw.html')),
|
||||
"demo_sql_pg_core": normalizePath(resolve(__dirname, 'frontend/demo_sql_pg_core.html')),
|
||||
"demo_sql_replay_candidates": normalizePath(resolve(__dirname, 'frontend/demo_sql_replay_candidates.html')),
|
||||
"demo_config": normalizePath(resolve(__dirname, 'frontend/demo_config.html')),
|
||||
},
|
||||
output: {
|
||||
entryFileNames: 'js/[name]-[hash].js',
|
||||
|
||||
Reference in New Issue
Block a user