2024-04-06 02:57:04 +00:00
|
|
|
<html>
|
2024-04-06 03:24:47 +00:00
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" href="../../css/spectre.min.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
2024-04-16 19:18:19 +00:00
|
|
|
<div id="data"></div>
|
2024-04-06 02:57:04 +00:00
|
|
|
|
2024-04-06 03:24:47 +00:00
|
|
|
<script src="../../core/lib/interface.js"></script>
|
|
|
|
<script>
|
2024-04-16 19:18:19 +00:00
|
|
|
var dataElement = document.getElementById("data");
|
2024-04-06 02:57:04 +00:00
|
|
|
|
2024-04-16 20:48:04 +00:00
|
|
|
function getData() {
|
|
|
|
// show loading window
|
2024-04-16 19:18:19 +00:00
|
|
|
Util.showModal("Loading...");
|
2024-04-16 20:48:04 +00:00
|
|
|
// get the data
|
2024-04-16 19:18:19 +00:00
|
|
|
dataElement.innerHTML = "";
|
2024-04-16 20:48:04 +00:00
|
|
|
var promise = Promise.resolve();
|
2024-04-16 19:18:19 +00:00
|
|
|
Puck.eval('require("Storage").list(/heart_rate_data\\.csv\\x01/)', files => {
|
|
|
|
if (files.length == 0) {
|
|
|
|
dataElement.innerHTML = "<p>No heart rate data found</p>";
|
2024-04-06 03:24:47 +00:00
|
|
|
} else {
|
2024-04-16 19:18:19 +00:00
|
|
|
files.forEach(fn => {
|
|
|
|
fn = fn.slice(0, -1);
|
2024-04-16 20:48:04 +00:00
|
|
|
dataElement.innerHTML += `
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-header">
|
|
|
|
<div class="card-title h5">${fn}</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-footer">
|
|
|
|
<button class="btn btn-primary" fn="${fn}" act="save">Save</button>
|
|
|
|
<button class="btn" fn="${fn}" act="delete">Delete</button>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
promise = promise.then(function() {
|
|
|
|
document.querySelector(`.btn[fn='${fn}'][act='save']`).addEventListener("click", function() {
|
|
|
|
Util.showModal("Downloading...");
|
|
|
|
Util.readStorageFile(fn, function(data) {
|
|
|
|
Util.saveCSV(fn.slice(0, -4), data);
|
|
|
|
Util.hideModal();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.querySelector(`.btn[fn='${fn}'][act='delete']`).addEventListener("click", function() {
|
|
|
|
Util.showModal("Deleting...");
|
|
|
|
Util.eraseStorageFile(fn, function() {
|
|
|
|
Util.hideModal();
|
|
|
|
getData();
|
|
|
|
});
|
2024-04-16 19:18:19 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2024-04-06 03:24:47 +00:00
|
|
|
}
|
2024-04-16 20:48:04 +00:00
|
|
|
// remove window
|
2024-04-10 19:36:33 +00:00
|
|
|
Util.hideModal();
|
2024-04-06 03:24:47 +00:00
|
|
|
});
|
|
|
|
}
|
2024-04-06 02:57:04 +00:00
|
|
|
|
2024-04-16 19:18:19 +00:00
|
|
|
// Called when app starts
|
2024-04-06 03:24:47 +00:00
|
|
|
function onInit() {
|
2024-04-16 20:48:04 +00:00
|
|
|
getData();
|
2024-04-06 03:24:47 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
2024-04-06 02:57:04 +00:00
|
|
|
</html>
|