atlas-map / templates /form.html
Richard Guo
password
2659651
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Atlas Map</title>
<!-- CSS only -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
}
.form-container {
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.1);
}
.form-container h2 {
margin-bottom: 30px;
}
#loading {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
}
.loading-content {
padding: 20px;
background-color: white;
border-radius: 5px;
font-size: 20px;
color: #333;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="container form-container">
<h2>HuggingFace Dataset to Atlas Map</h2>
<form id="myForm" action="/submit_form" method="post">
<div class="form-group">
<label for="dataset_name">Dataset Name:</label>
<input type="text" class="form-control" id="dataset_name" name="dataset_name">
<label for="atlas_api_token">Atlas API Token:</label>
<input type="password" class="form-control" id="atlas_api_token" name="atlas_api_token">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<div id="loading" style="display: none;">
<div class="loading-content">
Building map...
</div>
</div>
</div>
<script>
window.onload = function() {
document.getElementById('myForm').onsubmit = async function(e) {
e.preventDefault(); // Prevent the form from submitting normally
document.getElementById('loading').style.display = 'block'; // Show the loading message
let formData = new FormData(this);
let response = await fetch('/submit_form', {method: 'POST', body: formData}); // Send the form data to the server
let data = await response.json(); // Parse the server's response
checkStatus(data.task_id);
};
}
async function checkStatus(taskId) {
let response = await fetch(`/status/${taskId}`);
let data = await response.json();
if (data.status === 'running') {
setTimeout(() => checkStatus(taskId), 5000); // Check again in 5 seconds
} else {
window.location.href = data.url; // Redirect to the finished URL
}
}
</script>
</body>
</html>