mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-09-10 11:58:20 +02:00
Less steps to download
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"tabWidth": 4,
|
"tabWidth": 4,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"printWidth": 80,
|
"printWidth": 100,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"objectWrap": "collapse",
|
"objectWrap": "collapse",
|
||||||
|
@@ -13,10 +13,7 @@ export default tseslint.config(
|
|||||||
plugins: { 'react-hooks': reactHooks, 'react-refresh': reactRefresh },
|
plugins: { 'react-hooks': reactHooks, 'react-refresh': reactRefresh },
|
||||||
rules: {
|
rules: {
|
||||||
...reactHooks.configs.recommended.rules,
|
...reactHooks.configs.recommended.rules,
|
||||||
'react-refresh/only-export-components': [
|
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
||||||
'warn',
|
|
||||||
{ allowConstantExport: true },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -9,14 +9,12 @@ import MangaList from './Components/Mangas/MangaList.tsx';
|
|||||||
import { Search } from './Search.tsx';
|
import { Search } from './Search.tsx';
|
||||||
import MangaConnectorProvider from './contexts/MangaConnectorContext.tsx';
|
import MangaConnectorProvider from './contexts/MangaConnectorContext.tsx';
|
||||||
import LibraryProvider from './contexts/FileLibraryContext.tsx';
|
import LibraryProvider from './contexts/FileLibraryContext.tsx';
|
||||||
|
import MangaDetail from './MangaDetail.tsx';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [apiUri, setApiUri] = useState<string>(
|
const [apiUri, setApiUri] = useState<string>(
|
||||||
localStorage.getItem('apiUri') ??
|
localStorage.getItem('apiUri') ??
|
||||||
window.location.href.substring(
|
window.location.href.substring(0, window.location.href.lastIndexOf('/')) + '/api'
|
||||||
0,
|
|
||||||
window.location.href.lastIndexOf('/')
|
|
||||||
) + '/api'
|
|
||||||
);
|
);
|
||||||
const [apiConfig, setApiConfig] = useState<ApiConfig>({ baseUrl: apiUri });
|
const [apiConfig, setApiConfig] = useState<ApiConfig>({ baseUrl: apiUri });
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -24,6 +22,14 @@ export default function App() {
|
|||||||
}, [apiUri]);
|
}, [apiUri]);
|
||||||
|
|
||||||
const [searchOpen, setSearchOpen] = useState<boolean>(false);
|
const [searchOpen, setSearchOpen] = useState<boolean>(false);
|
||||||
|
const [downloadDrawerOpen, setDownloadDrawerOpen] = useState(false);
|
||||||
|
const [selectedMangaKey, setSelectedMangaKey] = useState<string>();
|
||||||
|
const [downloadSectionOpen, setDownloadSectionOpen] = useState(false);
|
||||||
|
function openMangaDownloadDrawer(mangaKey: string, downloadSectionOpen?: boolean) {
|
||||||
|
setDownloadDrawerOpen(true);
|
||||||
|
setSelectedMangaKey(mangaKey);
|
||||||
|
setDownloadSectionOpen(downloadSectionOpen ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ApiProvider apiConfig={apiConfig}>
|
<ApiProvider apiConfig={apiConfig}>
|
||||||
@@ -36,11 +42,19 @@ export default function App() {
|
|||||||
</Header>
|
</Header>
|
||||||
<Sheet className={'app-content'}>
|
<Sheet className={'app-content'}>
|
||||||
<MangaList
|
<MangaList
|
||||||
|
mangaOnClick={(m) => openMangaDownloadDrawer(m.key)}
|
||||||
openSearch={() => setSearchOpen(true)}
|
openSearch={() => setSearchOpen(true)}
|
||||||
/>
|
/>
|
||||||
<Search
|
<Search
|
||||||
open={searchOpen}
|
open={searchOpen}
|
||||||
setOpen={setSearchOpen}
|
setOpen={setSearchOpen}
|
||||||
|
mangaOnClick={(m) => openMangaDownloadDrawer(m.key, true)}
|
||||||
|
/>
|
||||||
|
<MangaDetail
|
||||||
|
open={downloadDrawerOpen}
|
||||||
|
setOpen={setDownloadDrawerOpen}
|
||||||
|
mangaKey={selectedMangaKey}
|
||||||
|
downloadOpen={downloadSectionOpen}
|
||||||
/>
|
/>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
|
@@ -6,9 +6,9 @@ import './loadingBorder.css';
|
|||||||
|
|
||||||
export default function TInput(props: TInputProps) {
|
export default function TInput(props: TInputProps) {
|
||||||
const [state, setState] = useState<TState>(TState.clean);
|
const [state, setState] = useState<TState>(TState.clean);
|
||||||
const [value, setValue] = useState<
|
const [value, setValue] = useState<string | number | readonly string[] | undefined>(
|
||||||
string | number | readonly string[] | undefined
|
props.defaultValue
|
||||||
>(props.defaultValue);
|
);
|
||||||
const [initialValue, setInitialValue] = useState<
|
const [initialValue, setInitialValue] = useState<
|
||||||
string | number | readonly string[] | undefined
|
string | number | readonly string[] | undefined
|
||||||
>(props.defaultValue);
|
>(props.defaultValue);
|
||||||
|
@@ -34,7 +34,5 @@ export const TColor = (state: TState): ColorPaletteProp => {
|
|||||||
|
|
||||||
export default interface TProps {
|
export default interface TProps {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
completionAction?: (
|
completionAction?: (value?: string | number | readonly string[]) => Promise<void>;
|
||||||
value?: string | number | readonly string[]
|
|
||||||
) => Promise<void>;
|
|
||||||
}
|
}
|
||||||
|
@@ -11,11 +11,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.manga-card-cover-blur {
|
.manga-card-cover-blur {
|
||||||
background: linear-gradient(
|
background: linear-gradient(150deg, rgba(245, 169, 184, 0.8) 50%, rgba(91, 206, 250, 0.3));
|
||||||
150deg,
|
|
||||||
rgba(245, 169, 184, 0.8) 50%,
|
|
||||||
rgba(91, 206, 250, 0.3)
|
|
||||||
);
|
|
||||||
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
|
||||||
backdrop-filter: blur(2px) brightness(70%);
|
backdrop-filter: blur(2px) brightness(70%);
|
||||||
-webkit-backdrop-filter: blur(2px) brightness(70%);
|
-webkit-backdrop-filter: blur(2px) brightness(70%);
|
||||||
|
@@ -10,11 +10,7 @@ import {
|
|||||||
import { EventHandler, ReactNode, useContext } from 'react';
|
import { EventHandler, ReactNode, useContext } from 'react';
|
||||||
import './MangaCard.css';
|
import './MangaCard.css';
|
||||||
import MangaConnectorIcon from './MangaConnectorIcon.tsx';
|
import MangaConnectorIcon from './MangaConnectorIcon.tsx';
|
||||||
import {
|
import { Manga, MangaReleaseStatus, MinimalManga } from '../../api/data-contracts.ts';
|
||||||
Manga,
|
|
||||||
MangaReleaseStatus,
|
|
||||||
MinimalManga,
|
|
||||||
} from '../../api/data-contracts.ts';
|
|
||||||
import { ApiContext } from '../../contexts/ApiContext.tsx';
|
import { ApiContext } from '../../contexts/ApiContext.tsx';
|
||||||
|
|
||||||
export default function MangaCard(props: MangaCardProps): ReactNode {
|
export default function MangaCard(props: MangaCardProps): ReactNode {
|
||||||
@@ -23,14 +19,10 @@ export default function MangaCard(props: MangaCardProps): ReactNode {
|
|||||||
return (
|
return (
|
||||||
<Badge
|
<Badge
|
||||||
badgeContent={props.manga?.mangaConnectorIds.map((id) => (
|
badgeContent={props.manga?.mangaConnectorIds.map((id) => (
|
||||||
<MangaConnectorIcon
|
<MangaConnectorIcon mangaConnectorName={id.mangaConnectorName} />
|
||||||
mangaConnectorName={id.mangaConnectorName}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
className={'manga-card-badge'}
|
className={'manga-card-badge'}
|
||||||
color={releaseColor(
|
color={releaseColor(props.manga?.releaseStatus ?? MangaReleaseStatus.Unreleased)}>
|
||||||
props.manga?.releaseStatus ?? MangaReleaseStatus.Unreleased
|
|
||||||
)}>
|
|
||||||
<Card
|
<Card
|
||||||
className={'manga-card'}
|
className={'manga-card'}
|
||||||
onClick={props.onClick}>
|
onClick={props.onClick}>
|
||||||
@@ -46,9 +38,7 @@ export default function MangaCard(props: MangaCardProps): ReactNode {
|
|||||||
<CardCover className={'manga-card-cover-blur'} />
|
<CardCover className={'manga-card-cover-blur'} />
|
||||||
<CardContent className={'manga-card-content'}>
|
<CardContent className={'manga-card-content'}>
|
||||||
<Typography level={'h4'}>
|
<Typography level={'h4'}>
|
||||||
{props.manga?.name ?? (
|
{props.manga?.name ?? <Skeleton>{stringWithRandomLength()}</Skeleton>}
|
||||||
<Skeleton>{stringWithRandomLength()}</Skeleton>
|
|
||||||
)}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
@@ -12,9 +12,7 @@ export default function MangaConnectorIcon({
|
|||||||
}): ReactNode {
|
}): ReactNode {
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
const [connector, setConnector] = useState<MangaConnector | undefined>(
|
const [connector, setConnector] = useState<MangaConnector | undefined>(mangaConnector);
|
||||||
mangaConnector
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (mangaConnector) {
|
if (mangaConnector) {
|
||||||
|
@@ -1,36 +1,39 @@
|
|||||||
import { Stack } from '@mui/joy';
|
import { Stack } from '@mui/joy';
|
||||||
import './MangaList.css';
|
import './MangaList.css';
|
||||||
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
import {
|
import { Manga, MangaReleaseStatus, MinimalManga } from '../../api/data-contracts.ts';
|
||||||
Manga,
|
|
||||||
MangaReleaseStatus,
|
|
||||||
MinimalManga,
|
|
||||||
} from '../../api/data-contracts.ts';
|
|
||||||
import { ApiContext } from '../../contexts/ApiContext.tsx';
|
import { ApiContext } from '../../contexts/ApiContext.tsx';
|
||||||
import MangaCard from './MangaCard.tsx';
|
import MangaCard from './MangaCard.tsx';
|
||||||
|
|
||||||
export default function MangaList({
|
export default function MangaList(props: MangaListProps): ReactNode {
|
||||||
openSearch,
|
|
||||||
}: {
|
|
||||||
openSearch: () => void;
|
|
||||||
}): ReactNode {
|
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
const [downloadingManga, setDownloadingManga] = useState<MinimalManga[]>(
|
const [downloadingManga, setDownloadingManga] = useState<MinimalManga[]>([]);
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
|
const [interval, setIntervalState] = useState<number>();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (interval) {
|
||||||
|
clearInterval(interval);
|
||||||
|
setIntervalState(undefined);
|
||||||
|
}
|
||||||
|
if (!Api) return;
|
||||||
|
updateDownloadingManga();
|
||||||
|
setIntervalState(setInterval(updateDownloadingManga, 5000));
|
||||||
|
}, [Api]);
|
||||||
|
|
||||||
|
const updateDownloadingManga = () => {
|
||||||
Api.mangaDownloadingList().then((data) => {
|
Api.mangaDownloadingList().then((data) => {
|
||||||
if (data.ok) {
|
if (data.ok) {
|
||||||
setDownloadingManga(data.data);
|
setDownloadingManga(data.data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [Api]);
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MangaCardList manga={downloadingManga}>
|
<MangaCardList
|
||||||
|
manga={downloadingManga}
|
||||||
|
mangaOnClick={props.mangaOnClick}>
|
||||||
<MangaCard
|
<MangaCard
|
||||||
onClick={openSearch}
|
onClick={props.openSearch}
|
||||||
manga={{
|
manga={{
|
||||||
name: 'Search',
|
name: 'Search',
|
||||||
description: 'Search for a new Manga',
|
description: 'Search for a new Manga',
|
||||||
@@ -43,6 +46,11 @@ export default function MangaList({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MangaListProps {
|
||||||
|
openSearch: () => void;
|
||||||
|
mangaOnClick?: Dispatch<Manga | MinimalManga>;
|
||||||
|
}
|
||||||
|
|
||||||
export function MangaCardList(props: MangaCardListProps): ReactNode {
|
export function MangaCardList(props: MangaCardListProps): ReactNode {
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
|
@@ -8,13 +8,10 @@ export default function ChapterNamingScheme(): ReactNode {
|
|||||||
const settings = useContext(SettingsContext);
|
const settings = useContext(SettingsContext);
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
const schemeChanged = async (
|
const schemeChanged = async (value: string | number | readonly string[] | undefined) => {
|
||||||
value: string | number | readonly string[] | undefined
|
|
||||||
) => {
|
|
||||||
if (typeof value != 'string') return Promise.reject();
|
if (typeof value != 'string') return Promise.reject();
|
||||||
try {
|
try {
|
||||||
const response =
|
const response = await Api.settingsChapterNamingSchemePartialUpdate(value);
|
||||||
await Api.settingsChapterNamingSchemePartialUpdate(value);
|
|
||||||
if (response.ok) return Promise.resolve();
|
if (response.ok) return Promise.resolve();
|
||||||
else return Promise.reject();
|
else return Promise.reject();
|
||||||
} catch {
|
} catch {
|
||||||
|
@@ -7,13 +7,10 @@ export default function DownloadLanguage(): ReactNode {
|
|||||||
const settings = useContext(SettingsContext);
|
const settings = useContext(SettingsContext);
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
const languageChanged = async (
|
const languageChanged = async (value: string | number | readonly string[] | undefined) => {
|
||||||
value: string | number | readonly string[] | undefined
|
|
||||||
) => {
|
|
||||||
if (typeof value != 'string') return Promise.reject();
|
if (typeof value != 'string') return Promise.reject();
|
||||||
try {
|
try {
|
||||||
const response =
|
const response = await Api.settingsDownloadLanguagePartialUpdate(value);
|
||||||
await Api.settingsDownloadLanguagePartialUpdate(value);
|
|
||||||
if (response.ok) return Promise.resolve();
|
if (response.ok) return Promise.resolve();
|
||||||
else return Promise.reject();
|
else return Promise.reject();
|
||||||
} catch {
|
} catch {
|
||||||
|
@@ -7,9 +7,7 @@ export default function FlareSolverr(): ReactNode {
|
|||||||
const settings = useContext(SettingsContext);
|
const settings = useContext(SettingsContext);
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
const uriChanged = async (
|
const uriChanged = async (value: string | number | readonly string[] | undefined) => {
|
||||||
value: string | number | readonly string[] | undefined
|
|
||||||
) => {
|
|
||||||
if (typeof value != 'string') return Promise.reject();
|
if (typeof value != 'string') return Promise.reject();
|
||||||
try {
|
try {
|
||||||
const response = await Api.settingsFlareSolverrUrlCreate(value);
|
const response = await Api.settingsFlareSolverrUrlCreate(value);
|
||||||
|
@@ -18,9 +18,7 @@ export default function Maintenance() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsItem title={'Maintenance'}>
|
<SettingsItem title={'Maintenance'}>
|
||||||
<TButton completionAction={cleanUnusedManga}>
|
<TButton completionAction={cleanUnusedManga}>Cleanup unused Manga</TButton>
|
||||||
Cleanup unused Manga
|
|
||||||
</TButton>
|
|
||||||
</SettingsItem>
|
</SettingsItem>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -12,13 +12,7 @@ import {
|
|||||||
} from '@mui/joy';
|
} from '@mui/joy';
|
||||||
import './Settings.css';
|
import './Settings.css';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {
|
import { createContext, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
createContext,
|
|
||||||
ReactNode,
|
|
||||||
useContext,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
import { SxProps } from '@mui/joy/styles/types';
|
import { SxProps } from '@mui/joy/styles/types';
|
||||||
import ImageCompression from './ImageCompression.tsx';
|
import ImageCompression from './ImageCompression.tsx';
|
||||||
import FlareSolverr from './FlareSolverr.tsx';
|
import FlareSolverr from './FlareSolverr.tsx';
|
||||||
@@ -29,15 +23,9 @@ import { ApiContext } from '../../contexts/ApiContext.tsx';
|
|||||||
import { TrangaSettings } from '../../api/data-contracts.ts';
|
import { TrangaSettings } from '../../api/data-contracts.ts';
|
||||||
import TInput from '../Inputs/TInput.tsx';
|
import TInput from '../Inputs/TInput.tsx';
|
||||||
|
|
||||||
export const SettingsContext = createContext<TrangaSettings | undefined>(
|
export const SettingsContext = createContext<TrangaSettings | undefined>(undefined);
|
||||||
undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function Settings({
|
export default function Settings({ setApiUri }: { setApiUri: (uri: string) => void }) {
|
||||||
setApiUri,
|
|
||||||
}: {
|
|
||||||
setApiUri: (uri: string) => void;
|
|
||||||
}) {
|
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
const [settings, setSettings] = useState<TrangaSettings>();
|
const [settings, setSettings] = useState<TrangaSettings>();
|
||||||
|
|
||||||
@@ -49,9 +37,7 @@ export default function Settings({
|
|||||||
});
|
});
|
||||||
}, [Api]);
|
}, [Api]);
|
||||||
|
|
||||||
const apiUriChanged = (
|
const apiUriChanged = (value: string | number | readonly string[] | undefined) => {
|
||||||
value: string | number | readonly string[] | undefined
|
|
||||||
) => {
|
|
||||||
if (typeof value != 'string') return Promise.reject();
|
if (typeof value != 'string') return Promise.reject();
|
||||||
setApiUri(value);
|
setApiUri(value);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
@@ -90,13 +76,7 @@ export default function Settings({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SettingsItem({
|
export function SettingsItem({ title, children }: { title: string; children: ReactNode }) {
|
||||||
title,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
title: string;
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<AccordionSummary>{title}</AccordionSummary>
|
<AccordionSummary>{title}</AccordionSummary>
|
||||||
|
@@ -5,11 +5,7 @@ import './Header.css';
|
|||||||
import { Article, GitHub } from '@mui/icons-material';
|
import { Article, GitHub } from '@mui/icons-material';
|
||||||
import { ApiContext } from './contexts/ApiContext.tsx';
|
import { ApiContext } from './contexts/ApiContext.tsx';
|
||||||
|
|
||||||
export default function Header({
|
export default function Header({ children }: { children?: ReactNode }): ReactElement {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children?: ReactNode;
|
|
||||||
}): ReactElement {
|
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -17,11 +13,7 @@ export default function Header({
|
|||||||
<Stack
|
<Stack
|
||||||
direction={'row'}
|
direction={'row'}
|
||||||
spacing={2}
|
spacing={2}
|
||||||
sx={{
|
sx={{ width: '100%', alignItems: 'center', justifyContent: 'space-between' }}
|
||||||
width: '100%',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
}}
|
|
||||||
useFlexGap>
|
useFlexGap>
|
||||||
<Stack
|
<Stack
|
||||||
sx={{ flexGrow: 1, flexBasis: 1 }}
|
sx={{ flexGrow: 1, flexBasis: 1 }}
|
||||||
@@ -30,12 +22,7 @@ export default function Header({
|
|||||||
{children}
|
{children}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
sx={{
|
sx={{ flexGrow: 1, height: '100%', flexBasis: 1, justifyContent: 'center' }}
|
||||||
flexGrow: 1,
|
|
||||||
height: '100%',
|
|
||||||
flexBasis: 1,
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
direction={'row'}>
|
direction={'row'}>
|
||||||
<img
|
<img
|
||||||
src={'/blahaj.png'}
|
src={'/blahaj.png'}
|
||||||
@@ -55,11 +42,7 @@ export default function Header({
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
sx={{
|
sx={{ flexGrow: 1, flexBasis: 1, justifyContent: 'flex-end' }}
|
||||||
flexGrow: 1,
|
|
||||||
flexBasis: 1,
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
}}
|
|
||||||
direction={'row'}
|
direction={'row'}
|
||||||
spacing={2}>
|
spacing={2}>
|
||||||
<Link
|
<Link
|
||||||
|
@@ -1,35 +1,85 @@
|
|||||||
import { Manga } from './api/data-contracts.ts';
|
|
||||||
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
|
Accordion,
|
||||||
|
AccordionDetails,
|
||||||
|
AccordionSummary,
|
||||||
|
Box,
|
||||||
Card,
|
Card,
|
||||||
CardCover,
|
CardCover,
|
||||||
|
Checkbox,
|
||||||
Chip,
|
Chip,
|
||||||
|
List,
|
||||||
|
ListItem,
|
||||||
Modal,
|
Modal,
|
||||||
ModalDialog,
|
ModalDialog,
|
||||||
|
Option,
|
||||||
|
Select,
|
||||||
Stack,
|
Stack,
|
||||||
Typography,
|
Typography,
|
||||||
useTheme,
|
useTheme,
|
||||||
} from '@mui/joy';
|
} from '@mui/joy';
|
||||||
import ModalClose from '@mui/joy/ModalClose';
|
import ModalClose from '@mui/joy/ModalClose';
|
||||||
|
import { FileLibrary, Manga, MangaConnectorId } from './api/data-contracts.ts';
|
||||||
import { ApiContext } from './contexts/ApiContext.tsx';
|
import { ApiContext } from './contexts/ApiContext.tsx';
|
||||||
import { MangaContext } from './contexts/MangaContext.tsx';
|
import { MangaContext } from './contexts/MangaContext.tsx';
|
||||||
import './Components/Mangas/MangaCard.css';
|
import { FileLibraryContext } from './contexts/FileLibraryContext.tsx';
|
||||||
|
import MangaConnectorIcon from './Components/Mangas/MangaConnectorIcon.tsx';
|
||||||
|
import TButton from './Components/Inputs/TButton.tsx';
|
||||||
import MarkdownPreview from '@uiw/react-markdown-preview';
|
import MarkdownPreview from '@uiw/react-markdown-preview';
|
||||||
|
|
||||||
export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
const Manga = useContext(MangaContext);
|
const Manga = useContext(MangaContext);
|
||||||
|
const Libraries = useContext(FileLibraryContext);
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
const [manga, setManga] = useState<Manga | undefined>(props.manga);
|
const [manga, setManga] = useState<Manga | undefined>(props.manga);
|
||||||
|
const [library, setLibrary] = useState<FileLibrary | undefined>();
|
||||||
|
const [downloadFromMap, setDownloadFromMap] = useState<Map<MangaConnectorId, boolean>>(
|
||||||
|
new Map()
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!props.open) return;
|
if (!props.open) return;
|
||||||
if (!props.mangaKey) return;
|
if (!props.mangaKey) return;
|
||||||
if (props.manga != undefined) return;
|
if (props.manga != undefined) return;
|
||||||
|
setLibrary(undefined);
|
||||||
Manga.GetManga(props.mangaKey).then(setManga);
|
Manga.GetManga(props.mangaKey).then(setManga);
|
||||||
}, [Api, Manga, props]);
|
}, [Api, Manga, props]);
|
||||||
|
|
||||||
const theme = useTheme();
|
useEffect(() => {
|
||||||
|
const newMap = new Map();
|
||||||
|
setLibrary(Libraries.find((library) => library.key == manga?.fileLibraryId));
|
||||||
|
manga?.mangaConnectorIds.forEach((id) => {
|
||||||
|
newMap.set(id, id.useForDownload);
|
||||||
|
});
|
||||||
|
setDownloadFromMap(newMap);
|
||||||
|
}, [manga, Libraries]);
|
||||||
|
|
||||||
|
const setDownload = async (): Promise<void> => {
|
||||||
|
if (!manga) return Promise.reject();
|
||||||
|
if (library) {
|
||||||
|
const s = await Api.mangaChangeLibraryCreate(manga.key, library?.key)
|
||||||
|
.then((result) => result.ok)
|
||||||
|
.catch(() => false);
|
||||||
|
if (!s) return Promise.reject();
|
||||||
|
}
|
||||||
|
for (const kv of downloadFromMap) {
|
||||||
|
const s = await Api.mangaSetAsDownloadFromCreate(
|
||||||
|
manga?.key,
|
||||||
|
kv[0].mangaConnectorName,
|
||||||
|
kv[1]
|
||||||
|
)
|
||||||
|
.then((result) => result.ok)
|
||||||
|
.catch(() => false);
|
||||||
|
if (!s) return Promise.reject();
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onLibraryChange = (_: any, value: string | null) => {
|
||||||
|
setLibrary(Libraries.find((library) => library.key == value));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -37,18 +87,17 @@ export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
|||||||
onClose={() => props.setOpen(false)}>
|
onClose={() => props.setOpen(false)}>
|
||||||
<ModalDialog>
|
<ModalDialog>
|
||||||
<ModalClose />
|
<ModalClose />
|
||||||
<div
|
<Typography
|
||||||
style={{
|
level={'h3'}
|
||||||
display: 'flex',
|
sx={{ width: '100%' }}>
|
||||||
flexWrap: 'wrap',
|
{manga?.name}
|
||||||
flexDirection: 'row',
|
</Typography>
|
||||||
}}>
|
<Stack
|
||||||
<Typography
|
direction={'row'}
|
||||||
level={'h3'}
|
gap={1}>
|
||||||
sx={{ width: '100%' }}>
|
<Card
|
||||||
{manga?.name}
|
className={'manga-card'}
|
||||||
</Typography>
|
sx={{ flexShrink: 0 }}>
|
||||||
<Card className={'manga-card'}>
|
|
||||||
<CardCover className={'manga-card-cover'}>
|
<CardCover className={'manga-card-cover'}>
|
||||||
<img
|
<img
|
||||||
src={
|
src={
|
||||||
@@ -62,7 +111,7 @@ export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
|||||||
<Stack
|
<Stack
|
||||||
direction={'column'}
|
direction={'column'}
|
||||||
gap={2}
|
gap={2}
|
||||||
sx={{ maxWidth: 'calc(100% - 230px)', margin: '5px' }}>
|
sx={{ flexShrink: 1 }}>
|
||||||
<Stack
|
<Stack
|
||||||
direction={'row'}
|
direction={'row'}
|
||||||
gap={0.5}
|
gap={0.5}
|
||||||
@@ -71,10 +120,7 @@ export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
|||||||
<Chip
|
<Chip
|
||||||
key={tag}
|
key={tag}
|
||||||
size={'sm'}
|
size={'sm'}
|
||||||
sx={{
|
sx={{ backgroundColor: theme.palette.primary.plainColor }}>
|
||||||
backgroundColor:
|
|
||||||
theme.palette.primary.plainColor,
|
|
||||||
}}>
|
|
||||||
{tag}
|
{tag}
|
||||||
</Chip>
|
</Chip>
|
||||||
))}
|
))}
|
||||||
@@ -82,10 +128,7 @@ export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
|||||||
<Chip
|
<Chip
|
||||||
key={author.key}
|
key={author.key}
|
||||||
size={'sm'}
|
size={'sm'}
|
||||||
sx={{
|
sx={{ backgroundColor: theme.palette.success.plainColor }}>
|
||||||
backgroundColor:
|
|
||||||
theme.palette.success.plainColor,
|
|
||||||
}}>
|
|
||||||
{author.name}
|
{author.name}
|
||||||
</Chip>
|
</Chip>
|
||||||
))}
|
))}
|
||||||
@@ -93,10 +136,7 @@ export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
|||||||
<Chip
|
<Chip
|
||||||
key={link.provider}
|
key={link.provider}
|
||||||
size={'sm'}
|
size={'sm'}
|
||||||
sx={{
|
sx={{ backgroundColor: theme.palette.neutral.plainColor }}>
|
||||||
backgroundColor:
|
|
||||||
theme.palette.neutral.plainColor,
|
|
||||||
}}>
|
|
||||||
<a href={link.url}>{link.provider}</a>
|
<a href={link.url}>{link.provider}</a>
|
||||||
</Chip>
|
</Chip>
|
||||||
))}
|
))}
|
||||||
@@ -110,18 +150,70 @@ export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
</Stack>
|
||||||
sx={{
|
|
||||||
flexGrow: 1,
|
<Accordion defaultExpanded={props.downloadOpen}>
|
||||||
flexBasis: 0,
|
<AccordionSummary>
|
||||||
margin: '5px 0',
|
<Typography level={'h3'}>Download</Typography>
|
||||||
alignItems: 'flex-end',
|
</AccordionSummary>
|
||||||
}}
|
<AccordionDetails>
|
||||||
flexWrap={'nowrap'}
|
<Stack
|
||||||
gap={1}>
|
direction={'column'}
|
||||||
{props.actions}
|
gap={2}
|
||||||
</Stack>
|
sx={{ flexBasis: 0 }}>
|
||||||
</div>
|
<Box>
|
||||||
|
<Typography>Select a Library to Download to:</Typography>
|
||||||
|
<Select
|
||||||
|
placeholder={'Select a Library'}
|
||||||
|
value={library?.key}
|
||||||
|
onChange={onLibraryChange}>
|
||||||
|
{Libraries.map((l) => (
|
||||||
|
<Option
|
||||||
|
key={l.key}
|
||||||
|
value={l.key}>
|
||||||
|
{l.libraryName} ({l.basePath})
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Typography>
|
||||||
|
Select which connectors you want to download this Manga from:
|
||||||
|
</Typography>
|
||||||
|
<List>
|
||||||
|
{manga?.mangaConnectorIds.map((id) => (
|
||||||
|
<ListItem key={id.key}>
|
||||||
|
<Checkbox
|
||||||
|
defaultChecked={id.useForDownload}
|
||||||
|
onChange={(c) =>
|
||||||
|
downloadFromMap.set(id, c.target.checked)
|
||||||
|
}
|
||||||
|
label={
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 5,
|
||||||
|
}}>
|
||||||
|
<MangaConnectorIcon
|
||||||
|
mangaConnectorName={
|
||||||
|
id.mangaConnectorName
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Typography>
|
||||||
|
{id.mangaConnectorName}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
</Box>
|
||||||
|
<TButton completionAction={setDownload}>Download All</TButton>
|
||||||
|
</Stack>
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
</ModalDialog>
|
</ModalDialog>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@@ -132,5 +224,5 @@ export interface MangaDetailProps {
|
|||||||
mangaKey?: string;
|
mangaKey?: string;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
setOpen: Dispatch<boolean>;
|
setOpen: Dispatch<boolean>;
|
||||||
actions?: ReactNode[];
|
downloadOpen?: boolean;
|
||||||
}
|
}
|
||||||
|
@@ -1,164 +0,0 @@
|
|||||||
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Card,
|
|
||||||
Checkbox,
|
|
||||||
Drawer,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
Option,
|
|
||||||
Select,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from '@mui/joy';
|
|
||||||
import ModalClose from '@mui/joy/ModalClose';
|
|
||||||
import { FileLibrary, Manga, MangaConnectorId } from './api/data-contracts.ts';
|
|
||||||
import { ApiContext } from './contexts/ApiContext.tsx';
|
|
||||||
import { MangaContext } from './contexts/MangaContext.tsx';
|
|
||||||
import { FileLibraryContext } from './contexts/FileLibraryContext.tsx';
|
|
||||||
import MangaConnectorIcon from './Components/Mangas/MangaConnectorIcon.tsx';
|
|
||||||
import TButton from './Components/Inputs/TButton.tsx';
|
|
||||||
|
|
||||||
export default function MangaDownloadDrawer(
|
|
||||||
props: MangaDownloadDrawerProps
|
|
||||||
): ReactNode {
|
|
||||||
const Api = useContext(ApiContext);
|
|
||||||
const Manga = useContext(MangaContext);
|
|
||||||
const Libraries = useContext(FileLibraryContext);
|
|
||||||
|
|
||||||
const [manga, setManga] = useState<Manga | undefined>(props.manga);
|
|
||||||
const [library, setLibrary] = useState<FileLibrary | undefined>();
|
|
||||||
const [downloadFromMap, setDownloadFromMap] = useState<
|
|
||||||
Map<MangaConnectorId, boolean>
|
|
||||||
>(new Map());
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!props.open) return;
|
|
||||||
if (!props.mangaKey) return;
|
|
||||||
if (props.manga != undefined) return;
|
|
||||||
Manga.GetManga(props.mangaKey).then(setManga);
|
|
||||||
}, [Api, Manga, props]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const newMap = new Map();
|
|
||||||
setLibrary(
|
|
||||||
Libraries.find((library) => library.key == manga?.fileLibraryId)
|
|
||||||
);
|
|
||||||
manga?.mangaConnectorIds.forEach((id) => {
|
|
||||||
newMap.set(id, id.useForDownload);
|
|
||||||
});
|
|
||||||
setDownloadFromMap(newMap);
|
|
||||||
}, [manga]);
|
|
||||||
|
|
||||||
const setDownload = async (): Promise<void> => {
|
|
||||||
if (!manga) return Promise.reject();
|
|
||||||
if (library) {
|
|
||||||
const s = await Api.mangaChangeLibraryCreate(
|
|
||||||
manga.key,
|
|
||||||
library?.key
|
|
||||||
)
|
|
||||||
.then((result) => result.ok)
|
|
||||||
.catch(() => false);
|
|
||||||
if (!s) return Promise.reject();
|
|
||||||
}
|
|
||||||
for (const kv of downloadFromMap) {
|
|
||||||
const s = await Api.mangaSetAsDownloadFromCreate(
|
|
||||||
manga?.key,
|
|
||||||
kv[0].mangaConnectorName,
|
|
||||||
kv[1]
|
|
||||||
)
|
|
||||||
.then((result) => result.ok)
|
|
||||||
.catch(() => false);
|
|
||||||
if (!s) return Promise.reject();
|
|
||||||
}
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onLibraryChange = (_: any, value: string | null) => {
|
|
||||||
setLibrary(Libraries.find((library) => library.key == value));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Drawer
|
|
||||||
open={props.open}
|
|
||||||
onClose={() => props.setOpen(false)}
|
|
||||||
anchor="left"
|
|
||||||
size="md">
|
|
||||||
<Card sx={{ flexGrow: 1, margin: '10px' }}>
|
|
||||||
<ModalClose />
|
|
||||||
<Typography level={'h3'}>Download</Typography>
|
|
||||||
<Typography level={'h4'}>{manga?.name}</Typography>
|
|
||||||
<Stack
|
|
||||||
direction={'column'}
|
|
||||||
gap={2}
|
|
||||||
sx={{ flexBasis: 0 }}>
|
|
||||||
<Box>
|
|
||||||
<Typography>
|
|
||||||
Select a Library to Download to:
|
|
||||||
</Typography>
|
|
||||||
<Select
|
|
||||||
placeholder={'Select a Library'}
|
|
||||||
value={library?.key}
|
|
||||||
onChange={onLibraryChange}>
|
|
||||||
{Libraries.map((l) => (
|
|
||||||
<Option
|
|
||||||
key={l.key}
|
|
||||||
value={l.key}>
|
|
||||||
{l.libraryName} ({l.basePath})
|
|
||||||
</Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Box>
|
|
||||||
<Box>
|
|
||||||
<Typography>
|
|
||||||
Select which connectors you want to download this
|
|
||||||
Manga from:
|
|
||||||
</Typography>
|
|
||||||
<List>
|
|
||||||
{manga?.mangaConnectorIds.map((id) => (
|
|
||||||
<ListItem key={id.key}>
|
|
||||||
<Checkbox
|
|
||||||
defaultChecked={id.useForDownload}
|
|
||||||
onChange={(c) =>
|
|
||||||
downloadFromMap.set(
|
|
||||||
id,
|
|
||||||
c.target.checked
|
|
||||||
)
|
|
||||||
}
|
|
||||||
label={
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: 5,
|
|
||||||
}}>
|
|
||||||
<MangaConnectorIcon
|
|
||||||
mangaConnectorName={
|
|
||||||
id.mangaConnectorName
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Typography>
|
|
||||||
{id.mangaConnectorName}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</ListItem>
|
|
||||||
))}
|
|
||||||
</List>
|
|
||||||
</Box>
|
|
||||||
<TButton completionAction={setDownload}>
|
|
||||||
Download All
|
|
||||||
</TButton>
|
|
||||||
</Stack>
|
|
||||||
</Card>
|
|
||||||
</Drawer>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MangaDownloadDrawerProps {
|
|
||||||
manga?: Manga;
|
|
||||||
mangaKey?: string;
|
|
||||||
open: boolean;
|
|
||||||
setOpen: Dispatch<boolean>;
|
|
||||||
}
|
|
@@ -1,6 +1,5 @@
|
|||||||
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Button,
|
|
||||||
List,
|
List,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemDecorator,
|
ListItemDecorator,
|
||||||
@@ -18,8 +17,6 @@ import TInput from './Components/Inputs/TInput.tsx';
|
|||||||
import { ApiContext } from './contexts/ApiContext.tsx';
|
import { ApiContext } from './contexts/ApiContext.tsx';
|
||||||
import { MangaCardList } from './Components/Mangas/MangaList.tsx';
|
import { MangaCardList } from './Components/Mangas/MangaList.tsx';
|
||||||
import { MangaConnector, MinimalManga } from './api/data-contracts.ts';
|
import { MangaConnector, MinimalManga } from './api/data-contracts.ts';
|
||||||
import MangaDetail from './MangaDetail.tsx';
|
|
||||||
import MangaDownloadDrawer from './MangaDownloadDrawer.tsx';
|
|
||||||
|
|
||||||
export function Search(props: SearchModalProps): ReactNode {
|
export function Search(props: SearchModalProps): ReactNode {
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
@@ -32,8 +29,7 @@ export function Search(props: SearchModalProps): ReactNode {
|
|||||||
}
|
}
|
||||||
}, [props]);
|
}, [props]);
|
||||||
|
|
||||||
const [selectedConnector, setSelectedConnector] =
|
const [selectedConnector, setSelectedConnector] = useState<MangaConnector>();
|
||||||
useState<MangaConnector>();
|
|
||||||
const [searchResults, setSearchResults] = useState<MinimalManga[]>([]);
|
const [searchResults, setSearchResults] = useState<MinimalManga[]>([]);
|
||||||
|
|
||||||
const startSearch = async (
|
const startSearch = async (
|
||||||
@@ -54,10 +50,7 @@ export function Search(props: SearchModalProps): ReactNode {
|
|||||||
} else {
|
} else {
|
||||||
if (!selectedConnector) return Promise.reject();
|
if (!selectedConnector) return Promise.reject();
|
||||||
try {
|
try {
|
||||||
const result2 = await Api.searchDetail(
|
const result2 = await Api.searchDetail(selectedConnector?.key, value);
|
||||||
selectedConnector?.key,
|
|
||||||
value
|
|
||||||
);
|
|
||||||
if (result2.ok) {
|
if (result2.ok) {
|
||||||
setSearchResults(result2.data);
|
setSearchResults(result2.data);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
@@ -68,23 +61,6 @@ export function Search(props: SearchModalProps): ReactNode {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const [selectedManga, setSelectedManga] = useState<
|
|
||||||
MinimalManga | undefined
|
|
||||||
>(undefined);
|
|
||||||
const [mangaDetailOpen, setMangaDetailOpen] = useState(false);
|
|
||||||
const [mangaDownloadDrawerOpen, setMangaDownloadDrawerOpen] =
|
|
||||||
useState(false);
|
|
||||||
|
|
||||||
function openMangaDetail(manga: MinimalManga) {
|
|
||||||
setSelectedManga(manga);
|
|
||||||
setMangaDetailOpen(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openMangaDownloadDrawer() {
|
|
||||||
setMangaDetailOpen(false);
|
|
||||||
setMangaDownloadDrawerOpen(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
open={props.open}
|
open={props.open}
|
||||||
@@ -95,18 +71,14 @@ export function Search(props: SearchModalProps): ReactNode {
|
|||||||
<Step
|
<Step
|
||||||
orientation={'vertical'}
|
orientation={'vertical'}
|
||||||
indicator={<StepIndicator>1</StepIndicator>}>
|
indicator={<StepIndicator>1</StepIndicator>}>
|
||||||
<Typography level={'title-lg'}>
|
<Typography level={'title-lg'}>Select a connector</Typography>
|
||||||
Select a connector
|
|
||||||
</Typography>
|
|
||||||
<List>
|
<List>
|
||||||
{MangaConnectors.map((c) => (
|
{MangaConnectors.map((c) => (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={c.key}
|
key={c.key}
|
||||||
onClick={() => setSelectedConnector(c)}>
|
onClick={() => setSelectedConnector(c)}>
|
||||||
<ListItemDecorator>
|
<ListItemDecorator>
|
||||||
<MangaConnectorIcon
|
<MangaConnectorIcon mangaConnector={c} />
|
||||||
mangaConnector={c}
|
|
||||||
/>
|
|
||||||
</ListItemDecorator>
|
</ListItemDecorator>
|
||||||
<Typography
|
<Typography
|
||||||
sx={
|
sx={
|
||||||
@@ -123,9 +95,7 @@ export function Search(props: SearchModalProps): ReactNode {
|
|||||||
<Step
|
<Step
|
||||||
orientation={'vertical'}
|
orientation={'vertical'}
|
||||||
indicator={<StepIndicator>2</StepIndicator>}>
|
indicator={<StepIndicator>2</StepIndicator>}>
|
||||||
<Typography level={'title-lg'}>
|
<Typography level={'title-lg'}>Enter a search term or URL</Typography>
|
||||||
Enter a search term or URL
|
|
||||||
</Typography>
|
|
||||||
<TInput
|
<TInput
|
||||||
placeholder={'Manga-name or URL'}
|
placeholder={'Manga-name or URL'}
|
||||||
completionAction={startSearch}
|
completionAction={startSearch}
|
||||||
@@ -134,22 +104,7 @@ export function Search(props: SearchModalProps): ReactNode {
|
|||||||
</Stepper>
|
</Stepper>
|
||||||
<MangaCardList
|
<MangaCardList
|
||||||
manga={searchResults}
|
manga={searchResults}
|
||||||
mangaOnClick={openMangaDetail}
|
mangaOnClick={props.mangaOnClick}
|
||||||
/>
|
|
||||||
<MangaDetail
|
|
||||||
mangaKey={selectedManga?.key}
|
|
||||||
open={mangaDetailOpen}
|
|
||||||
setOpen={setMangaDetailOpen}
|
|
||||||
actions={[
|
|
||||||
<Button onClick={openMangaDownloadDrawer}>
|
|
||||||
Download
|
|
||||||
</Button>,
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<MangaDownloadDrawer
|
|
||||||
open={mangaDownloadDrawerOpen}
|
|
||||||
setOpen={setMangaDownloadDrawerOpen}
|
|
||||||
mangaKey={selectedManga?.key}
|
|
||||||
/>
|
/>
|
||||||
</ModalDialog>
|
</ModalDialog>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -159,6 +114,7 @@ export function Search(props: SearchModalProps): ReactNode {
|
|||||||
export interface SearchModalProps {
|
export interface SearchModalProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
setOpen: Dispatch<boolean>;
|
setOpen: Dispatch<boolean>;
|
||||||
|
mangaOnClick?: (manga: MinimalManga) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUrl(str: string): boolean {
|
function isUrl(str: string): boolean {
|
||||||
|
@@ -33,9 +33,7 @@ import {
|
|||||||
} from './data-contracts';
|
} from './data-contracts';
|
||||||
import { ContentType, HttpClient, RequestParams } from './http-client';
|
import { ContentType, HttpClient, RequestParams } from './http-client';
|
||||||
|
|
||||||
export class V2<
|
export class V2<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
|
||||||
SecurityDataType = unknown,
|
|
||||||
> extends HttpClient<SecurityDataType> {
|
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
@@ -159,10 +157,7 @@ export class V2<
|
|||||||
* @summary Creates a new API.Schema.LibraryContext.LibraryConnectors.LibraryConnector
|
* @summary Creates a new API.Schema.LibraryContext.LibraryConnectors.LibraryConnector
|
||||||
* @request PUT:/v2/LibraryConnector
|
* @request PUT:/v2/LibraryConnector
|
||||||
*/
|
*/
|
||||||
libraryConnectorUpdate = (
|
libraryConnectorUpdate = (data: LibraryConnector, params: RequestParams = {}) =>
|
||||||
data: LibraryConnector,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<string, string>({
|
this.request<string, string>({
|
||||||
path: `/v2/LibraryConnector`,
|
path: `/v2/LibraryConnector`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -178,10 +173,7 @@ export class V2<
|
|||||||
* @summary Returns API.Schema.LibraryContext.LibraryConnectors.LibraryConnector with LibraryConnectorId
|
* @summary Returns API.Schema.LibraryContext.LibraryConnectors.LibraryConnector with LibraryConnectorId
|
||||||
* @request GET:/v2/LibraryConnector/{LibraryConnectorId}
|
* @request GET:/v2/LibraryConnector/{LibraryConnectorId}
|
||||||
*/
|
*/
|
||||||
libraryConnectorDetail = (
|
libraryConnectorDetail = (libraryConnectorId: string, params: RequestParams = {}) =>
|
||||||
libraryConnectorId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<LibraryConnector, string>({
|
this.request<LibraryConnector, string>({
|
||||||
path: `/v2/LibraryConnector/${libraryConnectorId}`,
|
path: `/v2/LibraryConnector/${libraryConnectorId}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -196,10 +188,7 @@ export class V2<
|
|||||||
* @summary Deletes API.Schema.LibraryContext.LibraryConnectors.LibraryConnector with LibraryConnectorId
|
* @summary Deletes API.Schema.LibraryContext.LibraryConnectors.LibraryConnector with LibraryConnectorId
|
||||||
* @request DELETE:/v2/LibraryConnector/{LibraryConnectorId}
|
* @request DELETE:/v2/LibraryConnector/{LibraryConnectorId}
|
||||||
*/
|
*/
|
||||||
libraryConnectorDelete = (
|
libraryConnectorDelete = (libraryConnectorId: string, params: RequestParams = {}) =>
|
||||||
libraryConnectorId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, string>({
|
this.request<void, string>({
|
||||||
path: `/v2/LibraryConnector/${libraryConnectorId}`,
|
path: `/v2/LibraryConnector/${libraryConnectorId}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
@@ -305,11 +294,7 @@ export class V2<
|
|||||||
* @request DELETE:/v2/Manga/{MangaId}
|
* @request DELETE:/v2/Manga/{MangaId}
|
||||||
*/
|
*/
|
||||||
mangaDelete = (mangaId: string, params: RequestParams = {}) =>
|
mangaDelete = (mangaId: string, params: RequestParams = {}) =>
|
||||||
this.request<void, string>({
|
this.request<void, string>({ path: `/v2/Manga/${mangaId}`, method: 'DELETE', ...params });
|
||||||
path: `/v2/Manga/${mangaId}`,
|
|
||||||
method: 'DELETE',
|
|
||||||
...params,
|
|
||||||
});
|
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
@@ -382,10 +367,7 @@ export class V2<
|
|||||||
* @summary Returns all downloaded API.Controllers.DTOs.Chapter for API.Controllers.DTOs.Manga with MangaId
|
* @summary Returns all downloaded API.Controllers.DTOs.Chapter for API.Controllers.DTOs.Manga with MangaId
|
||||||
* @request GET:/v2/Manga/{MangaId}/Chapters/Downloaded
|
* @request GET:/v2/Manga/{MangaId}/Chapters/Downloaded
|
||||||
*/
|
*/
|
||||||
mangaChaptersDownloadedList = (
|
mangaChaptersDownloadedList = (mangaId: string, params: RequestParams = {}) =>
|
||||||
mangaId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<Chapter[], string>({
|
this.request<Chapter[], string>({
|
||||||
path: `/v2/Manga/${mangaId}/Chapters/Downloaded`,
|
path: `/v2/Manga/${mangaId}/Chapters/Downloaded`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -400,10 +382,7 @@ export class V2<
|
|||||||
* @summary Returns all API.Controllers.DTOs.Chapter not downloaded for API.Controllers.DTOs.Manga with MangaId
|
* @summary Returns all API.Controllers.DTOs.Chapter not downloaded for API.Controllers.DTOs.Manga with MangaId
|
||||||
* @request GET:/v2/Manga/{MangaId}/Chapters/NotDownloaded
|
* @request GET:/v2/Manga/{MangaId}/Chapters/NotDownloaded
|
||||||
*/
|
*/
|
||||||
mangaChaptersNotDownloadedList = (
|
mangaChaptersNotDownloadedList = (mangaId: string, params: RequestParams = {}) =>
|
||||||
mangaId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<Chapter[], string>({
|
this.request<Chapter[], string>({
|
||||||
path: `/v2/Manga/${mangaId}/Chapters/NotDownloaded`,
|
path: `/v2/Manga/${mangaId}/Chapters/NotDownloaded`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -418,10 +397,7 @@ export class V2<
|
|||||||
* @summary Returns the latest API.Controllers.DTOs.Chapter of requested API.Controllers.DTOs.Manga available on API.MangaConnectors.MangaConnector
|
* @summary Returns the latest API.Controllers.DTOs.Chapter of requested API.Controllers.DTOs.Manga available on API.MangaConnectors.MangaConnector
|
||||||
* @request GET:/v2/Manga/{MangaId}/Chapter/LatestAvailable
|
* @request GET:/v2/Manga/{MangaId}/Chapter/LatestAvailable
|
||||||
*/
|
*/
|
||||||
mangaChapterLatestAvailableList = (
|
mangaChapterLatestAvailableList = (mangaId: string, params: RequestParams = {}) =>
|
||||||
mangaId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<number, string | void>({
|
this.request<number, string | void>({
|
||||||
path: `/v2/Manga/${mangaId}/Chapter/LatestAvailable`,
|
path: `/v2/Manga/${mangaId}/Chapter/LatestAvailable`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -436,10 +412,7 @@ export class V2<
|
|||||||
* @summary Returns the latest API.Controllers.DTOs.Chapter of requested API.Controllers.DTOs.Manga that is downloaded
|
* @summary Returns the latest API.Controllers.DTOs.Chapter of requested API.Controllers.DTOs.Manga that is downloaded
|
||||||
* @request GET:/v2/Manga/{MangaId}/Chapter/LatestDownloaded
|
* @request GET:/v2/Manga/{MangaId}/Chapter/LatestDownloaded
|
||||||
*/
|
*/
|
||||||
mangaChapterLatestDownloadedList = (
|
mangaChapterLatestDownloadedList = (mangaId: string, params: RequestParams = {}) =>
|
||||||
mangaId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<Chapter, string | ProblemDetails | void>({
|
this.request<Chapter, string | ProblemDetails | void>({
|
||||||
path: `/v2/Manga/${mangaId}/Chapter/LatestDownloaded`,
|
path: `/v2/Manga/${mangaId}/Chapter/LatestDownloaded`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -474,11 +447,7 @@ export class V2<
|
|||||||
* @summary Move API.Controllers.DTOs.Manga to different API.Schema.MangaContext.FileLibrary
|
* @summary Move API.Controllers.DTOs.Manga to different API.Schema.MangaContext.FileLibrary
|
||||||
* @request POST:/v2/Manga/{MangaId}/ChangeLibrary/{LibraryId}
|
* @request POST:/v2/Manga/{MangaId}/ChangeLibrary/{LibraryId}
|
||||||
*/
|
*/
|
||||||
mangaChangeLibraryCreate = (
|
mangaChangeLibraryCreate = (mangaId: string, libraryId: string, params: RequestParams = {}) =>
|
||||||
mangaId: string,
|
|
||||||
libraryId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, string>({
|
this.request<void, string>({
|
||||||
path: `/v2/Manga/${mangaId}/ChangeLibrary/${libraryId}`,
|
path: `/v2/Manga/${mangaId}/ChangeLibrary/${libraryId}`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -575,10 +544,7 @@ export class V2<
|
|||||||
* @summary Returns the API.MangaConnectors.MangaConnector (Scanlation-Sites) with the requested Name
|
* @summary Returns the API.MangaConnectors.MangaConnector (Scanlation-Sites) with the requested Name
|
||||||
* @request GET:/v2/MangaConnector/{MangaConnectorName}
|
* @request GET:/v2/MangaConnector/{MangaConnectorName}
|
||||||
*/
|
*/
|
||||||
mangaConnectorDetail = (
|
mangaConnectorDetail = (mangaConnectorName: string, params: RequestParams = {}) =>
|
||||||
mangaConnectorName: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<MangaConnector, string>({
|
this.request<MangaConnector, string>({
|
||||||
path: `/v2/MangaConnector/${mangaConnectorName}`,
|
path: `/v2/MangaConnector/${mangaConnectorName}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -748,10 +714,7 @@ export class V2<
|
|||||||
* @summary Creates a new API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
* @summary Creates a new API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
||||||
* @request PUT:/v2/NotificationConnector
|
* @request PUT:/v2/NotificationConnector
|
||||||
*/
|
*/
|
||||||
notificationConnectorUpdate = (
|
notificationConnectorUpdate = (data: NotificationConnector, params: RequestParams = {}) =>
|
||||||
data: NotificationConnector,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<string, string>({
|
this.request<string, string>({
|
||||||
path: `/v2/NotificationConnector`,
|
path: `/v2/NotificationConnector`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -797,10 +760,7 @@ export class V2<
|
|||||||
* @summary Creates a new Gotify-API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
* @summary Creates a new Gotify-API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
||||||
* @request PUT:/v2/NotificationConnector/Gotify
|
* @request PUT:/v2/NotificationConnector/Gotify
|
||||||
*/
|
*/
|
||||||
notificationConnectorGotifyUpdate = (
|
notificationConnectorGotifyUpdate = (data: GotifyRecord, params: RequestParams = {}) =>
|
||||||
data: GotifyRecord,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<string, string>({
|
this.request<string, string>({
|
||||||
path: `/v2/NotificationConnector/Gotify`,
|
path: `/v2/NotificationConnector/Gotify`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -817,10 +777,7 @@ export class V2<
|
|||||||
* @summary Creates a new Ntfy-API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
* @summary Creates a new Ntfy-API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
||||||
* @request PUT:/v2/NotificationConnector/Ntfy
|
* @request PUT:/v2/NotificationConnector/Ntfy
|
||||||
*/
|
*/
|
||||||
notificationConnectorNtfyUpdate = (
|
notificationConnectorNtfyUpdate = (data: NtfyRecord, params: RequestParams = {}) =>
|
||||||
data: NtfyRecord,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<string, string>({
|
this.request<string, string>({
|
||||||
path: `/v2/NotificationConnector/Ntfy`,
|
path: `/v2/NotificationConnector/Ntfy`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -837,10 +794,7 @@ export class V2<
|
|||||||
* @summary Creates a new Pushover-API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
* @summary Creates a new Pushover-API.Schema.NotificationsContext.NotificationConnectors.NotificationConnector
|
||||||
* @request PUT:/v2/NotificationConnector/Pushover
|
* @request PUT:/v2/NotificationConnector/Pushover
|
||||||
*/
|
*/
|
||||||
notificationConnectorPushoverUpdate = (
|
notificationConnectorPushoverUpdate = (data: PushoverRecord, params: RequestParams = {}) =>
|
||||||
data: PushoverRecord,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<string, string>({
|
this.request<string, string>({
|
||||||
path: `/v2/NotificationConnector/Pushover`,
|
path: `/v2/NotificationConnector/Pushover`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -887,10 +841,7 @@ export class V2<
|
|||||||
* @summary Returns the API.Schema.MangaContext.MangaConnectorId`1 with API.Schema.MangaContext.MangaConnectorId`1.Key
|
* @summary Returns the API.Schema.MangaContext.MangaConnectorId`1 with API.Schema.MangaContext.MangaConnectorId`1.Key
|
||||||
* @request GET:/v2/Query/Manga/MangaConnectorId/{MangaConnectorIdId}
|
* @request GET:/v2/Query/Manga/MangaConnectorId/{MangaConnectorIdId}
|
||||||
*/
|
*/
|
||||||
queryMangaMangaConnectorIdDetail = (
|
queryMangaMangaConnectorIdDetail = (mangaConnectorIdId: string, params: RequestParams = {}) =>
|
||||||
mangaConnectorIdId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<MangaConnectorId, string>({
|
this.request<MangaConnectorId, string>({
|
||||||
path: `/v2/Query/Manga/MangaConnectorId/${mangaConnectorIdId}`,
|
path: `/v2/Query/Manga/MangaConnectorId/${mangaConnectorIdId}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -920,10 +871,7 @@ export class V2<
|
|||||||
* @summary Returns the API.Schema.MangaContext.MangaConnectorId`1 with API.Schema.MangaContext.MangaConnectorId`1.Key
|
* @summary Returns the API.Schema.MangaContext.MangaConnectorId`1 with API.Schema.MangaContext.MangaConnectorId`1.Key
|
||||||
* @request GET:/v2/Query/Chapter/MangaConnectorId/{MangaConnectorIdId}
|
* @request GET:/v2/Query/Chapter/MangaConnectorId/{MangaConnectorIdId}
|
||||||
*/
|
*/
|
||||||
queryChapterMangaConnectorIdDetail = (
|
queryChapterMangaConnectorIdDetail = (mangaConnectorIdId: string, params: RequestParams = {}) =>
|
||||||
mangaConnectorIdId: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<MangaConnectorId, string>({
|
this.request<MangaConnectorId, string>({
|
||||||
path: `/v2/Query/Chapter/MangaConnectorId/${mangaConnectorIdId}`,
|
path: `/v2/Query/Chapter/MangaConnectorId/${mangaConnectorIdId}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -938,11 +886,7 @@ export class V2<
|
|||||||
* @summary Initiate a search for a API.Schema.MangaContext.Manga on API.Controllers.DTOs.MangaConnector with searchTerm
|
* @summary Initiate a search for a API.Schema.MangaContext.Manga on API.Controllers.DTOs.MangaConnector with searchTerm
|
||||||
* @request GET:/v2/Search/{MangaConnectorName}/{Query}
|
* @request GET:/v2/Search/{MangaConnectorName}/{Query}
|
||||||
*/
|
*/
|
||||||
searchDetail = (
|
searchDetail = (mangaConnectorName: string, query: string, params: RequestParams = {}) =>
|
||||||
mangaConnectorName: string,
|
|
||||||
query: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<MinimalManga[], string | ProblemDetails | void>({
|
this.request<MinimalManga[], string | ProblemDetails | void>({
|
||||||
path: `/v2/Search/${mangaConnectorName}/${query}`,
|
path: `/v2/Search/${mangaConnectorName}/${query}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -990,11 +934,7 @@ export class V2<
|
|||||||
* @request GET:/v2/Settings/UserAgent
|
* @request GET:/v2/Settings/UserAgent
|
||||||
*/
|
*/
|
||||||
settingsUserAgentList = (params: RequestParams = {}) =>
|
settingsUserAgentList = (params: RequestParams = {}) =>
|
||||||
this.request<string, any>({
|
this.request<string, any>({ path: `/v2/Settings/UserAgent`, method: 'GET', ...params });
|
||||||
path: `/v2/Settings/UserAgent`,
|
|
||||||
method: 'GET',
|
|
||||||
...params,
|
|
||||||
});
|
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
@@ -1003,10 +943,7 @@ export class V2<
|
|||||||
* @summary Set a new UserAgent
|
* @summary Set a new UserAgent
|
||||||
* @request PATCH:/v2/Settings/UserAgent
|
* @request PATCH:/v2/Settings/UserAgent
|
||||||
*/
|
*/
|
||||||
settingsUserAgentPartialUpdate = (
|
settingsUserAgentPartialUpdate = (data: string, params: RequestParams = {}) =>
|
||||||
data: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, any>({
|
this.request<void, any>({
|
||||||
path: `/v2/Settings/UserAgent`,
|
path: `/v2/Settings/UserAgent`,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
@@ -1023,11 +960,7 @@ export class V2<
|
|||||||
* @request DELETE:/v2/Settings/UserAgent
|
* @request DELETE:/v2/Settings/UserAgent
|
||||||
*/
|
*/
|
||||||
settingsUserAgentDelete = (params: RequestParams = {}) =>
|
settingsUserAgentDelete = (params: RequestParams = {}) =>
|
||||||
this.request<void, any>({
|
this.request<void, any>({ path: `/v2/Settings/UserAgent`, method: 'DELETE', ...params });
|
||||||
path: `/v2/Settings/UserAgent`,
|
|
||||||
method: 'DELETE',
|
|
||||||
...params,
|
|
||||||
});
|
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
@@ -1053,12 +986,7 @@ export class V2<
|
|||||||
MangaInfo?: number;
|
MangaInfo?: number;
|
||||||
},
|
},
|
||||||
any
|
any
|
||||||
>({
|
>({ path: `/v2/Settings/RequestLimits`, method: 'GET', format: 'json', ...params });
|
||||||
path: `/v2/Settings/RequestLimits`,
|
|
||||||
method: 'GET',
|
|
||||||
format: 'json',
|
|
||||||
...params,
|
|
||||||
});
|
|
||||||
/**
|
/**
|
||||||
* @description <h1>NOT IMPLEMENTED</h1>
|
* @description <h1>NOT IMPLEMENTED</h1>
|
||||||
*
|
*
|
||||||
@@ -1068,11 +996,7 @@ export class V2<
|
|||||||
* @request PATCH:/v2/Settings/RequestLimits
|
* @request PATCH:/v2/Settings/RequestLimits
|
||||||
*/
|
*/
|
||||||
settingsRequestLimitsPartialUpdate = (params: RequestParams = {}) =>
|
settingsRequestLimitsPartialUpdate = (params: RequestParams = {}) =>
|
||||||
this.request<any, void>({
|
this.request<any, void>({ path: `/v2/Settings/RequestLimits`, method: 'PATCH', ...params });
|
||||||
path: `/v2/Settings/RequestLimits`,
|
|
||||||
method: 'PATCH',
|
|
||||||
...params,
|
|
||||||
});
|
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
@@ -1120,10 +1044,7 @@ export class V2<
|
|||||||
* @originalName settingsRequestLimitsDelete
|
* @originalName settingsRequestLimitsDelete
|
||||||
* @duplicate
|
* @duplicate
|
||||||
*/
|
*/
|
||||||
settingsRequestLimitsDelete2 = (
|
settingsRequestLimitsDelete2 = (requestType: RequestType, params: RequestParams = {}) =>
|
||||||
requestType: RequestType,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<string, any>({
|
this.request<string, any>({
|
||||||
path: `/v2/Settings/RequestLimits/${requestType}`,
|
path: `/v2/Settings/RequestLimits/${requestType}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
@@ -1152,10 +1073,7 @@ export class V2<
|
|||||||
* @summary Set the Image-Compression-Level for Images
|
* @summary Set the Image-Compression-Level for Images
|
||||||
* @request PATCH:/v2/Settings/ImageCompressionLevel/{level}
|
* @request PATCH:/v2/Settings/ImageCompressionLevel/{level}
|
||||||
*/
|
*/
|
||||||
settingsImageCompressionLevelPartialUpdate = (
|
settingsImageCompressionLevelPartialUpdate = (level: number, params: RequestParams = {}) =>
|
||||||
level: number,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, ProblemDetails>({
|
this.request<void, ProblemDetails>({
|
||||||
path: `/v2/Settings/ImageCompressionLevel/${level}`,
|
path: `/v2/Settings/ImageCompressionLevel/${level}`,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
@@ -1170,11 +1088,7 @@ export class V2<
|
|||||||
* @request GET:/v2/Settings/BWImages
|
* @request GET:/v2/Settings/BWImages
|
||||||
*/
|
*/
|
||||||
settingsBwImagesList = (params: RequestParams = {}) =>
|
settingsBwImagesList = (params: RequestParams = {}) =>
|
||||||
this.request<boolean, any>({
|
this.request<boolean, any>({ path: `/v2/Settings/BWImages`, method: 'GET', ...params });
|
||||||
path: `/v2/Settings/BWImages`,
|
|
||||||
method: 'GET',
|
|
||||||
...params,
|
|
||||||
});
|
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
@@ -1183,10 +1097,7 @@ export class V2<
|
|||||||
* @summary Enable/Disable conversion of Images to Black and White
|
* @summary Enable/Disable conversion of Images to Black and White
|
||||||
* @request PATCH:/v2/Settings/BWImages/{enabled}
|
* @request PATCH:/v2/Settings/BWImages/{enabled}
|
||||||
*/
|
*/
|
||||||
settingsBwImagesPartialUpdate = (
|
settingsBwImagesPartialUpdate = (enabled: boolean, params: RequestParams = {}) =>
|
||||||
enabled: boolean,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, any>({
|
this.request<void, any>({
|
||||||
path: `/v2/Settings/BWImages/${enabled}`,
|
path: `/v2/Settings/BWImages/${enabled}`,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
@@ -1214,10 +1125,7 @@ export class V2<
|
|||||||
* @summary Sets the Chapter Naming Scheme
|
* @summary Sets the Chapter Naming Scheme
|
||||||
* @request PATCH:/v2/Settings/ChapterNamingScheme
|
* @request PATCH:/v2/Settings/ChapterNamingScheme
|
||||||
*/
|
*/
|
||||||
settingsChapterNamingSchemePartialUpdate = (
|
settingsChapterNamingSchemePartialUpdate = (data: string, params: RequestParams = {}) =>
|
||||||
data: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, any>({
|
this.request<void, any>({
|
||||||
path: `/v2/Settings/ChapterNamingScheme`,
|
path: `/v2/Settings/ChapterNamingScheme`,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
@@ -1233,10 +1141,7 @@ export class V2<
|
|||||||
* @summary Sets the FlareSolverr-URL
|
* @summary Sets the FlareSolverr-URL
|
||||||
* @request POST:/v2/Settings/FlareSolverr/Url
|
* @request POST:/v2/Settings/FlareSolverr/Url
|
||||||
*/
|
*/
|
||||||
settingsFlareSolverrUrlCreate = (
|
settingsFlareSolverrUrlCreate = (data: string, params: RequestParams = {}) =>
|
||||||
data: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, any>({
|
this.request<void, any>({
|
||||||
path: `/v2/Settings/FlareSolverr/Url`,
|
path: `/v2/Settings/FlareSolverr/Url`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -1294,10 +1199,7 @@ export class V2<
|
|||||||
* @summary Sets the language in which Manga are downloaded
|
* @summary Sets the language in which Manga are downloaded
|
||||||
* @request PATCH:/v2/Settings/DownloadLanguage/{Language}
|
* @request PATCH:/v2/Settings/DownloadLanguage/{Language}
|
||||||
*/
|
*/
|
||||||
settingsDownloadLanguagePartialUpdate = (
|
settingsDownloadLanguagePartialUpdate = (language: string, params: RequestParams = {}) =>
|
||||||
language: string,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<void, any>({
|
this.request<void, any>({
|
||||||
path: `/v2/Settings/DownloadLanguage/${language}`,
|
path: `/v2/Settings/DownloadLanguage/${language}`,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
@@ -1341,10 +1243,7 @@ export class V2<
|
|||||||
* @summary Get all API.Workers.BaseWorker in requested API.Workers.WorkerExecutionState
|
* @summary Get all API.Workers.BaseWorker in requested API.Workers.WorkerExecutionState
|
||||||
* @request GET:/v2/Worker/State/{State}
|
* @request GET:/v2/Worker/State/{State}
|
||||||
*/
|
*/
|
||||||
workerStateDetail = (
|
workerStateDetail = (state: WorkerExecutionState, params: RequestParams = {}) =>
|
||||||
state: WorkerExecutionState,
|
|
||||||
params: RequestParams = {}
|
|
||||||
) =>
|
|
||||||
this.request<Worker[], any>({
|
this.request<Worker[], any>({
|
||||||
path: `/v2/Worker/State/${state}`,
|
path: `/v2/Worker/State/${state}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -1375,11 +1274,7 @@ export class V2<
|
|||||||
* @request DELETE:/v2/Worker/{WorkerId}
|
* @request DELETE:/v2/Worker/{WorkerId}
|
||||||
*/
|
*/
|
||||||
workerDelete = (workerId: string, params: RequestParams = {}) =>
|
workerDelete = (workerId: string, params: RequestParams = {}) =>
|
||||||
this.request<void, string>({
|
this.request<void, string>({ path: `/v2/Worker/${workerId}`, method: 'DELETE', ...params });
|
||||||
path: `/v2/Worker/${workerId}`,
|
|
||||||
method: 'DELETE',
|
|
||||||
...params,
|
|
||||||
});
|
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
|
@@ -32,10 +32,7 @@ export interface FullRequestParams extends Omit<RequestInit, 'body'> {
|
|||||||
cancelToken?: CancelToken;
|
cancelToken?: CancelToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RequestParams = Omit<
|
export type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>;
|
||||||
FullRequestParams,
|
|
||||||
'body' | 'method' | 'query' | 'path'
|
|
||||||
>;
|
|
||||||
|
|
||||||
export interface ApiConfig<SecurityDataType = unknown> {
|
export interface ApiConfig<SecurityDataType = unknown> {
|
||||||
baseUrl?: string;
|
baseUrl?: string;
|
||||||
@@ -46,8 +43,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
|
|||||||
customFetch?: typeof fetch;
|
customFetch?: typeof fetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HttpResponse<D extends unknown, E extends unknown = unknown>
|
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
|
||||||
extends Response {
|
|
||||||
data: D;
|
data: D;
|
||||||
error: E;
|
error: E;
|
||||||
}
|
}
|
||||||
@@ -67,8 +63,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|||||||
private securityData: SecurityDataType | null = null;
|
private securityData: SecurityDataType | null = null;
|
||||||
private securityWorker?: ApiConfig<SecurityDataType>['securityWorker'];
|
private securityWorker?: ApiConfig<SecurityDataType>['securityWorker'];
|
||||||
private abortControllers = new Map<CancelToken, AbortController>();
|
private abortControllers = new Map<CancelToken, AbortController>();
|
||||||
private customFetch = (...fetchParams: Parameters<typeof fetch>) =>
|
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
|
||||||
fetch(...fetchParams);
|
|
||||||
|
|
||||||
private baseApiParams: RequestParams = {
|
private baseApiParams: RequestParams = {
|
||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
@@ -101,9 +96,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|||||||
|
|
||||||
protected toQueryString(rawQuery?: QueryParamsType): string {
|
protected toQueryString(rawQuery?: QueryParamsType): string {
|
||||||
const query = rawQuery || {};
|
const query = rawQuery || {};
|
||||||
const keys = Object.keys(query).filter(
|
const keys = Object.keys(query).filter((key) => 'undefined' !== typeof query[key]);
|
||||||
(key) => 'undefined' !== typeof query[key]
|
|
||||||
);
|
|
||||||
return keys
|
return keys
|
||||||
.map((key) =>
|
.map((key) =>
|
||||||
Array.isArray(query[key])
|
Array.isArray(query[key])
|
||||||
@@ -120,19 +113,15 @@ export class HttpClient<SecurityDataType = unknown> {
|
|||||||
|
|
||||||
private contentFormatters: Record<ContentType, (input: any) => any> = {
|
private contentFormatters: Record<ContentType, (input: any) => any> = {
|
||||||
[ContentType.Json]: (input: any) =>
|
[ContentType.Json]: (input: any) =>
|
||||||
input !== null &&
|
input !== null && (typeof input === 'object' || typeof input === 'string')
|
||||||
(typeof input === 'object' || typeof input === 'string')
|
|
||||||
? JSON.stringify(input)
|
? JSON.stringify(input)
|
||||||
: input,
|
: input,
|
||||||
[ContentType.JsonApi]: (input: any) =>
|
[ContentType.JsonApi]: (input: any) =>
|
||||||
input !== null &&
|
input !== null && (typeof input === 'object' || typeof input === 'string')
|
||||||
(typeof input === 'object' || typeof input === 'string')
|
|
||||||
? JSON.stringify(input)
|
? JSON.stringify(input)
|
||||||
: input,
|
: input,
|
||||||
[ContentType.Text]: (input: any) =>
|
[ContentType.Text]: (input: any) =>
|
||||||
input !== null && typeof input !== 'string'
|
input !== null && typeof input !== 'string' ? JSON.stringify(input) : input,
|
||||||
? JSON.stringify(input)
|
|
||||||
: input,
|
|
||||||
[ContentType.FormData]: (input: any) =>
|
[ContentType.FormData]: (input: any) =>
|
||||||
Object.keys(input || {}).reduce((formData, key) => {
|
Object.keys(input || {}).reduce((formData, key) => {
|
||||||
const property = input[key];
|
const property = input[key];
|
||||||
@@ -149,10 +138,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|||||||
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
|
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
|
||||||
};
|
};
|
||||||
|
|
||||||
protected mergeRequestParams(
|
protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams {
|
||||||
params1: RequestParams,
|
|
||||||
params2?: RequestParams
|
|
||||||
): RequestParams {
|
|
||||||
return {
|
return {
|
||||||
...this.baseApiParams,
|
...this.baseApiParams,
|
||||||
...params1,
|
...params1,
|
||||||
@@ -165,9 +151,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createAbortSignal = (
|
protected createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => {
|
||||||
cancelToken: CancelToken
|
|
||||||
): AbortSignal | undefined => {
|
|
||||||
if (this.abortControllers.has(cancelToken)) {
|
if (this.abortControllers.has(cancelToken)) {
|
||||||
const abortController = this.abortControllers.get(cancelToken);
|
const abortController = this.abortControllers.get(cancelToken);
|
||||||
if (abortController) {
|
if (abortController) {
|
||||||
@@ -202,16 +186,13 @@ export class HttpClient<SecurityDataType = unknown> {
|
|||||||
...params
|
...params
|
||||||
}: FullRequestParams): Promise<HttpResponse<T, E>> => {
|
}: FullRequestParams): Promise<HttpResponse<T, E>> => {
|
||||||
const secureParams =
|
const secureParams =
|
||||||
((typeof secure === 'boolean'
|
((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) &&
|
||||||
? secure
|
|
||||||
: this.baseApiParams.secure) &&
|
|
||||||
this.securityWorker &&
|
this.securityWorker &&
|
||||||
(await this.securityWorker(this.securityData))) ||
|
(await this.securityWorker(this.securityData))) ||
|
||||||
{};
|
{};
|
||||||
const requestParams = this.mergeRequestParams(params, secureParams);
|
const requestParams = this.mergeRequestParams(params, secureParams);
|
||||||
const queryString = query && this.toQueryString(query);
|
const queryString = query && this.toQueryString(query);
|
||||||
const payloadFormatter =
|
const payloadFormatter = this.contentFormatters[type || ContentType.Json];
|
||||||
this.contentFormatters[type || ContentType.Json];
|
|
||||||
const responseFormat = format || requestParams.format;
|
const responseFormat = format || requestParams.format;
|
||||||
|
|
||||||
return this.customFetch(
|
return this.customFetch(
|
||||||
@@ -220,18 +201,12 @@ export class HttpClient<SecurityDataType = unknown> {
|
|||||||
...requestParams,
|
...requestParams,
|
||||||
headers: {
|
headers: {
|
||||||
...(requestParams.headers || {}),
|
...(requestParams.headers || {}),
|
||||||
...(type && type !== ContentType.FormData
|
...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
|
||||||
? { 'Content-Type': type }
|
|
||||||
: {}),
|
|
||||||
},
|
},
|
||||||
signal:
|
signal:
|
||||||
(cancelToken
|
(cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) ||
|
||||||
? this.createAbortSignal(cancelToken)
|
null,
|
||||||
: requestParams.signal) || null,
|
body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body),
|
||||||
body:
|
|
||||||
typeof body === 'undefined' || body === null
|
|
||||||
? null
|
|
||||||
: payloadFormatter(body),
|
|
||||||
}
|
}
|
||||||
).then(async (response) => {
|
).then(async (response) => {
|
||||||
const r = response.clone() as HttpResponse<T, E>;
|
const r = response.clone() as HttpResponse<T, E>;
|
||||||
|
@@ -1,20 +1,10 @@
|
|||||||
import {
|
import { createContext, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
createContext,
|
|
||||||
ReactNode,
|
|
||||||
useContext,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
import { FileLibrary } from '../api/data-contracts.ts';
|
import { FileLibrary } from '../api/data-contracts.ts';
|
||||||
import { ApiContext } from './ApiContext.tsx';
|
import { ApiContext } from './ApiContext.tsx';
|
||||||
|
|
||||||
export const FileLibraryContext = createContext<FileLibrary[]>([]);
|
export const FileLibraryContext = createContext<FileLibrary[]>([]);
|
||||||
|
|
||||||
export default function LibraryProvider({
|
export default function LibraryProvider({ children }: { children: ReactNode }): ReactNode {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}): ReactNode {
|
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
const [state, setState] = useState<FileLibrary[]>([]);
|
const [state, setState] = useState<FileLibrary[]>([]);
|
||||||
|
@@ -1,20 +1,10 @@
|
|||||||
import {
|
import { createContext, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
createContext,
|
|
||||||
ReactNode,
|
|
||||||
useContext,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
import { MangaConnector } from '../api/data-contracts.ts';
|
import { MangaConnector } from '../api/data-contracts.ts';
|
||||||
import { ApiContext } from './ApiContext.tsx';
|
import { ApiContext } from './ApiContext.tsx';
|
||||||
|
|
||||||
export const MangaConnectorContext = createContext<MangaConnector[]>([]);
|
export const MangaConnectorContext = createContext<MangaConnector[]>([]);
|
||||||
|
|
||||||
export default function MangaConnectorProvider({
|
export default function MangaConnectorProvider({ children }: { children: ReactNode }) {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
const [state, setState] = useState<MangaConnector[]>([]);
|
const [state, setState] = useState<MangaConnector[]>([]);
|
||||||
@@ -27,7 +17,5 @@ export default function MangaConnectorProvider({
|
|||||||
});
|
});
|
||||||
}, [Api]);
|
}, [Api]);
|
||||||
|
|
||||||
return (
|
return <MangaConnectorContext value={state}>{children}</MangaConnectorContext>;
|
||||||
<MangaConnectorContext value={state}>{children}</MangaConnectorContext>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@@ -3,20 +3,14 @@ import { ApiContext } from './ApiContext.tsx';
|
|||||||
import { Manga } from '../api/data-contracts.ts';
|
import { Manga } from '../api/data-contracts.ts';
|
||||||
import { V2 } from '../api/V2.ts';
|
import { V2 } from '../api/V2.ts';
|
||||||
|
|
||||||
export const MangaContext = createContext<M>({
|
export const MangaContext = createContext<M>({ GetManga: () => Promise.reject() });
|
||||||
GetManga: () => Promise.reject(),
|
|
||||||
});
|
|
||||||
const manga: Map<string, Manga> = new Map();
|
const manga: Map<string, Manga> = new Map();
|
||||||
const promises: Map<string, Promise<Manga | undefined>> = new Map();
|
const promises: Map<string, Promise<Manga | undefined>> = new Map();
|
||||||
|
|
||||||
export default function MangaProvider({ children }: { children: ReactNode }) {
|
export default function MangaProvider({ children }: { children: ReactNode }) {
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
return (
|
return <MangaContext value={{ GetManga: (k) => getManga(k, Api) }}>{children}</MangaContext>;
|
||||||
<MangaContext value={{ GetManga: (k) => getManga(k, Api) }}>
|
|
||||||
{children}
|
|
||||||
</MangaContext>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getManga(key: string, Api: V2): Promise<Manga | undefined> {
|
function getManga(key: string, Api: V2): Promise<Manga | undefined> {
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"files": [],
|
"files": [],
|
||||||
"references": [
|
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
|
||||||
{ "path": "./tsconfig.app.json" },
|
|
||||||
{ "path": "./tsconfig.node.json" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,4 @@ import { defineConfig } from 'vite';
|
|||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({ plugins: [react()], server: { host: '127.0.0.1' } });
|
||||||
plugins: [react()],
|
|
||||||
server: { host: '127.0.0.1' },
|
|
||||||
});
|
|
||||||
|
Reference in New Issue
Block a user