From 1d4b6c967345bf26867e98abb65c5555f2335667 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 3 Aug 2026 15:41:53 +0000 Subject: [PATCH] feat: edit nodes, delete, status as separate menu items --- sources/python/main.py | 63 ++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/sources/python/main.py b/sources/python/main.py index 78786b3..4c252d1 100644 --- a/sources/python/main.py +++ b/sources/python/main.py @@ -150,7 +150,9 @@ def main(): n += 1 if deployed: - print(f" [{n}] Manage nodes"); n += 1 + print(f" [{n}] Edit nodes"); n += 1 + print(f" [{n}] Delete a node"); n += 1 + print(f" [{n}] Status"); n += 1 print(f" [{n}] Remote tunnel"); n += 1 print(" [q] Quit") @@ -168,8 +170,12 @@ def main(): str(nc.get("upstream_port","80")), "", nc.get("mode","monitoring")) deployed.add(name) - elif c == str(n-2) and deployed: - manage_nodes() + elif c == str(n-4) and deployed: + edit_nodes() + elif c == str(n-3) and deployed: + remove_menu() + elif c == str(n-2): + container_status() elif c == str(n-1): start_tunnel() elif c.lower() == "q": @@ -274,22 +280,39 @@ def start_tunnel(): except Exception as e: print(f"Tunnel failed: {e}") -def manage_nodes(): +def edit_nodes(): s = load_state().get("nodes", []) if not s: print("No nodes."); return - while True: - print("\n─── Manage Nodes ───") - for i, n in enumerate(s): - r = run(f"docker inspect -f '{{{{.State.Status}}}}' wallarm-{n['name']} 2>/dev/null") - st = "●" if r.stdout.strip() == "running" else "○" - print(f" [{i+1}] {st} {n['name']} (port {n.get('port','')})") - print(" [r] Restart [d] Delete [b] Back") - c = input("\nAction: ").strip() - if c.lower() == 'b': break - if c == 'r': - name = input("Node name: ").strip() - if name: run(f"docker restart wallarm-{name} 2>/dev/null"); print(f"Restarted {name}") - elif c == 'd': - name = input("Node name: ").strip() - if name: remove_container(name) - s = load_state().get("nodes", []) + print("\n─── Edit Node ───") + for i, n in enumerate(s): + r = run(f"docker inspect -f '{{{{.State.Status}}}}' wallarm-{n['name']} 2>/dev/null") + st = "●" if r.stdout.strip() == "running" else "○" + print(f" [{i+1}] {st} {n['name']} (port {n.get('port','')})") + print(" [b] Back") + c = input("\nSelect node: ").strip() + if c.lower() == 'b': return + if not c.isdigit(): return + idx = int(c) - 1 + if idx < 0 or idx >= len(s): return + n = s[idx] + print(f"\nEditing {n['name']}. Enter to keep current:") + port = input(f"Port [{n.get('port','')}]: ").strip() + upstream = input(f"Upstream [{n.get('upstream_ip','')}:{n.get('upstream_port','')}]: ").strip() + if port: n['port'] = int(port) + if ':' in upstream: + ip, p = upstream.split(':') + n['upstream_ip'] = ip; n['upstream_port'] = int(p) + save_state({"nodes": s}) + print(f"✅ Updated. Restart to apply.") + +def remove_menu(): + s = load_state().get("nodes", []) + if not s: print("No nodes."); return + print("\n─── Delete Node ───") + for i, n in enumerate(s): + print(f" [{i+1}] {n['name']} (port {n.get('port','')})") + c = input("\nSelect: ").strip() + if not c.isdigit(): return + idx = int(c) - 1 + if 0 <= idx < len(s): + remove_container(s[idx]["name"])