Spaces:
Sleeping
Sleeping
File size: 4,656 Bytes
b028028 |
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loading - Spaces Dashboard</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background: #0a0a0a;
color: #e5e5e5;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.container {
text-align: center;
max-width: 400px;
width: 90%;
}
h1 {
font-size: 1.25rem;
font-weight: 500;
margin-bottom: 0.5rem;
}
.subtitle {
color: #666;
font-size: 0.875rem;
margin-bottom: 2rem;
}
.progress-container {
margin-bottom: 1.5rem;
}
.progress-bar {
height: 4px;
background: #222;
border-radius: 2px;
overflow: hidden;
margin-bottom: 0.75rem;
}
.progress-fill {
height: 100%;
background: #22c55e;
width: 0%;
transition: width 0.3s;
}
.progress-text {
font-size: 0.875rem;
color: #888;
}
.stage {
font-size: 0.75rem;
color: #555;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 0.5rem;
}
.error {
color: #ef4444;
margin-top: 1rem;
}
</style>
</head>
<body>
<div class="container">
<h1>Loading your spaces</h1>
<p class="subtitle">Fetching data from Hugging Face...</p>
<div class="progress-container">
<div class="stage" id="stage">Initializing</div>
<div class="progress-bar">
<div class="progress-fill" id="progress-fill"></div>
</div>
<div class="progress-text" id="progress-text">0%</div>
</div>
<div class="error" id="error" style="display: none;"></div>
</div>
<script>
const jobId = "{{ job_id }}";
const progressFill = document.getElementById('progress-fill');
const progressText = document.getElementById('progress-text');
const stageEl = document.getElementById('stage');
const errorEl = document.getElementById('error');
const stageNames = {
'spaces': 'Fetching spaces',
'discussions': 'Loading discussions',
'pending': 'Initializing',
'': 'Initializing'
};
async function poll() {
try {
const resp = await fetch('/api/job/' + jobId);
const job = await resp.json();
if (job.error) {
errorEl.textContent = 'Error: ' + job.error;
errorEl.style.display = 'block';
return;
}
if (job.status === 'completed') {
progressFill.style.width = '100%';
progressText.textContent = 'Done!';
stageEl.textContent = 'Complete';
setTimeout(() => {
window.location.href = '/dashboard';
}, 500);
return;
}
if (job.status === 'failed') {
errorEl.textContent = 'Error: ' + (job.error || 'Unknown error');
errorEl.style.display = 'block';
progressFill.style.background = '#ef4444';
return;
}
// Update progress
const stage = job.progress_stage || '';
stageEl.textContent = stageNames[stage] || stage;
if (job.progress_total > 0) {
const pct = Math.round((job.progress_current / job.progress_total) * 100);
progressFill.style.width = pct + '%';
progressText.textContent = `${job.progress_current} / ${job.progress_total}`;
}
setTimeout(poll, 500);
} catch (err) {
errorEl.textContent = 'Connection error: ' + err.message;
errorEl.style.display = 'block';
setTimeout(poll, 2000);
}
}
poll();
</script>
</body>
</html>
|