feat(nav): embed request ui in home top tabs
Replace full-page navigation with a native emby-tab-button and pageTabContent panel so Request behaves like Home and Favorites. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
eb20e64c37
commit
0a5ea07838
10 files changed
+597
-461
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>1.0.0.2</Version>
|
||||
<AssemblyVersion>1.0.0.2</AssemblyVersion>
|
||||
<FileVersion>1.0.0.2</FileVersion>
|
||||
<Version>1.0.0.3</Version>
|
||||
<AssemblyVersion>1.0.0.3</AssemblyVersion>
|
||||
<FileVersion>1.0.0.3</FileVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,17 +1,13 @@
|
||||
(() => {
|
||||
"use strict";
|
||||
|
||||
const REQUEST_URL = "/Requests/Page";
|
||||
const TAB_ATTR = "data-jellyfin-request-tab";
|
||||
const STYLE_ID = "jellyfin-plugin-request-nav-style";
|
||||
const ASSET_CSS = "/Requests/Assets/request.css";
|
||||
const ASSET_JS = "/Requests/Assets/request.js";
|
||||
|
||||
function textOf(node) {
|
||||
return [
|
||||
node?.textContent,
|
||||
node?.getAttribute?.("aria-label"),
|
||||
node?.getAttribute?.("title"),
|
||||
node?.getAttribute?.("data-title")
|
||||
].filter(Boolean).join(" ").replace(/\s+/g, " ").trim().toLowerCase();
|
||||
}
|
||||
let ensuring = null;
|
||||
let assetsPromise = null;
|
||||
|
||||
function ensureStyle() {
|
||||
if (document.getElementById(STYLE_ID)) {
|
||||
@@ -20,37 +16,175 @@
|
||||
|
||||
const style = document.createElement("style");
|
||||
style.id = STYLE_ID;
|
||||
style.textContent = ".jf-request-menu-item{align-items:center;color:inherit;display:flex!important;gap:1rem;min-height:3rem;padding:.75rem 1.25rem;text-decoration:none}.jf-request-menu-item:hover,.jf-request-menu-item:focus,.jf-request-tab:hover,.jf-request-tab:focus{color:#00a4dc;text-decoration:none}.jf-request-menu-icon{align-items:center;display:inline-flex;font-size:1.45rem;justify-content:center;line-height:1;min-width:1.5rem}.jf-request-menu-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.jf-request-tab{align-items:center;color:inherit;display:inline-flex;text-decoration:none}";
|
||||
style.textContent = [
|
||||
".jf-request-tab-panel{padding:1rem 1.25rem 2rem;box-sizing:border-box;}",
|
||||
".jf-request-tab-panel .req-embed{max-width:1400px;margin:0 auto;}",
|
||||
".jf-request-menu-item{align-items:center;color:inherit;display:flex!important;gap:1rem;min-height:3rem;padding:.75rem 1.25rem;text-decoration:none;cursor:pointer;background:none;border:0;width:100%;text-align:left;font:inherit;}",
|
||||
".jf-request-menu-item:hover,.jf-request-menu-item:focus{color:#00a4dc;}",
|
||||
".jf-request-menu-icon{align-items:center;display:inline-flex;font-size:1.45rem;justify-content:center;line-height:1;min-width:1.5rem;}",
|
||||
".jf-request-menu-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}"
|
||||
].join("");
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
|
||||
function controlsIn(container) {
|
||||
return Array.from(container.querySelectorAll("a, button, [role='button'], [role='menuitem'], [role='link']"));
|
||||
function isHomeTabContext() {
|
||||
const hash = window.location.hash || "";
|
||||
const onHomeHash = hash === ""
|
||||
|| hash === "#/home"
|
||||
|| hash === "#/home.html"
|
||||
|| hash.indexOf("#/home?") === 0
|
||||
|| hash.indexOf("#/home.html?") === 0;
|
||||
if (!onHomeHash) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const page = document.getElementById("indexPage");
|
||||
if (!page || page.classList.contains("hide")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const visiblePage = document.querySelector(".page:not(.hide)");
|
||||
return !visiblePage || visiblePage.id === "indexPage";
|
||||
}
|
||||
|
||||
function openRequestPage(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
event.stopImmediatePropagation?.();
|
||||
window.location.assign(REQUEST_URL);
|
||||
function loadAssets() {
|
||||
if (assetsPromise) {
|
||||
return assetsPromise;
|
||||
}
|
||||
|
||||
assetsPromise = new Promise((resolve, reject) => {
|
||||
if (!document.querySelector(`link[href="${ASSET_CSS}"]`)) {
|
||||
const link = document.createElement("link");
|
||||
link.rel = "stylesheet";
|
||||
link.href = ASSET_CSS;
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
|
||||
if (window.JellyfinRequestUI) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = document.querySelector(`script[src="${ASSET_JS}"]`);
|
||||
if (existing) {
|
||||
existing.addEventListener("load", () => resolve(), { once: true });
|
||||
existing.addEventListener("error", () => reject(new Error("Failed to load request.js")), { once: true });
|
||||
return;
|
||||
}
|
||||
|
||||
const script = document.createElement("script");
|
||||
script.src = ASSET_JS;
|
||||
script.onload = () => resolve();
|
||||
script.onerror = () => reject(new Error("Failed to load request.js"));
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
|
||||
return assetsPromise;
|
||||
}
|
||||
|
||||
function wireLink(link) {
|
||||
link.href = REQUEST_URL;
|
||||
link.addEventListener("click", openRequestPage, true);
|
||||
return link;
|
||||
function createTabButton() {
|
||||
const titleEl = document.createElement("div");
|
||||
titleEl.className = "emby-button-foreground";
|
||||
titleEl.textContent = "Request";
|
||||
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.setAttribute("is", "empty-button");
|
||||
button.className = "emby-tab-button emby-button";
|
||||
button.setAttribute(TAB_ATTR, "request");
|
||||
button.setAttribute("aria-label", "Request");
|
||||
button.appendChild(titleEl);
|
||||
return button;
|
||||
}
|
||||
|
||||
function labelMatches(node, labels) {
|
||||
const label = textOf(node);
|
||||
return labels.some((value) => label === value || label.includes(value));
|
||||
function createTabPanel() {
|
||||
const panel = document.createElement("div");
|
||||
panel.className = "tabContent pageTabContent hide jf-request-tab-panel";
|
||||
panel.setAttribute(TAB_ATTR, "request");
|
||||
|
||||
const mount = document.createElement("div");
|
||||
mount.className = "sections jf-request-sections";
|
||||
mount.setAttribute("data-role", "request-mount");
|
||||
panel.appendChild(mount);
|
||||
return panel;
|
||||
}
|
||||
|
||||
function isDrawerElement(node) {
|
||||
return Boolean(node?.closest?.(".mainDrawer,.mainDrawer-scrollContainer,.drawerContent,.MuiDrawer-paper"));
|
||||
function findNativeButtons(tabsSlider) {
|
||||
return Array.from(tabsSlider.querySelectorAll(".emby-tab-button")).filter((btn) => !btn.hasAttribute(TAB_ATTR));
|
||||
}
|
||||
|
||||
function sideMenuContainers() {
|
||||
function placeInOrder(parent, nodes) {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const node = nodes[i];
|
||||
const previous = i > 0 ? nodes[i - 1] : null;
|
||||
if (!previous) {
|
||||
if (node.parentNode !== parent) {
|
||||
parent.appendChild(node);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const alreadyAfter = node.parentNode === parent
|
||||
&& (previous.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;
|
||||
if (!alreadyAfter) {
|
||||
parent.insertBefore(node, previous.nextSibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function syncIndexes(tabsSlider, page) {
|
||||
const buttons = Array.from(tabsSlider.querySelectorAll(".emby-tab-button"));
|
||||
buttons.forEach((button, index) => {
|
||||
button.setAttribute("data-index", String(index));
|
||||
const key = button.getAttribute(TAB_ATTR);
|
||||
if (key) {
|
||||
const panel = page.querySelector(`.tabContent[${TAB_ATTR}="${key}"]`);
|
||||
if (panel) {
|
||||
panel.setAttribute("data-index", String(index));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Native home/favorites panels.
|
||||
if (index === 0) {
|
||||
page.querySelector("#homeTab")?.setAttribute("data-index", "0");
|
||||
} else if (index === 1) {
|
||||
page.querySelector("#favoritesTab")?.setAttribute("data-index", "1");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function mountRequestUi(panel) {
|
||||
const mount = panel.querySelector('[data-role="request-mount"]');
|
||||
if (!mount) {
|
||||
return;
|
||||
}
|
||||
|
||||
await loadAssets();
|
||||
if (window.JellyfinRequestUI) {
|
||||
window.JellyfinRequestUI.mount(mount, { embed: true });
|
||||
}
|
||||
}
|
||||
|
||||
function activateRequestTab() {
|
||||
if (!isHomeTabContext()) {
|
||||
window.location.hash = "#/home";
|
||||
setTimeout(activateRequestTab, 250);
|
||||
return;
|
||||
}
|
||||
|
||||
ensureRequestTab().then(() => {
|
||||
const button = document.querySelector(`.headerTabs [${TAB_ATTR}="request"]`);
|
||||
if (button) {
|
||||
button.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function insertSideMenuItem() {
|
||||
ensureStyle();
|
||||
const selectors = [
|
||||
".mainDrawer-scrollContainer",
|
||||
".mainDrawer .scrollContainer",
|
||||
@@ -58,182 +192,131 @@
|
||||
".navMenu",
|
||||
".MuiDrawer-paper"
|
||||
];
|
||||
const found = new Set();
|
||||
|
||||
for (const selector of selectors) {
|
||||
for (const candidate of document.querySelectorAll(selector)) {
|
||||
if (candidate.classList?.contains("mainDrawerHandle")) {
|
||||
for (const container of document.querySelectorAll(selector)) {
|
||||
if (container.querySelector(".jf-request-menu-item")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const labels = controlsIn(candidate).map(textOf);
|
||||
const hasNormalNav = labels.includes("home")
|
||||
|| labels.includes("favorites")
|
||||
|| labels.includes("favourites")
|
||||
|| labels.some((label) => label.includes("home"));
|
||||
if (hasNormalNav) {
|
||||
found.add(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(found);
|
||||
}
|
||||
|
||||
function topNavContainers() {
|
||||
const found = new Set();
|
||||
const selectors = [
|
||||
".sectionTabs",
|
||||
".emby-tabs",
|
||||
".tabs",
|
||||
".headerTabs",
|
||||
".viewMenuBar",
|
||||
".skinHeader .tabs"
|
||||
];
|
||||
|
||||
for (const selector of selectors) {
|
||||
for (const candidate of document.querySelectorAll(selector)) {
|
||||
if (isDrawerElement(candidate)) {
|
||||
const controls = Array.from(container.querySelectorAll("a, button, [role='button'], [role='menuitem']"));
|
||||
const labels = controls.map((node) => (node.textContent || "").trim().toLowerCase());
|
||||
if (!labels.some((label) => label === "home" || label.includes("home"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const controls = controlsIn(candidate);
|
||||
const hasHome = controls.some((item) => labelMatches(item, ["home"]));
|
||||
const hasFavorites = controls.some((item) => labelMatches(item, ["favorites", "favourites"]));
|
||||
if (hasHome && hasFavorites) {
|
||||
found.add(candidate);
|
||||
const after = controls.find((item) => /^(favorites|favourites)$/i.test((item.textContent || "").trim()))
|
||||
|| controls.find((item) => /home/i.test(item.textContent || ""))
|
||||
|| controls[0];
|
||||
if (!after) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const link = document.createElement("button");
|
||||
link.type = "button";
|
||||
link.className = `${after.className || ""} jf-request-menu-item`.trim();
|
||||
link.setAttribute("aria-label", "Request");
|
||||
link.innerHTML = '<span class="material-icons jf-request-menu-icon" aria-hidden="true">add_circle_outline</span><span class="jf-request-menu-label">Request</span>';
|
||||
link.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
activateRequestTab();
|
||||
});
|
||||
|
||||
if (after.parentElement === container) {
|
||||
after.insertAdjacentElement("afterend", link);
|
||||
} else {
|
||||
after.parentElement?.insertAdjacentElement("afterend", link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const home of controlsIn(document).filter((item) => !isDrawerElement(item) && labelMatches(item, ["home"]))) {
|
||||
let candidate = home.parentElement;
|
||||
for (let depth = 0; candidate && depth < 4; depth += 1, candidate = candidate.parentElement) {
|
||||
const controls = controlsIn(candidate);
|
||||
const hasFavorites = controls.some((item) => labelMatches(item, ["favorites", "favourites"]));
|
||||
if (hasFavorites && controls.length <= 12) {
|
||||
found.add(candidate);
|
||||
break;
|
||||
function ensureRequestTab() {
|
||||
if (ensuring) {
|
||||
return ensuring;
|
||||
}
|
||||
|
||||
ensuring = (async () => {
|
||||
ensureStyle();
|
||||
insertSideMenuItem();
|
||||
|
||||
if (!isHomeTabContext()) {
|
||||
document.querySelectorAll(`.headerTabs [${TAB_ATTR}]`).forEach((node) => node.remove());
|
||||
return;
|
||||
}
|
||||
|
||||
const page = document.getElementById("indexPage");
|
||||
const tabsSlider = document.querySelector(".headerTabs .emby-tabs-slider");
|
||||
const tabsEl = document.querySelector('.headerTabs [is="emby-tabs"]');
|
||||
if (!page || !tabsSlider || !tabsEl) {
|
||||
return;
|
||||
}
|
||||
|
||||
const homeTab = page.querySelector("#homeTab");
|
||||
const favoritesTab = page.querySelector("#favoritesTab");
|
||||
if (!homeTab || !favoritesTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
let button = tabsSlider.querySelector(`[${TAB_ATTR}="request"]`);
|
||||
if (!button) {
|
||||
button = createTabButton();
|
||||
}
|
||||
|
||||
let panel = page.querySelector(`.tabContent[${TAB_ATTR}="request"]`);
|
||||
if (!panel) {
|
||||
panel = createTabPanel();
|
||||
}
|
||||
|
||||
const nativeButtons = findNativeButtons(tabsSlider);
|
||||
const homeButton = nativeButtons[0];
|
||||
const favoritesButton = nativeButtons[1] || nativeButtons[0];
|
||||
const orderedButtons = [homeButton, favoritesButton, button].filter(Boolean);
|
||||
const uniqueButtons = [...new Set(orderedButtons)];
|
||||
placeInOrder(tabsSlider, uniqueButtons);
|
||||
|
||||
// Keep native panels first, then Request, without detaching home rows incorrectly.
|
||||
const orderedPanels = [homeTab, favoritesTab, panel];
|
||||
placeInOrder(page, orderedPanels);
|
||||
|
||||
syncIndexes(tabsSlider, page);
|
||||
|
||||
if (typeof tabsEl.refresh === "function") {
|
||||
try {
|
||||
tabsEl.refresh();
|
||||
} catch {
|
||||
// best-effort
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(found).sort((left, right) => controlsIn(left).length - controlsIn(right).length);
|
||||
await mountRequestUi(panel);
|
||||
})().finally(() => {
|
||||
ensuring = null;
|
||||
});
|
||||
|
||||
return ensuring;
|
||||
}
|
||||
|
||||
function createMenuItem(reference) {
|
||||
const link = document.createElement("a");
|
||||
link.className = "jf-request-menu-item";
|
||||
link.setAttribute("aria-label", "Requests");
|
||||
wireLink(link);
|
||||
|
||||
const icon = document.createElement("span");
|
||||
icon.className = "material-icons jf-request-menu-icon";
|
||||
icon.setAttribute("aria-hidden", "true");
|
||||
icon.textContent = "add_circle_outline";
|
||||
|
||||
const label = document.createElement("span");
|
||||
label.className = "jf-request-menu-label";
|
||||
label.textContent = "Requests";
|
||||
|
||||
link.append(icon, label);
|
||||
|
||||
const referenceClass = reference?.getAttribute("class");
|
||||
if (referenceClass) {
|
||||
link.setAttribute("class", `${referenceClass} jf-request-menu-item`);
|
||||
}
|
||||
|
||||
const referenceRole = reference?.getAttribute("role");
|
||||
if (referenceRole) {
|
||||
link.setAttribute("role", referenceRole);
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
function createTopTab(reference) {
|
||||
const tag = reference?.tagName?.toLowerCase() === "button" ? "button" : "a";
|
||||
const link = document.createElement(tag);
|
||||
link.className = "jf-request-tab";
|
||||
link.textContent = "Request";
|
||||
link.setAttribute("aria-label", "Request");
|
||||
link.setAttribute("data-jellyfin-request", "request-tab");
|
||||
if (tag === "button") {
|
||||
link.type = "button";
|
||||
}
|
||||
|
||||
wireLink(link);
|
||||
|
||||
const referenceClass = reference?.getAttribute("class");
|
||||
if (referenceClass) {
|
||||
link.setAttribute("class", `${referenceClass} jf-request-tab`);
|
||||
}
|
||||
|
||||
const referenceRole = reference?.getAttribute("role");
|
||||
if (referenceRole) {
|
||||
link.setAttribute("role", referenceRole);
|
||||
}
|
||||
|
||||
const referenceTabIndex = reference?.getAttribute("tabindex");
|
||||
if (referenceTabIndex) {
|
||||
link.setAttribute("tabindex", referenceTabIndex);
|
||||
}
|
||||
|
||||
link.classList.remove("selected", "active", "is-active", "current");
|
||||
link.removeAttribute("aria-selected");
|
||||
return link;
|
||||
}
|
||||
|
||||
function insertTopTab() {
|
||||
ensureStyle();
|
||||
const existingTabs = Array.from(document.querySelectorAll(".jf-request-tab"));
|
||||
existingTabs.slice(1).forEach((node) => node.remove());
|
||||
if (existingTabs.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const container of topNavContainers()) {
|
||||
const controls = controlsIn(container);
|
||||
const after = controls.find((item) => /^(favorites|favourites)$/i.test(textOf(item)))
|
||||
|| controls.find((item) => /^home$/i.test(textOf(item)) || textOf(item).includes("home"));
|
||||
if (!after) {
|
||||
continue;
|
||||
function boot() {
|
||||
ensureRequestTab();
|
||||
document.addEventListener("viewshow", (event) => {
|
||||
if (event.target && event.target.id === "indexPage") {
|
||||
ensureRequestTab();
|
||||
}
|
||||
});
|
||||
window.addEventListener("hashchange", () => ensureRequestTab());
|
||||
setInterval(() => ensureRequestTab(), 1500);
|
||||
|
||||
after.insertAdjacentElement("afterend", createTopTab(after));
|
||||
return;
|
||||
const headerTabs = document.querySelector(".headerTabs");
|
||||
if (headerTabs) {
|
||||
new MutationObserver(() => ensureRequestTab()).observe(headerTabs, { childList: true, subtree: true });
|
||||
}
|
||||
}
|
||||
|
||||
function insertSideMenuItem() {
|
||||
ensureStyle();
|
||||
for (const container of sideMenuContainers()) {
|
||||
if (container.querySelector(".jf-request-menu-item")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const controls = controlsIn(container);
|
||||
const after = controls.find((item) => /^(favorites|favourites)$/i.test(textOf(item)))
|
||||
|| controls.find((item) => /^home$/i.test(textOf(item)) || textOf(item).includes("home"))
|
||||
|| controls[0];
|
||||
if (!after) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const link = createMenuItem(after);
|
||||
if (after.parentElement === container) {
|
||||
after.insertAdjacentElement("afterend", link);
|
||||
} else {
|
||||
after.parentElement?.insertAdjacentElement("afterend", link);
|
||||
}
|
||||
}
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", boot);
|
||||
} else {
|
||||
boot();
|
||||
}
|
||||
|
||||
function insertEntries() {
|
||||
insertTopTab();
|
||||
insertSideMenuItem();
|
||||
}
|
||||
|
||||
insertEntries();
|
||||
setInterval(insertEntries, 1000);
|
||||
new MutationObserver(insertEntries).observe(document.documentElement, { childList: true, subtree: true });
|
||||
})();
|
||||
@@ -27,6 +27,16 @@ body {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.req-embed {
|
||||
color: inherit;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.req-embed .req-title {
|
||||
font-size: 1.35rem;
|
||||
}
|
||||
|
||||
.req-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
@@ -2,31 +2,52 @@
|
||||
"use strict";
|
||||
|
||||
const API = "/Requests";
|
||||
const state = {
|
||||
mediaType: "multi",
|
||||
status: null,
|
||||
isAdmin: false,
|
||||
detail: null,
|
||||
requests: []
|
||||
};
|
||||
|
||||
const els = {
|
||||
statusBanner: document.getElementById("statusBanner"),
|
||||
globalMessage: document.getElementById("globalMessage"),
|
||||
searchInput: document.getElementById("searchInput"),
|
||||
searchBtn: document.getElementById("searchBtn"),
|
||||
results: document.getElementById("results"),
|
||||
detail: document.getElementById("detail"),
|
||||
mineList: document.getElementById("mineList"),
|
||||
adminList: document.getElementById("adminList"),
|
||||
adminTab: document.getElementById("adminTab"),
|
||||
searchView: document.getElementById("searchView"),
|
||||
mineView: document.getElementById("mineView"),
|
||||
adminView: document.getElementById("adminView")
|
||||
};
|
||||
const MARKUP = `
|
||||
<div class="req-root">
|
||||
<header class="req-header">
|
||||
<h1 class="req-title">Request</h1>
|
||||
<nav class="req-tabs" aria-label="Request views">
|
||||
<button type="button" class="req-tab active" data-view="search">Search</button>
|
||||
<button type="button" class="req-tab" data-view="mine">My requests</button>
|
||||
<button type="button" class="req-tab req-hidden" data-view="admin" data-role="admin-tab">Admin queue</button>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="req-status-banner req-hidden" data-role="status-banner"></div>
|
||||
<p class="req-message req-hidden" data-role="global-message"></p>
|
||||
<section data-role="search-view">
|
||||
<div class="req-search-row">
|
||||
<input data-role="search-input" type="search" placeholder="Search movies or TV shows" autocomplete="off" />
|
||||
<div class="req-type-toggle" role="group" aria-label="Media type">
|
||||
<button type="button" class="req-type-btn active" data-type="multi">All</button>
|
||||
<button type="button" class="req-type-btn" data-type="movie">Movies</button>
|
||||
<button type="button" class="req-type-btn" data-type="tv">TV</button>
|
||||
</div>
|
||||
<button type="button" class="req-btn primary" data-role="search-btn">Search</button>
|
||||
</div>
|
||||
<div class="req-grid" data-role="results"></div>
|
||||
<div class="req-detail req-hidden" data-role="detail"></div>
|
||||
</section>
|
||||
<section class="req-hidden" data-role="mine-view">
|
||||
<div class="req-list" data-role="mine-list"></div>
|
||||
</section>
|
||||
<section class="req-hidden" data-role="admin-view">
|
||||
<div class="req-list" data-role="admin-list"></div>
|
||||
</section>
|
||||
</div>`;
|
||||
|
||||
function authHeader() {
|
||||
try {
|
||||
if (typeof ApiClient !== "undefined" && ApiClient.accessToken) {
|
||||
const token = ApiClient.accessToken();
|
||||
if (token) {
|
||||
return {
|
||||
Authorization: `MediaBrowser Client="Request Plugin", Device="Browser", DeviceId="jellyfin-plugin-request", Version="1.0.0", Token="${token}"`,
|
||||
"X-Emby-Token": token
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const raw = localStorage.getItem("jellyfin_credentials");
|
||||
const credentials = raw ? JSON.parse(raw) : null;
|
||||
const server = credentials?.Servers?.find((item) => item.AccessToken) || credentials?.Servers?.[0];
|
||||
@@ -75,12 +96,6 @@
|
||||
return text ? JSON.parse(text) : null;
|
||||
}
|
||||
|
||||
function showMessage(text, isError) {
|
||||
els.globalMessage.textContent = text;
|
||||
els.globalMessage.classList.toggle("req-hidden", !text);
|
||||
els.globalMessage.classList.toggle("req-error", !!isError);
|
||||
}
|
||||
|
||||
function posterUrl(path, width) {
|
||||
return path ? `https://image.tmdb.org/t/p/w${width || 342}${path}` : "";
|
||||
}
|
||||
@@ -105,76 +120,108 @@
|
||||
.replaceAll('"', """);
|
||||
}
|
||||
|
||||
function setView(view) {
|
||||
document.querySelectorAll(".req-tab").forEach((tab) => {
|
||||
tab.classList.toggle("active", tab.dataset.view === view);
|
||||
});
|
||||
els.searchView.classList.toggle("req-hidden", view !== "search");
|
||||
els.mineView.classList.toggle("req-hidden", view !== "mine");
|
||||
els.adminView.classList.toggle("req-hidden", view !== "admin");
|
||||
if (view === "mine" || view === "admin") {
|
||||
loadRequests();
|
||||
}
|
||||
}
|
||||
function createController(root) {
|
||||
const state = {
|
||||
mediaType: "multi",
|
||||
status: null,
|
||||
isAdmin: false,
|
||||
detail: null,
|
||||
requests: []
|
||||
};
|
||||
|
||||
async function loadStatus() {
|
||||
try {
|
||||
state.status = await api("/Status");
|
||||
if (!state.status.isConfigured) {
|
||||
els.statusBanner.textContent = "TMDB is not configured. An administrator must set a TMDB API key in Dashboard → Plugins → Request.";
|
||||
els.statusBanner.classList.remove("req-hidden");
|
||||
} else if (!state.status.requestSubmissionEnabled) {
|
||||
els.statusBanner.textContent = "Search is available. Request submission is disabled by the administrator.";
|
||||
els.statusBanner.classList.remove("req-hidden");
|
||||
} else {
|
||||
els.statusBanner.classList.add("req-hidden");
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
}
|
||||
const els = {
|
||||
root,
|
||||
statusBanner: root.querySelector('[data-role="status-banner"]'),
|
||||
globalMessage: root.querySelector('[data-role="global-message"]'),
|
||||
searchInput: root.querySelector('[data-role="search-input"]'),
|
||||
searchBtn: root.querySelector('[data-role="search-btn"]'),
|
||||
results: root.querySelector('[data-role="results"]'),
|
||||
detail: root.querySelector('[data-role="detail"]'),
|
||||
mineList: root.querySelector('[data-role="mine-list"]'),
|
||||
adminList: root.querySelector('[data-role="admin-list"]'),
|
||||
adminTab: root.querySelector('[data-role="admin-tab"]'),
|
||||
searchView: root.querySelector('[data-role="search-view"]'),
|
||||
mineView: root.querySelector('[data-role="mine-view"]'),
|
||||
adminView: root.querySelector('[data-role="admin-view"]')
|
||||
};
|
||||
|
||||
async function loadCurrentUser() {
|
||||
try {
|
||||
const response = await fetch("/Users/Me", {
|
||||
cache: "no-store",
|
||||
headers: authHeader()
|
||||
function showMessage(text, isError) {
|
||||
els.globalMessage.textContent = text;
|
||||
els.globalMessage.classList.toggle("req-hidden", !text);
|
||||
els.globalMessage.classList.toggle("req-error", !!isError);
|
||||
}
|
||||
|
||||
function setView(view) {
|
||||
root.querySelectorAll(".req-tab").forEach((tab) => {
|
||||
tab.classList.toggle("active", tab.dataset.view === view);
|
||||
});
|
||||
if (!response.ok) {
|
||||
els.searchView.classList.toggle("req-hidden", view !== "search");
|
||||
els.mineView.classList.toggle("req-hidden", view !== "mine");
|
||||
els.adminView.classList.toggle("req-hidden", view !== "admin");
|
||||
if (view === "mine" || view === "admin") {
|
||||
loadRequests();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadStatus() {
|
||||
try {
|
||||
state.status = await api("/Status");
|
||||
if (!state.status.isConfigured) {
|
||||
els.statusBanner.textContent = "TMDB is not configured. An administrator must set a TMDB API key in Dashboard → Plugins → Request.";
|
||||
els.statusBanner.classList.remove("req-hidden");
|
||||
} else if (!state.status.requestSubmissionEnabled) {
|
||||
els.statusBanner.textContent = "Search is available. Request submission is disabled by the administrator.";
|
||||
els.statusBanner.classList.remove("req-hidden");
|
||||
} else {
|
||||
els.statusBanner.classList.add("req-hidden");
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadCurrentUser() {
|
||||
try {
|
||||
const response = await fetch("/Users/Me", {
|
||||
cache: "no-store",
|
||||
headers: authHeader()
|
||||
});
|
||||
if (!response.ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
const me = await response.json();
|
||||
state.isAdmin = !!me?.Policy?.IsAdministrator;
|
||||
els.adminTab.classList.toggle("req-hidden", !state.isAdmin);
|
||||
} catch {
|
||||
// Non-fatal.
|
||||
}
|
||||
}
|
||||
|
||||
async function runSearch() {
|
||||
const query = els.searchInput.value.trim();
|
||||
if (!query) {
|
||||
showMessage("Enter a search query.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
const me = await response.json();
|
||||
state.isAdmin = !!me?.Policy?.IsAdministrator;
|
||||
els.adminTab.classList.toggle("req-hidden", !state.isAdmin);
|
||||
} catch {
|
||||
// Non-fatal: admin tab stays hidden.
|
||||
}
|
||||
}
|
||||
|
||||
async function runSearch() {
|
||||
const query = els.searchInput.value.trim();
|
||||
if (!query) {
|
||||
showMessage("Enter a search query.", true);
|
||||
return;
|
||||
showMessage("Searching…");
|
||||
els.detail.classList.add("req-hidden");
|
||||
els.results.classList.remove("req-hidden");
|
||||
try {
|
||||
const results = await api(`/Search?query=${encodeURIComponent(query)}&type=${encodeURIComponent(state.mediaType)}`);
|
||||
showMessage(results.length ? "" : "No results found.");
|
||||
renderResults(results);
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
els.results.innerHTML = "";
|
||||
}
|
||||
}
|
||||
|
||||
showMessage("Searching…");
|
||||
els.detail.classList.add("req-hidden");
|
||||
try {
|
||||
const results = await api(`/Search?query=${encodeURIComponent(query)}&type=${encodeURIComponent(state.mediaType)}`);
|
||||
showMessage(results.length ? "" : "No results found.");
|
||||
renderResults(results);
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
els.results.innerHTML = "";
|
||||
}
|
||||
}
|
||||
|
||||
function renderResults(results) {
|
||||
els.results.innerHTML = results.map((item) => {
|
||||
const img = item.posterUrl || posterUrl(item.posterPath);
|
||||
return `
|
||||
function renderResults(results) {
|
||||
els.results.innerHTML = results.map((item) => {
|
||||
const img = item.posterUrl || posterUrl(item.posterPath);
|
||||
return `
|
||||
<article class="req-card" data-type="${escapeHtml(item.mediaType)}" data-id="${item.tmdbId}">
|
||||
${img ? `<img src="${escapeHtml(img)}" alt="" loading="lazy" />` : `<div class="req-card-body"><p class="req-muted">No poster</p></div>`}
|
||||
<div class="req-card-body">
|
||||
@@ -182,147 +229,147 @@
|
||||
<p class="req-muted">${escapeHtml(item.mediaType)}${item.year ? ` · ${item.year}` : ""}</p>
|
||||
</div>
|
||||
</article>`;
|
||||
}).join("");
|
||||
}).join("");
|
||||
|
||||
els.results.querySelectorAll(".req-card").forEach((card) => {
|
||||
card.addEventListener("click", () => openDetail(card.dataset.type, Number(card.dataset.id)));
|
||||
});
|
||||
}
|
||||
|
||||
async function openDetail(type, tmdbId) {
|
||||
showMessage("Loading details…");
|
||||
try {
|
||||
const detail = await api(`/Media/${encodeURIComponent(type)}/${tmdbId}`);
|
||||
state.detail = detail;
|
||||
showMessage("");
|
||||
renderDetail(detail);
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
els.results.querySelectorAll(".req-card").forEach((card) => {
|
||||
card.addEventListener("click", () => openDetail(card.dataset.type, Number(card.dataset.id)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function renderDetail(detail) {
|
||||
const img = detail.posterUrl || posterUrl(detail.posterPath, 500);
|
||||
const allowSeasons = state.status?.allowSeasonSelection !== false && detail.mediaType === "tv";
|
||||
const seasonHtml = allowSeasons
|
||||
? `<div class="req-seasons">
|
||||
<label class="req-season"><input type="checkbox" id="allSeasons" checked /> All seasons</label>
|
||||
async function openDetail(type, tmdbId) {
|
||||
showMessage("Loading details…");
|
||||
try {
|
||||
const detail = await api(`/Media/${encodeURIComponent(type)}/${tmdbId}`);
|
||||
state.detail = detail;
|
||||
showMessage("");
|
||||
renderDetail(detail);
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
function renderDetail(detail) {
|
||||
const img = detail.posterUrl || posterUrl(detail.posterPath, 500);
|
||||
const allowSeasons = state.status?.allowSeasonSelection !== false && detail.mediaType === "tv";
|
||||
const seasonHtml = allowSeasons
|
||||
? `<div class="req-seasons">
|
||||
<label class="req-season"><input type="checkbox" data-role="all-seasons" checked /> All seasons</label>
|
||||
${detail.seasons.map((season) => `
|
||||
<label class="req-season">
|
||||
<input type="checkbox" class="season-box" value="${season.seasonNumber}" disabled />
|
||||
${escapeHtml(season.name)} <span class="req-muted">(${season.episodeCount})</span>
|
||||
</label>`).join("")}
|
||||
</div>`
|
||||
: detail.mediaType === "tv"
|
||||
? `<p class="req-muted">This request will cover all seasons.</p>`
|
||||
: "";
|
||||
: detail.mediaType === "tv"
|
||||
? `<p class="req-muted">This request will cover all seasons.</p>`
|
||||
: "";
|
||||
|
||||
els.detail.classList.remove("req-hidden");
|
||||
els.detail.innerHTML = `
|
||||
els.detail.classList.remove("req-hidden");
|
||||
els.detail.innerHTML = `
|
||||
${img ? `<img class="req-detail-poster" src="${escapeHtml(img)}" alt="" />` : "<div></div>"}
|
||||
<div class="req-detail-meta">
|
||||
<button type="button" class="req-btn" id="backToResults">Back to results</button>
|
||||
<button type="button" class="req-btn" data-role="back-results">Back to results</button>
|
||||
<h2 class="req-detail-title">${escapeHtml(detail.title)}</h2>
|
||||
<p class="req-muted">${escapeHtml(detail.mediaType)}${detail.year ? ` · ${detail.year}` : ""}</p>
|
||||
<p>${escapeHtml(detail.overview || "No overview available.")}</p>
|
||||
${seasonHtml}
|
||||
<div class="req-detail-actions">
|
||||
<button type="button" class="req-btn primary" id="submitRequest" ${state.status?.requestSubmissionEnabled ? "" : "disabled"}>
|
||||
<button type="button" class="req-btn primary" data-role="submit-request" ${state.status?.requestSubmissionEnabled ? "" : "disabled"}>
|
||||
Request
|
||||
</button>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
els.results.classList.add("req-hidden");
|
||||
document.getElementById("backToResults").addEventListener("click", () => {
|
||||
els.detail.classList.add("req-hidden");
|
||||
els.results.classList.remove("req-hidden");
|
||||
});
|
||||
|
||||
const allSeasons = document.getElementById("allSeasons");
|
||||
if (allSeasons) {
|
||||
allSeasons.addEventListener("change", () => {
|
||||
document.querySelectorAll(".season-box").forEach((box) => {
|
||||
box.disabled = allSeasons.checked;
|
||||
if (allSeasons.checked) {
|
||||
box.checked = false;
|
||||
}
|
||||
});
|
||||
els.results.classList.add("req-hidden");
|
||||
els.detail.querySelector('[data-role="back-results"]').addEventListener("click", () => {
|
||||
els.detail.classList.add("req-hidden");
|
||||
els.results.classList.remove("req-hidden");
|
||||
});
|
||||
|
||||
const allSeasons = els.detail.querySelector('[data-role="all-seasons"]');
|
||||
if (allSeasons) {
|
||||
allSeasons.addEventListener("change", () => {
|
||||
els.detail.querySelectorAll(".season-box").forEach((box) => {
|
||||
box.disabled = allSeasons.checked;
|
||||
if (allSeasons.checked) {
|
||||
box.checked = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
els.detail.querySelector('[data-role="submit-request"]').addEventListener("click", () => submitRequest(detail));
|
||||
}
|
||||
|
||||
document.getElementById("submitRequest").addEventListener("click", () => submitRequest(detail));
|
||||
}
|
||||
async function submitRequest(detail) {
|
||||
const payload = {
|
||||
mediaType: detail.mediaType,
|
||||
tmdbId: detail.tmdbId,
|
||||
allSeasons: true,
|
||||
seasons: null
|
||||
};
|
||||
|
||||
async function submitRequest(detail) {
|
||||
const payload = {
|
||||
mediaType: detail.mediaType,
|
||||
tmdbId: detail.tmdbId,
|
||||
allSeasons: true,
|
||||
seasons: null
|
||||
};
|
||||
const allSeasons = els.detail.querySelector('[data-role="all-seasons"]');
|
||||
if (detail.mediaType === "tv" && allSeasons && !allSeasons.checked) {
|
||||
const selected = Array.from(els.detail.querySelectorAll(".season-box:checked")).map((box) => Number(box.value));
|
||||
if (!selected.length) {
|
||||
showMessage("Select at least one season, or choose all seasons.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
const allSeasons = document.getElementById("allSeasons");
|
||||
if (detail.mediaType === "tv" && allSeasons && !allSeasons.checked) {
|
||||
const selected = Array.from(document.querySelectorAll(".season-box:checked")).map((box) => Number(box.value));
|
||||
if (!selected.length) {
|
||||
showMessage("Select at least one season, or choose all seasons.", true);
|
||||
payload.allSeasons = false;
|
||||
payload.seasons = selected;
|
||||
}
|
||||
|
||||
try {
|
||||
await api("", { method: "POST", body: JSON.stringify(payload) });
|
||||
showMessage(`Requested “${detail.title}”.`);
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRequests() {
|
||||
try {
|
||||
state.requests = await api("");
|
||||
renderRequestList(els.mineList, state.requests, false);
|
||||
if (state.isAdmin) {
|
||||
const pendingFirst = [...state.requests].sort((a, b) => {
|
||||
const aPending = statusName(a.status) === "Pending" ? 0 : 1;
|
||||
const bPending = statusName(b.status) === "Pending" ? 0 : 1;
|
||||
return aPending - bPending || new Date(b.createdAtUtc) - new Date(a.createdAtUtc);
|
||||
});
|
||||
renderRequestList(els.adminList, pendingFirst, true);
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
function renderRequestList(container, items, adminMode) {
|
||||
if (!items.length) {
|
||||
container.innerHTML = `<p class="req-message">No requests yet.</p>`;
|
||||
return;
|
||||
}
|
||||
|
||||
payload.allSeasons = false;
|
||||
payload.seasons = selected;
|
||||
}
|
||||
|
||||
try {
|
||||
await api("", { method: "POST", body: JSON.stringify(payload) });
|
||||
showMessage(`Requested “${detail.title}”.`);
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRequests() {
|
||||
try {
|
||||
state.requests = await api("");
|
||||
renderRequestList(els.mineList, state.requests, false);
|
||||
if (state.isAdmin) {
|
||||
const pendingFirst = [...state.requests].sort((a, b) => {
|
||||
const aPending = statusName(a.status) === "Pending" ? 0 : 1;
|
||||
const bPending = statusName(b.status) === "Pending" ? 0 : 1;
|
||||
return aPending - bPending || new Date(b.createdAtUtc) - new Date(a.createdAtUtc);
|
||||
});
|
||||
renderRequestList(els.adminList, pendingFirst, true);
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
function renderRequestList(container, items, adminMode) {
|
||||
if (!items.length) {
|
||||
container.innerHTML = `<p class="req-message">No requests yet.</p>`;
|
||||
return;
|
||||
}
|
||||
|
||||
container.innerHTML = items.map((item) => {
|
||||
const img = posterUrl(item.posterPath, 185);
|
||||
const seasons = item.allSeasons
|
||||
? "All seasons"
|
||||
: (item.seasons || []).length
|
||||
? `Seasons ${(item.seasons || []).join(", ")}`
|
||||
: "";
|
||||
const actions = adminMode
|
||||
? `
|
||||
container.innerHTML = items.map((item) => {
|
||||
const img = posterUrl(item.posterPath, 185);
|
||||
const seasons = item.allSeasons
|
||||
? "All seasons"
|
||||
: (item.seasons || []).length
|
||||
? `Seasons ${(item.seasons || []).join(", ")}`
|
||||
: "";
|
||||
const actions = adminMode
|
||||
? `
|
||||
<button type="button" class="req-btn" data-action="approve" data-id="${item.id}">Approve</button>
|
||||
<button type="button" class="req-btn" data-action="reject" data-id="${item.id}">Reject</button>
|
||||
<button type="button" class="req-btn" data-action="fulfill" data-id="${item.id}">Fulfilled</button>
|
||||
<button type="button" class="req-btn danger" data-action="delete" data-id="${item.id}">Delete</button>`
|
||||
: (statusName(item.status) === "Pending"
|
||||
? `<button type="button" class="req-btn danger" data-action="delete" data-id="${item.id}">Cancel</button>`
|
||||
: "");
|
||||
: (statusName(item.status) === "Pending"
|
||||
? `<button type="button" class="req-btn danger" data-action="delete" data-id="${item.id}">Cancel</button>`
|
||||
: "");
|
||||
|
||||
return `
|
||||
return `
|
||||
<article class="req-list-item">
|
||||
${img ? `<img src="${escapeHtml(img)}" alt="" />` : "<div></div>"}
|
||||
<div>
|
||||
@@ -334,47 +381,78 @@
|
||||
</div>
|
||||
<div class="req-list-actions">${actions}</div>
|
||||
</article>`;
|
||||
}).join("");
|
||||
}).join("");
|
||||
|
||||
container.querySelectorAll("[data-action]").forEach((button) => {
|
||||
button.addEventListener("click", () => handleRequestAction(button.dataset.action, button.dataset.id));
|
||||
});
|
||||
}
|
||||
container.querySelectorAll("[data-action]").forEach((button) => {
|
||||
button.addEventListener("click", () => handleRequestAction(button.dataset.action, button.dataset.id));
|
||||
});
|
||||
}
|
||||
|
||||
async function handleRequestAction(action, id) {
|
||||
try {
|
||||
if (action === "delete") {
|
||||
await api(`/${id}`, { method: "DELETE" });
|
||||
} else {
|
||||
await api(`/${id}/${action}`, { method: "POST", body: "{}" });
|
||||
async function handleRequestAction(action, id) {
|
||||
try {
|
||||
if (action === "delete") {
|
||||
await api(`/${id}`, { method: "DELETE" });
|
||||
} else {
|
||||
await api(`/${id}/${action}`, { method: "POST", body: "{}" });
|
||||
}
|
||||
|
||||
await loadRequests();
|
||||
showMessage("Updated.");
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
|
||||
await loadRequests();
|
||||
showMessage("Updated.");
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
}
|
||||
|
||||
root.querySelectorAll(".req-tab").forEach((tab) => {
|
||||
tab.addEventListener("click", () => setView(tab.dataset.view));
|
||||
});
|
||||
|
||||
root.querySelectorAll(".req-type-btn").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
root.querySelectorAll(".req-type-btn").forEach((item) => item.classList.remove("active"));
|
||||
button.classList.add("active");
|
||||
state.mediaType = button.dataset.type;
|
||||
});
|
||||
});
|
||||
|
||||
els.searchBtn.addEventListener("click", runSearch);
|
||||
els.searchInput.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
runSearch();
|
||||
}
|
||||
});
|
||||
|
||||
loadStatus();
|
||||
loadCurrentUser();
|
||||
|
||||
return { setView, reload: () => { loadStatus(); loadRequests(); } };
|
||||
}
|
||||
|
||||
document.querySelectorAll(".req-tab").forEach((tab) => {
|
||||
tab.addEventListener("click", () => setView(tab.dataset.view));
|
||||
});
|
||||
|
||||
document.querySelectorAll(".req-type-btn").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
document.querySelectorAll(".req-type-btn").forEach((item) => item.classList.remove("active"));
|
||||
button.classList.add("active");
|
||||
state.mediaType = button.dataset.type;
|
||||
});
|
||||
});
|
||||
|
||||
els.searchBtn.addEventListener("click", runSearch);
|
||||
els.searchInput.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
runSearch();
|
||||
function mount(container, options = {}) {
|
||||
if (!container) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
loadStatus();
|
||||
loadCurrentUser();
|
||||
if (container.dataset.reqMounted === "1") {
|
||||
return container._jellyfinRequestController || null;
|
||||
}
|
||||
|
||||
container.innerHTML = MARKUP;
|
||||
const root = container.querySelector(".req-root");
|
||||
if (options.embed) {
|
||||
root.classList.add("req-embed");
|
||||
}
|
||||
|
||||
const controller = createController(root);
|
||||
container.dataset.reqMounted = "1";
|
||||
container._jellyfinRequestController = controller;
|
||||
return controller;
|
||||
}
|
||||
|
||||
window.JellyfinRequestUI = { mount };
|
||||
|
||||
const autoRoot = document.getElementById("jellyfin-request-root");
|
||||
if (autoRoot) {
|
||||
mount(autoRoot, { embed: autoRoot.dataset.embed === "true" });
|
||||
}
|
||||
})();
|
||||
@@ -7,40 +7,7 @@
|
||||
<link rel="stylesheet" href="/Requests/Assets/request.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header class="req-header">
|
||||
<h1 class="req-title">Request</h1>
|
||||
<nav class="req-tabs" aria-label="Request views">
|
||||
<button type="button" class="req-tab active" data-view="search">Search</button>
|
||||
<button type="button" class="req-tab" data-view="mine">My requests</button>
|
||||
<button type="button" class="req-tab req-hidden" data-view="admin" id="adminTab">Admin queue</button>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div id="statusBanner" class="req-status-banner req-hidden"></div>
|
||||
<p id="globalMessage" class="req-message req-hidden"></p>
|
||||
|
||||
<section id="searchView">
|
||||
<div class="req-search-row">
|
||||
<input id="searchInput" type="search" placeholder="Search movies or TV shows" autocomplete="off" />
|
||||
<div class="req-type-toggle" role="group" aria-label="Media type">
|
||||
<button type="button" class="req-type-btn active" data-type="multi">All</button>
|
||||
<button type="button" class="req-type-btn" data-type="movie">Movies</button>
|
||||
<button type="button" class="req-type-btn" data-type="tv">TV</button>
|
||||
</div>
|
||||
<button type="button" class="req-btn primary" id="searchBtn">Search</button>
|
||||
</div>
|
||||
<div id="results" class="req-grid"></div>
|
||||
<div id="detail" class="req-detail req-hidden"></div>
|
||||
</section>
|
||||
|
||||
<section id="mineView" class="req-hidden">
|
||||
<div id="mineList" class="req-list"></div>
|
||||
</section>
|
||||
|
||||
<section id="adminView" class="req-hidden">
|
||||
<div id="adminList" class="req-list"></div>
|
||||
</section>
|
||||
|
||||
<div id="jellyfin-request-root"></div>
|
||||
<script src="/Requests/Assets/request.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -25,9 +25,7 @@ https://www.iamparadox.dev/jellyfin/plugins/manifest.json
|
||||
|
||||
4. From **Catalog**, install **File Transformation**, then install **Request**, then restart Jellyfin.
|
||||
5. Configure under **Dashboard → Plugins → Request** (TMDB API key + enable submissions).
|
||||
6. Hard-refresh the browser (Ctrl+F5). You should see a **Request** tab next to Home/Favorites.
|
||||
|
||||
Direct page (even without the tab): `/Requests/Page`
|
||||
6. Hard-refresh the browser (Ctrl+F5). You should see a **Request** tab next to Home/Favorites that shows the request UI under the same top bar (no full-page navigation).
|
||||
|
||||
## Requirements
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: "Request"
|
||||
guid: "11c08950-c4bb-484d-89ff-205b3724416b"
|
||||
version: "1.0.0.2"
|
||||
version: "1.0.0.3"
|
||||
targetAbi: "10.11.11.0"
|
||||
framework: "net9.0"
|
||||
overview: "Request movies and TV shows from a local admin review queue"
|
||||
|
||||
+5
-5
@@ -9,12 +9,12 @@
|
||||
"repositoryUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies",
|
||||
"versions": [
|
||||
{
|
||||
"version": "1.0.0.2",
|
||||
"changelog": "Inject Request tab via File Transformation (Docker/Unraid safe); keep disk patch fallback",
|
||||
"version": "1.0.0.3",
|
||||
"changelog": "Show Request UI under the home top tabs like Home/Favorites instead of navigating away",
|
||||
"targetAbi": "10.11.11.0",
|
||||
"sourceUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main/release/Jellyfin.Plugin.Request_1.0.0.2.zip",
|
||||
"checksum": "DFD860D8E616B33B7BE31B3CEE462EAB",
|
||||
"timestamp": "2026-08-02T20:41:46.8916597Z",
|
||||
"sourceUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main/release/Jellyfin.Plugin.Request_1.0.0.3.zip",
|
||||
"checksum": "F11AA68370A2E1B81AC14EB6D1DB123C",
|
||||
"timestamp": "2026-08-02T21:00:07.1780246Z",
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
param(
|
||||
[string]$Version = "1.0.0.2",
|
||||
[string]$Version = "1.0.0.3",
|
||||
[string]$TargetAbi = "10.11.11.0",
|
||||
[string]$RepoRawBase = "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main"
|
||||
)
|
||||
@@ -17,7 +17,7 @@ $dllPath = Join-Path $root "Jellyfin.Plugin.Request\bin\Release\net9.0\Jellyfin.
|
||||
$zipPath = Join-Path $releaseDir $zipFileName
|
||||
$manifestPath = Join-Path $root "manifest.json"
|
||||
$timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")
|
||||
$changelog = "Inject Request tab via File Transformation (Docker/Unraid safe); keep disk patch fallback"
|
||||
$changelog = "Show Request UI under the home top tabs like Home/Favorites instead of navigating away"
|
||||
|
||||
Write-Host "Building plugin..."
|
||||
dotnet build (Join-Path $root "Jellyfin.Plugin.Request.sln") -c Release
|
||||
|
||||
Reference in new issue
Block a user