edit interface file
parent
e0efdc75ea
commit
01a5d2c238
|
|
@ -9,43 +9,34 @@
|
|||
<script>
|
||||
var dataElement = document.getElementById("data");
|
||||
|
||||
function saveHeartRateData() {
|
||||
Util.showModal("Saving...");
|
||||
var csvContent = "Timestamp,Heart Rate(bpm),HRV(ms)\n";
|
||||
// Assuming logData contains the heart rate data
|
||||
logData.forEach(entry => {
|
||||
csvContent += `${entry.timestamp},${entry.heartRate},${entry.hrv}\n`;
|
||||
});
|
||||
var fileName = "heart_rate_data.csv"; // Set the desired file name
|
||||
Util.saveCSV(fileName, csvContent, function(success) {
|
||||
if (success) {
|
||||
dataElement.innerHTML = "<p>Heart rate data saved successfully</p>";
|
||||
Util.hideModal(); // Move hideModal() call inside the success callback
|
||||
} else {
|
||||
dataElement.innerHTML = "<p>Error saving heart rate data</p>";
|
||||
Util.hideModal(); // Move hideModal() call inside the error callback
|
||||
}
|
||||
});
|
||||
function displayOptions() {
|
||||
// Display options to save the heart rate data file
|
||||
dataElement.innerHTML = `
|
||||
<button class="btn btn-primary" onclick="saveHeartRateData()">Save</button>
|
||||
`;
|
||||
}
|
||||
|
||||
function deleteHeartRateData() {
|
||||
Util.showModal("Deleting...");
|
||||
var fileName = "heart_rate_data.csv"; // Set the desired file name
|
||||
Util.eraseStorageFile(fileName, function(success) {
|
||||
if (success) {
|
||||
dataElement.innerHTML = "<p>Heart rate data deleted successfully</p>";
|
||||
} else {
|
||||
dataElement.innerHTML = "<p>Error deleting heart rate data</p>";
|
||||
}
|
||||
Util.hideModal(); // Always hide the modal after the operation completes
|
||||
function saveHeartRateData() {
|
||||
Util.showModal("Saving...");
|
||||
var fileName = "heart_rate_data.csv"; // Set the file name to save
|
||||
// Read the heart rate data from the watch's storage
|
||||
Util.readStorageFile(fileName, function(data) {
|
||||
// Save the data to the device through app loader
|
||||
Util.saveFileToDevice(fileName, data, function(success) {
|
||||
if (success) {
|
||||
dataElement.innerHTML = "<p>Heart rate data saved successfully</p>";
|
||||
} else {
|
||||
dataElement.innerHTML = "<p>Error saving heart rate data</p>";
|
||||
}
|
||||
Util.hideModal();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Called when app starts
|
||||
function onInit() {
|
||||
// Only show options to save or delete data
|
||||
saveHeartRateData();
|
||||
deleteHeartRateData();
|
||||
// Display option to save data
|
||||
displayOptions();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue