From 8d0094aa76c7454dc6ce0f810e5fe2f06cd595bb Mon Sep 17 00:00:00 2001 From: ArEnSc <6252325+ArEnSc@users.noreply.github.com> Date: Fri, 5 Jul 2024 22:18:04 -0400 Subject: [PATCH] progress bar implementation (#585) changes for progress bar --- .../comps/GenerateModals/InProgressCard.tsx | 24 ++++++------------- app/pages/PageEnigma/models/mediaInfo.ts | 1 + 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/app/pages/PageEnigma/comps/GenerateModals/InProgressCard.tsx b/app/pages/PageEnigma/comps/GenerateModals/InProgressCard.tsx index 7c4b18f57a..4f88e6660c 100644 --- a/app/pages/PageEnigma/comps/GenerateModals/InProgressCard.tsx +++ b/app/pages/PageEnigma/comps/GenerateModals/InProgressCard.tsx @@ -20,34 +20,25 @@ interface Props { movie: ActiveJob; } -function getPercent(status: JobState) { +function getPercent(status: JobState, percentage: number) { if ( [ - JobState.PENDING, JobState.COMPLETE_FAILURE, JobState.ATTEMPT_FAILED, JobState.DEAD, ].includes(status) ) { return 0; + } else { + return percentage; } - - if (status === JobState.PENDING) { - return 20; - } - - if (status === JobState.STARTED) { - return 40; - } - - if (status === JobState.COMPLETE_SUCCESS) { - return 100; - } - return 0; } export function InProgressCard({ movie }: Props) { - const completePercent = getPercent(movie.status.status as JobState); + const completePercent = getPercent( + movie.status.status as JobState, + movie.status.progress_percentage, + ); const completeLength = (600 * completePercent) / 100; const deleteJob = useCallback(async (movieJob: ActiveJob) => { @@ -65,7 +56,6 @@ export function InProgressCard({ movie }: Props) { response.errorMessage || "Error deleting the file.", ); }, []); - console.log(movie); return (
diff --git a/app/pages/PageEnigma/models/mediaInfo.ts b/app/pages/PageEnigma/models/mediaInfo.ts index 451f934b6a..49cfa1955b 100644 --- a/app/pages/PageEnigma/models/mediaInfo.ts +++ b/app/pages/PageEnigma/models/mediaInfo.ts @@ -79,6 +79,7 @@ export interface Status { maybe_assigned_worker: string; maybe_extra_status_description: string; maybe_failure_category: string; + progress_percentage: number; maybe_first_started_at: string; requires_keepalive: boolean; status: string;