-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* integeration Signed-off-by: Pranjal Rana <[email protected]> * cors Signed-off-by: Pranjal Rana <[email protected]> * dive-inspect-images Signed-off-by: Pranjal Rana <[email protected]> * adding-inspect-image-ui Signed-off-by: Pranjal Rana <[email protected]> * adding_images_api_func Signed-off-by: Pranjal Rana <[email protected]> * completing-images-component Signed-off-by: Pranjal Rana <[email protected]> * adding-slim-functionality Signed-off-by: Pranjal Rana <[email protected]> * completing-project Signed-off-by: Pranjal Rana <[email protected]> --------- Signed-off-by: Pranjal Rana <[email protected]>
- Loading branch information
1 parent
07e9ebf
commit 2ab5196
Showing
7 changed files
with
225 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
{ | ||
"layer": [ | ||
{ | ||
"index": 0, | ||
"id": "af10c63fa8e077a49490c4796c73a9c1e08575bc52bbbdf67cefb58112738683", | ||
"digestId": "sha256:dd4d83ab39e37b7b32fd9c3c6ba97ab1f7421fad7d3d0e8c2c02ff0d624232bd", | ||
"sizeBytes": 52387835, | ||
"command": "" | ||
} | ||
], | ||
"image": { | ||
"sizeBytes": 52387835, | ||
"inefficientBytes": 0, | ||
"efficiencyScore": 1, | ||
"fileReference": [] | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<any>({}); | ||
const [details_layers,setdetails_layers] = React.useState<any[]>([]); | ||
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 ( | ||
<div className="pl-5 space-y-4" style={{backgroundColor:"#0f1d32"}}> | ||
<h3 className="text-3xl ml-80 mt-10 text-white" style={{fontFamily:"poppins"}}>Analyzing Optimized Image:</h3> | ||
<div className="flex ml-80 space-x-4"> | ||
<div> | ||
<div className=" rounded-md p-4"> | ||
<div className="text-sm text-gray-400" style={{fontFamily:"poppins"}}>Total Size</div> | ||
{isLoading ? ( | ||
// Display loading GIF while data is being fetched | ||
<div className='mt-8'> | ||
<img src="../../1488.gif" alt="Loading" /> | ||
</div> | ||
) : ( | ||
<h2 className="text-2xl text-white" style={{fontFamily:"poppins"}}>{details_image.sizeBytes} Bytes</h2> | ||
)} | ||
</div> | ||
<div className=" rounded-md p-4"> | ||
<div className="text-sm text-gray-400" style={{fontFamily:"poppins"}}>Inefficient Bytes</div> | ||
{isLoading ? ( | ||
// Display loading GIF while data is being fetched | ||
<div className=' mt-8'> | ||
<img src="../../1488.gif" alt="Loading" /> | ||
</div> | ||
) : ( | ||
<h2 className="text-2xl text-white" style={{fontFamily:"poppins"}}>{details_image.inefficientBytes} Bytes</h2> | ||
)} | ||
</div> | ||
<div className=" rounded-md p-4"> | ||
<div className="text-sm text-gray-400" style={{fontFamily:"poppins"}}>Efficiency Score</div> | ||
{isLoading ? ( | ||
// Display loading GIF while data is being fetched | ||
<div className=' mt-8'> | ||
<img src="../../1488.gif" alt="Loading" /> | ||
</div> | ||
) : ( | ||
<h2 className="text-2xl text-white" style={{fontFamily:"poppins"}}>{Math.floor(details_image.efficiencyScore*100)} %</h2> | ||
)} | ||
</div> | ||
<div className='flex'> | ||
<div className='w-40 mt-5'> | ||
<button onClick={()=> 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 | ||
</button> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<div > | ||
<div style={{ width: 200, height: 200, marginLeft:200 }}> | ||
{isLoading ? ( | ||
// Display loading GIF while data is being fetched | ||
<div className='flex justify-center mt-40'> | ||
<img src="../../1488.gif" alt="Loading" /> | ||
</div> | ||
) : ( | ||
<CircularProgressbar strokeWidth={4} value={Math.floor(details_image.efficiencyScore*100)} text={`${Math.floor(details_image.efficiencyScore*100)}%`} styles={buildStyles({ | ||
strokeLinecap: 'round', | ||
textSize: '16px', | ||
pathTransitionDuration: 0.5, | ||
textColor: '#97feef', | ||
trailColor: 'transparent', | ||
pathColor:"#f06155", | ||
|
||
})} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
<div className="ml-20 space-y-2"> | ||
<h3 className="text-3xl text-white" style={{fontFamily:"poppins"}}>Layers</h3> | ||
<div> | ||
<div className="mt-10 w-4/5"> | ||
<div className="bg-white shadow-md rounded-lg"> | ||
{isLoading ? ( | ||
// Display loading GIF while data is being fetched | ||
<div className='flex justify-center mt-8'> | ||
<img src="../../1488.gif" alt="Loading" /> | ||
</div> | ||
) : ( | ||
<table className="w-full table-fixed"> | ||
<thead style={{backgroundColor:"rgb(29 50 80)"}}> | ||
<tr> | ||
<th className="px-4 py-2 text-left text-white font-semibold" style={{fontFamily:"poppins"}}>Index</th> | ||
<th className="px-4 py-2 text-left text-white font-semibold" style={{fontFamily:"poppins"}}>Digest ID</th> | ||
<th className="px-4 py-2 text-left text-white font-semibold" style={{fontFamily:"poppins"}}>ID</th> | ||
<th className="px-4 py-2 text-left text-white font-semibold" style={{fontFamily:"poppins"}}>Size</th> | ||
<th className="px-4 py-2 text-right text-white font-semibold" style={{fontFamily:"poppins"}}>Command</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{details_layers.map((layer:any, index:number) => ( | ||
<tr key={index} style={{ backgroundColor: "rgb(36 64 105)", borderBottom: "1px solid #1d3250",cursor: "pointer" }}> | ||
<td className="px-4 text-white py-2" style={{ maxWidth: "100px", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", fontFamily:"poppins" }}>{layer.index}</td> | ||
<td className="px-4 text-white py-2" style={{ maxWidth: "200px", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", fontFamily:"poppins" }}>{layer.digestId}</td> | ||
<td className="px-4 text-white py-2" style={{ maxWidth: "200px", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", fontFamily:"poppins" }}>{layer.id}</td> | ||
<td className="px-4 text-white py-2" style={{ }}>{layer.sizeBytes} Bytes</td> | ||
<td className="px-4 text-white py-2 text-right" style={{ maxWidth: "150px", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", fontFamily:"poppins" }}>{layer.command}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
|
||
</table> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters