pksaheb commited on
Commit
2f2dbac
·
verified ·
1 Parent(s): 60f45af

here all is ok ....just theexport data button not working ...means data not get downloaded ...also add manual stop button to stp recording - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +50 -3
index.html CHANGED
@@ -281,9 +281,12 @@
281
  Last 20 readings
282
  </div>
283
  <div class="flex space-x-2">
284
- <button class="bg-industrial-700 hover:bg-industrial-600 text-white px-3 py-1 rounded text-sm">
285
  <i class="fas fa-download mr-1"></i> Export Data
286
  </button>
 
 
 
287
  </div>
288
  </div>
289
 
@@ -813,20 +816,64 @@
813
  historyBody.innerHTML = historyHTML;
814
  }
815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816
  // Initialize the app when DOM is loaded
817
  document.addEventListener('DOMContentLoaded', () => {
818
  init();
819
 
820
- // Start periodic capture after initialization
821
  let captureInterval;
822
- document.getElementById('captureBtn').addEventListener('click', () => {
 
 
 
823
  if (captureInterval) {
824
  stopPeriodicCapture(captureInterval);
825
  captureInterval = null;
 
 
826
  } else {
827
  captureInterval = startPeriodicCapture(10);
 
 
 
 
 
 
 
 
 
 
 
 
828
  }
829
  });
 
 
 
830
  });
831
  </script>
832
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=pksaheb/temperature-monitoring" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
 
281
  Last 20 readings
282
  </div>
283
  <div class="flex space-x-2">
284
+ <button id="exportDataBtn" class="bg-industrial-700 hover:bg-industrial-600 text-white px-3 py-1 rounded text-sm">
285
  <i class="fas fa-download mr-1"></i> Export Data
286
  </button>
287
+ <button id="stopRecordingBtn" class="bg-danger-600 hover:bg-danger-500 text-white px-3 py-1 rounded text-sm ml-2 hidden">
288
+ <i class="fas fa-stop mr-1"></i> Stop Recording
289
+ </button>
290
  </div>
291
  </div>
292
 
 
816
  historyBody.innerHTML = historyHTML;
817
  }
818
 
819
+ // Export data as CSV
820
+ function exportData() {
821
+ if (temperatureHistory.length === 0) {
822
+ logDebug("No data to export");
823
+ return;
824
+ }
825
+
826
+ let csvContent = "Timestamp,Temperature,Status\n";
827
+ temperatureHistory.forEach(reading => {
828
+ csvContent += `${reading.timestamp},${reading.temp},${reading.status}\n`;
829
+ });
830
+
831
+ const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
832
+ const url = URL.createObjectURL(blob);
833
+ const link = document.createElement('a');
834
+ link.setAttribute('href', url);
835
+ link.setAttribute('download', `thermoscan_data_${new Date().toISOString().slice(0,10)}.csv`);
836
+ link.style.visibility = 'hidden';
837
+ document.body.appendChild(link);
838
+ link.click();
839
+ document.body.removeChild(link);
840
+ logDebug("Data exported as CSV");
841
+ }
842
+
843
  // Initialize the app when DOM is loaded
844
  document.addEventListener('DOMContentLoaded', () => {
845
  init();
846
 
847
+ // Start/stop periodic capture
848
  let captureInterval;
849
+ const captureBtn = document.getElementById('captureBtn');
850
+ const stopRecordingBtn = document.getElementById('stopRecordingBtn');
851
+
852
+ captureBtn.addEventListener('click', () => {
853
  if (captureInterval) {
854
  stopPeriodicCapture(captureInterval);
855
  captureInterval = null;
856
+ captureBtn.innerHTML = '<i class="fas fa-camera mr-1"></i> Capture & Analyze';
857
+ stopRecordingBtn.classList.add('hidden');
858
  } else {
859
  captureInterval = startPeriodicCapture(10);
860
+ captureBtn.innerHTML = '<i class="fas fa-pause mr-1"></i> Pause Recording';
861
+ stopRecordingBtn.classList.remove('hidden');
862
+ }
863
+ });
864
+
865
+ // Stop recording button
866
+ stopRecordingBtn.addEventListener('click', () => {
867
+ if (captureInterval) {
868
+ stopPeriodicCapture(captureInterval);
869
+ captureInterval = null;
870
+ captureBtn.innerHTML = '<i class="fas fa-camera mr-1"></i> Capture & Analyze';
871
+ stopRecordingBtn.classList.add('hidden');
872
  }
873
  });
874
+
875
+ // Export data button
876
+ document.getElementById('exportDataBtn').addEventListener('click', exportData);
877
  });
878
  </script>
879
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=pksaheb/temperature-monitoring" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>