routers.html: add authenticated dashboard to homepage

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-08-09 23:43:48 -07:00
parent af51b5c460
commit 5a175bd92a
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
6 changed files with 269 additions and 2 deletions

54
templates/dashboard.html Normal file
View file

@ -0,0 +1,54 @@
<div id="intro" class="box">
<h2>{{ "Dashboard" | tr }}</h2>
<h3>{{ "My Flagged Packages" | tr }}</h3>
{% if not flagged_packages %}
<p>{{ "No packages matched your search criteria." | tr }}</p>
{% else %}
{% with table_id = "flagged-packages", packages = flagged_packages %}
{% include 'partials/packages/results.html' %}
{% endwith %}
{% endif %}
<h3>{{ "My Requests" | tr }}</h3>
{% if not package_requests %}
<p>{{ "No requests matched your search criteria." | tr }}</p>
{% else %}
{% with requests = package_requests %}
{% include 'partials/packages/requests.html' %}
{% endwith %}
{% endif %}
</div>
<div id="intro" class="box">
<h2>{{ "My Packages" | tr }}</h2>
<p>
<a href="/packages/?SeB=m&K={{ request.user.Username }}">
{{ "Search for packages I maintain" | tr }}
</a>
</p>
{% if not packages %}
<p>{{ "No packages matched your search criteria." | tr }}</p>
{% else %}
{% with table_id = "my-packages" %}
{% include 'partials/packages/results.html' %}
{% endwith %}
{% endif %}
</div>
<div id="intro" class="box">
<h2>{{ "Co-Maintained Packages" | tr }}</h2>
<p>
<a href="/packages/?SeB=c&K={{ request.user.Username }}">
{{ "Search for packages I co-maintain" | tr }}
</a>
</p>
{% if not comaintained %}
<p>{{ "No packages matched your search criteria." | tr }}</p>
{% else %}
{% with table_id = "comaintained-packages", packages = comaintained %}
{% include 'partials/packages/results.html' %}
{% endwith %}
{% endif %}
</div>

View file

@ -3,7 +3,11 @@
{% block pageContent %}
<div id="content-left-wrapper">
<div id="content-left">
{% include 'home.html' %}
{% if request.user.is_authenticated() %}
{% include 'dashboard.html' %}
{% else %}
{% include 'home.html' %}
{% endif %}
</div>
</div>
<div id="content-right">

View file

@ -0,0 +1,38 @@
<table id="pkgreq-results" class="results">
<thead>
<tr>
<th>{{ "Package" | tr }}</th>
<th>{{ "Type" | tr }}</th>
<th>{{ "Comments" | tr }}</th>
<th>{{ "Filed by" | tr }}</th>
<th>{{ "Date" | tr }}</th>
<th>{{ "Status" | tr }}</th>
</tr>
</thead>
<tbody>
{% for request in requests %}
{% set requested = request.RequestTS | dt | as_timezone(timezone) %}
<tr>
<td>
<a href="/pkgbase/{{ request.PackageBase.Name }}">
{{ request.PackageBase.Name }}
</a>
</td>
<td>{{ request.RequestType.name_display() | tr }}</td>
<td class="wrap">{{ request.Comments }}</td>
<td>
<a href="/account/{{ request.User.Username }}"
title="{{ 'View account information for %s' | tr | format(request.User.Username) }}">
{{ request.User.Username }}
</a>
</td>
<td>{{ requested.strftime("%Y-%m-%d %H:%M") }}</td>
<td>{{ request.status_display() | tr }}</td>
</tr>
{% endfor %}
</tbody>
</table>

View file

@ -0,0 +1,55 @@
<table {% if table_id %}id="{{ table_id }}"{% endif %} class="results">
<thead>
<tr>
<th>{{ "Name" | tr }}</th>
<th>{{ "Version" | tr }}</th>
<th>{{ "Votes" | tr }}</th>
<th>{{ "Popularity" | tr }}</th>
<th>{{ "Voted" | tr }}</th>
<th>{{ "Notify" | tr }}</th>
<th>{{ "Description" | tr }}</th>
<th>{{ "Maintainer" | tr }}</th>
</tr>
</thead>
<tbody>
{% for pkg in packages %}
{% set flagged = pkg.PackageBase.OutOfDateTS %}
<tr>
<td>
<a href="/packages/{{ pkg.Name }}">
{{ pkg.Name }}
</a>
</td>
{% if flagged %}
<td class="flagged">{{ pkg.Version }}</td>
{% else %}
<td>{{ pkg.Version }}</td>
{% endif %}
<td>{{ pkg.PackageBase.NumVotes }}</td>
<td>
{{ pkg.PackageBase.Popularity | number_format(2) }}
</td>
<td>
<!-- If I voted, display "Yes". -->
{% if request.user.voted_for(pkg) %}
{{ "Yes" | tr }}
{% endif %}
</td>
<td>
<!-- If I'm being notified, display "Yes". -->
{% if request.user.notified(pkg) %}
{{ "Yes" | tr }}
{% endif %}
</td>
<td class="wrap">{{ pkg.Description or '' }}</td>
<td>
{% set maintainer = pkg.PackageBase.Maintainer %}
<a href="/account/{{ maintainer.Username }}">
{{ maintainer.Username }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>