myst/web/app/templates/dashboard.html

199 lines
9.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block title %}Dashboard — Firebreak{% endblock %}
{% block content %}
<div class="flex flex-col gap-6">
<section class="flex flex-col justify-between gap-4 pb-6 border-b border-border sm:flex-row sm:items-end">
<div>
<h1 class="mt-2 text-3xl font-semibold leading-10 tracking-normal">Welcome,</h1>
<p class=" text-2xl text-muted-foreground">{{ user.display_name or user.email }}.</p>
</div>
{% if pat_registered %}
<button type="button"
id="open-snapshot-picker"
class="btn btn-primary w-fit"
commandfor="snapshot-picker"
command="show-modal"
hx-get="{{ url_for('get_snapshot_picker_step', step='repository').path }}"
hx-target="#snapshot-picker-body"
hx-swap="innerHTML"
hx-indicator="#snapshot-picker-scope"
hx-sync="#snapshot-picker:replace">Select snapshot</button>
{% else %}
<span class="btn btn-primary w-fit opacity-50 pointer-events-none"
aria-disabled="true">Select snapshot</span>
{% endif %}
</section>
{% if pat_registered %}
{% include "snapshot_preview.html" %}
<dialog id="snapshot-picker"
class="picker-dialog"
aria-labelledby="snapshot-title"
aria-describedby="snapshot-description">
<div class="picker-layout">
<header class="picker-header">
<div>
<h2 id="snapshot-title" class="picker-title">Select a snapshot</h2>
<p id="snapshot-description" class="picker-description">
Choose a repository, then a branch and commit. This previews a snapshot without creating a share link.
</p>
</div>
<button type="button"
class="picker-close"
aria-label="Close dialog"
commandfor="snapshot-picker"
command="close">
<svg width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
aria-hidden="true">
<path d="M4 4l8 8M12 4l-8 8" stroke-linecap="round" />
</svg>
</button>
</header>
<div id="snapshot-picker-scope" class="picker-steps picker-load-scope">
<p class="picker-status picker-loading" role="status">Loading selection…</p>
<div id="snapshot-picker-body" class="picker-loaded">
<p class="picker-status" role="status">Could not load repositories. Close the picker and try again.</p>
</div>
</div>
</div>
</dialog>
{% endif %}
<section class="grid gap-4 md:grid-cols-3">
<div class="p-4 card">
<p class="section-header-subtle">Active share links</p>
<p class="mt-3 text-2xl font-semibold text-foreground">0</p>
<p class="mt-2 text-xs text-muted-foreground">No active share links yet.</p>
</div>
<div class="p-4 card">
<p class="section-header-subtle">Default expiry</p>
<p class="mt-3 text-2xl font-semibold text-foreground">7 days</p>
<p class="mt-2 text-xs text-muted-foreground">Applied to newly created share links.</p>
</div>
<div class="p-4 card">
<p class="section-header-subtle">Audit events</p>
<p class="mt-3 text-2xl font-semibold text-foreground">0</p>
<p class="mt-2 text-xs text-muted-foreground">Viewer activity will appear here.</p>
</div>
</section>
{% if not pat_registered %}
<div class="rounded-lg border border-warning-muted bg-warning-muted/40 px-5 py-4">
<p class="text-sm font-semibold text-warning-foreground">Access token required</p>
<p class="mt-1 text-sm text-muted-foreground">
Register a Forgejo access token to browse repositories and select a snapshot.
</p>
<a href="/settings" class="btn btn-sm btn-primary mt-3 w-fit">Go to Settings</a>
</div>
{% endif %}
<div class="space-y-3">
<div>
<h2 class="text-base font-semibold">Share links</h2>
<p class="mt-2 text-sm text-muted-foreground">Share links you’ve created.</p>
</div>
<section class="card">
<div class="overflow-x-auto">
<table class="w-full min-w-180 text-left text-sm">
<thead class="bg-muted text-xs font-semibold uppercase tracking-[0.05em] text-muted-foreground">
<tr>
<th class="px-4 py-3">Repository</th>
<th class="px-4 py-3">Commit</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3">Views</th>
<th class="px-4 py-3">Expires</th>
</tr>
</thead>
<tbody class="divide-y divide-border">
<tr class="text-muted-foreground text-center">
<td class="px-4 py-5" colspan="5">You have not created any share links yet.</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
<div class="space-y-3">
<div class="flex flex-col justify-between gap-2 sm:flex-row sm:items-end">
<div>
<h2 class="text-base font-semibold">Repositories</h2>
<p class="mt-2 text-sm text-muted-foreground">Repositories owned by your Forgejo account.</p>
</div>
{% if pat_registered and repo_total_count %}
<p class="text-xs text-muted-foreground">{{ repo_total_count }} total</p>
{% endif %}
</div>
<section class="card">
<div class="overflow-x-auto">
<table class="w-full min-w-180 text-left text-sm">
<thead class="bg-muted text-xs font-semibold uppercase tracking-[0.05em] text-muted-foreground">
<tr>
<th class="px-4 py-3">Repository</th>
<th class="px-4 py-3">Default branch</th>
<th class="px-4 py-3">Visibility</th>
<th class="px-4 py-3">Updated</th>
</tr>
</thead>
<tbody class="divide-y divide-border">
{% if not pat_registered %}
<tr class="text-muted-foreground text-center">
<td class="px-4 py-5" colspan="4">Register a Forgejo access token to view your repositories.</td>
</tr>
{% elif repo_error %}
<tr class="text-center text-warning-foreground">
<td class="px-4 py-5" colspan="4" role="alert">{{ repo_error }}</td>
</tr>
{% elif repos %}
{% for repo in repos %}
<tr class="hover:bg-muted/40">
<td class="px-4 py-3">
<a href="{{ repo.html_url }}"
target="_blank"
rel="noopener noreferrer"
class="font-medium text-foreground hover:underline">{{ repo.repo_name }}</a>
{% if repo.description %}
<p class="mt-1 max-w-xl truncate text-xs text-muted-foreground">{{ repo.description }}</p>
{% endif %}
{% if repo.archived %}
<span class="badge-warning mt-1 inline-flex">Archived</span>
{% endif %}
</td>
<td class="px-4 py-3 font-mono text-xs">{{ repo.default_branch }}</td>
<td class="px-4 py-3">
{% if repo.visibility == "public" %}
<span class="badge-success">Public</span>
{% else %}
<span class="badge bg-muted text-muted-foreground">Private</span>
{% endif %}
</td>
<td class="px-4 py-3 whitespace-nowrap text-xs text-muted-foreground">{{ repo.updated_at.strftime("%b %d, %Y") }}</td>
</tr>
{% endfor %}
{% else %}
<tr class="text-muted-foreground text-center">
<td class="px-4 py-5" colspan="4">No owned repositories found on this page.</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
{% if pat_registered and not repo_error and (repo_has_previous_page or repo_has_next_page) %}
<nav class="flex items-center justify-between border-t border-border px-4 py-3" aria-label="Repository pages">
{% if repo_has_previous_page %}
<a href="/dashboard?page={{ repo_page - 1 }}" class="btn btn-sm btn-secondary">Previous</a>
{% else %}
<span></span>
{% endif %}
<span class="text-xs text-muted-foreground">Page {{ repo_page }}</span>
{% if repo_has_next_page %}
<a href="/dashboard?page={{ repo_page + 1 }}" class="btn btn-sm btn-secondary">Next</a>
{% else %}
<span></span>
{% endif %}
</nav>
{% endif %}
</section>
</div>
</div>
{% endblock %}