Skip to content

Commit

Permalink
feat: add reset capacity button
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaixhin committed Jul 15, 2016
1 parent ee53cf2 commit dc9e413
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions views/machine.jade
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ block content
ul.list-unstyled
- each gpu in machine.gpus
li= gpu
h2 Capacity
button.btn.btn-warning.reset(type="button") Reset Capacity
h2 Projects
ul.list-unstyled
- each project in projects
Expand All @@ -37,6 +39,29 @@ block scripts
var ws = null; // WebSocket
var $status = $("#machine-status"); // Machine status icon

// Reset machine capacity
$("button.reset").on("click", function() {
var $el = $(this);
var id = $el.data("id");

var confirmReset = confirm("Are you sure you want to reset this machine's capacity?");
if (confirmReset) {
// Reset capacity
$.ajax({
url: "#{machine.address}/capacity/reset",
type: "POST"
})
.then(function() {
alert("Capacity successfully reset.");
})
.catch(function(err) {
alert(err.statusText);
});
}
return false; // Stop event and propagation
});


// Connects to WebSocket server
var wsConnect = function() {
ws = new WebSocket(host); // Attempt to connect
Expand Down

0 comments on commit dc9e413

Please sign in to comment.