File size: 3,125 Bytes
442f97c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1779f92
 
2659651
442f97c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!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>