437 lines
15 KiB
HTML
Executable File
437 lines
15 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="vi">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Reports Management</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%);
|
|
padding: 20px;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
background: white;
|
|
border-radius: 20px;
|
|
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.header {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 30px;
|
|
text-align: center;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 2.5em;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.header p {
|
|
opacity: 0.9;
|
|
font-size: 1.1em;
|
|
}
|
|
|
|
.content {
|
|
padding: 30px;
|
|
}
|
|
|
|
.section {
|
|
margin-bottom: 30px;
|
|
padding: 20px;
|
|
background: #f8f9fa;
|
|
border-radius: 10px;
|
|
}
|
|
|
|
.section h2 {
|
|
color: #667eea;
|
|
margin-bottom: 15px;
|
|
font-size: 1.5em;
|
|
}
|
|
|
|
.btn {
|
|
padding: 12px 30px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
font-size: 1em;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: #6c757d;
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger {
|
|
background: #dc3545;
|
|
color: white;
|
|
}
|
|
|
|
.btn-success {
|
|
background: #28a745;
|
|
color: white;
|
|
}
|
|
|
|
.reports-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
|
|
gap: 20px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.report-card {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
border: 1px solid #e0e0e0;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.report-card:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 5px 20px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.report-card h3 {
|
|
color: #667eea;
|
|
margin-bottom: 10px;
|
|
font-size: 1.1em;
|
|
}
|
|
|
|
.report-card .meta {
|
|
color: #666;
|
|
font-size: 0.9em;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.report-card .badge {
|
|
display: inline-block;
|
|
padding: 5px 12px;
|
|
border-radius: 15px;
|
|
font-size: 0.85em;
|
|
font-weight: 600;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.badge-training {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
|
|
.badge-prediction {
|
|
background: #ff6b6b;
|
|
color: white;
|
|
}
|
|
|
|
.badge-batch {
|
|
background: #feca57;
|
|
color: #333;
|
|
}
|
|
|
|
.report-card .actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
margin-top: 15px;
|
|
}
|
|
|
|
.report-card .btn {
|
|
padding: 8px 15px;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.stat-card {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
border-left: 4px solid #667eea;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.stat-card h3 {
|
|
color: #666;
|
|
font-size: 0.9em;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.stat-card .value {
|
|
color: #667eea;
|
|
font-size: 2em;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.filter-section {
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
gap: 10px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.filter-btn {
|
|
padding: 10px 20px;
|
|
background: white;
|
|
border: 2px solid #667eea;
|
|
color: #667eea;
|
|
border-radius: 20px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.filter-btn:hover,
|
|
.filter-btn.active {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 60px 20px;
|
|
color: #999;
|
|
}
|
|
|
|
.empty-state i {
|
|
font-size: 4em;
|
|
margin-bottom: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>📝 Reports Management</h1>
|
|
<p>Quản lý báo cáo training và prediction</p>
|
|
</div>
|
|
|
|
<div style="background: white; padding: 15px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; border-bottom: 2px solid #e0e0e0;">
|
|
<a href="/" style="padding: 10px 20px; background: #667eea; color: white; border-radius: 8px; text-decoration: none; font-weight: 600;">🏠 Trang Chủ</a>
|
|
<a href="/training" style="padding: 10px 20px; background: #4facfe; color: white; border-radius: 8px; text-decoration: none; font-weight: 600;">🎓 Training</a>
|
|
<a href="/prediction" style="padding: 10px 20px; background: #4facfe; color: white; border-radius: 8px; text-decoration: none; font-weight: 600;">🗺️ Prediction</a>
|
|
<a href="/batch" style="padding: 10px 20px; background: #764ba2; color: white; border-radius: 8px; text-decoration: none; font-weight: 600;">🚀 Batch Processing</a>
|
|
<a href="/ndvi" style="padding: 10px 20px; background: #2ecc71; color: white; border-radius: 8px; text-decoration: none; font-weight: 600;">🌿 NDVI Analysis</a>
|
|
<a href="/reports" style="padding: 10px 20px; background: #f093fb; color: white; border-radius: 8px; text-decoration: none; font-weight: 600;">📝 Reports (Active)</a>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<!-- Statistics -->
|
|
<div class="stats-grid" id="statsGrid">
|
|
<div class="stat-card">
|
|
<h3>📊 Total Reports</h3>
|
|
<div class="value" id="statTotal">0</div>
|
|
</div>
|
|
<div class="stat-card" style="border-left-color: #667eea;">
|
|
<h3>🎓 Training Reports</h3>
|
|
<div class="value" id="statTraining" style="color: #667eea;">0</div>
|
|
</div>
|
|
<div class="stat-card" style="border-left-color: #ff6b6b;">
|
|
<h3>🗺️ Prediction Reports</h3>
|
|
<div class="value" id="statPrediction" style="color: #ff6b6b;">0</div>
|
|
</div>
|
|
<div class="stat-card" style="border-left-color: #feca57;">
|
|
<h3>🚀 Batch Reports</h3>
|
|
<div class="value" id="statBatch" style="color: #feca57;">0</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filters -->
|
|
<div class="filter-section">
|
|
<button class="filter-btn active" onclick="filterReports('all')">Tất cả</button>
|
|
<button class="filter-btn" onclick="filterReports('training')">Training</button>
|
|
<button class="filter-btn" onclick="filterReports('prediction')">Prediction</button>
|
|
<button class="filter-btn" onclick="filterReports('batch')">Batch Jobs</button>
|
|
<button class="btn btn-secondary" onclick="loadReports()" style="margin-left: auto;">🔄 Refresh</button>
|
|
</div>
|
|
|
|
<!-- Reports Grid -->
|
|
<div class="section">
|
|
<div id="reportsGrid" class="reports-grid">
|
|
<div class="empty-state">
|
|
<p>⏳ Đang tải...</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const API_BASE = 'http://localhost:8000/api';
|
|
let allReports = [];
|
|
let currentFilter = 'all';
|
|
|
|
// Load reports on page load
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
loadReports();
|
|
});
|
|
|
|
async function loadReports() {
|
|
try {
|
|
const response = await fetch(`${API_BASE}/reports/list`);
|
|
const data = await response.json();
|
|
|
|
allReports = data.reports;
|
|
updateStats(data.reports);
|
|
displayReports(filterReportsByType(data.reports, currentFilter));
|
|
} catch (error) {
|
|
console.error('Error loading reports:', error);
|
|
document.getElementById('reportsGrid').innerHTML = `
|
|
<div class="empty-state">
|
|
<p style="color: red;">❌ Lỗi khi tải reports: ${error.message}</p>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
function updateStats(reports) {
|
|
const total = reports.length;
|
|
const training = reports.filter(r => r.type === 'training').length;
|
|
const prediction = reports.filter(r => r.type === 'prediction').length;
|
|
const batch = reports.filter(r => r.is_batch_job).length;
|
|
|
|
document.getElementById('statTotal').textContent = total;
|
|
document.getElementById('statTraining').textContent = training;
|
|
document.getElementById('statPrediction').textContent = prediction;
|
|
document.getElementById('statBatch').textContent = batch;
|
|
}
|
|
|
|
function filterReports(type) {
|
|
currentFilter = type;
|
|
|
|
// Update active button
|
|
document.querySelectorAll('.filter-btn').forEach(btn => {
|
|
btn.classList.remove('active');
|
|
});
|
|
event.target.classList.add('active');
|
|
|
|
// Filter and display
|
|
const filtered = filterReportsByType(allReports, type);
|
|
displayReports(filtered);
|
|
}
|
|
|
|
function filterReportsByType(reports, type) {
|
|
if (type === 'all') return reports;
|
|
if (type === 'batch') return reports.filter(r => r.is_batch_job);
|
|
return reports.filter(r => r.type === type);
|
|
}
|
|
|
|
function displayReports(reports) {
|
|
const grid = document.getElementById('reportsGrid');
|
|
|
|
if (reports.length === 0) {
|
|
grid.innerHTML = `
|
|
<div class="empty-state">
|
|
<p>📝 Không có báo cáo nào</p>
|
|
</div>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
grid.innerHTML = reports.map(report => {
|
|
const badgeClass = report.type === 'training' ? 'badge-training' : 'badge-prediction';
|
|
const badgeText = report.type === 'training' ? '🎓 Training' : '🗺️ Prediction';
|
|
const batchBadge = report.is_batch_job ? '<span class="badge badge-batch">🚀 Batch Job</span>' : '';
|
|
|
|
const createdDate = new Date(report.created).toLocaleString('vi-VN');
|
|
|
|
let metaInfo = `
|
|
<p>📅 ${createdDate}</p>
|
|
<p>💾 ${report.size_kb} KB</p>
|
|
`;
|
|
|
|
if (report.batch_metadata) {
|
|
metaInfo += `
|
|
<p style="margin-top: 5px; font-weight: 600;">
|
|
📦 ${report.batch_metadata.batch_name || 'Batch Job'}
|
|
</p>
|
|
`;
|
|
}
|
|
|
|
return `
|
|
<div class="report-card">
|
|
<span class="badge ${badgeClass}">${badgeText}</span>
|
|
${batchBadge}
|
|
<h3>📄 ${report.filename}</h3>
|
|
<div class="meta">
|
|
${metaInfo}
|
|
</div>
|
|
<div class="actions">
|
|
<button class="btn btn-primary" onclick="viewReport('${report.filename}')">
|
|
👁️ Xem
|
|
</button>
|
|
<button class="btn btn-success" onclick="downloadReport('${report.filename}')">
|
|
💾 Tải
|
|
</button>
|
|
<button class="btn btn-danger" onclick="deleteReport('${report.filename}')">
|
|
🗑️ Xóa
|
|
</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
function viewReport(filename) {
|
|
window.open(`${API_BASE}/reports/view/${filename}`, '_blank');
|
|
}
|
|
|
|
function downloadReport(filename) {
|
|
window.location.href = `${API_BASE}/reports/download/${filename}`;
|
|
}
|
|
|
|
async function deleteReport(filename) {
|
|
if (!confirm(`Bạn có chắc muốn xóa báo cáo: ${filename}?`)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(`${API_BASE}/reports/delete/${filename}`, {
|
|
method: 'DELETE'
|
|
});
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
alert('✅ Đã xóa báo cáo thành công!');
|
|
loadReports();
|
|
} else {
|
|
alert('❌ Không thể xóa báo cáo!');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error deleting report:', error);
|
|
alert('❌ Lỗi khi xóa báo cáo: ' + error.message);
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|