Skip to content

Commit dc9e413

Browse files
committed
feat: add reset capacity button
1 parent ee53cf2 commit dc9e413

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

views/machine.jade

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ block content
2525
ul.list-unstyled
2626
- each gpu in machine.gpus
2727
li= gpu
28+
h2 Capacity
29+
button.btn.btn-warning.reset(type="button") Reset Capacity
2830
h2 Projects
2931
ul.list-unstyled
3032
- each project in projects
@@ -37,6 +39,29 @@ block scripts
3739
var ws = null; // WebSocket
3840
var $status = $("#machine-status"); // Machine status icon
3941

42+
// Reset machine capacity
43+
$("button.reset").on("click", function() {
44+
var $el = $(this);
45+
var id = $el.data("id");
46+
47+
var confirmReset = confirm("Are you sure you want to reset this machine's capacity?");
48+
if (confirmReset) {
49+
// Reset capacity
50+
$.ajax({
51+
url: "#{machine.address}/capacity/reset",
52+
type: "POST"
53+
})
54+
.then(function() {
55+
alert("Capacity successfully reset.");
56+
})
57+
.catch(function(err) {
58+
alert(err.statusText);
59+
});
60+
}
61+
return false; // Stop event and propagation
62+
});
63+
64+
4065
// Connects to WebSocket server
4166
var wsConnect = function() {
4267
ws = new WebSocket(host); // Attempt to connect

0 commit comments

Comments
 (0)