add(core): open filesystem while adding library path

This commit is contained in:
Steppenstreuner
2026-08-28 13:21:32 +02:00
parent 3b617a910a
commit 262700ee45
4 changed files with 196 additions and 109 deletions
+18
View File
@@ -84,6 +84,24 @@ $("#lib-form").addEventListener("submit", async (e) => {
} catch (err) { toast(err.message, true); }
});
// path autocompletion for the library form
{
const pathInput = document.querySelector('#lib-form [name=root_path]');
const datalist = $("#path-suggestions");
let pathTimer;
pathInput.addEventListener("input", () => {
clearTimeout(pathTimer);
const value = pathInput.value;
if (!value.startsWith("/")) return;
pathTimer = setTimeout(async () => {
try {
const res = await api("/api/fs/browse?path=" + encodeURIComponent(value));
datalist.innerHTML = res.dirs.map((d) => `<option value="${esc(d)}">`).join("");
} catch {}
}, 150);
});
}
function libOptions(mediaType) {
return libraries
.filter((l) => l.media_type === mediaType)