Commit c4061f0b authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Cleanup/refactor reboot/reload JS code.

parent 08168395
......@@ -1039,37 +1039,22 @@ $(function ()
}
//
// Request a node reboot from the backend cluster.
// Request a node reboot or reload from the backend cluster.
//
function DoReboot(nodeList)
{
var callback = function(json) {
sup.HideModal('#waitwait-modal');
if (json.code) {
sup.SpitOops("oops", "Failed to reboot: " + json.value);
return;
}
// Trigger status to change the nodes.
GetStatus();
}
sup.ShowModal('#waitwait-modal');
var xmlthing = sup.CallServerMethod(ajaxurl,
"status",
"Reboot",
{"uuid" : uuid,
"node_ids" : nodeList});
xmlthing.done(callback);
DoRebootReload("reboot", nodeList);
}
//
// Request a node reload from the backend cluster.
//
function DoReload(nodeList)
{
DoRebootReload("reload", nodeList);
}
function DoRebootReload(which, nodeList)
{
var tag = (which == "reload" ? "Reload" : "Reboot");
// Handler for hide modal to unbind the click handler.
$('#confirm_reload_modal').on('hidden.bs.modal', function (event) {
//console.info("reload hide");
$(this).unbind(event);
$('#confirm_reload_button').unbind("click.reload");
});
......@@ -1077,25 +1062,24 @@ $(function ()
// Throw up a confirmation modal, with handler bound to confirm.
$('#confirm_reload_button').bind("click.reload", function (event) {
sup.HideModal('#confirm_reload_modal');
//console.info("Reload confirm");
var callback = function(json) {
sup.HideModal('#waitwait-modal');
if (json.code) {
sup.SpitOops("oops", "Failed to reload: " + json.value);
sup.SpitOops("oops",
"Failed to " + which + ": " + json.value);
return;
}
// Trigger status update.
GetStatus();
}
sup.ShowModal('#waitwait-modal');
var xmlthing = sup.CallServerMethod(ajaxurl,
"status",
"Reload",
var xmlthing = sup.CallServerMethod(ajaxurl, "status", tag,
{"uuid" : uuid,
"node_ids" : nodeList});
xmlthing.done(callback);
});
$('#confirm_reload_modal #confirm-which').html(tag);
sup.ShowModal('#confirm_reload_modal');
}
......
......@@ -726,7 +726,7 @@ pre {
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<center><h3>Confirm Node Reload</h3>
<center><h3>Confirm Node <span id="confirm-which"></span></h3>
<button type='button' style='margin-right: 20px;'
class='btn btn-primary btn-sm'
data-dismiss='modal' aria-hidden='true'>
......
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