Merge pull request 'admin: fix empty tables (DT engine ordering)' (#12) from preprod into main
Build & Deploy / build (push) Successful in 33s

This commit was merged in pull request #12.
This commit is contained in:
2026-07-15 09:52:00 +00:00
@@ -342,7 +342,7 @@ public class AdminController : ControllerBase
$"<div class='card'><div class='v'>{Esc(value)}</div><div class='l'>{Esc(label)}</div></div>"; $"<div class='card'><div class='v'>{Esc(value)}</div><div class='l'>{Esc(label)}</div></div>";
private static string Layout(string title, string body) => private static string Layout(string title, string body) =>
Head.Replace("__TITLE__", Esc(title)) + body + Foot; Head.Replace("__TITLE__", Esc(title)) + DtScript + body + Foot;
// Static shell (no C# interpolation → JS braces/quotes stay literal). Single quotes only. // Static shell (no C# interpolation → JS braces/quotes stay literal). Single quotes only.
private const string Head = @"<!doctype html><html lang='fr'><head> private const string Head = @"<!doctype html><html lang='fr'><head>
@@ -380,8 +380,11 @@ th.dth{cursor:pointer;user-select:none;white-space:nowrap}th.dth:hover{color:var
<span class='muted' style='margin-left:auto'>read-only · LAN</span></header> <span class='muted' style='margin-left:auto'>read-only · LAN</span></header>
<main>"; <main>";
private const string Foot = @"</main> private const string Foot = @"</main></body></html>";
<script>
// Client-side table engine, injected right after <main> so DT is defined before any
// page-level DT.init() runs. Single quotes only (verbatim string → JS braces stay literal).
private const string DtScript = @"<script>
const DT={ const DT={
init(cfg){const el=document.getElementById(cfg.id);el.innerHTML='<p class=muted>Chargement…</p>'; init(cfg){const el=document.getElementById(cfg.id);el.innerHTML='<p class=muted>Chargement…</p>';
fetch(cfg.url).then(r=>r.json()).then(rows=>DT.build(el,cfg,rows)).catch(e=>{el.innerHTML='<p class=muted>Erreur: '+e+'</p>';});}, fetch(cfg.url).then(r=>r.json()).then(rows=>DT.build(el,cfg,rows)).catch(e=>{el.innerHTML='<p class=muted>Erreur: '+e+'</p>';});},
@@ -424,5 +427,5 @@ const DT={
return '<span style=color:'+c+';font-weight:600>'+DT.esc(r)+'</span>';}, return '<span style=color:'+c+';font-weight:600>'+DT.esc(r)+'</span>';},
esc(s){const d=document.createElement('div');d.textContent=(s==null?'':''+s);return d.innerHTML;} esc(s){const d=document.createElement('div');d.textContent=(s==null?'':''+s);return d.innerHTML;}
}; };
</script></body></html>"; </script>";
} }