Spaces:
Running
Running
auto-download rework..
Browse files- frontend/vehicles.html +27 -29
frontend/vehicles.html
CHANGED
|
@@ -1506,34 +1506,31 @@
|
|
| 1506 |
infoRow('Real-time Ratio', d.speed_vs_realtime + 'x', 'Processing speed relative to video playback rate.');
|
| 1507 |
|
| 1508 |
if (d.video_id) {
|
| 1509 |
-
loadReports(d.video_id)
|
| 1510 |
-
|
| 1511 |
-
|
| 1512 |
-
|
| 1513 |
-
|
| 1514 |
-
|
| 1515 |
-
|
| 1516 |
-
|
| 1517 |
-
|
| 1518 |
-
|
| 1519 |
-
|
| 1520 |
-
|
| 1521 |
-
|
| 1522 |
-
|
| 1523 |
-
|
| 1524 |
-
|
| 1525 |
-
|
| 1526 |
-
|
| 1527 |
-
|
| 1528 |
-
|
| 1529 |
-
|
| 1530 |
-
|
| 1531 |
-
|
| 1532 |
-
|
| 1533 |
-
|
| 1534 |
-
.catch(err => console.error('[UrbanFlow] Auto-download failed:', err));
|
| 1535 |
-
}, 3000);
|
| 1536 |
-
}
|
| 1537 |
}
|
| 1538 |
|
| 1539 |
// Show New Analysis button in Settings
|
|
@@ -1593,7 +1590,7 @@
|
|
| 1593 |
async function loadReports(videoId) {
|
| 1594 |
const res = await fetch(`/reports/${videoId}`, { method: 'POST' });
|
| 1595 |
const data = await res.json();
|
| 1596 |
-
if (!data.files || !data.files.length) return;
|
| 1597 |
|
| 1598 |
document.getElementById('reports-pending').classList.add('hidden');
|
| 1599 |
const grid = document.getElementById('reports-grid');
|
|
@@ -1649,6 +1646,7 @@
|
|
| 1649 |
`;
|
| 1650 |
grid.appendChild(card);
|
| 1651 |
});
|
|
|
|
| 1652 |
}
|
| 1653 |
|
| 1654 |
function toggleExportMaster(el) {
|
|
|
|
| 1506 |
infoRow('Real-time Ratio', d.speed_vs_realtime + 'x', 'Processing speed relative to video playback rate.');
|
| 1507 |
|
| 1508 |
if (d.video_id) {
|
| 1509 |
+
loadReports(d.video_id).then(data => {
|
| 1510 |
+
if (!data) return;
|
| 1511 |
+
|
| 1512 |
+
// Auto-Download Logic (Respects live toggle state)
|
| 1513 |
+
if (document.getElementById('sv-auto-download').classList.contains('active')) {
|
| 1514 |
+
const preferredFmt = document.getElementById('sv-report').value;
|
| 1515 |
+
console.log(`[UrbanFlow] Auto-downloading ${preferredFmt} reports...`);
|
| 1516 |
+
|
| 1517 |
+
// Download the primary charts in the user's preferred format
|
| 1518 |
+
data.files.forEach(targetFile => {
|
| 1519 |
+
// We only auto-download the primary KPI charts, not everything
|
| 1520 |
+
const isTarget = targetFile.endsWith(`.${preferredFmt}`) &&
|
| 1521 |
+
(targetFile.includes('congestion') || targetFile.includes('direction') || targetFile.includes('flow'));
|
| 1522 |
+
|
| 1523 |
+
if (isTarget) {
|
| 1524 |
+
const link = document.createElement('a');
|
| 1525 |
+
link.href = `/reports/${d.video_id}/${targetFile}`;
|
| 1526 |
+
link.download = targetFile;
|
| 1527 |
+
document.body.appendChild(link);
|
| 1528 |
+
link.click();
|
| 1529 |
+
document.body.removeChild(link);
|
| 1530 |
+
}
|
| 1531 |
+
});
|
| 1532 |
+
}
|
| 1533 |
+
});
|
|
|
|
|
|
|
|
|
|
| 1534 |
}
|
| 1535 |
|
| 1536 |
// Show New Analysis button in Settings
|
|
|
|
| 1590 |
async function loadReports(videoId) {
|
| 1591 |
const res = await fetch(`/reports/${videoId}`, { method: 'POST' });
|
| 1592 |
const data = await res.json();
|
| 1593 |
+
if (!data.files || !data.files.length) return null;
|
| 1594 |
|
| 1595 |
document.getElementById('reports-pending').classList.add('hidden');
|
| 1596 |
const grid = document.getElementById('reports-grid');
|
|
|
|
| 1646 |
`;
|
| 1647 |
grid.appendChild(card);
|
| 1648 |
});
|
| 1649 |
+
return data;
|
| 1650 |
}
|
| 1651 |
|
| 1652 |
function toggleExportMaster(el) {
|