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
|
|
|
|
2023-07-23 14:37:18 +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-07-23 14:37:18 +05:30
|
|
|
}) {
|
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">
|
2024-01-15 19:02:21 +05:30
|
|
|
<div className="flex flex-col items-center bg-base-100/50 backdrop-blur-lg p-4 rounded-btn">
|
2024-01-15 15:55:28 +05:30
|
|
|
<img
|
|
|
|
src="icon.png"
|
|
|
|
alt="Upscayl Icon"
|
2024-01-15 19:02:21 +05:30
|
|
|
className="w-12 h-12 spinner mb-4"
|
2024-01-15 15:55:28 +05:30
|
|
|
/>
|
2024-01-15 19:02:21 +05:30
|
|
|
<p className="rounded-full px-2 font-bold pb-2">
|
2023-09-09 17:48:00 +05:30
|
|
|
{batchMode && "Batch Upscale In Progress: " + batchProgress}
|
2024-01-15 15:55:28 +05:30
|
|
|
|
2023-07-23 14:37:18 +05:30
|
|
|
{!batchMode &&
|
|
|
|
(doubleUpscaylCounter > 0
|
|
|
|
? `${progress}\nPass ${doubleUpscaylCounter}`
|
|
|
|
: `${progress}`)}
|
2022-11-12 02:09:28 +05:30
|
|
|
</p>
|
2024-01-15 15:55:28 +05:30
|
|
|
|
2024-01-15 19:02:21 +05:30
|
|
|
<p className="rounded-full px-2 text-sm font-medium pb-3 animate-pulse">
|
2023-03-12 13:29:07 +05:30
|
|
|
Doing the Upscayl magic...
|
|
|
|
</p>
|
2024-01-15 15:55:28 +05:30
|
|
|
{batchMode && (
|
2024-01-15 19:02:21 +05:30
|
|
|
<p className="text-xs rounded-btn text-base-content/70 text-center pb-4 w-64">
|
2024-01-15 15:55:28 +05:30
|
|
|
Info: The images will be converted and scaled after the upscaling
|
|
|
|
process.
|
|
|
|
</p>
|
|
|
|
)}
|
2024-01-15 19:02:21 +05:30
|
|
|
<button onClick={stopHandler} className="btn-outline btn">
|
2023-04-29 22:42:40 +05:30
|
|
|
STOP
|
|
|
|
</button>
|
2022-11-12 02:09:28 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ProgressBar;
|