wip
This commit is contained in:
parent
66fe31eabe
commit
67dae6f5e4
7 changed files with 490 additions and 23 deletions
|
@ -529,3 +529,75 @@ def settings():
|
|||
return redirect(url_for("dashboard.settings"))
|
||||
|
||||
return render_template("dashboard/settings.html", title="User Settings")
|
||||
|
||||
|
||||
@bp.route("/overview")
|
||||
@login_required
|
||||
def overview():
|
||||
"""Hierarchical overview of subnets, servers, and applications"""
|
||||
# Get all subnets with their servers
|
||||
subnets = Subnet.query.all()
|
||||
|
||||
# Get servers without subnets
|
||||
standalone_servers = Server.query.filter(Server.subnet_id.is_(None)).all()
|
||||
|
||||
# Create a hierarchical structure
|
||||
hierarchy = {
|
||||
'subnets': [],
|
||||
'standalone_servers': []
|
||||
}
|
||||
|
||||
# Organize subnets and their servers
|
||||
for subnet in subnets:
|
||||
subnet_data = {
|
||||
'id': subnet.id,
|
||||
'cidr': subnet.cidr,
|
||||
'description': subnet.description,
|
||||
'location': subnet.location,
|
||||
'servers': []
|
||||
}
|
||||
|
||||
for server in subnet.servers:
|
||||
server_data = {
|
||||
'id': server.id,
|
||||
'hostname': server.hostname,
|
||||
'ip_address': server.ip_address,
|
||||
'apps': []
|
||||
}
|
||||
|
||||
for app in server.apps:
|
||||
app_data = {
|
||||
'id': app.id,
|
||||
'name': app.name,
|
||||
'ports': app.ports
|
||||
}
|
||||
server_data['apps'].append(app_data)
|
||||
|
||||
subnet_data['servers'].append(server_data)
|
||||
|
||||
hierarchy['subnets'].append(subnet_data)
|
||||
|
||||
# Organize standalone servers
|
||||
for server in standalone_servers:
|
||||
server_data = {
|
||||
'id': server.id,
|
||||
'hostname': server.hostname,
|
||||
'ip_address': server.ip_address,
|
||||
'apps': []
|
||||
}
|
||||
|
||||
for app in server.apps:
|
||||
app_data = {
|
||||
'id': app.id,
|
||||
'name': app.name,
|
||||
'ports': app.ports
|
||||
}
|
||||
server_data['apps'].append(app_data)
|
||||
|
||||
hierarchy['standalone_servers'].append(server_data)
|
||||
|
||||
return render_template(
|
||||
"dashboard/overview.html",
|
||||
title="Infrastructure Overview",
|
||||
hierarchy=hierarchy
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue