Skip to content

Commit

Permalink
Merge pull request #49 from shaifulazh/frontend-loader
Browse files Browse the repository at this point in the history
Frontend loader
  • Loading branch information
ryansurf authored Jul 19, 2024
2 parents cf59c82 + 55c6369 commit 3f3202c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ cancelbutton.addEventListener("click",function(){
document.getElementById("curlInput").value ="";
});

const elLoadingDiv = document.getElementById("loadingDiv");
elLoadingDiv.style.display = "none";


document.getElementById("reportForm").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent default form submission
Expand Down Expand Up @@ -42,6 +45,8 @@ function httpGetAsync(theUrl, callback) {
document.addEventListener("submit", function() {
// Function to make the HTTP GET request and update the HTML content
// Function to make the HTTP GET request and update the HTML content

handleLoadingChange()
function fetchDataAndUpdateHTML() {
// Make the HTTP GET request
// Get the value of the location input field
Expand All @@ -67,15 +72,27 @@ document.addEventListener("submit", function() {

// Update the content of the serverResponse div with the extracted data
document.getElementById('serverResponse').innerHTML = extractedData;
handleLoadingChange()
})
.catch(error => {
console.error('Error fetching data:', error);
handleLoadingChange()
});
}
// Call the function to fetch data and update HTML content when the form is submitted
fetchDataAndUpdateHTML();
});

function handleLoadingChange() {
var serverResponse = document.getElementById("serverResponse");
if (elLoadingDiv.style.display === "none") {
elLoadingDiv.style.display = "block";
serverResponse.style.display = "none"

} else {
elLoadingDiv.style.display = "none";
serverResponse.style.display = "block"
}
}


9 changes: 9 additions & 0 deletions src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@
<div class="flex flex-col h-[50vh] max-w-xl min-w-96">
<div id="serverResponse" class="text-black flex flex-row justify-center pb-8 bg-white p-4 rounded-lg shadow-lg">
</div>
<div id="loadingDiv" class="flex">
<div class="relative">
<!-- Outer Ring-->
<div class="w-6 h-6 rounded-full absolute
border-4 border-solid border-gray-200"></div>
<!-- Inner Ring -->
<div class="w-6 h-6 rounded-full animate-spin absolute
border-4 border-solid border-blue-500 border-t-transparent"></div>
</div>
</div>
</div>
<script>
Expand Down

1 comment on commit 3f3202c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src
   __init__.py00100% 
   api.py101694%30, 48, 70–71, 103–104
   art.py9367%24–25, 37
   cli.py23483%34, 50–51, 55
   gpt.py10640%16–21, 32–45
   helper.py1555863%53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 91, 102–106, 132, 134, 136, 145–153, 165, 178–179, 197–199, 209, 211–212, 234–235, 272–282, 289–297
   send_email.py24240%5–48
   server.py41410%5–82
   settings.py220100% 
TOTAL38514263% 

Tests Skipped Failures Errors Time
9 0 💤 0 ❌ 0 🔥 13.766s ⏱️

Please sign in to comment.