Files
dobetternorge-tools/dashboard/feedback.php
T
daveadmin 519bdbb6e5 feat(tools): owner feedback review surface + tool_feedback migration
Adds the missing migration for the tool_feedback table (dobetternorge_maindb)
that the in-result feedback widget writes to, repoints api/feedback.php to
dbnmDb() for consistency with the engine-config table, and adds an owner-only
dashboard (page + read API + nav) summarising ratings and notes by tool/engine.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-21 15:19:45 +02:00

81 lines
4.1 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../includes/bootstrap.php';
if (!dbnToolsIsAuthenticated()) {
dbnToolsRequirePageAuth($_SERVER['REQUEST_URI'] ?? '/dashboard/feedback.php');
}
if (!dbnToolsIsOwner()) {
http_response_code(403);
echo '<!doctype html><meta charset="utf-8"><title>Owner access required</title>'
. '<p style="font-family:sans-serif;max-width:540px;margin:4rem auto;">'
. 'Owner access required. <a href="/dashboard/">Back to dashboard</a></p>';
exit;
}
$dashboardPage = 'feedback';
$dashboardTitle = 'Tool Feedback';
$dashboardLead = 'Thumbs up/down + optional notes users left on tool results. Voluntary, case-content-free — a signal for what is working per tool and engine.';
require_once __DIR__ . '/../includes/layout_dashboard.php';
?>
<section class="dash-card">
<div class="dash-card__head">
<h2>Overview</h2>
<div class="dash-card__actions">
<button class="dash-btn" type="button" id="fbRefresh">↻ Refresh</button>
</div>
</div>
<div id="fbTotals" class="fb-totals"><div class="dms-loading"></div></div>
</section>
<section class="dash-card">
<div class="dash-card__head"><h2>By tool</h2></div>
<div id="fbByTool" class="fb-table"><div class="dms-loading"></div></div>
</section>
<section class="dash-card">
<div class="dash-card__head"><h2>By engine</h2></div>
<div id="fbByEngine" class="fb-table"><div class="dms-loading"></div></div>
</section>
<section class="dash-card">
<div class="dash-card__head"><h2>Recent notes</h2></div>
<p style="margin-top:0; max-width:74ch; line-height:1.6; font-size:0.86rem; color:rgba(22,19,15,0.6);">
Latest voluntary comments (newest first). These are user-written notes, not pasted case text.
</p>
<div id="fbRecent" class="fb-notes"><div class="dms-loading"></div></div>
</section>
<style>
.fb-totals { display:flex; gap:16px; flex-wrap:wrap; }
.fb-stat { background:#fff; border:1px solid var(--dms-stroke,#e3ddd2); border-radius:var(--dms-radius,10px); padding:14px 20px; min-width:120px; }
.fb-stat__num { font-size:26px; font-weight:700; color:var(--dms-navy,#16130f); }
.fb-stat__lbl { font-size:11px; text-transform:uppercase; letter-spacing:0.05em; color:rgba(22,19,15,0.5); margin-top:2px; }
.fb-stat--pos .fb-stat__num { color:#2f7d32; }
.fb-stat--neg .fb-stat__num { color:#b3261e; }
.fb-table { background:#fff; border:1px solid var(--dms-stroke,#e3ddd2); border-radius:var(--dms-radius,10px); overflow:hidden; }
.fb-head, .fb-row { display:grid; grid-template-columns:1.6fr 0.7fr 0.7fr 0.7fr 1.1fr; gap:12px; padding:10px 16px; align-items:center; font-size:13px; }
.fb-head { font-size:10px; text-transform:uppercase; letter-spacing:0.05em; color:rgba(22,19,15,0.4); background:rgba(22,19,15,0.02); border-bottom:1px solid var(--dms-stroke-soft,#efe9dd); }
.fb-row { border-bottom:1px solid var(--dms-stroke-soft,#efe9dd); }
.fb-row:last-child { border-bottom:0; }
.fb-row__name { font-weight:600; color:var(--dms-navy,#16130f); }
.fb-pos { color:#2f7d32; font-weight:600; }
.fb-neg { color:#b3261e; font-weight:600; }
.fb-bar { height:6px; border-radius:3px; background:#e9e3d6; overflow:hidden; }
.fb-bar__fill { height:100%; background:#2f7d32; }
.fb-meta { font-size:11px; color:rgba(22,19,15,0.45); }
.fb-notes { display:flex; flex-direction:column; gap:10px; }
.fb-note { background:#fff; border:1px solid var(--dms-stroke,#e3ddd2); border-radius:8px; padding:10px 14px; font-size:13px; }
.fb-note__head { display:flex; gap:10px; align-items:center; margin-bottom:4px; }
.fb-note__tool { font-weight:600; color:var(--dms-navy,#16130f); }
.fb-note__rating { font-size:11px; font-weight:600; padding:2px 8px; border-radius:999px; }
.fb-note__rating.is-pos { background:rgba(47,125,50,0.14); color:#2f7d32; }
.fb-note__rating.is-neg { background:rgba(179,38,30,0.12); color:#b3261e; }
.fb-note__text { color:rgba(22,19,15,0.85); white-space:pre-wrap; }
.fb-empty { padding:18px 16px; color:rgba(22,19,15,0.5); font-size:13px; }
</style>
<script src="/assets/js/dashboard/feedback.js" defer></script>
<?php require_once __DIR__ . '/../includes/layout_dashboard_footer.php'; ?>