left4me/l4d2web/templates/_overlay_item_table.html
mwiegand df1ccb4cca
feat(l4d2-web): workshop overlay UI (routes + templates)
Adds workshop_routes blueprint with add-items / remove-item / manual-
build endpoints plus admin /admin/workshop/refresh. Add-items handles
single ID, single URL, multi-line batch, or a collection ID; auto-
enqueues a coalesced build_overlay job per call. Reject non-L4D2 items
with 400, duplicate associations with friendly toast, intruders with
403.

Generalizes overlay_routes: type+name only on create (no path field);
external is admin-only and system-wide, workshop is per-user and
auto-pathed. Update is name-only. Delete recursively removes the
on-disk dir only for managed paths (path == str(id)); legacy externals
are left in place. The pre-existing in-use guard is preserved.

Page routes filter the overlay listing by user permissions and load
workshop items + the latest related job for the detail view.

Templates: unified Create modal with type radio (no path field).
Type-aware overlay detail: workshop overlays show a multi-line input
+ items/collection radio + item table partial with thumbnails, manual
Rebuild button, and a small status indicator pulled from the latest
related job. Admin page gets a "Refresh all workshop items" button.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 16:50:54 +02:00

50 lines
1.7 KiB
HTML

{% set can_edit = g.user.admin or (overlay and overlay.type == 'workshop' and overlay.user_id == g.user.id) %}
<table class="table">
<thead>
<tr>
<th></th>
<th>Steam ID</th>
<th>Title</th>
<th>Filename</th>
<th>Size</th>
<th>Updated</th>
<th>Status</th>
{% if can_edit %}<th></th>{% endif %}
</tr>
</thead>
<tbody>
{% for item in workshop_items %}
<tr>
<td>
{% if item.preview_url %}
<img src="{{ item.preview_url }}" alt="" width="48" height="48" loading="lazy">
{% endif %}
</td>
<td><a href="https://steamcommunity.com/sharedfiles/filedetails/?id={{ item.steam_id }}" target="_blank" rel="noopener">{{ item.steam_id }}</a></td>
<td>{{ item.title }}</td>
<td class="muted">{{ item.filename }}</td>
<td class="muted">{{ item.file_size }}</td>
<td class="muted">{{ item.time_updated }}</td>
<td>
{% if item.last_error %}
<span class="warning">{{ item.last_error }}</span>
{% elif item.last_downloaded_at %}
cached
{% else %}
<span class="muted">pending</span>
{% endif %}
</td>
{% if can_edit %}
<td>
<form method="post" action="/overlays/{{ overlay.id }}/items/{{ item.id }}/delete" class="inline-form">
<input type="hidden" name="csrf_token" value="{{ session.get('csrf_token', '') }}">
<button type="submit" class="button-secondary">Remove</button>
</form>
</td>
{% endif %}
</tr>
{% else %}
<tr><td colspan="{% if can_edit %}8{% else %}7{% endif %}" class="muted">No workshop items yet.</td></tr>
{% endfor %}
</tbody>
</table>