From 2ff8d57c08d3ed87209b6e75665aa2d543d06a8c Mon Sep 17 00:00:00 2001 From: Mukan Erkin Date: Sat, 25 Apr 2026 10:45:06 +0300 Subject: [PATCH] feat(mse): shared bot modal component + pagination on positions/bots - Extract bot creation modal to _bot_modal.html partial (TomSelect, min_notional display) - bots.html and index.html now include the partial via {% include %} - Remove duplicate modal JS from bots.html; add onBotCreated/onModeChange hooks - Add 20-item pagination to positions.html (open + closed tables) - positions.html: remove redundant loadMode (handled by _header.html partial) Co-Authored-By: Claude Sonnet 4.6 --- Cargo.lock | 17 +++ Cargo.toml | 1 + src/tmpl.rs | 3 +- src/web/_bot_modal.html | 127 ++++++++++++++++++++++ src/web/bots.html | 122 ++------------------- src/web/index.html | 235 +++++++++++++--------------------------- src/web/positions.html | 79 ++++++++++---- 7 files changed, 290 insertions(+), 294 deletions(-) create mode 100644 src/web/_bot_modal.html diff --git a/Cargo.lock b/Cargo.lock index e7b6876..98b7cd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1061,6 +1061,12 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +[[package]] +name = "memo-map" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d1115007560874e373613744c6fba374c17688327a71c1476d1a5954cc857b" + [[package]] name = "mime" version = "0.3.17" @@ -1077,6 +1083,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "minijinja" +version = "2.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805bfd7352166bae857ee569628b52bcd85a1cecf7810861ebceb1686b72b75d" +dependencies = [ + "memo-map", + "serde", +] + [[package]] name = "mio" version = "1.2.0" @@ -1105,6 +1121,7 @@ dependencies = [ "hex", "hmac", "log", + "minijinja", "reqwest", "rusqlite", "serde", diff --git a/Cargo.toml b/Cargo.toml index 5f23b78..67f5f3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,3 +61,4 @@ axum-extra = { version = "0.9", features = ["cookie"] } # Async stream generator async-stream = "0.3" +minijinja = "2.19.0" diff --git a/src/tmpl.rs b/src/tmpl.rs index 036c0eb..2f626d3 100644 --- a/src/tmpl.rs +++ b/src/tmpl.rs @@ -6,7 +6,8 @@ static ENV: OnceLock> = OnceLock::new(); fn env() -> &'static Environment<'static> { ENV.get_or_init(|| { let mut e = Environment::new(); - e.add_template_owned("_header.html", include_str!("web/_header.html").to_string()).unwrap(); + e.add_template_owned("_header.html", include_str!("web/_header.html").to_string()).unwrap(); + e.add_template_owned("_bot_modal.html", include_str!("web/_bot_modal.html").to_string()).unwrap(); e.add_template_owned("index.html", include_str!("web/index.html").to_string()).unwrap(); e.add_template_owned("bots.html", include_str!("web/bots.html").to_string()).unwrap(); e.add_template_owned("bot.html", include_str!("web/bot.html").to_string()).unwrap(); diff --git a/src/web/_bot_modal.html b/src/web/_bot_modal.html new file mode 100644 index 0000000..15e63e8 --- /dev/null +++ b/src/web/_bot_modal.html @@ -0,0 +1,127 @@ + + + diff --git a/src/web/bots.html b/src/web/bots.html index 2f56d6f..b0c057f 100644 --- a/src/web/bots.html +++ b/src/web/bots.html @@ -114,6 +114,11 @@ .ts-dropdown .option { padding: 7px 12px; color: var(--text) !important; } .ts-dropdown .option:hover, .ts-dropdown .option.active { background: rgba(108,99,255,.2) !important; } .ts-wrapper .ts-control .item { color: var(--text) !important; background: rgba(108,99,255,.15) !important; border-radius: 3px; padding: 1px 6px; border: none !important; } + .pagination { display: flex; align-items: center; gap: 4px; padding: 12px 0 4px; flex-wrap: wrap; } + .pg-btn { padding: 4px 10px; border-radius: 5px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; transition: all .15s; } + .pg-btn:hover { background: rgba(255,255,255,.05); color: var(--text); } + .pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; } + .pg-info { font-size: 11px; color: var(--muted); margin-left: 8px; } @@ -136,58 +141,9 @@ - - +{% include "_bot_modal.html" %} diff --git a/src/web/index.html b/src/web/index.html index 2deca7a..b9f994d 100644 --- a/src/web/index.html +++ b/src/web/index.html @@ -94,55 +94,19 @@ .ts-dropdown .option.active { background: rgba(108,99,255,0.2) !important; color: var(--text) !important; } .ts-dropdown .option.selected { background: rgba(108,99,255,0.1) !important; } .ts-wrapper .ts-control .item { color: var(--text) !important; background: rgba(108,99,255,0.15) !important; border-radius: 3px; padding: 1px 6px; border: none !important; } + + /* Pagination */ + .pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 0; border-top: 1px solid var(--border); } + .pg-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 3px; padding: 2px 9px; font-size: 11px; cursor: pointer; } + .pg-btn:hover { color: var(--text); border-color: var(--accent); } + .pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; } + .pg-info { font-size: 11px; color: var(--muted); margin-left: 6px; } - +{% include "_bot_modal.html" %} {% include "_header.html" %} @@ -165,6 +129,7 @@ BotSembolAlışHedefMiktarZaman Açık pozisyon yok +
@@ -173,14 +138,15 @@ BotSembolAlışHedefMiktarDurumZaman Henüz işlem yok +