Total Size
+
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
{details_image.sizeBytes} Bytes
+ )}
Inefficient Bytes
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
{details_image.inefficientBytes} Bytes
+ )}
Efficiency Score
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
{Math.floor(details_image.efficiencyScore*100)} %
-
+ )}
-
-
- Containers
+ navigate("/optimized_image")} className='text-black text-md bg-white rounded-md w-32 h-8 hover:shadow-[5px_5px_0px_0px_rgba(109,40,217)] transition-all' style={{fontFamily:"poppins"}}>
+ Optimize
+
@@ -64,6 +93,13 @@ export default function Images({ID}:any){
Layers
-
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
@@ -110,6 +152,8 @@ export default function Images({ID}:any){
+ )}
+
diff --git a/src/Components/Optimized.tsx b/src/Components/Optimized.tsx
new file mode 100644
index 0000000..aba9587
--- /dev/null
+++ b/src/Components/Optimized.tsx
@@ -0,0 +1,143 @@
+import React, { useEffect } from 'react'
+import { CircularProgressbar, buildStyles } from 'react-circular-progressbar';
+import { Inspect_optimized_Image_Api } from '../helpers/api'
+import 'react-circular-progressbar/dist/styles.css';
+import { useNavigate } from 'react-router-dom';
+
+
+
+export default function Optimized({ID}:any){
+ const navigate = useNavigate();
+ const [details_image,setdetails_image] = React.useState
({});
+ const [details_layers,setdetails_layers] = React.useState([]);
+ const [isLoading, setIsLoading] = React.useState(true);
+
+ useEffect(() => {
+ const handleInspectImage = async(ID:string) => {
+ try{
+ console.log(ID)
+ const response = await Inspect_optimized_Image_Api(ID);
+ if(response.status === 200){
+ console.log(response);
+ setdetails_image(response.data.image);
+ setdetails_layers(response.data.layer);
+ setIsLoading(false);
+ }
+ }catch(error){
+ console.log(error);
+ }
+ }
+ handleInspectImage(ID);
+
+ },[ID]);
+ return (
+
+
Analyzing Optimized Image:
+
+
+
+
Total Size
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
+
{details_image.sizeBytes} Bytes
+ )}
+
+
+
Inefficient Bytes
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
+
{details_image.inefficientBytes} Bytes
+ )}
+
+
+
Efficiency Score
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
+
{Math.floor(details_image.efficiencyScore*100)} %
+ )}
+
+
+
+ navigate("/")} className='text-black text-md bg-white rounded-md w-32 h-8 hover:shadow-[5px_5px_0px_0px_rgba(109,40,217)] transition-all' style={{fontFamily:"poppins"}}>
+ Containers
+
+
+
+
+
+
+
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
+
+ )}
+
+
+
+
+
Layers
+
+
+
+ {isLoading ? (
+ // Display loading GIF while data is being fetched
+
+

+
+ ) : (
+
+
+
+ Index |
+ Digest ID |
+ ID |
+ Size |
+ Command |
+
+
+
+ {details_layers.map((layer:any, index:number) => (
+
+ {layer.index} |
+ {layer.digestId} |
+ {layer.id} |
+ {layer.sizeBytes} Bytes |
+ {layer.command} |
+
+ ))}
+
+
+
+ )}
+
+
+
+
+
+ )
+}
diff --git a/src/helpers/api.ts b/src/helpers/api.ts
index 974c597..60bad54 100644
--- a/src/helpers/api.ts
+++ b/src/helpers/api.ts
@@ -1,6 +1,7 @@
// Purpose: API helper functions.
import axios from 'axios'
+
export function Connection_Api() {
return new Promise((resolve, reject) => {
const ws = new WebSocket("ws://localhost:8000/stats");
@@ -24,3 +25,9 @@ export async function Inspect_Image_Api(id:string) {
return response;
}
+export async function Inspect_optimized_Image_Api(id:string) {
+ const response= await axios.get(`http://localhost:8000/optimize_image/${id}`);
+ return response;
+}
+
+