Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Added setting to show hidden webdav items in ui explorer.
nzbdav-dev7d6cb5ea3f0e
diff --git a/backend/Api/Controllers/ListWebdavDirectory/ListWebdavDirectoryController.cs b/backend/Api/Controllers/ListWebdavDirectory/ListWebdavDirectoryController.csindex 08f2e1af..26b93d61 100644--- a/backend/Api/Controllers/ListWebdavDirectory/ListWebdavDirectoryController.cs+++ b/backend/Api/Controllers/ListWebdavDirectory/ListWebdavDirectoryController.cs@@ -1,6 +1,7 @@using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc;using NWebDav.Server.Stores;+using NzbWebDAV.Config;using NzbWebDAV.WebDav;using NzbWebDAV.WebDav.Base;@@ -8,7 +9,7 @@ namespace NzbWebDAV.Api.Controllers.ListWebdavDirectory;[ApiController][Route("api/list-webdav-directory")]-public class ListWebdavDirectoryController(DatabaseStore store) : BaseApiController+public class ListWebdavDirectoryController(DatabaseStore store, ConfigManager configManager) : BaseApiController{private async Task<ListWebdavDirectoryResponse> ListWebdavDirectory(ListWebdavDirectoryRequest request){@@ -16,8 +17,12 @@ public class ListWebdavDirectoryController(DatabaseStore store) : BaseApiControlif (item is null) throw new BadHttpRequestException("The directory does not exist.");if (item is not IStoreCollection dir) throw new BadHttpRequestException("The directory does not exist.");var children = new List<ListWebdavDirectoryResponse.DirectoryItem>();+ var showHiddenWebdavFiles = configManager.ShowHiddenWebdavFiles();await foreach (var child in dir.GetItemsAsync(HttpContext.RequestAborted)){+ if (!showHiddenWebdavFiles && child.Name.StartsWith('.'))+ continue;+children.Add(new ListWebdavDirectoryResponse.DirectoryItem(){Name = child.Name,diff --git a/backend/Config/ConfigManager.cs b/backend/Config/ConfigManager.csindex 8d14d2af..a9e19ec2 100644--- a/backend/Config/ConfigManager.cs+++ b/backend/Config/ConfigManager.cs@@ -100,6 +100,13 @@ public class ConfigManagerreturn (configValue != null ? bool.Parse(configValue) : defaultValue);}+ public bool ShowHiddenWebdavFiles()+ {+ var defaultValue = false;+ var configValue = StringUtil.EmptyToNull(GetConfigValue("webdav.show-hidden-files"));+ return (configValue != null ? bool.Parse(configValue) : defaultValue);+ }+public class ConfigEventArgs : EventArgs{public Dictionary<string, string> ChangedConfig { get; set; } = new();diff --git a/frontend/app/routes/explore/route.module.css b/frontend/app/routes/explore/route.module.cssindex 1bead573..08d1ed06 100644--- a/frontend/app/routes/explore/route.module.css+++ b/frontend/app/routes/explore/route.module.css@@ -96,4 +96,8 @@flex-grow: 1;position: unset;min-height: unset;+}++.hidden * {+ opacity: 50%;}\ No newline at end of filediff --git a/frontend/app/routes/explore/route.module.css.d.ts b/frontend/app/routes/explore/route.module.css.d.tsindex a0bd42ac..b1a037d9 100644--- a/frontend/app/routes/explore/route.module.css.d.ts+++ b/frontend/app/routes/explore/route.module.css.d.ts@@ -7,6 +7,7 @@ declare const styles: {readonly "item-name": string;readonly "video-icon": string;readonly "loading": string;+ readonly "hidden": string;};export = styles;diff --git a/frontend/app/routes/explore/route.tsx b/frontend/app/routes/explore/route.tsxindex a682ebdd..81dd1dbb 100644--- a/frontend/app/routes/explore/route.tsx+++ b/frontend/app/routes/explore/route.tsx@@ -69,13 +69,13 @@ function Body(props: ExplorePageData) {{!isNavigating &&<div>{items.filter(x => x.isDirectory).map((x, index) =>- <Link key={`${index}_dir_item`} to={getDirectoryPath(x.name)} className={styles.item}>+ <Link key={`${index}_dir_item`} to={getDirectoryPath(x.name)} className={getClassName(x)}><div className={styles["directory-icon"]} /><div className={styles["item-name"]}>{x.name}</div></Link>)}{items.filter(x => !x.isDirectory).map((x, index) =>- <a key={`${index}_file_item`} href={getFilePath(x as ExploreFile)} className={styles.item}>+ <a key={`${index}_file_item`} href={getFilePath(x as ExploreFile)} className={getClassName(x)}><div className={getIcon(x as ExploreFile)} /><div className={styles["item-name"]}>{x.name}</div></a>@@ -104,4 +104,10 @@ function getWebdavPath(pathname: string): string {function getParentDirectories(webdavPath: string): string[] {return webdavPath == "" ? [] : webdavPath.split('/');+}++function getClassName(item: DirectoryItem | ExploreFile) {+ let className = styles.item;+ if (item.name.startsWith('.')) className += " " + styles.hidden;+ return className;}\ No newline at end of filediff --git a/frontend/app/routes/settings/route.tsx b/frontend/app/routes/settings/route.tsxindex ba37ed9d..1389cdf9 100644--- a/frontend/app/routes/settings/route.tsx+++ b/frontend/app/routes/settings/route.tsx@@ -20,6 +20,7 @@ const defaultConfig = {"usenet.pass": "","webdav.user": "","webdav.pass": "",+ "webdav.show-hidden-files": "false","rclone.mount-dir": "",}diff --git a/frontend/app/routes/settings/sabnzbd/sabnzbd.tsx b/frontend/app/routes/settings/sabnzbd/sabnzbd.tsxindex 44e436fb..9f9a4b28 100644--- a/frontend/app/routes/settings/sabnzbd/sabnzbd.tsx+++ b/frontend/app/routes/settings/sabnzbd/sabnzbd.tsx@@ -30,7 +30,7 @@ export function SabnzbdSettings({ config, setNewConfig }: SabnzbdSettingsProps)</Button></InputGroup><Form.Text id="api-key-help" muted>- Use this API key when configuring your download client in Radarr or Sonarr+ Use this API key when configuring your download client in Radarr or Sonarr.</Form.Text></Form.Group><hr />diff --git a/frontend/app/routes/settings/webdav/webdav.tsx b/frontend/app/routes/settings/webdav/webdav.tsxindex 18944510..8f3a058e 100644--- a/frontend/app/routes/settings/webdav/webdav.tsx+++ b/frontend/app/routes/settings/webdav/webdav.tsx@@ -37,7 +37,20 @@ export function WebdavSettings({ config, setNewConfig }: SabnzbdSettingsProps) {value={config["webdav.pass"]}onChange={e => setNewConfig({ ...config, "webdav.pass": e.target.value })} /><Form.Text id="webdav-pass-help" muted>- Use this password to connect to the webdav+ Use this password to connect to the webdav.+ </Form.Text>+ </Form.Group>+ <hr />+ <Form.Group>+ <Form.Check+ className={styles.input}+ type="checkbox"+ aria-describedby="show-hidden-files-help"+ label={`Show hidden files on Dav Explorer`}+ checked={config["webdav.show-hidden-files"] === "true"}+ onChange={e => setNewConfig({ ...config, "webdav.show-hidden-files": "" + e.target.checked })} />+ <Form.Text id="show-hidden-files-help" muted>+ Hidden files or directories are those whose names are prefixed by a period.</Form.Text></Form.Group></div>@@ -47,6 +60,7 @@ export function WebdavSettings({ config, setNewConfig }: SabnzbdSettingsProps) {export function isWebdavSettingsUpdated(config: Record<string, string>, newConfig: Record<string, string>) {return config["webdav.user"] !== newConfig["webdav.user"]|| config["webdav.pass"] !== newConfig["webdav.pass"]+ || config["webdav.show-hidden-files"] !== newConfig["webdav.show-hidden-files"]}export function isWebdavSettingsValid(newConfig: Record<string, string>) {