Skip to content

Commit

Permalink
fix: confirm delete machine/project
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaixhin committed Jun 14, 2016
1 parent d6d0834 commit 4b1d10b
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions views/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -126,46 +126,52 @@ block scripts
var id = $el.data("id");

if (type === "projects") {
// Delete experiment files
$.ajax({
url: "/api/v1/projects/" + id + "/experiments/files",
type: "DELETE"
})
.then(function() {
// Then delete experiments
var confirmDelete = confirm("Are you sure you want to delete this project and all associated experiments?");
if (confirmDelete) {
// Delete experiment files
$.ajax({
url: "/api/v1/projects/" + id + "/experiments",
url: "/api/v1/projects/" + id + "/experiments/files",
type: "DELETE"
})
.then(function() {
// Then delete project
// Then delete experiments
$.ajax({
url: "/api/v1/projects/" + id,
url: "/api/v1/projects/" + id + "/experiments",
type: "DELETE"
})
.then(function() {
location.reload(); // Refresh page
})
.catch(function(err) {
console.log(err);
// Then delete project
$.ajax({
url: "/api/v1/projects/" + id,
type: "DELETE"
})
.then(function() {
location.reload(); // Refresh page
})
.catch(function(err) {
console.log(err);
});
});
})
.catch(function(err) {
console.log(err);
});
})
.catch(function(err) {
console.log(err);
});
}
} else {
// Delete machine
$.ajax({
url: "/api/v1/machines/" + id,
type: "DELETE"
})
.then(function() {
location.reload(); // Refresh page
})
.catch(function(err) {
console.log(err);
});
var confirmDelete = confirm("Are you sure you want to delete this machine?\nTo re-register, you will need to delete 'specs.json' before running FGMachine again.");
if (confirmDelete) {
// Delete machine
$.ajax({
url: "/api/v1/machines/" + id,
type: "DELETE"
})
.then(function() {
location.reload(); // Refresh page
})
.catch(function(err) {
console.log(err);
});
}
}
return false; // Stop event and propagation
});
Expand Down

0 comments on commit 4b1d10b

Please sign in to comment.