Add index report drill-down to Jellyfin plugin

This commit is contained in:
Sleeps
2026-10-07 13:54:56 +01:00
parent 1dbf09b5d5
commit 41f2d32b93
@@ -70,7 +70,17 @@
</div>
<progress id="overallProgress" max="100" value="0" style="width:100%;height:1.1em;"></progress>
</div>
<div id="indexStatus" class="fieldDescription" style="margin-bottom:1.5em;"></div>
<div id="indexStatus" class="fieldDescription" style="margin-bottom:.75em;"></div>
<div style="margin-bottom:.5em;">
<button is="emby-button" type="button" id="reportFailed" class="raised"><span>Failed</span></button>
<button is="emby-button" type="button" id="reportRemoved" class="raised"><span>Removed</span></button>
<button is="emby-button" type="button" id="reportIndexed" class="raised"><span>Indexed</span></button>
</div>
<div id="indexReportMeta" class="fieldDescription" style="margin-bottom:.5em;"></div>
<div id="indexReportList" style="max-height:20em;overflow:auto;margin-bottom:.5em;"></div>
<button is="emby-button" type="button" id="indexReportMore" class="raised" style="display:none;margin-bottom:1.5em;">
<span>Show more</span>
</button>
<h2>Captioning</h2>
<div class="fieldDescription" style="margin-bottom:1em;">
@@ -115,6 +125,9 @@
var lastIndexRunning = false;
var lastCaptionRunning = false;
var lastCaptionStatus = null;
var reportCategory = null;
var reportOffset = 0;
var reportTotal = 0;
function selectedLibraryIds() {
return Array.prototype.slice.call(
@@ -200,6 +213,79 @@
}
}
function refreshIndexReportSummary() {
return ApiClient.getJSON(
ApiClient.getUrl('Plugins/SceneSearch/IndexReport') + '?limit=1'
).then(function (report) {
var summary = (report && report.summary) || {};
page.querySelector('#reportFailed span').textContent =
'Failed (' + (summary.failed || 0) + ')';
page.querySelector('#reportRemoved span').textContent =
'Removed (' + (summary.pruned || 0) + ')';
page.querySelector('#reportIndexed span').textContent =
'Indexed (' + (summary.indexed || 0) + ')';
if (!report || !report.available) {
page.querySelector('#indexReportMeta').textContent =
'No saved index report yet.';
}
}).catch(function () {
// Status remains usable even if no report is available.
});
}
function loadIndexReport(category, append) {
append = !!append;
var offset = append ? reportOffset : 0;
var url = ApiClient.getUrl('Plugins/SceneSearch/IndexReport') +
'?category=' + encodeURIComponent(category) +
'&offset=' + offset + '&limit=200';
return ApiClient.getJSON(url).then(function (report) {
reportCategory = category;
var items = (report && report.items) || [];
reportOffset = offset + items.length;
reportTotal = Number((report && report.total) || 0);
var container = page.querySelector('#indexReportList');
if (!append) {
container.innerHTML = '';
}
items.forEach(function (item) {
var row = document.createElement('div');
row.style.cssText =
'padding:.65em 0;border-bottom:1px solid rgba(255,255,255,.12)';
var title = document.createElement('strong');
title.textContent = item.title || item.item_id || '(unnamed)';
row.appendChild(title);
var meta = document.createElement('div');
meta.className = 'fieldDescription';
meta.textContent =
(item.library || item.library_id || '') +
(item.item_id ? ' · ' + item.item_id : '');
row.appendChild(meta);
var reason = document.createElement('div');
reason.textContent = item.reason || '';
row.appendChild(reason);
container.appendChild(row);
});
page.querySelector('#indexReportMeta').textContent =
reportTotal + ' ' + category + ' item' +
(reportTotal === 1 ? '' : 's') +
(report.finished_at ? ' · last run ' + report.finished_at : '');
page.querySelector('#indexReportMore').style.display =
reportOffset < reportTotal ? '' : 'none';
}).catch(function () {
page.querySelector('#indexReportMeta').textContent =
'Could not load the saved index report.';
});
}
function refreshStatus() {
return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/IndexStatus'))
.then(function (status) {
@@ -208,6 +294,7 @@
if (lastIndexRunning && !running) {
loadLibraries();
refreshIndexReportSummary();
}
lastIndexRunning = running;
})
@@ -346,7 +433,12 @@
page.querySelector('#maxResults').value = config.MaxResults || 20;
page.querySelector('#timeoutSeconds').value = config.TimeoutSeconds || 60;
return Promise.all([loadLibraries(), refreshStatus(), refreshCaptionStatus()]);
return Promise.all([
loadLibraries(),
refreshStatus(),
refreshCaptionStatus(),
refreshIndexReportSummary()
]);
}).then(function () {
if (!statusTimer) {
statusTimer = setInterval(refreshStatus, 2000);
@@ -370,6 +462,21 @@
}
});
page.querySelector('#reportFailed').addEventListener('click', function () {
loadIndexReport('failed', false);
});
page.querySelector('#reportRemoved').addEventListener('click', function () {
loadIndexReport('removed', false);
});
page.querySelector('#reportIndexed').addEventListener('click', function () {
loadIndexReport('indexed', false);
});
page.querySelector('#indexReportMore').addEventListener('click', function () {
if (reportCategory) {
loadIndexReport(reportCategory, true);
}
});
page.querySelector('#applyLibraries').addEventListener('click', function () {
var ids = selectedLibraryIds();
if (!ids.length && !window.confirm(