From 4c81c571a4221fe217b5442dd31655df0879432b Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 18 Jun 2025 17:51:29 +0200 Subject: [PATCH] Job Drawer add "Re-Run" button, Move Chapter-Drawer to the bottom of the screen (inline with Manga-Drawer) Format JobState and JobType (with spaces) --- tranga-website/src/Components/Chapter.tsx | 9 ++-- tranga-website/src/Components/Jobs.tsx | 51 +++++++++++++---------- tranga-website/src/api/types/Jobs/IJob.ts | 9 +++- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/tranga-website/src/Components/Chapter.tsx b/tranga-website/src/Components/Chapter.tsx index 5ef0ba9..cf89e49 100644 --- a/tranga-website/src/Components/Chapter.tsx +++ b/tranga-website/src/Components/Chapter.tsx @@ -1,14 +1,15 @@ import React, {ReactElement, useContext, useState} from "react"; import IChapter from "../api/types/IChapter.ts"; -import {Box, Chip, Link, Stack, Typography} from "@mui/joy"; +import {Box, Chip, Link, Stack, Tooltip, Typography} from "@mui/joy"; import {MangaFromId} from "./Manga.tsx"; import {ChapterContext} from "../api/Contexts/ChapterContext.tsx"; import Drawer from "@mui/joy/Drawer"; import ModalClose from "@mui/joy/ModalClose"; +import {Archive} from "@mui/icons-material"; export function ChapterPopupFromId({chapterId, open, setOpen, children}: { chapterId: string | null, open: boolean, setOpen: React.Dispatch>, children?: ReactElement | ReactElement[] | undefined }) { return ( - setOpen(false)}> + setOpen(false)}> { chapterId !== null ? @@ -35,13 +36,13 @@ export function ChapterFromId({chapterId, children} : { chapterId: string, child export function Chapter({chapter, children} : { chapter: IChapter, children?: ReactElement | ReactElement[] | undefined }){ return ( - + {chapter.title} Volume {chapter.volumeNumber} Chapter {chapter.chapterNumber} - Title {chapter.title} + {children} diff --git a/tranga-website/src/Components/Jobs.tsx b/tranga-website/src/Components/Jobs.tsx index 4381f02..987b187 100644 --- a/tranga-website/src/Components/Jobs.tsx +++ b/tranga-website/src/Components/Jobs.tsx @@ -9,11 +9,11 @@ import { Table, Typography } from "@mui/joy"; -import {GetJobsInState, GetJobsOfTypeAndWithState, GetJobsWithType} from "../api/Job.tsx"; +import {GetJobsInState, GetJobsOfTypeAndWithState, GetJobsWithType, StartJob} from "../api/Job.tsx"; import * as React from "react"; import {useCallback, useContext, useEffect, useState} from "react"; import {ApiUriContext} from "../api/fetchApi.tsx"; -import IJob, {JobState, JobType} from "../api/types/Jobs/IJob.ts"; +import IJob, {JobState, JobStateToString, JobType, JobTypeToString} from "../api/types/Jobs/IJob.ts"; import ModalClose from "@mui/joy/ModalClose"; import {MangaPopupFromId} from "./MangaPopup.tsx"; import IJobWithMangaId from "../api/types/Jobs/IJobWithMangaId.ts"; @@ -85,6 +85,10 @@ export default function JobsDrawer({open, connected, setOpen} : {open: boolean, setSelectedChapterId(chapterId); setChapterPopupOpen(true); } + + const ReRunJob = useCallback((jobId: string) => { + StartJob(apiUri, jobId, false); + }, [apiUri]); return ( setOpen(false)}> @@ -95,13 +99,13 @@ export default function JobsDrawer({open, connected, setOpen} : {open: boolean, State }> - {Object.keys(JobState).map((state) => )} + {Object.keys(JobState).map((state) => )} /{Math.ceil(allJobs.length / pageSize)}}/> - +
- - - - - - - + + + + + + + + - {allJobs.slice((page-1)*pageSize, page*pageSize).map((job) => ( - - - - - - - - ))} + {allJobs.slice((page-1)*pageSize, page*pageSize).map((job) => ( + + + + + + + + + ))}
TypeStateLast ExecutionNextExecutionExtra
TypeStateLast ExecutionNext ExecutionExtra
{job.jobType}{job.state}{new Date(job.lastExecution).toLocaleString()}{new Date(job.nextExecution).toLocaleString()}{ExtraContent(job, OpenMangaPopupDrawer, OpenChapterPopupDrawer)}
{JobTypeToString(job.jobType)}{JobStateToString(job.state)}{new Date(job.lastExecution).toLocaleString()}{new Date(job.nextExecution).toLocaleString()}{ExtraContent(job, OpenMangaPopupDrawer, OpenChapterPopupDrawer)}
@@ -150,8 +156,7 @@ function ExtraContent(job: IJob, OpenMangaPopupDrawer: (mangaId: string) => void case JobType.MoveMangaLibraryJob: return case JobType.DownloadSingleChapterJob: - case JobType.UpdateSingleChapterDownloadedJob: - return + return default: return null; } diff --git a/tranga-website/src/api/types/Jobs/IJob.ts b/tranga-website/src/api/types/Jobs/IJob.ts index 027ac3e..e7ad426 100644 --- a/tranga-website/src/api/types/Jobs/IJob.ts +++ b/tranga-website/src/api/types/Jobs/IJob.ts @@ -16,14 +16,21 @@ export enum JobType { RetrieveChaptersJob = "RetrieveChaptersJob", UpdateChaptersDownloadedJob = "UpdateChaptersDownloadedJob", MoveMangaLibraryJob = "MoveMangaLibraryJob", - UpdateSingleChapterDownloadedJob = "UpdateSingleChapterDownloadedJob", UpdateCoverJob = "UpdateCoverJob" } +export function JobTypeToString(job: JobType | string): string { + return job.replace(/([A-Z])/g, ' $1').replace("Job", "").trim(); +} + export enum JobState { FirstExecution = "FirstExecution", Running = "Running", Completed = "Completed", CompletedWaiting = "CompletedWaiting", Failed = "Failed" +} + +export function JobStateToString(state: JobState | string): string { + return state.replace(/([A-Z])/g, ' $1').trim(); } \ No newline at end of file