Split targeted library removal from indexing

This commit is contained in:
Sleeps
2026-10-07 13:44:04 +01:00
parent 89fc300945
commit 7c01538571
+35 -2
View File
@@ -72,10 +72,11 @@
<button id="refreshLibraries" type="button" class="secondary">Refresh</button>
</div>
</div>
<div class="muted" style="margin-bottom:8px">Deselected libraries are removed from Scene Search SQLite and Meilisearch when you apply the selection.</div>
<div class="muted" style="margin-bottom:8px">Apply selection removes deselected libraries directly from SQLite and Meilisearch. It does not rebuild the whole search index.</div>
<div id="libraries" class="muted">Loading…</div>
<div class="row" style="margin-top:14px">
<button id="indexNow" type="button">Apply library selection / index</button>
<button id="applyLibraries" type="button" class="secondary">Apply selection only</button>
<button id="indexNow" type="button">Index selected libraries</button>
<label><input id="forceIndex" type="checkbox"> Force rebuild</label>
</div>
</section>
@@ -239,6 +240,37 @@
}
}
async function applyLibrarySelection() {
const ids = selectedLibraries();
if (!ids.length && !window.confirm(
'No libraries are selected. This will remove all Jellyfin-backed Scene Search data from SQLite and Meilisearch. Continue?'
)) {
return;
}
try {
$('indexStatus').className = 'status';
$('indexStatus').textContent = 'Applying library selection...';
const result = await api('/api/jellyfin/libraries/selection', {
method:'POST',
body:JSON.stringify({library_ids:ids, force:false})
});
const removedLibraries = Number(result.removed_libraries || 0);
const removedMedia = Number(result.removed_media || 0);
$('indexStatus').className = 'status ok';
$('indexStatus').textContent = removedLibraries
? 'Selection applied: removed ' + removedLibraries + ' librar' +
(removedLibraries === 1 ? 'y' : 'ies') + ' and ' + removedMedia + ' media items'
: 'Selection applied: nothing to remove';
$('indexDetail').textContent = 'No full Meilisearch rebuild was run.';
await loadLibraries();
refreshHealth();
} catch (e) {
$('indexStatus').className = 'status error';
$('indexStatus').textContent = e.message;
}
}
async function startIndex() {
const ids = selectedLibraries();
if (!ids.length && !window.confirm(
@@ -436,6 +468,7 @@
};
$('refreshLibraries').onclick = loadLibraries;
$('selectAll').onclick = () => document.querySelectorAll('.libraryCheck').forEach(x => x.checked = true);
$('applyLibraries').onclick = applyLibrarySelection;
$('indexNow').onclick = startIndex;
$('captionNow').onclick = startCaption;
$('captionPause').onclick = toggleCaptionPause;