Spaces:
Sleeping
Sleeping
File size: 16,930 Bytes
868635f 1265936 868635f 39ab179 868635f 39ab179 868635f |
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plot Gallery - CAMS Air Pollution Dashboard</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1400px;
margin: 0 auto;
}
.header {
background: rgba(255, 255, 255, 0.95);
border-radius: 15px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
backdrop-filter: blur(4px);
border: 1px solid rgba(255, 255, 255, 0.18);
}
.header h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 10px;
}
h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 30px;
}
h2 {
color: #34495e;
border-bottom: 2px solid #3498db;
padding-bottom: 10px;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 10px;
}
.section {
background: rgba(255, 255, 255, 0.95);
border-radius: 15px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
backdrop-filter: blur(4px);
border: 1px solid rgba(255, 255, 255, 0.18);
}
.controls {
display: flex;
gap: 15px;
justify-content: center;
margin-bottom: 20px;
flex-wrap: wrap;
}
.btn {
background: linear-gradient(45deg, #3498db, #2980b9);
color: white;
padding: 12px 24px;
border: none;
border-radius: 25px;
text-decoration: none;
font-weight: 600;
transition: all 0.3s ease;
cursor: pointer;
font-size: 14px;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(52, 152, 219, 0.4);
}
.btn-secondary {
background: linear-gradient(45deg, #95a5a6, #7f8c8d);
}
.btn-danger {
background: linear-gradient(45deg, #e74c3c, #c0392b);
}
.plots-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
}
.plot-card {
background: white;
border-radius: 10px;
padding: 15px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
border: 2px solid transparent;
}
.plot-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
border-color: #3498db;
}
.plot-preview {
width: 100%;
height: 200px;
background: #f8f9fa;
border-radius: 8px;
margin-bottom: 15px;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
position: relative;
}
.plot-preview img {
max-width: 100%;
max-height: 100%;
object-fit: cover;
border-radius: 8px;
}
.plot-preview.interactive {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
font-size: 48px;
}
.plot-info {
color: #2c3e50;
}
.plot-info h3 {
margin-bottom: 10px;
color: #34495e;
font-size: 16px;
}
.plot-meta {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-bottom: 15px;
font-size: 12px;
color: #7f8c8d;
}
.plot-meta span {
background: #ecf0f1;
padding: 4px 8px;
border-radius: 4px;
}
.plot-actions {
display: flex;
gap: 8px;
justify-content: space-between;
}
.btn-small {
padding: 6px 12px;
font-size: 12px;
border-radius: 15px;
text-decoration: none;
font-weight: 500;
}
.btn-view {
background: linear-gradient(45deg, #27ae60, #219a52);
color: white;
}
.btn-download {
background: linear-gradient(45deg, #f39c12, #e67e22);
color: white;
}
.btn-delete {
background: linear-gradient(45deg, #e74c3c, #c0392b);
color: white;
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.stat-card {
background: rgba(52, 152, 219, 0.1);
padding: 15px;
border-radius: 10px;
text-align: center;
border-left: 4px solid #3498db;
}
.stat-number {
font-size: 24px;
font-weight: bold;
color: #2980b9;
}
.stat-label {
color: #7f8c8d;
font-size: 12px;
margin-top: 5px;
}
.empty-state {
text-align: center;
padding: 40px;
color: #7f8c8d;
}
.empty-state h3 {
margin-bottom: 10px;
color: #95a5a6;
}
@media (max-width: 768px) {
.plots-grid {
grid-template-columns: 1fr;
}
.controls {
justify-content: center;
}
.btn {
padding: 10px 20px;
font-size: 12px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>π Plot Gallery</h1>
<p style="text-align: center; color: #7f8c8d; margin-top: 10px;">
View and manage all your saved pollution maps
</p>
</div>
<div class="controls">
<a href="{{ url_for('index') }}" class="btn btn-secondary">β Back to Dashboard</a>
<a href="{{ url_for('cleanup') }}" class="btn btn-danger"
onclick="return confirm('This will delete plots older than 24 hours. Continue?')">
π§Ή Clean Old Plots
</a>
</div>
<!-- Statistics -->
<div class="section">
<div class="stats">
<div class="stat-card">
<div class="stat-number">{{ total_plots }}</div>
<div class="stat-label">Total Plots</div>
</div>
<div class="stat-card">
<div class="stat-number">{{ static_plots|length }}</div>
<div class="stat-label">Static Plots</div>
</div>
<div class="stat-card">
<div class="stat-number">{{ interactive_plots|length }}</div>
<div class="stat-label">Interactive Plots</div>
</div>
</div>
</div>
<!-- Interactive Plots Section -->
<div class="section">
<h2>π― Interactive Plots</h2>
{% if interactive_plots %}
<div class="plots-grid">
{% for plot in interactive_plots %}
<div class="plot-card">
<div class="plot-preview interactive">
π
</div>
<div class="plot-info">
<h3>{{ plot.variable|title }} - {{ plot.region|title }}{{ ' (' + plot.plot_type + ')' if plot.plot_type else '' }}</h3>
<div class="plot-meta">
<span>π
{{ plot.created.strftime('%Y-%m-%d %H:%M') }}</span>
<span>π¨ {{ plot.theme|title }}</span>
<span>π {{ "%.1f"|format(plot.size/1024) }} KB</span>
<span>π Interactive</span>
</div>
<div class="plot-actions">
<a href="{{ url_for('view_interactive_plot', filename=plot.filename) }}"
class="btn-small btn-view">ποΈ View</a>
<a href="{{ url_for('serve_plot', filename=plot.filename) }}"
class="btn-small btn-download" download>πΎ Download</a>
<button onclick="deletePlot('{{ plot.filename }}')"
class="btn-small btn-delete">ποΈ Delete</button>
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="empty-state">
<h3>No Interactive Plots Yet</h3>
<p>Create your first interactive plot from the dashboard!</p>
</div>
{% endif %}
</div>
<!-- Static Plots Section -->
<div class="section">
<h2>π Static Plots</h2>
{% if static_plots %}
<div class="plots-grid">
{% for plot in static_plots %}
<div class="plot-card">
<div class="plot-preview">
<img src="{{ url_for('serve_plot', filename=plot.filename) }}"
alt="{{ plot.variable }} plot"
onerror="this.style.display='none'; this.parentElement.innerHTML='<div style=\'color: #e74c3c; text-align: center;\'>π·<br>Preview unavailable</div>'">
</div>
<div class="plot-info">
<h3>{{ plot.variable|title }} - {{ plot.region|title }}{{ ' (' + plot.plot_type + ')' if plot.plot_type else '' }}</h3>
<div class="plot-meta">
<span>π
{{ plot.created.strftime('%Y-%m-%d %H:%M') }}</span>
<span>π¨ {{ plot.theme|title }}</span>
<span>π {{ "%.1f"|format(plot.size/1024) }} KB</span>
<span>πΌοΈ {{ plot.extension.upper() }}</span>
</div>
<div class="plot-actions">
<a href="{{ url_for('serve_plot', filename=plot.filename) }}"
class="btn-small btn-view" target="_blank">ποΈ View</a>
<a href="{{ url_for('serve_plot', filename=plot.filename) }}"
class="btn-small btn-download" download>πΎ Download</a>
<button onclick="deletePlot('{{ plot.filename }}')"
class="btn-small btn-delete">ποΈ Delete</button>
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="empty-state">
<h3>No Static Plots Yet</h3>
<p>Generate your first static plot from the dashboard!</p>
</div>
{% endif %}
</div>
</div>
<script>
// Add loading indicators for actions
document.addEventListener('DOMContentLoaded', function() {
const viewButtons = document.querySelectorAll('.btn-view');
viewButtons.forEach(button => {
button.addEventListener('click', function() {
const originalText = this.textContent;
this.textContent = 'β³ Loading...';
// Reset after a delay if still on page
setTimeout(() => {
this.textContent = originalText;
}, 3000);
});
});
const downloadButtons = document.querySelectorAll('.btn-download');
downloadButtons.forEach(button => {
button.addEventListener('click', function() {
const originalText = this.textContent;
this.textContent = 'π₯ Downloading...';
setTimeout(() => {
this.textContent = originalText;
}, 2000);
});
});
// Delete plot functionality - fixed to work properly with onclick
window.deletePlot = function(filename) {
if (confirm(`Are you sure you want to delete "${filename}"? This action cannot be undone.`)) {
// Find the button that was clicked by searching for the button with this filename
const buttons = document.querySelectorAll('.btn-delete');
let button = null;
buttons.forEach(btn => {
if (btn.getAttribute('onclick').includes(filename)) {
button = btn;
}
});
if (!button) {
alert('Error: Could not find the delete button');
return;
}
const originalText = button.textContent;
button.textContent = 'ποΈ Deleting...';
button.disabled = true;
fetch(`/delete_plot/${filename}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
}
})
.then(response => {
console.log('Delete response status:', response.status);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('Delete response data:', data);
if (data.success) {
// Remove the plot card from the DOM
button.closest('.plot-card').remove();
// Show success message
const successMsg = document.createElement('div');
successMsg.style.cssText = `
position: fixed; top: 20px; right: 20px; z-index: 10000;
background: #27ae60; color: white; padding: 15px 25px;
border-radius: 8px; font-weight: bold; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
`;
successMsg.textContent = `β
${filename} deleted successfully`;
document.body.appendChild(successMsg);
setTimeout(() => {
successMsg.remove();
// Reload page to update statistics
window.location.reload();
}, 2000);
} else {
alert(`Failed to delete plot: ${data.error}`);
button.textContent = originalText;
button.disabled = false;
}
})
.catch(error => {
console.error('Error:', error);
alert(`An error occurred while deleting the plot: ${error.message}`);
button.textContent = originalText;
button.disabled = false;
});
}
}
});
</script>
</body>
</html> |