mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 08:09:18 +02:00
- Remove duplicate 'Téléversements abandonnés' heading already communicated by the summary - Replace #peertube-orphans-wrapper with display:contents wrapper so PeerTube details sit as direct grid siblings - Add hx-confirm to all delete buttons (filepond, trash, PeerTube orphans)
116 lines
5.0 KiB
PHP
116 lines
5.0 KiB
PHP
<?php
|
|
/**
|
|
* PeerTube orphan check as HTML fragment (admin).
|
|
*
|
|
* GET /admin/actions/peertube-orphans-fragment.php
|
|
*
|
|
* Returns an HTML fragment ready for HTMX swap into #peertube-orphans-fragment.
|
|
*/
|
|
require_once __DIR__ . '/../../../bootstrap.php';
|
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
// Re-use the existing JSON endpoint internally
|
|
ob_start();
|
|
require __DIR__ . '/peertube-orphans.php';
|
|
$json = ob_get_clean();
|
|
$d = json_decode($json, true);
|
|
|
|
if (!($d['configured'] ?? false)): ?>
|
|
<div id="peertube-orphans-fragment" style="display:contents">
|
|
<details id="peertube-orphans-col" class="n-section" open>
|
|
<summary>
|
|
<?= icon('video') ?>
|
|
Vidéos PeerTube orphelines
|
|
</summary>
|
|
<div id="peertube-orphans-stats">
|
|
<p style="margin:0;color:var(--color-warning)">⚠️ PeerTube non configuré.</p>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
<?php return; endif; ?>
|
|
|
|
<?php if (!empty($d['error'])): ?>
|
|
<div id="peertube-orphans-fragment" style="display:contents">
|
|
<details id="peertube-orphans-col" class="n-section" open>
|
|
<summary>
|
|
<?= icon('video') ?>
|
|
Vidéos PeerTube orphelines
|
|
</summary>
|
|
<div id="peertube-orphans-stats">
|
|
<p style="margin:0;color:var(--color-error)">✗ <?= htmlspecialchars($d['error']) ?></p>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
<?php return; endif; ?>
|
|
|
|
<div id="peertube-orphans-fragment" style="display:contents">
|
|
<details id="peertube-orphans-col" class="n-section" open>
|
|
<summary>
|
|
<?= icon('video') ?>
|
|
Vidéos PeerTube orphelines <span class="n-meta"><?= (int)($d['orphan_count'] ?? 0) ?> vidéos orphelines</span>
|
|
</summary>
|
|
<div id="peertube-orphans-stats">
|
|
<?php if (($d['orphan_count'] ?? 0) > 0): ?>
|
|
<table class="n-table">
|
|
<thead><tr><th>Nom</th><th>Date</th><th width="1%"></th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ($d['orphans'] as $v): ?>
|
|
<tr>
|
|
<td>
|
|
<strong><?= htmlspecialchars($v['name']) ?></strong>
|
|
<span class="n-table__info" style="display:block"><?= htmlspecialchars($v['uuid']) ?></span>
|
|
</td>
|
|
<td style="white-space:nowrap"><?= htmlspecialchars(substr($v['createdAt'] ?? '', 0, 10)) ?></td>
|
|
<td style="white-space:nowrap">
|
|
<button type="button" class="btn btn--sm btn--danger" style="font-size:0.85em;padding:2px var(--space-xs)"
|
|
hx-post="/admin/actions/peertube-delete.php"
|
|
hx-confirm="Supprimer définitivement cette vidéo de PeerTube ?"
|
|
hx-vals='{"csrf_token":"<?= htmlspecialchars($_SESSION['csrf_token']) ?>","uuid":"<?= htmlspecialchars($v['uuid']) ?>"}'
|
|
hx-target="#peertube-orphans-fragment"
|
|
hx-swap="outerHTML"
|
|
hx-trigger="click"
|
|
hx-indicator="#peertube-orphans-fragment">
|
|
<?= icon('trash') ?>
|
|
Supprimer
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php else: ?>
|
|
<p style="margin:0;color:var(--accent-green)">✓ Aucune vidéo orpheline.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</details>
|
|
|
|
<?php if (($d['stale_count'] ?? 0) > 0): ?>
|
|
<details id="peertube-stale-section" class="n-section" open>
|
|
<summary>
|
|
<?= icon('warning-diamond') ?>
|
|
Références DB obsolètes <span class="n-meta"><?= $d['stale_count'] ?></span>
|
|
</summary>
|
|
<p style="margin:0 0 var(--space-sm) 0;font-size:0.85em;color:var(--text-secondary)">Ces UUID sont référencés en base de données mais n'existent plus sur la chaîne PeerTube. Les TFE liés affichent des liens morts.</p>
|
|
<table class="n-table">
|
|
<thead><tr><th>UUID</th><th>TFE(s)</th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ($d['stale_entries'] as $s): ?>
|
|
<tr>
|
|
<td style="word-break:break-all;color:var(--text-secondary)"><?= htmlspecialchars($s['uuid']) ?></td>
|
|
<td>
|
|
<?php if (!empty($s['theses'])): ?>
|
|
<?= implode(', ', array_map(function($t) {
|
|
$label = $t['identifier'] ?: '#' . $t['thesis_id'];
|
|
return '<a href="/admin/contenus-edit.php?id=' . (int)$t['thesis_id'] . '" target="_blank">' . htmlspecialchars($label) . '</a>';
|
|
}, $s['theses'])) ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</details>
|
|
<?php endif; ?>
|
|
</div>
|