jadefin/mods/jade/Shortcuts.js

67 lines
2.2 KiB
JavaScript

//@ts-check
import JadefinIntegrity from '../../JadefinIntegrity.js';
import Jadefin from "../../Jadefin.js";
import JadefinMod from "../../JadefinMod.js";
import JadefinModules from "../../JadefinModules.js";
import { rd, rdom, rd$, RDOMListHelper } from "../../utils/rdom.js";
export default JadefinIntegrity("Shortcuts", import.meta.url, () => new (class Shortcuts extends JadefinMod {
constructor() {
super();
}
async init(name, url) {
await super.init(name, url);
await this.initStyle();
const ExtrasMenu = /** @type {import("../ExtrasMenu.js").default} */ (Jadefin.getMod("ExtrasMenu"));
ExtrasMenu.items.push({
name: "Jellyseerr",
secondaryText: "Add new movies or series",
icon: "playlist_add_circle",
in: ExtrasMenu.IN_DRAWER,
cbEl: (/** @type {HTMLElement} */ el, current, alive) => {
el.setAttribute("href", "https://jellyseerr.0x0a.de/");
},
cb: () => {
window.open("https://jellyseerr.0x0a.de/", "_blank");
}
});
ExtrasMenu.items.push({
name: "Scan All Libraries",
secondaryText: "Rescan all libraries",
icon: "sync",
in: ExtrasMenu.IN_CUSTOM,
inCustom: (current, item) => current == ExtrasMenu.IN_LIBRARY && (JadefinModules.ApiClient._currentUser?.Policy.IsAdministrator ?? false),
cbEl: (/** @type {HTMLElement} */ el, current, alive) => {
this.log.i(`Injecting library scan task button into extras popup: ${alive}`);
this.log.dir(el);
if (alive) {
el.classList.add("refreshButton");
el.querySelector(".listItemBody")?.appendChild(rd$()`
<progress min="0" max="100" class="refreshProgress"></progress>
`);
}
JadefinModules.taskButton({
mode: alive ? "on" : "off",
taskKey: "RefreshLibrary",
button: el,
progressElem: el.querySelector(".refreshProgress")
});
},
cb: () => {
}
});
}
})());