From ac0ad0e2801b50b82e87dd7b16b76521e8bfdad9 Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Thu, 9 May 2024 06:42:23 +0700 Subject: [PATCH] Add `itemsPerPage` and `searchResult` config --- src/app/[...rest]/deploy/@form.api-config.tsx | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/src/app/[...rest]/deploy/@form.api-config.tsx b/src/app/[...rest]/deploy/@form.api-config.tsx index def64e0..c50cc0a 100644 --- a/src/app/[...rest]/deploy/@form.api-config.tsx +++ b/src/app/[...rest]/deploy/@form.api-config.tsx @@ -123,6 +123,8 @@ export default function ApiConfig({ ); } set("api", "isTeamDrive", config.api.isTeamDrive || false); + set("api", "itemsPerPage", config.api.itemsPerPage || 50); + set("api", "searchResult", config.api.searchResult || 5); set( "api", "proxyThumbnail", @@ -143,6 +145,11 @@ export default function ApiConfig({ "maxFileSize", config.api.maxFileSize || 4 * 1024 * 1024, ); + set( + "api", + "streamMaxSize", + config.api.streamMaxSize || 100 * 1024 * 1024, + ); fileInput.value = ""; toast.success("Config loaded from file"); @@ -269,6 +276,82 @@ This ID will be encrypted in the config file`} )} +
+ > + key='itemsPerPage' + title='Items Per Page' + description={`Set how many items to display per page in the file list. +It's recommended to set this to a reasonable number, since it will affect the load time of the page. + +Default is 50.`} + error={error.get.itemsPerPage} + required + > + { + if (error.get.itemsPerPage) { + error.set("itemsPerPage", ""); + } + set("api", "itemsPerPage", parseInt(e.target.value)); + }} + onBlur={async () => { + try { + const value = get.api.itemsPerPage; + error.set("itemsPerPage", ""); + + if (value <= 0) + throw new Error("Items Per Page must be more than 0"); + } catch (err) { + const e = err as Error; + error.set("itemsPerPage", e.message); + } + }} + /> + + + > + key='searchResult' + title='Search Result' + description={`Set how many items to display in the search result. +It's recommended to set this to a small number, since it will affect the load time of the page. + +Default is 5.`} + error={error.get.searchResult} + required + > + { + if (error.get.searchResult) { + error.set("searchResult", ""); + } + set("api", "searchResult", parseInt(e.target.value)); + }} + onBlur={async () => { + try { + const value = get.api.searchResult; + error.set("searchResult", ""); + + if (value <= 0) + throw new Error("Search Result must be more than 0"); + } catch (err) { + const e = err as Error; + error.set("searchResult", e.message); + } + }} + /> + +
+ > key='proxyThumbnail' title='Proxy Thumbnail' @@ -397,6 +480,53 @@ Set to 0 to disable the limit.`} }} /> + + > + key='streamMaxSize' + title='Max Stream Size (in MB)' + description={`For previewing large files, the file will be streamed in chunks. +There are response limit in some deploy platform like Vercel, also Google Drive will return 403 error if we tried using fetch to download large file on client. + +Make sure it's within reasonable size, since it will count towards your server bandwidth usage. +This will also affect the maximum file size that can be previewed. Especially for media files like video, audio, and images. +(Manga preview will automatically limited to the first 5MB) + +Default is 100MB, set to 0 to disable the limit.`} + error={error.get.streamMaxSize} + required + > + { + if (error.get.maxFileSize) { + error.set("streamMaxSize", ""); + } + set( + "api", + "streamMaxSize", + parseInt(e.target.value) * 1024 * 1024, + ); + }} + onBlur={async () => { + try { + const value = get.api.streamMaxSize; + error.set("streamMaxSize", ""); + + if (value < 0) + throw new Error( + "Max stream size must be more than or equal to 0", + ); + } catch (err) { + const e = err as Error; + error.set("streamMaxSize", e.message); + } + }} + /> + );