diff --git a/app.py b/app.py index 68ef5f6..c6d5325 100644 --- a/app.py +++ b/app.py @@ -205,24 +205,69 @@ def get_server_stats(): @app.route('/') def index(): """Dashboard home page""" - stats = get_server_stats() - return render_template('dashboard.html', - caddy_count=stats['caddy_servers'], - nginx_count=stats['nginx_servers'], - domain_count=stats['total_domains'], - last_update=stats['last_update'], - caddy_proxies=caddy_proxies, # Pass all proxies data - nginx_proxies=nginx_proxies) # Pass all proxies data + # Calculate stats + caddy_servers = len(caddy_proxies) + nginx_servers = len(nginx_proxies) + + # Calculate total domains + total_domains = 0 + domain_list = [] + + # Build the domain list for both Caddy and Nginx + for server, domains in caddy_proxies.items(): + for domain, target in domains.items(): + domain_list.append({ + "domain": domain, + "target": target, + "server": server, + "server_type": "caddy" + }) + total_domains += 1 + + for server, domains in nginx_proxies.items(): + for domain, target in domains.items(): + domain_list.append({ + "domain": domain, + "target": target, + "server": server, + "server_type": "nginx" + }) + total_domains += 1 + + # Sort domains by name + domain_list.sort(key=lambda x: x["domain"]) + + # Get the latest update time + last_update = "Never" + if timestamps: + # Find the most recent timestamp + latest_time = max(timestamps.values()) + last_update = latest_time + + return render_template('dashboard.html', + caddy_count=caddy_servers, + nginx_count=nginx_servers, + domain_count=total_domains, + last_update=last_update, + domain_list=domain_list, # Pass the pre-built list + caddy_proxies=caddy_proxies, + nginx_proxies=nginx_proxies) @app.route('/caddy') -def caddy_dashboard(): - """Caddy specific dashboard""" - return render_template('index.html', proxies=caddy_proxies, timestamps=timestamps, server_type="Caddy") +def caddy_view(): + """View for Caddy servers only""" + return render_template('index.html', + proxies=caddy_proxies, + timestamps=timestamps, + server_type="Caddy") @app.route('/nginx') -def nginx_dashboard(): - """Nginx specific dashboard""" - return render_template('index.html', proxies=nginx_proxies, timestamps=timestamps, server_type="Nginx") +def nginx_view(): + """View for Nginx servers only""" + return render_template('index.html', + proxies=nginx_proxies, + timestamps=timestamps, + server_type="Nginx") @app.route('/api/update', methods=['POST']) def update_proxies(): diff --git a/templates/dashboard.html b/templates/dashboard.html index 5e633cb..27abf5e 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -146,42 +146,33 @@
No domains configured yet