Commit 33f3812e authored by Leigh B Stoller's avatar Leigh B Stoller

Clean up a bunch of button enable/disable stuff.

parent 6e9457c0
...@@ -56,7 +56,7 @@ function ($, sup, moment) ...@@ -56,7 +56,7 @@ function ($, sup, moment)
event.preventDefault(); event.preventDefault();
sup.HideModal('#terminate_modal'); sup.HideModal('#terminate_modal');
ButtonDisable(); DisableButtons();
var callback = function(json) { var callback = function(json) {
// This is considered the home page, for now. // This is considered the home page, for now.
...@@ -130,7 +130,7 @@ function ($, sup, moment) ...@@ -130,7 +130,7 @@ function ($, sup, moment)
StartResizeWatchdog() StartResizeWatchdog()
StatusWatchCallBack.active = 1; StatusWatchCallBack.active = 1;
} }
ButtonEnable(); EnableButtons();
} }
else if (status == 'failed') { else if (status == 'failed') {
bgtype = "bg-danger"; bgtype = "bg-danger";
...@@ -143,19 +143,20 @@ function ($, sup, moment) ...@@ -143,19 +143,20 @@ function ($, sup, moment)
$("#quickvm_progress").addClass("progress-bar-danger"); $("#quickvm_progress").addClass("progress-bar-danger");
$("#quickvm_progress_bar").width("100%"); $("#quickvm_progress_bar").width("100%");
} }
ButtonDisable(); DisableButtons();
EnableButton("terminate");
} }
else if (status == 'imaging') { else if (status == 'imaging') {
bgtype = "bg-warning"; bgtype = "bg-warning";
statustext = "Your experiment is busy while we copy your disk "; statustext = "Your experiment is busy while we copy your disk";
status_html = "<font color=red>imaging</font>"; status_html = "<font color=red>imaging</font>";
ButtonDisable(); DisableButtons();
} }
else if (status == 'terminating' || status == 'terminated') { else if (status == 'terminating' || status == 'terminated') {
status_html = "<font color=red>" + status + "</font>"; status_html = "<font color=red>" + status + "</font>";
bgtype = "bg-danger"; bgtype = "bg-danger";
statustext = "Your experiment has been terminated!"; statustext = "Your experiment has been terminated!";
ButtonDisable(); DisableButtons();
StartCountdownClock.stop = 1; StartCountdownClock.stop = 1;
} }
$("#statusmessage").html(statustext); $("#statusmessage").html(statustext);
...@@ -174,29 +175,42 @@ function ($, sup, moment) ...@@ -174,29 +175,42 @@ function ($, sup, moment)
// //
// Enable/Disable buttons. // Enable/Disable buttons.
// //
function ButtonEnable() function EnableButtons()
{ {
ButtonState(1); EnableButton("terminate");
EnableButton("extend");
EnableButton("snapshot");
} }
function ButtonDisable() function DisableButtons()
{ {
ButtonState(0); DisableButton("terminate");
DisableButton("extend");
DisableButton("snapshot");
} }
function ButtonState(enable) function EnableButton(button)
{ {
ButtonState(button, 1);
}
function DisableButton(button)
{
ButtonState(button, 0);
}
function ButtonState(button, enable)
{
if (button == "terminate")
button = "#terminate_button";
else if (button == "extend")
button = "#extend_button";
else if (button == "snapshot" && nodecount == 1)
button = "#snapshot_button";
else
return;
if (enable) { if (enable) {
$("#terminate_button").prop("disabled", false); $(button).removeAttr("disabled");
$("#extend_button").prop("disabled", false);
if (nodecount == 1) {
$("#snapshot_button").prop("disabled", false);
}
} }
else { else {
$("#terminate_button").prop("disabled", true); $(button).attr("disabled", "disabled");
$("#extend_button").prop("disabled", true);
if (nodecount == 1) {
$("#snapshot_button").prop("disabled", true);
}
} }
} }
...@@ -584,6 +598,7 @@ function ($, sup, moment) ...@@ -584,6 +598,7 @@ function ($, sup, moment)
// single node experiments can do this. // single node experiments can do this.
if (nodecount == 1) { if (nodecount == 1) {
$("#snapshot_button").removeClass("invisible"); $("#snapshot_button").removeClass("invisible");
EnableButton("snapshot");
} }
// And start up ssh for single node topologies. // And start up ssh for single node topologies.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment