cams-pollution-dashboard / templates /view_interactive.html
aditya-me13's picture
Checkpoint on 9th Oct - Everything Working
39ab179
raw
history blame
7.61 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Interactive Plot - CAMS Dashboard</title>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<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);
text-align: center;
}
.header h1 {
color: #2c3e50;
margin-bottom: 10px;
}
.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-download {
background: linear-gradient(45deg, #27ae60, #219a52);
}
.plot-container {
background: rgba(255, 255, 255, 0.95);
border-radius: 15px;
padding: 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);
}
.plot-content {
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
.plot-info-section {
background: rgba(255, 255, 255, 0.95);
border-radius: 15px;
padding: 20px;
margin-top: 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);
}
.info-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
}
.info-item {
background: rgba(52, 73, 94, 0.1);
padding: 15px;
border-radius: 10px;
border-left: 4px solid #3498db;
}
.info-item h3 {
color: #2c3e50;
margin-bottom: 5px;
font-size: 14px;
font-weight: 600;
}
.info-item p {
color: #34495e;
font-size: 16px;
font-weight: 500;
}
@media (max-width: 768px) {
.container {
padding: 10px;
}
.controls {
justify-content: center;
}
.btn {
padding: 10px 20px;
font-size: 12px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🌍 Interactive Plot Viewer</h1>
<p style="color: #7f8c8d; margin-top: 10px;">
Viewing saved interactive plot: {{ plot_info.filename }}
</p>
</div>
<div class="controls">
<a href="{{ url_for('gallery') }}" class="btn btn-secondary">← Back to Gallery</a>
<a href="{{ url_for('index') }}" class="btn btn-secondary">🏠 Dashboard</a>
<a href="{{ url_for('serve_plot', filename=plot_info.filename) }}"
class="btn btn-download" download>πŸ“₯ Download HTML</a>
</div>
<div class="plot-container">
<div class="plot-content">
{{ plot_html|safe }}
</div>
</div>
<div class="plot-info-section">
<h2 style="color: #2c3e50; margin-bottom: 20px;">πŸ“Š Plot Information</h2>
<div class="info-grid">
<div class="info-item">
<h3>πŸ§ͺ Variable</h3>
<p>{{ plot_info.variable }}</p>
</div>
{% if plot_info.pressure_level %}
<div class="info-item">
<h3>🌑️ Pressure Level</h3>
<p>{{ plot_info.pressure_level }}</p>
</div>
{% endif %}
<div class="info-item">
<h3>🎨 Color Theme</h3>
<p>{{ plot_info.theme }}</p>
</div>
<div class="info-item">
<h3>⏰ Generated</h3>
<p>{{ plot_info.generated_time }}</p>
</div>
<div class="info-item">
<h3>🎯 Type</h3>
<p>{{ plot_info.plot_type }} Plot</p>
</div>
<div class="info-item" style="grid-column: 1 / -1;">
<h3>πŸ“ Filename</h3>
<p style="font-family: monospace; background: #f8f9fa; padding: 8px; border-radius: 4px; word-break: break-all;">{{ plot_info.filename }}</p>
</div>
</div>
</div>
</div>
<script>
// Enhanced interactivity for saved plots
document.addEventListener('DOMContentLoaded', function() {
console.log('Viewing saved interactive plot');
// Check if Plotly is loaded
if (typeof Plotly === 'undefined') {
console.error('Plotly is not loaded!');
return;
}
// Find the plotly div
const plotDiv = document.querySelector('.plotly-graph-div');
if (plotDiv) {
console.log('Found Plotly plot');
// Add responsive behavior
window.addEventListener('resize', function() {
Plotly.Plots.resize(plotDiv);
});
}
// Add loading indicators for download
const downloadBtn = document.querySelector('.btn-download');
if (downloadBtn) {
downloadBtn.addEventListener('click', function() {
const originalText = this.textContent;
this.textContent = '⏳ Preparing download...';
this.style.pointerEvents = 'none';
setTimeout(() => {
this.textContent = originalText;
this.style.pointerEvents = 'auto';
}, 2000);
});
}
});
</script>
</body>
</html>