Skip to content

Commit

Permalink
add feedback to zoned cleaning and goto buttons on the map tab
Browse files Browse the repository at this point in the history
  • Loading branch information
rand256 committed Jul 1, 2019
1 parent 9bad260 commit 0f36c93
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions client/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,36 @@
* Calls the goto api route with the currently set goto coordinates
*/
function goto_point(point) {
fetch("../api/go_to", {
method: "put",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(point)
})
.then(res => res.text())
.then(console.log);
let button = document.getElementById("goto");
loadingBar.setAttribute("indeterminate", "indeterminate");
button.setAttribute("disabled", "disabled");
fn.requestWithPayload("api/go_to", JSON.stringify(point), "PUT", function (err) {
loadingBar.removeAttribute("indeterminate");
button.removeAttribute("disabled");
if (err) {
ons.notification.toast(err, { buttonLabel: 'Dismiss', timeout: 1500 })
} else {
ons.notification.toast("Command successfully sent!", { buttonLabel: 'Dismiss', timeout: 1500 });
}
});
}

/**
* Calls the zoned_cleanup api route with the currently set zone
*/
function zoned_cleanup(zones) {
fetch("../api/start_cleaning_zone", {
method: "put",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(zones)
})
.then(res => res.text())
.then(console.log);
let button = document.getElementById("start_zoned_cleanup");
loadingBar.setAttribute("indeterminate", "indeterminate");
button.setAttribute("disabled", "disabled");
fn.requestWithPayload("api/start_cleaning_zone", JSON.stringify(zones), "PUT", function (err) {
loadingBar.removeAttribute("indeterminate");
button.removeAttribute("disabled");
if (err) {
ons.notification.toast(err, { buttonLabel: 'Dismiss', timeout: 1500 })
} else {
ons.notification.toast("Command successfully sent!", { buttonLabel: 'Dismiss', timeout: 1500 });
}
});
}

document.getElementById("goto").onclick = () => {
Expand Down

0 comments on commit 0f36c93

Please sign in to comment.