Subh775 commited on
Commit
180fd01
·
1 Parent(s): d04eb83

self explanatory info, format cnclusion for png/pdf

Browse files
Files changed (1) hide show
  1. frontend/vehicles.html +23 -11
frontend/vehicles.html CHANGED
@@ -683,8 +683,8 @@
683
  </div>
684
  <div class="s-row" data-param="report">
685
  <div>
686
- <div class="text-xs font-semibold text-slate-700">Report Format</div>
687
- <div class="text-[10px] text-slate-400">Export file type for charts</div>
688
  </div>
689
  <select class="custom-select" id="sv-report">
690
  <option value="png" selected>PNG Image</option>
@@ -723,8 +723,14 @@
723
  </div>
724
  <div class="s-row" data-param="smoothing">
725
  <div>
726
- <div class="text-xs font-semibold text-slate-700">Congestion Smoothing</div>
727
- <div class="text-[10px] text-slate-400">Alpha factor for rolling average</div>
 
 
 
 
 
 
728
  </div>
729
  <div class="s-stepper"><button onclick="stepParam('smoothing',-0.05)">&#8249;</button><span
730
  class="s-val" id="sv-smoothing">0.25</span><button
@@ -1502,25 +1508,31 @@
1502
  if (d.video_id) {
1503
  loadReports(d.video_id);
1504
 
1505
- // Auto-Download Logic
1506
  if (document.getElementById('sv-auto-download').classList.contains('active')) {
1507
- console.log('[UrbanFlow] Auto-download triggered...');
 
 
1508
  setTimeout(() => {
1509
  fetch(`/reports_list/${d.video_id}`)
1510
  .then(r => r.json())
1511
  .then(res => {
1512
- const pdf = res.files.find(f => f.endsWith('.pdf'));
1513
- if (pdf) {
 
 
 
 
1514
  const link = document.createElement('a');
1515
- link.href = `/reports/${d.video_id}/${pdf}`;
1516
- link.download = pdf;
1517
  document.body.appendChild(link);
1518
  link.click();
1519
  document.body.removeChild(link);
1520
  }
1521
  })
1522
  .catch(err => console.error('[UrbanFlow] Auto-download failed:', err));
1523
- }, 2500); // 2.5s buffer for PDF generation
1524
  }
1525
  }
1526
 
 
683
  </div>
684
  <div class="s-row" data-param="report">
685
  <div>
686
+ <div class="text-xs font-semibold text-slate-700">Individual Chart Export</div>
687
+ <div class="text-[10px] text-slate-400">Format for separate KPI chart files</div>
688
  </div>
689
  <select class="custom-select" id="sv-report">
690
  <option value="png" selected>PNG Image</option>
 
723
  </div>
724
  <div class="s-row" data-param="smoothing">
725
  <div>
726
+ <div class="text-xs font-semibold text-slate-700 flex items-center">
727
+ Congestion Smoothing
728
+ <span class="info-wrap ml-1">
729
+ <span class="info-btn"><i class="fa-solid fa-circle-info text-[9px]"></i></span>
730
+ <span class="info-tip">Reduces jitter/noise in the line chart. Low values (0.05-0.2) create very smooth trends; high values (0.8+) show raw spiky data.</span>
731
+ </span>
732
+ </div>
733
+ <div class="text-[10px] text-slate-400">EMA Alpha factor for the rolling average</div>
734
  </div>
735
  <div class="s-stepper"><button onclick="stepParam('smoothing',-0.05)">&#8249;</button><span
736
  class="s-val" id="sv-smoothing">0.25</span><button
 
1508
  if (d.video_id) {
1509
  loadReports(d.video_id);
1510
 
1511
+ // Auto-Download Logic (Respects live toggle state)
1512
  if (document.getElementById('sv-auto-download').classList.contains('active')) {
1513
+ const preferredFmt = document.getElementById('sv-report').value; // Get png or pdf
1514
+ console.log(`[UrbanFlow] Auto-download triggered for .${preferredFmt}...`);
1515
+
1516
  setTimeout(() => {
1517
  fetch(`/reports_list/${d.video_id}`)
1518
  .then(r => r.json())
1519
  .then(res => {
1520
+ // Try to find the file matching the preferred format first
1521
+ let targetFile = res.files.find(f => f.endsWith(`.${preferredFmt}`));
1522
+ // Fallback to any PDF if preferred format not found
1523
+ if (!targetFile) targetFile = res.files.find(f => f.endsWith('.pdf'));
1524
+
1525
+ if (targetFile) {
1526
  const link = document.createElement('a');
1527
+ link.href = `/reports/${d.video_id}/${targetFile}`;
1528
+ link.download = targetFile;
1529
  document.body.appendChild(link);
1530
  link.click();
1531
  document.body.removeChild(link);
1532
  }
1533
  })
1534
  .catch(err => console.error('[UrbanFlow] Auto-download failed:', err));
1535
+ }, 3000);
1536
  }
1537
  }
1538