|
|
|
|
@@ -6,7 +6,6 @@
|
|
|
|
|
<title>Furumi Agent — Admin</title>
|
|
|
|
|
<style>
|
|
|
|
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
|
|
|
|
|
|
|
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
|
|
|
|
|
|
:root {
|
|
|
|
|
@@ -27,101 +26,52 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html, body { height: 100%; overflow: hidden; }
|
|
|
|
|
body { font-family: 'Inter', sans-serif; background: var(--bg-base); color: var(--text); display: flex; flex-direction: column; }
|
|
|
|
|
|
|
|
|
|
body {
|
|
|
|
|
font-family: 'Inter', sans-serif;
|
|
|
|
|
background: var(--bg-base);
|
|
|
|
|
color: var(--text);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header {
|
|
|
|
|
background: var(--bg-panel);
|
|
|
|
|
border-bottom: 1px solid var(--border);
|
|
|
|
|
padding: 12px 24px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header h1 {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stats {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 16px;
|
|
|
|
|
margin-left: auto;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
color: var(--text-dim);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stats .stat { display: flex; gap: 4px; align-items: center; }
|
|
|
|
|
header { background: var(--bg-panel); border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
|
|
|
|
|
header h1 { font-size: 15px; font-weight: 600; }
|
|
|
|
|
.stats { display: flex; gap: 14px; margin-left: auto; font-size: 12px; color: var(--text-dim); }
|
|
|
|
|
.stats .stat { display: flex; gap: 3px; align-items: center; }
|
|
|
|
|
.stats .stat-value { color: var(--text); font-weight: 600; }
|
|
|
|
|
.agent-status { font-size: 11px; padding: 3px 8px; border-radius: 4px; }
|
|
|
|
|
.agent-status.idle { background: #052e16; color: var(--success); }
|
|
|
|
|
.agent-status.busy { background: #1e1b4b; color: var(--accent); animation: pulse 1.5s infinite; }
|
|
|
|
|
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
|
|
|
|
|
|
|
|
|
|
nav {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nav button {
|
|
|
|
|
background: none;
|
|
|
|
|
border: none;
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
padding: 6px 12px;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-family: inherit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nav { display: flex; gap: 3px; }
|
|
|
|
|
nav button { background: none; border: none; color: var(--text-muted); padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; font-family: inherit; }
|
|
|
|
|
nav button:hover { background: var(--bg-hover); color: var(--text); }
|
|
|
|
|
nav button.active { background: var(--bg-active); color: var(--accent); }
|
|
|
|
|
|
|
|
|
|
main {
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
padding: 16px 24px;
|
|
|
|
|
}
|
|
|
|
|
/* Filter bar */
|
|
|
|
|
.filter-bar { display: flex; gap: 4px; padding: 10px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; align-items: center; flex-wrap: wrap; }
|
|
|
|
|
.filter-btn { font-size: 11px; padding: 4px 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px; color: var(--text-muted); cursor: pointer; font-family: inherit; }
|
|
|
|
|
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
|
|
|
|
|
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
|
|
|
|
|
.filter-btn .count { font-weight: 600; margin-left: 3px; }
|
|
|
|
|
|
|
|
|
|
table {
|
|
|
|
|
width: 100%;
|
|
|
|
|
border-collapse: collapse;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
th {
|
|
|
|
|
text-align: left;
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
border-bottom: 1px solid var(--border);
|
|
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
background: var(--bg-base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
td {
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
border-bottom: 1px solid var(--border);
|
|
|
|
|
max-width: 200px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
|
|
|
|
main { flex: 1; overflow-y: auto; }
|
|
|
|
|
|
|
|
|
|
/* Table */
|
|
|
|
|
table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
|
|
|
th { text-align: left; padding: 6px 10px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-base); z-index: 2; font-size: 11px; }
|
|
|
|
|
td { padding: 5px 10px; border-bottom: 1px solid var(--border); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
|
|
|
tr:hover td { background: var(--bg-hover); }
|
|
|
|
|
tr.selected td { background: var(--bg-active); }
|
|
|
|
|
|
|
|
|
|
.status {
|
|
|
|
|
padding: 2px 8px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
text-transform: uppercase;
|
|
|
|
|
}
|
|
|
|
|
/* Group header */
|
|
|
|
|
.group-header td { background: var(--bg-card); font-weight: 600; color: var(--text-dim); font-size: 11px; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
|
|
|
|
|
.group-header:hover td { background: var(--bg-card); }
|
|
|
|
|
|
|
|
|
|
/* Inline edit */
|
|
|
|
|
td.editable { cursor: text; }
|
|
|
|
|
td.editable:hover { outline: 1px dashed var(--border); outline-offset: -2px; }
|
|
|
|
|
td .inline-input { background: var(--bg-card); border: 1px solid var(--accent); border-radius: 3px; padding: 2px 5px; color: var(--text); font-size: 12px; font-family: inherit; width: 100%; }
|
|
|
|
|
|
|
|
|
|
/* Checkbox */
|
|
|
|
|
.cb { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
|
|
|
|
|
|
|
|
|
|
.status { padding: 2px 7px; border-radius: 3px; font-size: 10px; font-weight: 600; text-transform: uppercase; }
|
|
|
|
|
.status-pending { background: #1e293b; color: var(--text-muted); }
|
|
|
|
|
.status-processing { background: #1e1b4b; color: var(--accent); }
|
|
|
|
|
.status-review { background: #422006; color: var(--warning); }
|
|
|
|
|
@@ -129,180 +79,54 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
|
|
.status-rejected { background: #450a0a; color: var(--danger); }
|
|
|
|
|
.status-error { background: #450a0a; color: var(--danger); }
|
|
|
|
|
|
|
|
|
|
.actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
|
border: none;
|
|
|
|
|
padding: 4px 10px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-family: inherit;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.actions { display: flex; gap: 3px; }
|
|
|
|
|
.btn { border: none; padding: 3px 8px; border-radius: 3px; cursor: pointer; font-size: 11px; font-family: inherit; font-weight: 500; }
|
|
|
|
|
.btn-approve { background: #052e16; color: var(--success); }
|
|
|
|
|
.btn-approve:hover { background: #065f46; }
|
|
|
|
|
.btn-reject { background: #450a0a; color: var(--danger); }
|
|
|
|
|
.btn-reject:hover { background: #7f1d1d; }
|
|
|
|
|
.btn-retry { background: #1e1b4b; color: var(--accent); }
|
|
|
|
|
.btn-retry:hover { background: #312e81; }
|
|
|
|
|
.btn-edit { background: var(--bg-active); color: var(--text-dim); }
|
|
|
|
|
.btn-edit:hover { background: var(--bg-hover); color: var(--text); }
|
|
|
|
|
|
|
|
|
|
.empty {
|
|
|
|
|
text-align: center;
|
|
|
|
|
padding: 48px;
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Modal */
|
|
|
|
|
.modal-overlay {
|
|
|
|
|
display: none;
|
|
|
|
|
position: fixed;
|
|
|
|
|
inset: 0;
|
|
|
|
|
background: rgba(0,0,0,0.7);
|
|
|
|
|
z-index: 100;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-overlay.visible { display: flex; }
|
|
|
|
|
|
|
|
|
|
.modal {
|
|
|
|
|
background: var(--bg-panel);
|
|
|
|
|
border: 1px solid var(--border);
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
padding: 24px;
|
|
|
|
|
min-width: 400px;
|
|
|
|
|
max-width: 600px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal h2 { font-size: 16px; margin-bottom: 16px; }
|
|
|
|
|
|
|
|
|
|
.modal label {
|
|
|
|
|
display: block;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
margin-top: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal input, .modal textarea {
|
|
|
|
|
width: 100%;
|
|
|
|
|
background: var(--bg-card);
|
|
|
|
|
border: 1px solid var(--border);
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
padding: 8px 10px;
|
|
|
|
|
color: var(--text);
|
|
|
|
|
font-family: inherit;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal textarea { resize: vertical; min-height: 60px; }
|
|
|
|
|
|
|
|
|
|
.modal-actions {
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-actions .btn {
|
|
|
|
|
padding: 8px 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn-primary { background: var(--accent); color: white; }
|
|
|
|
|
.btn-primary:hover { background: var(--accent-dim); }
|
|
|
|
|
.btn-cancel { background: var(--bg-card); color: var(--text-dim); }
|
|
|
|
|
.btn-cancel:hover { background: var(--bg-hover); }
|
|
|
|
|
|
|
|
|
|
/* Detail fields in modal */
|
|
|
|
|
.detail-row {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
}
|
|
|
|
|
.empty { text-align: center; padding: 48px; color: var(--text-muted); font-size: 13px; }
|
|
|
|
|
|
|
|
|
|
/* Floating batch toolbar */
|
|
|
|
|
.batch-bar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 20px; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 32px rgba(0,0,0,0.6); z-index: 50; transition: opacity 0.2s, transform 0.2s; }
|
|
|
|
|
.batch-bar.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(20px); }
|
|
|
|
|
.batch-bar .batch-count { font-size: 13px; font-weight: 600; margin-right: 8px; color: var(--accent); }
|
|
|
|
|
.batch-bar .btn { padding: 6px 14px; font-size: 12px; }
|
|
|
|
|
|
|
|
|
|
/* Modal */
|
|
|
|
|
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; align-items: center; justify-content: center; }
|
|
|
|
|
.modal-overlay.visible { display: flex; }
|
|
|
|
|
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 24px; min-width: 400px; max-width: 600px; max-height: 90vh; overflow-y: auto; }
|
|
|
|
|
.modal h2 { font-size: 15px; margin-bottom: 14px; }
|
|
|
|
|
.modal label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; margin-top: 10px; }
|
|
|
|
|
.modal input, .modal textarea { width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px; padding: 7px 9px; color: var(--text); font-family: inherit; font-size: 12px; }
|
|
|
|
|
.modal textarea { resize: vertical; min-height: 50px; }
|
|
|
|
|
.modal-actions { margin-top: 16px; display: flex; gap: 6px; justify-content: flex-end; }
|
|
|
|
|
.modal-actions .btn { padding: 7px 14px; }
|
|
|
|
|
|
|
|
|
|
.detail-row { display: flex; gap: 10px; margin-top: 6px; }
|
|
|
|
|
.detail-row .field { flex: 1; }
|
|
|
|
|
.raw-value { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
|
|
|
|
|
|
|
|
|
|
.raw-value {
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
margin-top: 2px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Featured artists tags */
|
|
|
|
|
.feat-tags {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
min-height: 28px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.feat-tag {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 4px;
|
|
|
|
|
background: var(--bg-active);
|
|
|
|
|
border: 1px solid var(--border);
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
padding: 2px 8px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.feat-tag .remove {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Featured artist tags */
|
|
|
|
|
.feat-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; min-height: 24px; }
|
|
|
|
|
.feat-tag { display: flex; align-items: center; gap: 3px; background: var(--bg-active); border: 1px solid var(--border); border-radius: 3px; padding: 1px 7px; font-size: 11px; }
|
|
|
|
|
.feat-tag .remove { cursor: pointer; color: var(--text-muted); font-size: 13px; line-height: 1; }
|
|
|
|
|
.feat-tag .remove:hover { color: var(--danger); }
|
|
|
|
|
|
|
|
|
|
/* Artist search dropdown */
|
|
|
|
|
.artist-search-wrap {
|
|
|
|
|
position: relative;
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.artist-search-wrap input {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.artist-dropdown {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 100%;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
background: var(--bg-card);
|
|
|
|
|
border: 1px solid var(--border);
|
|
|
|
|
border-radius: 0 0 6px 6px;
|
|
|
|
|
max-height: 160px;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
z-index: 10;
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.artist-search-wrap { position: relative; margin-top: 5px; }
|
|
|
|
|
.artist-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: 0 0 5px 5px; max-height: 140px; overflow-y: auto; z-index: 10; display: none; }
|
|
|
|
|
.artist-dropdown.open { display: block; }
|
|
|
|
|
|
|
|
|
|
.artist-option {
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.artist-option { padding: 5px 9px; cursor: pointer; font-size: 12px; }
|
|
|
|
|
.artist-option:hover { background: var(--bg-hover); }
|
|
|
|
|
|
|
|
|
|
.artist-option .sim {
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
@@ -310,26 +134,40 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
|
|
<header>
|
|
|
|
|
<h1>Furumi Agent</h1>
|
|
|
|
|
<nav>
|
|
|
|
|
<button class="active" onclick="showTab('queue')">Queue</button>
|
|
|
|
|
<button onclick="showTab('artists')">Artists</button>
|
|
|
|
|
<button class="active" onclick="showTab('queue',this)">Queue</button>
|
|
|
|
|
<button onclick="showTab('artists',this)">Artists</button>
|
|
|
|
|
</nav>
|
|
|
|
|
<span class="agent-status idle" id="agentStatus">Idle</span>
|
|
|
|
|
<div class="stats" id="statsBar"></div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div class="filter-bar" id="filterBar"></div>
|
|
|
|
|
|
|
|
|
|
<main id="content"></main>
|
|
|
|
|
|
|
|
|
|
<div class="batch-bar hidden" id="batchBar">
|
|
|
|
|
<span class="batch-count" id="batchCount">0 selected</span>
|
|
|
|
|
<button class="btn btn-approve" onclick="batchAction('approve')">Approve</button>
|
|
|
|
|
<button class="btn btn-reject" onclick="batchAction('reject')">Reject</button>
|
|
|
|
|
<button class="btn btn-retry" onclick="batchAction('retry')">Retry</button>
|
|
|
|
|
<button class="btn btn-edit" onclick="batchAction('delete')">Delete</button>
|
|
|
|
|
<button class="btn btn-cancel" onclick="clearSelection()">Cancel</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="modal-overlay" id="modalOverlay" onclick="if(event.target===this)closeModal()">
|
|
|
|
|
<div class="modal" id="modal"></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
// Derive API base from current page path so it works behind any reverse-proxy prefix
|
|
|
|
|
// e.g. page at "/admin" or "/admin/" → API = "/admin/api"
|
|
|
|
|
// e.g. page at "/" → API = "/api"
|
|
|
|
|
const _base = location.pathname.replace(/\/+$/, '');
|
|
|
|
|
const API = _base + '/api';
|
|
|
|
|
let currentTab = 'queue';
|
|
|
|
|
let currentFilter = null;
|
|
|
|
|
let queueItems = [];
|
|
|
|
|
let selected = new Set();
|
|
|
|
|
let searchTimer = null;
|
|
|
|
|
let editFeatured = [];
|
|
|
|
|
let statsCache = null;
|
|
|
|
|
|
|
|
|
|
async function api(path, opts) {
|
|
|
|
|
const r = await fetch(API + path, opts);
|
|
|
|
|
@@ -337,117 +175,235 @@ async function api(path, opts) {
|
|
|
|
|
const text = await r.text();
|
|
|
|
|
if (!text) return null;
|
|
|
|
|
try { return JSON.parse(text); }
|
|
|
|
|
catch(e) { console.error('API parse error:', r.status, text); return null; }
|
|
|
|
|
catch(e) { console.error('API error:', r.status, text); return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- Stats & polling ---
|
|
|
|
|
async function loadStats() {
|
|
|
|
|
const s = await api('/stats');
|
|
|
|
|
if (!s) return;
|
|
|
|
|
statsCache = s;
|
|
|
|
|
document.getElementById('statsBar').innerHTML = `
|
|
|
|
|
<div class="stat">Tracks: <span class="stat-value">${s.total_tracks}</span></div>
|
|
|
|
|
<div class="stat">Artists: <span class="stat-value">${s.total_artists}</span></div>
|
|
|
|
|
<div class="stat">Albums: <span class="stat-value">${s.total_albums}</span></div>
|
|
|
|
|
<div class="stat">Pending: <span class="stat-value">${s.pending_count}</span></div>
|
|
|
|
|
<div class="stat">Review: <span class="stat-value">${s.review_count}</span></div>
|
|
|
|
|
<div class="stat">Errors: <span class="stat-value">${s.error_count}</span></div>
|
|
|
|
|
`;
|
|
|
|
|
// Agent status
|
|
|
|
|
const el = document.getElementById('agentStatus');
|
|
|
|
|
if (s.pending_count > 0) { el.textContent = 'Processing...'; el.className = 'agent-status busy'; }
|
|
|
|
|
else { el.textContent = 'Idle'; el.className = 'agent-status idle'; }
|
|
|
|
|
|
|
|
|
|
// Update filter counts if on queue tab
|
|
|
|
|
if (currentTab === 'queue') renderFilterBar(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderFilterBar(s) {
|
|
|
|
|
const bar = document.getElementById('filterBar');
|
|
|
|
|
if (currentTab !== 'queue') { bar.innerHTML = ''; return; }
|
|
|
|
|
const f = currentFilter;
|
|
|
|
|
bar.innerHTML = `
|
|
|
|
|
<button class="filter-btn ${!f?'active':''}" onclick="loadQueue()">All</button>
|
|
|
|
|
<button class="filter-btn ${f==='review'?'active':''}" onclick="loadQueue('review')">Review<span class="count">${s.review_count}</span></button>
|
|
|
|
|
<button class="filter-btn ${f==='pending'?'active':''}" onclick="loadQueue('pending')">Pending<span class="count">${s.pending_count}</span></button>
|
|
|
|
|
<button class="filter-btn ${f==='error'?'active':''}" onclick="loadQueue('error')">Errors<span class="count">${s.error_count}</span></button>
|
|
|
|
|
<button class="filter-btn ${f==='approved'?'active':''}" onclick="loadQueue('approved')">Approved</button>
|
|
|
|
|
<button class="filter-btn ${f==='rejected'?'active':''}" onclick="loadQueue('rejected')">Rejected</button>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showTab(tab) {
|
|
|
|
|
function showTab(tab, btn) {
|
|
|
|
|
currentTab = tab;
|
|
|
|
|
document.querySelectorAll('nav button').forEach(b => b.classList.remove('active'));
|
|
|
|
|
event.target.classList.add('active');
|
|
|
|
|
if (tab === 'queue') loadQueue();
|
|
|
|
|
else if (tab === 'artists') loadArtists();
|
|
|
|
|
btn.classList.add('active');
|
|
|
|
|
clearSelection();
|
|
|
|
|
if (tab === 'queue') { loadQueue(); loadStats(); }
|
|
|
|
|
else if (tab === 'artists') { loadArtists(); document.getElementById('filterBar').innerHTML = ''; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadQueue(status) {
|
|
|
|
|
// --- Queue ---
|
|
|
|
|
async function loadQueue(status, keepSelection) {
|
|
|
|
|
currentFilter = status;
|
|
|
|
|
const qs = status ? `?status=${status}` : '';
|
|
|
|
|
const items = await api(`/queue${qs}`);
|
|
|
|
|
const el = document.getElementById('content');
|
|
|
|
|
if (!keepSelection) clearSelection();
|
|
|
|
|
const qs = status ? `?status=${status}&limit=200` : '?limit=200';
|
|
|
|
|
queueItems = await api(`/queue${qs}`) || [];
|
|
|
|
|
// Prune selection: remove ids no longer in the list
|
|
|
|
|
const currentIds = new Set(queueItems.map(i => i.id));
|
|
|
|
|
for (const id of [...selected]) { if (!currentIds.has(id)) selected.delete(id); }
|
|
|
|
|
updateBatchBar();
|
|
|
|
|
renderQueue();
|
|
|
|
|
if (statsCache) renderFilterBar(statsCache);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!items.length) {
|
|
|
|
|
el.innerHTML = '<div class="empty">No items in queue</div>';
|
|
|
|
|
return;
|
|
|
|
|
function renderQueue() {
|
|
|
|
|
const el = document.getElementById('content');
|
|
|
|
|
if (!queueItems.length) { el.innerHTML = '<div class="empty">No items in queue</div>'; return; }
|
|
|
|
|
|
|
|
|
|
// Group by album
|
|
|
|
|
const groups = {};
|
|
|
|
|
const noAlbum = [];
|
|
|
|
|
for (const it of queueItems) {
|
|
|
|
|
const key = it.norm_album || it.raw_album || it.path_album;
|
|
|
|
|
if (key) { (groups[key] = groups[key] || []).push(it); }
|
|
|
|
|
else noAlbum.push(it);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let html = `
|
|
|
|
|
<div style="margin-bottom:12px;display:flex;gap:4px">
|
|
|
|
|
<button class="btn ${!status?'btn-primary':'btn-edit'}" onclick="loadQueue()">All</button>
|
|
|
|
|
<button class="btn ${status==='review'?'btn-primary':'btn-edit'}" onclick="loadQueue('review')">Review</button>
|
|
|
|
|
<button class="btn ${status==='pending'?'btn-primary':'btn-edit'}" onclick="loadQueue('pending')">Pending</button>
|
|
|
|
|
<button class="btn ${status==='approved'?'btn-primary':'btn-edit'}" onclick="loadQueue('approved')">Approved</button>
|
|
|
|
|
<button class="btn ${status==='error'?'btn-primary':'btn-edit'}" onclick="loadQueue('error')">Errors</button>
|
|
|
|
|
</div>
|
|
|
|
|
<table>
|
|
|
|
|
<tr><th>Status</th><th>Raw Artist</th><th>Raw Title</th><th>Norm Artist</th><th>Norm Title</th><th>Norm Album</th><th>Conf</th><th>Actions</th></tr>
|
|
|
|
|
`;
|
|
|
|
|
let html = `<table><tr>
|
|
|
|
|
<th style="width:30px"><input type="checkbox" class="cb" onchange="toggleSelectAll(this.checked)"></th>
|
|
|
|
|
<th style="width:70px">Status</th>
|
|
|
|
|
<th>Artist</th>
|
|
|
|
|
<th>Title</th>
|
|
|
|
|
<th>Album</th>
|
|
|
|
|
<th style="width:40px">Yr</th>
|
|
|
|
|
<th style="width:30px">#</th>
|
|
|
|
|
<th style="width:40px">Conf</th>
|
|
|
|
|
<th style="width:130px">Actions</th>
|
|
|
|
|
</tr>`;
|
|
|
|
|
|
|
|
|
|
for (const it of items) {
|
|
|
|
|
const renderRow = (it) => {
|
|
|
|
|
const sel = selected.has(it.id) ? ' selected' : '';
|
|
|
|
|
const conf = it.confidence != null ? it.confidence.toFixed(2) : '-';
|
|
|
|
|
html += `<tr>
|
|
|
|
|
const artist = it.norm_artist || it.raw_artist || '-';
|
|
|
|
|
const title = it.norm_title || it.raw_title || '-';
|
|
|
|
|
const album = it.norm_album || it.raw_album || '-';
|
|
|
|
|
const year = it.norm_year || it.raw_year || '';
|
|
|
|
|
const tnum = it.norm_track_number || it.raw_track_number || '';
|
|
|
|
|
const canApprove = it.status === 'review';
|
|
|
|
|
const canRetry = it.status === 'error';
|
|
|
|
|
return `<tr class="${sel}" data-id="${it.id}">
|
|
|
|
|
<td><input type="checkbox" class="cb" ${selected.has(it.id)?'checked':''} onchange="toggleSelect('${it.id}',this.checked)"></td>
|
|
|
|
|
<td><span class="status status-${it.status}">${it.status}</span></td>
|
|
|
|
|
<td title="${esc(it.raw_artist)}">${esc(it.raw_artist || '-')}</td>
|
|
|
|
|
<td title="${esc(it.raw_title)}">${esc(it.raw_title || '-')}</td>
|
|
|
|
|
<td title="${esc(it.norm_artist)}">${esc(it.norm_artist || '-')}</td>
|
|
|
|
|
<td title="${esc(it.norm_title)}">${esc(it.norm_title || '-')}</td>
|
|
|
|
|
<td title="${esc(it.norm_album)}">${esc(it.norm_album || '-')}</td>
|
|
|
|
|
<td class="editable" ondblclick="inlineEdit(this,'${it.id}','norm_artist')" title="${esc(it.raw_artist||'')}">${esc(artist)}</td>
|
|
|
|
|
<td class="editable" ondblclick="inlineEdit(this,'${it.id}','norm_title')" title="${esc(it.raw_title||'')}">${esc(title)}</td>
|
|
|
|
|
<td class="editable" ondblclick="inlineEdit(this,'${it.id}','norm_album')" title="${esc(it.raw_album||'')}">${esc(album)}</td>
|
|
|
|
|
<td>${year}</td>
|
|
|
|
|
<td>${tnum}</td>
|
|
|
|
|
<td>${conf}</td>
|
|
|
|
|
<td class="actions">
|
|
|
|
|
${it.status === 'review' ? `<button class="btn btn-approve" onclick="approveItem('${it.id}')">Approve</button>` : ''}
|
|
|
|
|
${it.status === 'review' ? `<button class="btn btn-reject" onclick="rejectItem('${it.id}')">Reject</button>` : ''}
|
|
|
|
|
${canApprove ? `<button class="btn btn-approve" onclick="approveItem('${it.id}')">Approve</button>` : ''}
|
|
|
|
|
${canApprove ? `<button class="btn btn-reject" onclick="rejectItem('${it.id}')">Reject</button>` : ''}
|
|
|
|
|
${canRetry ? `<button class="btn btn-retry" onclick="retryItem('${it.id}')">Retry</button>` : ''}
|
|
|
|
|
<button class="btn btn-edit" onclick="editItem('${it.id}')">Edit</button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>`;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
html += '</table>';
|
|
|
|
|
el.innerHTML = html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadArtists() {
|
|
|
|
|
const artists = await api('/artists');
|
|
|
|
|
const el = document.getElementById('content');
|
|
|
|
|
|
|
|
|
|
if (!artists.length) {
|
|
|
|
|
el.innerHTML = '<div class="empty">No artists yet</div>';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let html = '<table><tr><th>ID</th><th>Name</th><th>Actions</th></tr>';
|
|
|
|
|
for (const a of artists) {
|
|
|
|
|
html += `<tr>
|
|
|
|
|
<td>${a.id}</td>
|
|
|
|
|
<td>${esc(a.name)}</td>
|
|
|
|
|
<td class="actions">
|
|
|
|
|
<button class="btn btn-edit" onclick="editArtist(${a.id}, '${esc(a.name)}')">Rename</button>
|
|
|
|
|
</td>
|
|
|
|
|
// Render grouped
|
|
|
|
|
for (const [albumName, items] of Object.entries(groups)) {
|
|
|
|
|
const artist = items[0].norm_artist || items[0].raw_artist || '?';
|
|
|
|
|
const year = items[0].norm_year || items[0].raw_year || '';
|
|
|
|
|
const yearStr = year ? ` (${year})` : '';
|
|
|
|
|
const albumIds = items.map(i => i.id);
|
|
|
|
|
html += `<tr class="group-header">
|
|
|
|
|
<td><input type="checkbox" class="cb" onchange="toggleSelectGroup(${JSON.stringify(albumIds).replace(/"/g,'"')},this.checked)"></td>
|
|
|
|
|
<td colspan="8">${esc(artist)} — ${esc(albumName)}${yearStr} (${items.length} tracks)</td>
|
|
|
|
|
</tr>`;
|
|
|
|
|
for (const it of items) html += renderRow(it);
|
|
|
|
|
}
|
|
|
|
|
// Ungrouped
|
|
|
|
|
if (noAlbum.length) {
|
|
|
|
|
if (Object.keys(groups).length) {
|
|
|
|
|
html += `<tr class="group-header"><td></td><td colspan="8">Ungrouped</td></tr>`;
|
|
|
|
|
}
|
|
|
|
|
for (const it of noAlbum) html += renderRow(it);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</table>';
|
|
|
|
|
el.innerHTML = html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function approveItem(id) {
|
|
|
|
|
await api(`/queue/${id}/approve`, { method: 'POST' });
|
|
|
|
|
// --- Selection ---
|
|
|
|
|
function toggleSelect(id, checked) {
|
|
|
|
|
if (checked) selected.add(id); else selected.delete(id);
|
|
|
|
|
updateBatchBar();
|
|
|
|
|
// Update row style
|
|
|
|
|
const row = document.querySelector(`tr[data-id="${id}"]`);
|
|
|
|
|
if (row) row.classList.toggle('selected', checked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleSelectAll(checked) {
|
|
|
|
|
selected.clear();
|
|
|
|
|
if (checked) queueItems.forEach(it => selected.add(it.id));
|
|
|
|
|
updateBatchBar();
|
|
|
|
|
renderQueue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleSelectGroup(ids, checked) {
|
|
|
|
|
ids.forEach(id => { if (checked) selected.add(id); else selected.delete(id); });
|
|
|
|
|
updateBatchBar();
|
|
|
|
|
renderQueue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearSelection() { selected.clear(); updateBatchBar(); }
|
|
|
|
|
|
|
|
|
|
function updateBatchBar() {
|
|
|
|
|
const bar = document.getElementById('batchBar');
|
|
|
|
|
if (selected.size > 0) {
|
|
|
|
|
bar.classList.remove('hidden');
|
|
|
|
|
document.getElementById('batchCount').textContent = selected.size + ' selected';
|
|
|
|
|
} else {
|
|
|
|
|
bar.classList.add('hidden');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function batchAction(action) {
|
|
|
|
|
const ids = [...selected];
|
|
|
|
|
if (!ids.length) return;
|
|
|
|
|
if (action === 'delete' && !confirm(`Delete ${ids.length} item(s)?`)) return;
|
|
|
|
|
await api(`/queue/batch/${action}`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
body: JSON.stringify({ ids }),
|
|
|
|
|
});
|
|
|
|
|
clearSelection();
|
|
|
|
|
loadStats();
|
|
|
|
|
loadQueue(currentFilter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function rejectItem(id) {
|
|
|
|
|
await api(`/queue/${id}/reject`, { method: 'POST' });
|
|
|
|
|
loadStats();
|
|
|
|
|
loadQueue(currentFilter);
|
|
|
|
|
// --- Single actions ---
|
|
|
|
|
async function approveItem(id) { await api(`/queue/${id}/approve`, { method: 'POST' }); loadStats(); loadQueue(currentFilter); }
|
|
|
|
|
async function rejectItem(id) { await api(`/queue/${id}/reject`, { method: 'POST' }); loadStats(); loadQueue(currentFilter); }
|
|
|
|
|
async function retryItem(id) { await api(`/queue/${id}/retry`, { method: 'POST' }); loadStats(); loadQueue(currentFilter); }
|
|
|
|
|
|
|
|
|
|
// --- Inline editing ---
|
|
|
|
|
function inlineEdit(td, id, field) {
|
|
|
|
|
if (td.querySelector('.inline-input')) return;
|
|
|
|
|
const current = td.textContent.trim();
|
|
|
|
|
const input = document.createElement('input');
|
|
|
|
|
input.className = 'inline-input';
|
|
|
|
|
input.value = current === '-' ? '' : current;
|
|
|
|
|
td.textContent = '';
|
|
|
|
|
td.appendChild(input);
|
|
|
|
|
input.focus();
|
|
|
|
|
input.select();
|
|
|
|
|
|
|
|
|
|
const save = async () => {
|
|
|
|
|
const val = input.value.trim();
|
|
|
|
|
td.textContent = val || '-';
|
|
|
|
|
// Send update
|
|
|
|
|
const body = {};
|
|
|
|
|
body[field] = val || null;
|
|
|
|
|
await api(`/queue/${id}/update`, {
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
body: JSON.stringify(body),
|
|
|
|
|
});
|
|
|
|
|
// Update local cache
|
|
|
|
|
const item = queueItems.find(i => i.id === id);
|
|
|
|
|
if (item) item[field] = val || null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
input.addEventListener('blur', save);
|
|
|
|
|
input.addEventListener('keydown', e => {
|
|
|
|
|
if (e.key === 'Enter') { e.preventDefault(); input.blur(); }
|
|
|
|
|
if (e.key === 'Escape') { td.textContent = current; }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let editFeatured = [];
|
|
|
|
|
let searchTimer = null;
|
|
|
|
|
|
|
|
|
|
// --- Full edit modal ---
|
|
|
|
|
async function editItem(id) {
|
|
|
|
|
const item = await api(`/queue/${id}`);
|
|
|
|
|
if (!item) return;
|
|
|
|
|
|
|
|
|
|
// Parse featured artists from JSON string
|
|
|
|
|
editFeatured = [];
|
|
|
|
|
if (item.norm_featured_artists) {
|
|
|
|
|
try { editFeatured = JSON.parse(item.norm_featured_artists); } catch(e) {}
|
|
|
|
|
@@ -497,7 +453,7 @@ async function editItem(id) {
|
|
|
|
|
oninput="onFeatSearch(this.value)" onkeydown="onFeatKey(event)">
|
|
|
|
|
<div class="artist-dropdown" id="feat-dropdown"></div>
|
|
|
|
|
</div>
|
|
|
|
|
${item.llm_notes ? `<label>Agent Notes</label><div class="raw-value" style="margin-bottom:8px">${esc(item.llm_notes)}</div>` : ''}
|
|
|
|
|
${item.llm_notes ? `<label>Agent Notes</label><div class="raw-value" style="margin-bottom:6px">${esc(item.llm_notes)}</div>` : ''}
|
|
|
|
|
${item.error_message ? `<label>Error</label><div class="raw-value" style="color:var(--danger)">${esc(item.error_message)}</div>` : ''}
|
|
|
|
|
<div class="modal-actions">
|
|
|
|
|
<button class="btn btn-cancel" onclick="closeModal()">Cancel</button>
|
|
|
|
|
@@ -508,76 +464,6 @@ async function editItem(id) {
|
|
|
|
|
openModal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderFeatTags() {
|
|
|
|
|
const el = document.getElementById('feat-tags');
|
|
|
|
|
if (!el) return;
|
|
|
|
|
el.innerHTML = editFeatured.map((name, i) =>
|
|
|
|
|
`<span class="feat-tag">${esc(name)}<span class="remove" onclick="removeFeat(${i})">×</span></span>`
|
|
|
|
|
).join('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeFeat(idx) {
|
|
|
|
|
editFeatured.splice(idx, 1);
|
|
|
|
|
renderFeatTags();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addFeat(name) {
|
|
|
|
|
name = name.trim();
|
|
|
|
|
if (!name || editFeatured.includes(name)) return;
|
|
|
|
|
editFeatured.push(name);
|
|
|
|
|
renderFeatTags();
|
|
|
|
|
const input = document.getElementById('feat-search');
|
|
|
|
|
if (input) { input.value = ''; }
|
|
|
|
|
closeFeatDropdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onFeatSearch(q) {
|
|
|
|
|
clearTimeout(searchTimer);
|
|
|
|
|
if (q.length < 2) { closeFeatDropdown(); return; }
|
|
|
|
|
searchTimer = setTimeout(async () => {
|
|
|
|
|
const results = await api(`/artists/search?q=${encodeURIComponent(q)}&limit=8`);
|
|
|
|
|
const dd = document.getElementById('feat-dropdown');
|
|
|
|
|
if (!results || !results.length) {
|
|
|
|
|
// Show option to add as new
|
|
|
|
|
dd.innerHTML = `<div class="artist-option" onclick="addFeat('${esc(q)}')">
|
|
|
|
|
Add "${esc(q)}" as new
|
|
|
|
|
</div>`;
|
|
|
|
|
dd.classList.add('open');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let html = '';
|
|
|
|
|
for (const a of results) {
|
|
|
|
|
html += `<div class="artist-option" onclick="addFeat('${esc(a.name)}')">
|
|
|
|
|
${esc(a.name)}
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
// Always offer to add typed value as-is
|
|
|
|
|
const typed = document.getElementById('feat-search').value.trim();
|
|
|
|
|
if (typed && !results.find(a => a.name.toLowerCase() === typed.toLowerCase())) {
|
|
|
|
|
html += `<div class="artist-option" onclick="addFeat('${esc(typed)}')">
|
|
|
|
|
Add "${esc(typed)}" as new
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
dd.innerHTML = html;
|
|
|
|
|
dd.classList.add('open');
|
|
|
|
|
}, 250);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onFeatKey(e) {
|
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
const val = e.target.value.trim();
|
|
|
|
|
if (val) addFeat(val);
|
|
|
|
|
} else if (e.key === 'Escape') {
|
|
|
|
|
closeFeatDropdown();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeFeatDropdown() {
|
|
|
|
|
const dd = document.getElementById('feat-dropdown');
|
|
|
|
|
if (dd) dd.classList.remove('open');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function saveEdit(id) {
|
|
|
|
|
const body = {
|
|
|
|
|
norm_artist: document.getElementById('ed-artist').value || null,
|
|
|
|
|
@@ -597,6 +483,96 @@ async function saveEdit(id) {
|
|
|
|
|
loadQueue(currentFilter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- Featured artists ---
|
|
|
|
|
function renderFeatTags() {
|
|
|
|
|
const el = document.getElementById('feat-tags');
|
|
|
|
|
if (!el) return;
|
|
|
|
|
el.innerHTML = editFeatured.map((name, i) =>
|
|
|
|
|
`<span class="feat-tag">${esc(name)}<span class="remove" onclick="removeFeat(${i})">×</span></span>`
|
|
|
|
|
).join('');
|
|
|
|
|
}
|
|
|
|
|
function removeFeat(idx) { editFeatured.splice(idx, 1); renderFeatTags(); }
|
|
|
|
|
function addFeat(name) {
|
|
|
|
|
name = name.trim();
|
|
|
|
|
if (!name || editFeatured.includes(name)) return;
|
|
|
|
|
editFeatured.push(name);
|
|
|
|
|
renderFeatTags();
|
|
|
|
|
const input = document.getElementById('feat-search');
|
|
|
|
|
if (input) input.value = '';
|
|
|
|
|
closeFeatDropdown();
|
|
|
|
|
}
|
|
|
|
|
function onFeatSearch(q) {
|
|
|
|
|
clearTimeout(searchTimer);
|
|
|
|
|
if (q.length < 2) { closeFeatDropdown(); return; }
|
|
|
|
|
searchTimer = setTimeout(async () => {
|
|
|
|
|
const results = await api(`/artists/search?q=${encodeURIComponent(q)}&limit=8`);
|
|
|
|
|
const dd = document.getElementById('feat-dropdown');
|
|
|
|
|
if (!results || !results.length) {
|
|
|
|
|
dd.innerHTML = `<div class="artist-option" onclick="addFeat('${esc(q)}')">Add "${esc(q)}" as new</div>`;
|
|
|
|
|
dd.classList.add('open');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let html = results.map(a => `<div class="artist-option" onclick="addFeat('${esc(a.name)}')">${esc(a.name)}</div>`).join('');
|
|
|
|
|
const typed = document.getElementById('feat-search').value.trim();
|
|
|
|
|
if (typed && !results.find(a => a.name.toLowerCase() === typed.toLowerCase())) {
|
|
|
|
|
html += `<div class="artist-option" onclick="addFeat('${esc(typed)}')">Add "${esc(typed)}" as new</div>`;
|
|
|
|
|
}
|
|
|
|
|
dd.innerHTML = html;
|
|
|
|
|
dd.classList.add('open');
|
|
|
|
|
}, 250);
|
|
|
|
|
}
|
|
|
|
|
function onFeatKey(e) {
|
|
|
|
|
if (e.key === 'Enter') { e.preventDefault(); addFeat(e.target.value); }
|
|
|
|
|
else if (e.key === 'Escape') closeFeatDropdown();
|
|
|
|
|
}
|
|
|
|
|
function closeFeatDropdown() { const dd = document.getElementById('feat-dropdown'); if (dd) dd.classList.remove('open'); }
|
|
|
|
|
|
|
|
|
|
// --- Artists tab ---
|
|
|
|
|
async function loadArtists() {
|
|
|
|
|
const artists = await api('/artists');
|
|
|
|
|
const el = document.getElementById('content');
|
|
|
|
|
if (!artists || !artists.length) { el.innerHTML = '<div class="empty">No artists yet</div>'; return; }
|
|
|
|
|
let html = '<table><tr><th>ID</th><th>Name</th><th>Actions</th></tr>';
|
|
|
|
|
for (const a of artists) {
|
|
|
|
|
html += `<tr>
|
|
|
|
|
<td>${a.id}</td>
|
|
|
|
|
<td class="editable" ondblclick="inlineEditArtist(this,${a.id})">${esc(a.name)}</td>
|
|
|
|
|
<td class="actions">
|
|
|
|
|
<button class="btn btn-edit" onclick="editArtist(${a.id},'${esc(a.name)}')">Rename</button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>`;
|
|
|
|
|
}
|
|
|
|
|
html += '</table>';
|
|
|
|
|
el.innerHTML = html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function inlineEditArtist(td, id) {
|
|
|
|
|
if (td.querySelector('.inline-input')) return;
|
|
|
|
|
const current = td.textContent.trim();
|
|
|
|
|
const input = document.createElement('input');
|
|
|
|
|
input.className = 'inline-input';
|
|
|
|
|
input.value = current;
|
|
|
|
|
td.textContent = '';
|
|
|
|
|
td.appendChild(input);
|
|
|
|
|
input.focus();
|
|
|
|
|
input.select();
|
|
|
|
|
const save = async () => {
|
|
|
|
|
const val = input.value.trim();
|
|
|
|
|
if (!val || val === current) { td.textContent = current; return; }
|
|
|
|
|
td.textContent = val;
|
|
|
|
|
await api(`/artists/${id}`, {
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
body: JSON.stringify({ name: val }),
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
input.addEventListener('blur', save);
|
|
|
|
|
input.addEventListener('keydown', e => {
|
|
|
|
|
if (e.key === 'Enter') { e.preventDefault(); input.blur(); }
|
|
|
|
|
if (e.key === 'Escape') { td.textContent = current; }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function editArtist(id, currentName) {
|
|
|
|
|
const name = prompt('New artist name:', currentName);
|
|
|
|
|
if (!name || name === currentName) return;
|
|
|
|
|
@@ -608,18 +584,20 @@ async function editArtist(id, currentName) {
|
|
|
|
|
loadArtists();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- Helpers ---
|
|
|
|
|
function openModal() { document.getElementById('modalOverlay').classList.add('visible'); }
|
|
|
|
|
function closeModal() { document.getElementById('modalOverlay').classList.remove('visible'); }
|
|
|
|
|
|
|
|
|
|
function esc(s) {
|
|
|
|
|
if (s == null) return '';
|
|
|
|
|
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Init
|
|
|
|
|
// --- Init ---
|
|
|
|
|
loadStats();
|
|
|
|
|
loadQueue();
|
|
|
|
|
setInterval(loadStats, 10000);
|
|
|
|
|
setInterval(loadStats, 5000);
|
|
|
|
|
// Auto-refresh queue when on queue tab
|
|
|
|
|
setInterval(() => { if (currentTab === 'queue') loadQueue(currentFilter, true); }, 5000);
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
|