Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
feat: allow exporting nzb from history table.
nzbdav-dev7928d4b1fb5f
diff --git a/frontend/app/clients/backend-client.server.ts b/frontend/app/clients/backend-client.server.tsindex cb7f99ab..c44f6cc2 100644--- a/frontend/app/clients/backend-client.server.ts+++ b/frontend/app/clients/backend-client.server.ts@@ -261,6 +261,7 @@ export type HistorySlot = {storage: string,download_time: number,fail_message: string,+ nzb_blob_id?: string,}export type DirectoryItem = {diff --git a/frontend/app/routes/explore/dropdown-options/dropdown-options.module.css b/frontend/app/routes/explore/dropdown-options/dropdown-options.module.cssindex 66994596..b8fe2f95 100644--- a/frontend/app/routes/explore/dropdown-options/dropdown-options.module.css+++ b/frontend/app/routes/explore/dropdown-options/dropdown-options.module.css@@ -14,6 +14,11 @@.option {display: block;++ a {+ text-decoration: inherit;+ color: inherit;+ }}.optionButton {@@ -31,7 +36,13 @@.optionButton:hover,.optionButton:focus-visible {- background-color: #002b36;+ background-color: hsla(192, 100%, 40%, 0.2);color: white;outline: none;}+++.optionButton.danger:hover,+.optionButton.danger:focus-visible {+ background-color: hsla(0, 100%, 70%, 0.4);+}\ No newline at end of filediff --git a/frontend/app/routes/explore/dropdown-options/dropdown-options.module.css.d.ts b/frontend/app/routes/explore/dropdown-options/dropdown-options.module.css.d.tsindex 9780f3e9..a5dc2601 100644--- a/frontend/app/routes/explore/dropdown-options/dropdown-options.module.css.d.ts+++ b/frontend/app/routes/explore/dropdown-options/dropdown-options.module.css.d.ts@@ -2,5 +2,6 @@ declare const styles: {readonly dropdown: string;readonly option: string;readonly optionButton: string;+ readonly danger: string;};export default styles;diff --git a/frontend/app/routes/explore/dropdown-options/dropdown-options.tsx b/frontend/app/routes/explore/dropdown-options/dropdown-options.tsxindex 7876c13a..3b8580be 100644--- a/frontend/app/routes/explore/dropdown-options/dropdown-options.tsx+++ b/frontend/app/routes/explore/dropdown-options/dropdown-options.tsx@@ -1,8 +1,10 @@-import { useEffect, useRef, type ReactNode } from "react";+import { useEffect, useRef, type CSSProperties, type ReactNode } from "react";import styles from "./dropdown-options.module.css";import { classNames } from "~/utils/styling";export type DropdownOptionsProps = {+ className?: string,+ style?: CSSPropertiesisOpen?: boolean;options: (DropdownOption | undefined)[];onClose?: () => void;@@ -10,11 +12,12 @@ export type DropdownOptionsProps = {export type DropdownOption = {option: ReactNode;+ variant?: undefined | "danger"linkTo?: string,onSelect?: () => void;}-export function DropdownOptions({ isOpen = true, options, onClose }: DropdownOptionsProps) {+export function DropdownOptions({ className, style, isOpen = true, options, onClose }: DropdownOptionsProps) {const ref = useRef<HTMLUListElement>(null);useEffect(() => {@@ -32,14 +35,17 @@ export function DropdownOptions({ isOpen = true, options, onClose }: DropdownOpt}, [isOpen, onClose]);return !isOpen ? null : (- <ul ref={ref} className={classNames([styles.dropdown])}>+ <ul ref={ref} className={classNames([styles.dropdown, className])} style={style}>{options.filter(x => !!x).map((option, index) => (<li key={index} className={styles.option}>{option.linkTo && <><a href={option.linkTo}><buttontype="button"- className={styles.optionButton}+ className={classNames([+ styles.optionButton,+ option.variant && styles[option.variant]+ ])}onClick={() => option.onSelect?.()}>{option.option}@@ -49,7 +55,10 @@ export function DropdownOptions({ isOpen = true, options, onClose }: DropdownOpt{!option.linkTo &&<buttontype="button"- className={styles.optionButton}+ className={classNames([+ styles.optionButton,+ option.variant && styles[option.variant]+ ])}onClick={() => option.onSelect?.()}>{option.option}@@ -59,4 +68,4 @@ export function DropdownOptions({ isOpen = true, options, onClose }: DropdownOpt))}</ul>);-}+}\ No newline at end of filediff --git a/frontend/app/routes/explore/item-menu/item-menu.tsx b/frontend/app/routes/explore/item-menu/item-menu.tsxindex edd5b002..8e4d66a7 100644--- a/frontend/app/routes/explore/item-menu/item-menu.tsx+++ b/frontend/app/routes/explore/item-menu/item-menu.tsx@@ -52,9 +52,9 @@ export function ExportNzb(): ReactNode {);}-export function Delete(): ReactNode {+export function Remove(): ReactNode {return (- <><TrashIcon /> Delete</>+ <><TrashIcon /> Remove</>);}diff --git a/frontend/app/routes/queue/components/action-button/action-button.module.css b/frontend/app/routes/queue/components/action-button/action-button.module.cssindex d08c1755..5520bb1b 100644--- a/frontend/app/routes/queue/components/action-button/action-button.module.css+++ b/frontend/app/routes/queue/components/action-button/action-button.module.css@@ -7,32 +7,111 @@flex-direction: row;gap: 5px;align-items: center;+ justify-content: center;+ border: 1px solid white;+ border-radius: .375rem;&:hover {- .trash-icon {- fill: white;+ cursor: pointer;+ }+}++.disabled {+ cursor: not-allowed;++ .action-button {+ pointer-events: none;+ }+}++.explore {+ border-color: #ffc107;++ .directory-icon {+ display: inline-block;+ width: 16px;+ height: 16px;+ fill: #adb8b8;+ }++ @media not (pointer: coarse),+ (min-width: 900px) {+ &:hover {+ background-color: #ffc107;++ .directory-icon {+ fill: white;+ filter: drop-shadow(0 0 8px black);+ }}+ }++ &:active {+ background-color: #f0b607;.directory-icon {fill: white;+ filter: drop-shadow(0 0 8px black);}}}-.trash-icon {- display: inline-block;- width: calc(22/24 * 16px);- height: 16px;- fill: #adb8b8;+.menu {+ border-color: hsl(192, 100%, 20%);+ font-size: 16px;+ user-select: none;+ width: 30px;++ @media not (pointer: coarse),+ (min-width: 900px) {+ &:hover {+ background-color: hsl(192, 100%, 14%);+ color: white;+ text-shadow: 0 0 2px black;+ }+ }++ &:active {+ background-color: hsl(192, 100%, 13%);+ color: white;+ text-shadow: 0 0 2px black;+ }}-.directory-icon {- display: inline-block;- width: 16px;- height: 16px;- fill: #adb8b8;+.menu.selected {+ background-color: hsl(192, 100%, 14%);+ color: white;+ text-shadow: 0 0 2px black;}-.text {- /* color: #adb8b8; */+.delete {+ border-color: #dc3545;++ .trash-icon {+ display: inline-block;+ width: calc(22/24 * 16px);+ height: 16px;+ fill: #adb8b8;+ }++ @media not (pointer: coarse),+ (min-width: 900px) {+ &:hover {+ background-color: #dc3545;++ .trash-icon {+ fill: white;+ filter: drop-shadow(0 0 3px black);+ }+ }+ }++ &:active {+ background-color: #c93140;++ .trash-icon {+ fill: white;+ filter: drop-shadow(0 0 3px black);+ }+ }}\ No newline at end of filediff --git a/frontend/app/routes/queue/components/action-button/action-button.module.css.d.ts b/frontend/app/routes/queue/components/action-button/action-button.module.css.d.tsindex 8fd6feb8..2f3dd343 100644--- a/frontend/app/routes/queue/components/action-button/action-button.module.css.d.ts+++ b/frontend/app/routes/queue/components/action-button/action-button.module.css.d.ts@@ -3,6 +3,13 @@ declare const styles: {readonly "trash-icon": string;readonly "directory-icon": string;readonly "text": string;+ readonly "disabled": string;+ readonly "selected": string;++ // action types+ readonly "delete": string;+ readonly "explore": string;+ readonly "menu": string;};export = styles;diff --git a/frontend/app/routes/queue/components/action-button/action-button.tsx b/frontend/app/routes/queue/components/action-button/action-button.tsxindex 0789bd5b..8a761eab 100644--- a/frontend/app/routes/queue/components/action-button/action-button.tsx+++ b/frontend/app/routes/queue/components/action-button/action-button.tsx@@ -1,25 +1,31 @@-import { Button } from "react-bootstrap";import styles from "./action-button.module.css";import type { ReactNode } from "react";+import { classNames } from "~/utils/styling";export type ActionButtonProps = {- type: "delete" | "explore",+ type: "delete" | "explore" | "menu",text?: string,disabled?: boolean,- onClick?: () => void,+ selected?: boolean,+ onClick?: (e: React.MouseEvent) => void,}-export function ActionButton({ type, text, disabled, onClick }: ActionButtonProps) {- const variant = type === "delete" ? "outline-danger" : "outline-warning";+export function ActionButton({ type, text, disabled, selected, onClick }: ActionButtonProps): ReactNode {+ const classes = classNames([+ styles["action-button"],+ styles[type],+ selected && styles.selected+ ]);+return (- <Button- className={styles["action-button"]}- variant={variant} onClick={onClick}- disabled={disabled}>- {type === "delete" && <TrashIcon />}- {type === "explore" && <DirectoryIcon />}- {text && <div className={styles.text}>{text}</div>}- </Button>+ <div className={disabled ? styles["disabled"] : undefined}>+ <div className={classes} onClick={onClick}>+ {type === "delete" && <TrashIcon />}+ {type === "explore" && <DirectoryIcon />}+ {type === "menu" && "⋯"}+ {text && <div className={styles.text}>{text}</div>}+ </div>+ </div>)}diff --git a/frontend/app/routes/queue/components/history-table/history-table.tsx b/frontend/app/routes/queue/components/history-table/history-table.tsxindex fd528da7..a8d7d94b 100644--- a/frontend/app/routes/queue/components/history-table/history-table.tsx+++ b/frontend/app/routes/queue/components/history-table/history-table.tsx@@ -8,6 +8,8 @@ import { getLeafDirectoryName } from "~/utils/path"import { PageRow, PageTable } from "../page-table/page-table"import styles from "../../route.module.css"import { PageSection } from "../page-section/page-section"+import { DropdownOptions } from "~/routes/explore/dropdown-options/dropdown-options"+import { ExportNzb, Remove } from "~/routes/explore/item-menu/item-menu"export type HistoryTableProps = {historySlots: PresentationHistorySlot[],@@ -158,15 +160,32 @@ export function HistoryRow({ slot, onIsSelectedChanged, onIsRemovingChanged, onR}export function Actions({ slot, onRemove }: { slot: PresentationHistorySlot, onRemove: () => void }) {+ const [isMenuOpen, setIsMenuOpen] = useState(false);+// determine explore action link urlvar downloadFolder = slot.storage && getLeafDirectoryName(slot.storage);const encodedCategory = downloadFolder && encodeURIComponent(slot.category);const encodedDownloadFolder = downloadFolder && encodeURIComponent(downloadFolder);var folderLink = downloadFolder && `/explore/content/${encodedCategory}/${encodedDownloadFolder}`;+ // determine nzb download URL+ var nzbDownloadUrl = slot.nzb_blob_id+ ? `/api/download-nzb?nzbBlobId=${slot.nzb_blob_id}`+ : null;+// determine whether explore action should be disabledvar isFolderDisabled = !downloadFolder || !!slot.isRemoving || !!slot.fail_message;+ const onMenuClick = useCallback((e: React.MouseEvent) => {+ e.stopPropagation();+ setIsMenuOpen(x => !x);+ }, []);++ const onRemoveSelected = useCallback(() => {+ setIsMenuOpen(false);+ onRemove?.();+ }, [onRemove]);+return (<>{!isFolderDisabled &&@@ -177,7 +196,21 @@ export function Actions({ slot, onRemove }: { slot: PresentationHistorySlot, onR{isFolderDisabled &&<ActionButton type="explore" disabled />}- <ActionButton type="delete" disabled={!!slot.isRemoving} onClick={onRemove} />+ <div style={{ position: "relative" }}>+ <ActionButton+ type="menu"+ disabled={!!slot.isRemoving}+ selected={isMenuOpen}+ onClick={onMenuClick} />+ <DropdownOptions+ style={{ marginTop: "5px" }}+ isOpen={isMenuOpen}+ onClose={() => setIsMenuOpen(false)}+ options={[+ !!nzbDownloadUrl ? { option: <ExportNzb />, linkTo: nzbDownloadUrl } : undefined,+ { option: <Remove />, onSelect: onRemoveSelected, variant: "danger" },+ ]} />+ </div></>);}\ No newline at end of filediff --git a/frontend/app/routes/queue/components/page-table/page-table.tsx b/frontend/app/routes/queue/components/page-table/page-table.tsxindex 23ff727d..13205d62 100644--- a/frontend/app/routes/queue/components/page-table/page-table.tsx+++ b/frontend/app/routes/queue/components/page-table/page-table.tsx@@ -17,7 +17,7 @@ export type PageTableProps = {export function PageTable({ children, headerCheckboxState, onHeaderCheckboxChange, footer }: PageTableProps) {return (<div className={styles.tableContainer}>- <Table className={styles.table} responsive>+ <Table className={styles.table}><thead><tr><th>