feat: full edit menu (5 fields), delete [b] back, fix status display
This commit is contained in:
parent
9c6ddd2da1
commit
678fa83f31
1 changed files with 43 additions and 12 deletions
|
|
@ -134,13 +134,12 @@ def remove_container(name):
|
|||
print(f"✅ {name} removed")
|
||||
|
||||
def container_status():
|
||||
r = run("docker ps --filter 'name=wallarm-' --format '{{.Names}}\t{{.Status}}\t{{.Ports}}'")
|
||||
r = run("docker ps --filter 'name=wallarm-' --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' 2>/dev/null")
|
||||
if not r.stdout.strip():
|
||||
print("No containers running.")
|
||||
return
|
||||
print("\n─── Containers ───")
|
||||
for line in r.stdout.strip().split("\n"):
|
||||
print(f" {line}")
|
||||
print(r.stdout)
|
||||
|
||||
# ─── Deploy All ───────────────────────────────────────────────────────
|
||||
|
||||
|
|
@ -322,22 +321,54 @@ def edit_nodes():
|
|||
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.")
|
||||
|
||||
cfg = load_config()
|
||||
nc = cfg.get(n['name'], {})
|
||||
|
||||
while True:
|
||||
print(f"\n─── Editing: {n['name']} ───")
|
||||
print(f" [1] Token: {'*'*8}")
|
||||
print(f" [2] Cloud: {nc.get('cloud','EU')}")
|
||||
print(f" [3] Port: {n.get('port','')}")
|
||||
print(f" [4] Upstream: {nc.get('upstream_ip','')}:{nc.get('upstream_port','')}")
|
||||
print(f" [5] Mode: {nc.get('mode','monitoring')}")
|
||||
print(f" [s] Save & restart")
|
||||
print(f" [b] Back")
|
||||
|
||||
c = input("\nEdit field: ").strip()
|
||||
if c == '1': nc['token'] = input("New token: ").strip() or nc.get('token','')
|
||||
elif c == '2':
|
||||
print(" [1] EU [2] US")
|
||||
r = input("Cloud: ").strip()
|
||||
nc['cloud'] = "US" if r == "2" else "EU"
|
||||
elif c == '3': nc['port'] = input("Port: ").strip() or nc.get('port','')
|
||||
elif c == '4':
|
||||
up = input("Upstream (ip:port): ").strip()
|
||||
if ':' in up:
|
||||
ip, p = up.split(':')
|
||||
nc['upstream_ip'] = ip; nc['upstream_port'] = p
|
||||
elif c == '5':
|
||||
print(" [1] monitoring [2] safe_blocking [3] block [4] off")
|
||||
m = input("Mode: ").strip()
|
||||
nc['mode'] = {"1":"monitoring","2":"safe_blocking","3":"block","4":"off"}.get(m, nc.get('mode','monitoring'))
|
||||
elif c.lower() == 's':
|
||||
with open(CONF, "w") as f: json.dump(cfg, f, indent=2)
|
||||
deploy_container(n['name'], nc['token'], nc.get('cloud','EU'),
|
||||
str(nc.get('port','')), nc.get('upstream_ip',''),
|
||||
str(nc.get('upstream_port','')), "",
|
||||
nc.get('mode','monitoring'))
|
||||
print(f"✅ {n['name']} updated & restarted.")
|
||||
break
|
||||
elif c.lower() == 'b': break
|
||||
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','')})")
|
||||
print(" [b] Back")
|
||||
c = input("\nSelect: ").strip()
|
||||
if c.lower() == 'b': return
|
||||
if not c.isdigit(): return
|
||||
idx = int(c) - 1
|
||||
if 0 <= idx < len(s):
|
||||
|
|
|
|||
Loading…
Reference in a new issue