1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-01-29 03:15:49 +01:00

48 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-10-21 19:44:42 +05:30
import React, { useEffect } from "react";
2023-07-22 16:37:53 +05:30
import Spinner from "../../icons/Spinner";
2022-11-12 02:09:28 +05:30
function ProgressBar({
progress,
doubleUpscaylCounter,
stopHandler,
batchMode,
2023-10-21 19:13:03 +05:30
}: {
progress: string;
doubleUpscaylCounter: number;
stopHandler: () => void;
batchMode: boolean;
}) {
2023-09-09 17:48:00 +05:30
const [batchProgress, setBatchProgress] = React.useState(0);
2023-10-21 19:44:42 +05:30
useEffect(() => {
2023-10-21 19:13:03 +05:30
const progressString = progress.trim().replace(/\n/g, "");
// Remove trailing and leading spaces
2023-10-21 19:44:42 +05:30
if (progressString.includes("Successful")) {
2023-09-09 17:48:00 +05:30
setBatchProgress((prev) => prev + 1);
}
}, [progress]);
2022-11-12 02:09:28 +05:30
return (
2023-03-12 13:29:07 +05:30
<div className="absolute flex h-full w-full flex-col items-center justify-center bg-base-300/50 backdrop-blur-lg">
2022-11-12 02:09:28 +05:30
<div className="flex flex-col items-center gap-2">
2023-03-12 13:29:07 +05:30
<Spinner />
2023-03-12 14:10:16 +05:30
<p className="rounded-full bg-base-300 px-2 py-1 font-bold">
2023-09-09 17:48:00 +05:30
{batchMode && "Batch Upscale In Progress: " + batchProgress}
{!batchMode &&
(doubleUpscaylCounter > 0
? `${progress}\nPass ${doubleUpscaylCounter}`
: `${progress}`)}
2022-11-12 02:09:28 +05:30
</p>
2023-03-12 13:29:07 +05:30
<p className="rounded-full bg-base-300 px-2 py-1 text-sm font-medium">
Doing the Upscayl magic...
</p>
<button onClick={stopHandler} className="btn-danger btn">
2023-04-29 22:42:40 +05:30
STOP
</button>
2022-11-12 02:09:28 +05:30
</div>
</div>
);
}
export default ProgressBar;