dashboard update for profile page.

This commit is contained in:
Michael Woods
2025-12-21 22:38:44 -05:00
parent ea1c4835ec
commit 7fb1a28506
3 changed files with 58 additions and 0 deletions

View File

@@ -29,4 +29,17 @@ async def dashboard(
return templates.TemplateResponse( return templates.TemplateResponse(
"dashboard.html", "dashboard.html",
{"request": request, "current_user": current_user.username, "messages": messages} {"request": request, "current_user": current_user.username, "messages": messages}
)
@router.get("/dashboard/profile", response_class=HTMLResponse)
async def profile_page(
request: Request,
current_user: HttpUser = Depends(get_current_http_user)
):
from packetserver.http.routers.profile import profile as api_profile
profile_data = await api_profile(current_user=current_user)
return templates.TemplateResponse(
"profile.html",
{"request": request, "current_user": current_user.username, "profile": profile_data}
) )

View File

@@ -16,6 +16,7 @@
{# Basic Auth note #} {# Basic Auth note #}
<small class="text-light ms-3">(Close browser to logout)</small> <small class="text-light ms-3">(Close browser to logout)</small>
</span> </span>
<a href="{{ url_for('profile_page') }}" class="btn btn-outline-light btn-sm me-2">Profile</a>
</div> </div>
</nav> </nav>

View File

@@ -0,0 +1,44 @@
{% extends "base.html" %}
{% block title %}Profile - {{ current_user }}{% endblock %}
{% block content %}
<h2 class="mb-4">User Profile: {{ profile.username }}</h2>
<div class="row">
<div class="col-md-8">
<div class="card">
<div class="card-header">
<strong>General Information</strong>
</div>
<div class="card-body">
<table class="table table-borderless">
<tr><th>Status</th><td>{{ profile.status or "Not set" }}</td></tr>
<tr><th>Bio</th><td>{{ profile.bio or "No bio" }}</td></tr>
<tr><th>Email</th><td>{{ profile.email or "Not set" }}</td></tr>
<tr><th>Location</th><td>{{ profile.location or "Not set" }}</td></tr>
<tr><th>Social Links</th><td>{% if profile.socials %}{{ profile.socials | join(', ') }}{% else %}None{% endif %}</td></tr>
<tr><th>Created</th><td>{{ profile.created_at }}</td></tr>
<tr><th>Last Seen</th><td>{{ profile.last_seen }}</td></tr>
</table>
</div>
</div>
<div class="card mt-4">
<div class="card-header">
<strong>HTTP Gateway Access</strong>
</div>
<div class="card-body">
<table class="table table-borderless">
<tr><th>HTTP Enabled</th><td>{% if profile.http_enabled %}<span class="text-success">Yes</span>{% else %}<span class="text-danger">No</span>{% endif %}</td></tr>
<tr><th>RF Gateway Enabled</th><td>{% if profile.rf_enabled %}<span class="text-success">Yes</span>{% else %}<span class="text-warning">No (blacklisted)</span>{% endif %}</td></tr>
<tr><th>HTTP Account Created</th><td>{{ profile.http_created_at }}</td></tr>
<tr><th>Last HTTP Login</th><td>{{ profile.http_last_login or "Never" }}</td></tr>
</table>
</div>
</div>
</div>
</div>
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary mt-3">← Back to Dashboard</a>
{% endblock %}