wip
This commit is contained in:
parent
bd58cdb842
commit
ac3acbd1a0
2 changed files with 69 additions and 33 deletions
71
app.py
71
app.py
|
@ -205,24 +205,69 @@ def get_server_stats():
|
|||
@app.route('/')
|
||||
def index():
|
||||
"""Dashboard home page"""
|
||||
stats = get_server_stats()
|
||||
# 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=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
|
||||
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():
|
||||
|
|
|
@ -146,42 +146,33 @@
|
|||
</div>
|
||||
|
||||
<div class="divide-y divide-zinc-800">
|
||||
{% set domain_list = [] %}
|
||||
{% for server_type, servers in [('caddy', caddy_proxies), ('nginx', nginx_proxies)] %}
|
||||
{% for server, domains in servers.items() %}
|
||||
{% for domain, target in domains.items() %}
|
||||
{% do domain_list.append((domain, target, server, server_type)) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% for domain, target, server, server_type in domain_list[:20] %}
|
||||
{% if domain_list %}
|
||||
{% for item in domain_list[:20] %}
|
||||
<div class="px-6 py-3 flex items-center justify-between hover:bg-zinc-800/30">
|
||||
<div class="flex items-center">
|
||||
<div
|
||||
class="w-8 h-8 flex-shrink-0 flex items-center justify-center rounded-full
|
||||
{% if server_type == 'caddy' %}bg-blue-500/10 text-blue-400{% else %}bg-green-500/10 text-green-400{% endif %} mr-3">
|
||||
{% if item.server_type == 'caddy' %}bg-blue-500/10 text-blue-400{% else %}bg-green-500/10 text-green-400{% endif %} mr-3">
|
||||
<i class="fas fa-globe text-xs"></i>
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://{{ domain }}" target="_blank"
|
||||
<a href="https://{{ item.domain }}" target="_blank"
|
||||
class="text-sm font-medium text-white hover:text-blue-400 transition-colors">
|
||||
{{ domain }}
|
||||
{{ item.domain }}
|
||||
</a>
|
||||
<p class="text-xs text-gray-500">{{ server }}</p>
|
||||
<p class="text-xs text-gray-500">{{ item.server }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<span class="text-xs text-gray-500 font-mono mr-4">{{ target }}</span>
|
||||
<a href="/{% if server_type == 'caddy' %}caddy{% else %}nginx{% endif %}"
|
||||
<span class="text-xs text-gray-500 font-mono mr-4">{{ item.target }}</span>
|
||||
<a href="/{% if item.server_type == 'caddy' %}caddy{% else %}nginx{% endif %}"
|
||||
class="text-xs px-2 py-1 rounded bg-zinc-800 hover:bg-zinc-700 transition-colors">
|
||||
{{ server_type }}
|
||||
{{ item.server_type }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if domain_list|length == 0 %}
|
||||
{% else %}
|
||||
<div class="px-6 py-4 text-gray-500 text-center">
|
||||
<p>No domains configured yet</p>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue