feat: add per-panel debug data copy actions
Adds copy buttons to each debug dashboard sub-panel so admins can quickly export diagnostics for troubleshooting. Users and storage export as JSON; stream/cache and orphaned output panels export as CSV for easy sharing and analysis.
@@ -158,6 +158,7 @@
158
158
- Admin panel - Includes an icon-only global favicon button that opens the shared icon picker modal.
159
159
- Admin panel - Users section includes a conditional orphaned-user-folders subsection that appears only when non-empty orphan folders exist.
160
160
- Debug dashboard modal - Shows active signed-in users, total/per-root storage usage, active stream footprint, cached subtitle usage by video, and orphaned stream output directories.
161
- Debug dashboard modal - Each diagnostics sub-panel includes a copy action for quick report sharing: users/storage copy JSON, stream/cache and orphaned output tables copy CSV.
161
162
- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
162
163
- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
163
164
@@ -158,6 +158,7 @@158
- Admin panel - Includes an icon-only global favicon button that opens the shared icon picker modal.
158
- Admin panel - Includes an icon-only global favicon button that opens the shared icon picker modal.
159
- Admin panel - Users section includes a conditional orphaned-user-folders subsection that appears only when non-empty orphan folders exist.
159
- Admin panel - Users section includes a conditional orphaned-user-folders subsection that appears only when non-empty orphan folders exist.
160
- Debug dashboard modal - Shows active signed-in users, total/per-root storage usage, active stream footprint, cached subtitle usage by video, and orphaned stream output directories.
160
- Debug dashboard modal - Shows active signed-in users, total/per-root storage usage, active stream footprint, cached subtitle usage by video, and orphaned stream output directories.
161
- Debug dashboard modal - Each diagnostics sub-panel includes a copy action for quick report sharing: users/storage copy JSON, stream/cache and orphaned output tables copy CSV.
161
- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
162
- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
162
- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
163
- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
163
164
@@ -5793,6 +5793,7 @@ async function deleteItem (item)
5793
5793
5794
5794
let _adminUpdateStatus = null;
5795
5795
let _debugRefreshTimer = null;
5796
let _debugLatestData = null;
5796
5797
5797
5798
function formatTimestamp (ms)
5798
5799
{
@@ -5827,6 +5828,8 @@ function renderDebugTable (containerId, columns, rows)
5827
5828
5828
5829
function renderDebugDashboardData (data)
5829
5830
{
5831
_debugLatestData = data;
5832
5830
5833
const generatedAt = document.getElementById('debug-generated-at');
5831
5834
if (generatedAt) generatedAt.textContent = `Last update: ${formatTimestamp(data.generatedAt)}`;
5832
5835
@@ -5896,6 +5899,108 @@ function renderDebugDashboardData (data)
5896
5899
);
5897
5900
}
5898
5901
5902
function csvEscape (value)
5903
{
5904
const raw = String(value == null ? '' : value);
5905
if (/[,"\n\r]/.test(raw)) return `"${raw.replace(/"/g, '""')}"`;
5906
return raw;
5907
}
5908
5909
function toCsv (rows, columns)
5910
{
5911
const header = columns.join(',');
5912
const body = rows.map((row) => columns.map((col) => csvEscape(row[col])).join(',')).join('\n');
5913
return `${header}\n${body}`;
5914
}
5915
5916
async function copyDebugText (text, successMessage)
5917
{
5918
const payload = String(text || '');
5919
if (!payload.trim())
5920
{
5921
toast('No debug data to copy yet.', 'err');
5922
return;
5923
}
5924
5925
try
5926
{
5927
await navigator.clipboard.writeText(payload);
5928
toast(successMessage, 'ok');
5929
} catch
5930
{
5931
toast('Could not copy to clipboard.', 'err');
5932
}
5933
}
5934
5935
function copyDebugUsersJson ()
5936
{
5937
const users = Array.isArray(_debugLatestData && _debugLatestData.loggedInUsers)
5938
? _debugLatestData.loggedInUsers
5939
: [];
5940
void copyDebugText(JSON.stringify(users, null, 2), 'Copied users JSON.');
5941
}
5942
5943
function copyDebugStorageJson ()
5944
{
5945
const payload = {
5946
generatedAt: _debugLatestData && _debugLatestData.generatedAt,
5947
storage: _debugLatestData && _debugLatestData.storage,
5948
};
5949
void copyDebugText(JSON.stringify(payload, null, 2), 'Copied storage JSON.');
5950
}
5951
5952
function copyDebugVideoFilesCsv ()
5953
{
5954
const files = Array.isArray(_debugLatestData && _debugLatestData.videoFiles)
5955
? _debugLatestData.videoFiles
5956
: [];
5957
5958
const rows = files.map((row) => ({
5959
filePath: row.filePath || '',
5960
viewers: Number(row.viewers || 0),
5961
segmentFiles: Number(row.stream && row.stream.output ? row.stream.output.segmentFiles : 0),
5962
segmentBytes: Number(row.stream && row.stream.output ? row.stream.output.segmentBytes : 0),
5963
eventEntries: Number(row.subtitleCache ? row.subtitleCache.eventEntries : 0),
5964
eventBytes: Number(row.subtitleCache ? row.subtitleCache.eventBytes : 0),
5965
eventPngBytes: Number(row.subtitleCache ? row.subtitleCache.eventImageBytes : 0),
5966
frameEntries: Number(row.subtitleCache ? row.subtitleCache.frameEntries : 0),
5967
frameBytes: Number(row.subtitleCache ? row.subtitleCache.frameBytes : 0),
5968
sessionIds: Array.isArray(row.activeSessionIds) ? row.activeSessionIds.join(';') : '',
5969
}));
5970
5971
const csv = toCsv(rows, [
5972
'filePath',
5973
'viewers',
5974
'segmentFiles',
5975
'segmentBytes',
5976
'eventEntries',
5977
'eventBytes',
5978
'eventPngBytes',
5979
'frameEntries',
5980
'frameBytes',
5981
'sessionIds',
5982
]);
5983
void copyDebugText(csv, 'Copied video/cache CSV.');
5984
}
5985
5986
function copyDebugOrphanedCsv ()
5987
{
5988
const rowsRaw = Array.isArray(_debugLatestData && _debugLatestData.videoStream && _debugLatestData.videoStream.orphanedOutputDirs)
5989
? _debugLatestData.videoStream.orphanedOutputDirs
5990
: [];
5991
5992
const rows = rowsRaw.map((row) => ({
5993
outputDir: row.outputDir || '',
5994
totalFiles: Number(row.output && row.output.totalFiles || 0),
5995
totalBytes: Number(row.output && row.output.totalBytes || 0),
5996
segmentFiles: Number(row.output && row.output.segmentFiles || 0),
5997
segmentBytes: Number(row.output && row.output.segmentBytes || 0),
5998
}));
5999
6000
const csv = toCsv(rows, ['outputDir', 'totalFiles', 'totalBytes', 'segmentFiles', 'segmentBytes']);
6001
void copyDebugText(csv, 'Copied orphaned output CSV.');
6002
}
6003
5899
6004
async function refreshDebugDashboard ()
5900
6005
{
5901
6006
const data = await api('GET', '/admin/debug/stream-stats');
@@ -6078,9 +6183,11 @@ async function refreshAdminConfig ()
6078
6183
6079
6184
async function refreshAdminUsers ()
6080
6185
{
6186
if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
6081
6187
const data = await api('GET', '/admin/users');
6082
6188
if (!data) return;
6083
6189
const container = document.getElementById('admin-users-list');
6190
if (!container) return;
6084
6191
container.innerHTML = '';
6085
6192
6086
6193
// Need paths for permission rows
@@ -6118,6 +6225,7 @@ async function refreshAdminUsers ()
6118
6225
6119
6226
async function refreshAdminOrphanUserFolders ()
6120
6227
{
6228
if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
6121
6229
const section = document.getElementById('admin-orphan-userfolders-section');
6122
6230
const list = document.getElementById('admin-orphan-userfolders-list');
6123
6231
if (!section || !list) return;
@@ -7173,12 +7281,23 @@ function wireEvents ()
7173
7281
});
7174
7282
document.getElementById('admin-modal-close').addEventListener('click', () =>
7175
7283
document.getElementById('admin-modal').classList.add('hidden'));
7176
document.getElementById('debug-modal-close').addEventListener('click', closeDebugModal);
7177
document.getElementById('debug-refresh').addEventListener('click', () =>
7284
const debugModalClose = document.getElementById('debug-modal-close');
7285
if (debugModalClose) debugModalClose.addEventListener('click', closeDebugModal);
7286
const debugRefresh = document.getElementById('debug-refresh');
7287
if (debugRefresh) debugRefresh.addEventListener('click', () =>
7178
7288
{
7179
7289
void refreshDebugDashboard();
7180
7290
});
7181
document.getElementById('debug-modal').addEventListener('click', (e) =>
7291
const debugCopyUsers = document.getElementById('debug-copy-users');
7292
if (debugCopyUsers) debugCopyUsers.addEventListener('click', copyDebugUsersJson);
7293
const debugCopyStorage = document.getElementById('debug-copy-storage');
7294
if (debugCopyStorage) debugCopyStorage.addEventListener('click', copyDebugStorageJson);
7295
const debugCopyVideoFiles = document.getElementById('debug-copy-video-files');
7296
if (debugCopyVideoFiles) debugCopyVideoFiles.addEventListener('click', copyDebugVideoFilesCsv);
7297
const debugCopyOrphaned = document.getElementById('debug-copy-orphaned');
7298
if (debugCopyOrphaned) debugCopyOrphaned.addEventListener('click', copyDebugOrphanedCsv);
7299
const debugModal = document.getElementById('debug-modal');
7300
if (debugModal) debugModal.addEventListener('click', (e) =>
7182
7301
{
7183
7302
if (e.target && e.target.id === 'debug-modal') closeDebugModal();
7184
7303
});
@@ -5793,6 +5793,7 @@ async function deleteItem (item)5793
5793
5794
let _adminUpdateStatus = null;5794
let _adminUpdateStatus = null;5795
let _debugRefreshTimer = null;5795
let _debugRefreshTimer = null;5796
let _debugLatestData = null;5796
5797
5797
function formatTimestamp (ms)5798
function formatTimestamp (ms)5798
{5799
{@@ -5827,6 +5828,8 @@ function renderDebugTable (containerId, columns, rows)5827
5828
5828
function renderDebugDashboardData (data)5829
function renderDebugDashboardData (data)5829
{5830
{5831
_debugLatestData = data;5832
5830
const generatedAt = document.getElementById('debug-generated-at');5833
const generatedAt = document.getElementById('debug-generated-at');5831
if (generatedAt) generatedAt.textContent = `Last update: ${formatTimestamp(data.generatedAt)}`;5834
if (generatedAt) generatedAt.textContent = `Last update: ${formatTimestamp(data.generatedAt)}`;5832
5835
@@ -5896,6 +5899,108 @@ function renderDebugDashboardData (data)5896
);5899
);5897
}5900
}5898
5901
5902
function csvEscape (value)5903
{5904
const raw = String(value == null ? '' : value);5905
if (/[,"\n\r]/.test(raw)) return `"${raw.replace(/"/g, '""')}"`;5906
return raw;5907
}5908
5909
function toCsv (rows, columns)5910
{5911
const header = columns.join(',');5912
const body = rows.map((row) => columns.map((col) => csvEscape(row[col])).join(',')).join('\n');5913
return `${header}\n${body}`;5914
}5915
5916
async function copyDebugText (text, successMessage)5917
{5918
const payload = String(text || '');5919
if (!payload.trim())5920
{5921
toast('No debug data to copy yet.', 'err');5922
return;5923
}5924
5925
try5926
{5927
await navigator.clipboard.writeText(payload);5928
toast(successMessage, 'ok');5929
} catch5930
{5931
toast('Could not copy to clipboard.', 'err');5932
}5933
}5934
5935
function copyDebugUsersJson ()5936
{5937
const users = Array.isArray(_debugLatestData && _debugLatestData.loggedInUsers)5938
? _debugLatestData.loggedInUsers5939
: [];5940
void copyDebugText(JSON.stringify(users, null, 2), 'Copied users JSON.');5941
}5942
5943
function copyDebugStorageJson ()5944
{5945
const payload = {5946
generatedAt: _debugLatestData && _debugLatestData.generatedAt,5947
storage: _debugLatestData && _debugLatestData.storage,5948
};5949
void copyDebugText(JSON.stringify(payload, null, 2), 'Copied storage JSON.');5950
}5951
5952
function copyDebugVideoFilesCsv ()5953
{5954
const files = Array.isArray(_debugLatestData && _debugLatestData.videoFiles)5955
? _debugLatestData.videoFiles5956
: [];5957
5958
const rows = files.map((row) => ({5959
filePath: row.filePath || '',5960
viewers: Number(row.viewers || 0),5961
segmentFiles: Number(row.stream && row.stream.output ? row.stream.output.segmentFiles : 0),5962
segmentBytes: Number(row.stream && row.stream.output ? row.stream.output.segmentBytes : 0),5963
eventEntries: Number(row.subtitleCache ? row.subtitleCache.eventEntries : 0),5964
eventBytes: Number(row.subtitleCache ? row.subtitleCache.eventBytes : 0),5965
eventPngBytes: Number(row.subtitleCache ? row.subtitleCache.eventImageBytes : 0),5966
frameEntries: Number(row.subtitleCache ? row.subtitleCache.frameEntries : 0),5967
frameBytes: Number(row.subtitleCache ? row.subtitleCache.frameBytes : 0),5968
sessionIds: Array.isArray(row.activeSessionIds) ? row.activeSessionIds.join(';') : '',5969
}));5970
5971
const csv = toCsv(rows, [5972
'filePath',5973
'viewers',5974
'segmentFiles',5975
'segmentBytes',5976
'eventEntries',5977
'eventBytes',5978
'eventPngBytes',5979
'frameEntries',5980
'frameBytes',5981
'sessionIds',5982
]);5983
void copyDebugText(csv, 'Copied video/cache CSV.');5984
}5985
5986
function copyDebugOrphanedCsv ()5987
{5988
const rowsRaw = Array.isArray(_debugLatestData && _debugLatestData.videoStream && _debugLatestData.videoStream.orphanedOutputDirs)5989
? _debugLatestData.videoStream.orphanedOutputDirs5990
: [];5991
5992
const rows = rowsRaw.map((row) => ({5993
outputDir: row.outputDir || '',5994
totalFiles: Number(row.output && row.output.totalFiles || 0),5995
totalBytes: Number(row.output && row.output.totalBytes || 0),5996
segmentFiles: Number(row.output && row.output.segmentFiles || 0),5997
segmentBytes: Number(row.output && row.output.segmentBytes || 0),5998
}));5999
6000
const csv = toCsv(rows, ['outputDir', 'totalFiles', 'totalBytes', 'segmentFiles', 'segmentBytes']);6001
void copyDebugText(csv, 'Copied orphaned output CSV.');6002
}6003
5899
async function refreshDebugDashboard ()6004
async function refreshDebugDashboard ()5900
{6005
{5901
const data = await api('GET', '/admin/debug/stream-stats');6006
const data = await api('GET', '/admin/debug/stream-stats');@@ -6078,9 +6183,11 @@ async function refreshAdminConfig ()6078
6183
6079
async function refreshAdminUsers ()6184
async function refreshAdminUsers ()6080
{6185
{6186
if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;6081
const data = await api('GET', '/admin/users');6187
const data = await api('GET', '/admin/users');6082
if (!data) return;6188
if (!data) return;6083
const container = document.getElementById('admin-users-list');6189
const container = document.getElementById('admin-users-list');6190
if (!container) return;6084
container.innerHTML = '';6191
container.innerHTML = '';6085
6192
6086
// Need paths for permission rows6193
// Need paths for permission rows@@ -6118,6 +6225,7 @@ async function refreshAdminUsers ()6118
6225
6119
async function refreshAdminOrphanUserFolders ()6226
async function refreshAdminOrphanUserFolders ()6120
{6227
{6228
if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;6121
const section = document.getElementById('admin-orphan-userfolders-section');6229
const section = document.getElementById('admin-orphan-userfolders-section');6122
const list = document.getElementById('admin-orphan-userfolders-list');6230
const list = document.getElementById('admin-orphan-userfolders-list');6123
if (!section || !list) return;6231
if (!section || !list) return;@@ -7173,12 +7281,23 @@ function wireEvents ()7173
});7281
});7174
document.getElementById('admin-modal-close').addEventListener('click', () =>7282
document.getElementById('admin-modal-close').addEventListener('click', () =>7175
document.getElementById('admin-modal').classList.add('hidden'));7283
document.getElementById('admin-modal').classList.add('hidden'));7176
document.getElementById('debug-modal-close').addEventListener('click', closeDebugModal);7284
const debugModalClose = document.getElementById('debug-modal-close');7177
document.getElementById('debug-refresh').addEventListener('click', () =>7285
if (debugModalClose) debugModalClose.addEventListener('click', closeDebugModal);7286
const debugRefresh = document.getElementById('debug-refresh');7287
if (debugRefresh) debugRefresh.addEventListener('click', () =>7178
{7288
{7179
void refreshDebugDashboard();7289
void refreshDebugDashboard();7180
});7290
});7181
document.getElementById('debug-modal').addEventListener('click', (e) =>7291
const debugCopyUsers = document.getElementById('debug-copy-users');7292
if (debugCopyUsers) debugCopyUsers.addEventListener('click', copyDebugUsersJson);7293
const debugCopyStorage = document.getElementById('debug-copy-storage');7294
if (debugCopyStorage) debugCopyStorage.addEventListener('click', copyDebugStorageJson);7295
const debugCopyVideoFiles = document.getElementById('debug-copy-video-files');7296
if (debugCopyVideoFiles) debugCopyVideoFiles.addEventListener('click', copyDebugVideoFilesCsv);7297
const debugCopyOrphaned = document.getElementById('debug-copy-orphaned');7298
if (debugCopyOrphaned) debugCopyOrphaned.addEventListener('click', copyDebugOrphanedCsv);7299
const debugModal = document.getElementById('debug-modal');7300
if (debugModal) debugModal.addEventListener('click', (e) =>7182
{7301
{7183
if (e.target && e.target.id === 'debug-modal') closeDebugModal();7302
if (e.target && e.target.id === 'debug-modal') closeDebugModal();7184
});7303
});@@ -243,24 +243,36 @@
243
243
</div>
244
244
245
245
<section>
246
<h3>Signed-in Users</h3>
246
<div class="debug-section-head">
247
<h3>Signed-in Users</h3>
248
<button id="debug-copy-users" class="debug-copy-btn" type="button">Copy JSON</button>
249
</div>
247
250
<div id="debug-users" class="debug-chips"></div>
248
251
</section>
249
252
250
253
<section>
251
<h3>Storage Usage</h3>
254
<div class="debug-section-head">
255
<h3>Storage Usage</h3>
256
<button id="debug-copy-storage" class="debug-copy-btn" type="button">Copy JSON</button>
257
</div>
252
258
<div id="debug-storage-summary" class="debug-summary-grid"></div>
253
259
<div id="debug-roots" class="debug-table-wrap"></div>
254
260
</section>
255
261
256
262
<section>
257
<h3>Video Streams and Caches</h3>
263
<div class="debug-section-head">
264
<h3>Video Streams and Caches</h3>
265
<button id="debug-copy-video-files" class="debug-copy-btn" type="button">Copy CSV</button>
266
</div>
258
267
<p class="muted">Includes files with cached subtitle data even if no viewers are currently watching.</p>
259
268
<div id="debug-video-files" class="debug-table-wrap"></div>
260
269
</section>
261
270
262
271
<section>
263
<h3>Orphaned Stream Output Directories</h3>
272
<div class="debug-section-head">
273
<h3>Orphaned Stream Output Directories</h3>
274
<button id="debug-copy-orphaned" class="debug-copy-btn" type="button">Copy CSV</button>
275
</div>
264
276
<div id="debug-orphaned-streams" class="debug-table-wrap"></div>
265
277
</section>
266
278
</div>
@@ -243,24 +243,36 @@243
</div>243
</div>244
244
245
<section>245
<section>246
<h3>Signed-in Users</h3>246
<div class="debug-section-head">247
<h3>Signed-in Users</h3>248
<button id="debug-copy-users" class="debug-copy-btn" type="button">Copy JSON</button>249
</div>247
<div id="debug-users" class="debug-chips"></div>250
<div id="debug-users" class="debug-chips"></div>248
</section>251
</section>249
252
250
<section>253
<section>251
<h3>Storage Usage</h3>254
<div class="debug-section-head">255
<h3>Storage Usage</h3>256
<button id="debug-copy-storage" class="debug-copy-btn" type="button">Copy JSON</button>257
</div>252
<div id="debug-storage-summary" class="debug-summary-grid"></div>258
<div id="debug-storage-summary" class="debug-summary-grid"></div>253
<div id="debug-roots" class="debug-table-wrap"></div>259
<div id="debug-roots" class="debug-table-wrap"></div>254
</section>260
</section>255
261
256
<section>262
<section>257
<h3>Video Streams and Caches</h3>263
<div class="debug-section-head">264
<h3>Video Streams and Caches</h3>265
<button id="debug-copy-video-files" class="debug-copy-btn" type="button">Copy CSV</button>266
</div>258
<p class="muted">Includes files with cached subtitle data even if no viewers are currently watching.</p>267
<p class="muted">Includes files with cached subtitle data even if no viewers are currently watching.</p>259
<div id="debug-video-files" class="debug-table-wrap"></div>268
<div id="debug-video-files" class="debug-table-wrap"></div>260
</section>269
</section>261
270
262
<section>271
<section>263
<h3>Orphaned Stream Output Directories</h3>272
<div class="debug-section-head">273
<h3>Orphaned Stream Output Directories</h3>274
<button id="debug-copy-orphaned" class="debug-copy-btn" type="button">Copy CSV</button>275
</div>264
<div id="debug-orphaned-streams" class="debug-table-wrap"></div>276
<div id="debug-orphaned-streams" class="debug-table-wrap"></div>265
</section>277
</section>266
</div>278
</div>@@ -994,6 +994,27 @@ button.danger.admin-update-highlight {
994
994
margin: 0.75rem 0 1rem;
995
995
}
996
996
997
.debug-section-head {
998
display: flex;
999
align-items: center;
1000
justify-content: space-between;
1001
gap: 0.8rem;
1002
}
1003
1004
.debug-copy-btn {
1005
padding: 0.3rem 0.55rem;
1006
border-radius: 7px;
1007
font-size: 0.78rem;
1008
border: 1px solid var(--border);
1009
background: var(--bg);
1010
color: var(--text-muted);
1011
}
1012
1013
.debug-copy-btn:hover {
1014
color: var(--text);
1015
border-color: var(--accent);
1016
}
1017
997
1018
.debug-summary-grid {
998
1019
display: grid;
999
1020
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
@@ -994,6 +994,27 @@ button.danger.admin-update-highlight {994
margin: 0.75rem 0 1rem;
994
margin: 0.75rem 0 1rem;
995
}
995
}
996
996
997
.debug-section-head {
998
display: flex;
999
align-items: center;
1000
justify-content: space-between;
1001
gap: 0.8rem;
1002
}
1003
1004
.debug-copy-btn {
1005
padding: 0.3rem 0.55rem;
1006
border-radius: 7px;
1007
font-size: 0.78rem;
1008
border: 1px solid var(--border);
1009
background: var(--bg);
1010
color: var(--text-muted);
1011
}
1012
1013
.debug-copy-btn:hover {
1014
color: var(--text);
1015
border-color: var(--accent);
1016
}
1017
997
.debug-summary-grid {
1018
.debug-summary-grid {
998
display: grid;
1019
display: grid;
999
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
1020
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));