2017-08-31 00:52:20 +03:00
|
|
|
$(function() {
|
|
|
|
$('#mountFormTrigger').click(function(event){
|
|
|
|
$.ajax({
|
2017-09-01 14:52:47 +03:00
|
|
|
url:"status",
|
2017-08-31 00:52:20 +03:00
|
|
|
success:function(data){
|
|
|
|
var status = JSON.parse(data);
|
|
|
|
var htmlSelect = '';
|
|
|
|
for (n in status["quorum"]) { htmlSelect += "<option value=" + n + ">" + n + "</option>";}
|
|
|
|
$('#selectNode').html(htmlSelect);
|
2017-09-01 17:42:27 +03:00
|
|
|
}
|
2017-08-31 00:52:20 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
function resolve() {
|
|
|
|
$.ajax({
|
2017-09-01 17:42:27 +03:00
|
|
|
url:"resolve",
|
2017-08-31 00:52:20 +03:00
|
|
|
data:{"node":deadNode},
|
|
|
|
success:function(data){$('#details').css("display", "none");}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function unmount(a, b, c) {
|
|
|
|
var u = confirm(a + ": confirm unmount of " + b);
|
|
|
|
if (u == true) {
|
|
|
|
$.ajax({
|
2017-09-01 14:52:47 +03:00
|
|
|
url:"unmount",
|
2017-08-31 00:52:20 +03:00
|
|
|
data:{"node":a, "mountpoint":b, "block":c},
|
|
|
|
success:function(data){
|
|
|
|
var res = JSON.parse(data);
|
|
|
|
message = "<h3>" + res["state"] + "</h3> <p>"+ res["message"] +"</p>";
|
|
|
|
$("#rspContainer").css("display", "block");
|
|
|
|
$("#rsp").html(message)
|
|
|
|
if (res["state"] == 'OK'){$("#rspContainer").css("background-color", "#4CAF50" );}
|
|
|
|
else {$("#rspContainer").css("background-color", "#f44336" )}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayData(a){
|
|
|
|
$("#status").html("<p>"+a.health+"</p>");
|
|
|
|
if (a.health == 'deadly.') {
|
|
|
|
$('#showDeadlyDetails').css("display","block");
|
|
|
|
$('#resolve').css("display","block");
|
|
|
|
$("#mountFormTrigger").addClass("w3-disabled")
|
|
|
|
} else {
|
|
|
|
$('#showDeadlyDetails').css("display","none");
|
|
|
|
$('#resolve').css("display","none");
|
|
|
|
$("#mountFormTrigger").removeClass("w3-disabled")
|
|
|
|
$('#details').css("border", "0");
|
|
|
|
}
|
|
|
|
$("#leader").text(a.leader);
|
|
|
|
$( "#statusContainer:contains('alive')" ).css("background-color", "#4CAF50" );
|
|
|
|
$( "#statusContainer:contains('resizing')" ).css("background-color", "#ff9800" );
|
|
|
|
$( "#statusContainer:contains('deadly')" ).css("background-color", "#f44336" );;
|
|
|
|
var node2 = {"quorum":[]};
|
|
|
|
for (var node in a.quorum){
|
|
|
|
node2.quorum.push(node)
|
|
|
|
};
|
|
|
|
w3DisplayData("id01", node2);
|
|
|
|
$('.tablink').css('display', 'block');
|
2017-09-01 17:42:27 +03:00
|
|
|
if (selected_node != undefined && selected_node != 'dead'){
|
|
|
|
var t = new Date(a.quorum[selected_node]["updated"] * 1000)
|
2017-08-31 00:52:20 +03:00
|
|
|
var up_formatted = t.getFullYear() + "/" +
|
|
|
|
(t.getMonth() + 1) + "/" +
|
|
|
|
t.getDate() + " " +
|
|
|
|
t.getHours() + ":" +
|
|
|
|
t.getMinutes() + ":" +
|
|
|
|
t.getSeconds();
|
2017-09-01 17:42:27 +03:00
|
|
|
$("#name").html(selected_node);
|
|
|
|
$("#ipv4").html(a.quorum[selected_node]["ip"]["v4"].join("<br>"));
|
|
|
|
$("#ipv6").html(a.quorum[selected_node]["ip"]["v6"].join("<br>"));
|
2017-08-31 00:52:20 +03:00
|
|
|
$("#updated").html(up_formatted);
|
2017-09-01 17:42:27 +03:00
|
|
|
if (a.quorum[selected_node]["mounts"] != null) {
|
2017-08-31 00:52:20 +03:00
|
|
|
var mnt_block = "";
|
2017-09-01 17:42:27 +03:00
|
|
|
for (i in a.quorum[selected_node].mounts) {
|
|
|
|
var mnt = a.quorum[selected_node].mounts[i];
|
2017-09-01 21:40:43 +03:00
|
|
|
mnt_block += "<a href='javascript:void(0)' onClick='unmount(selected_node, a.quorum[selected_node].mounts[i].mountpoint, a.quorum[selected_node].mounts[i].block)' >unmount</a><br>Mountpoint: "
|
2017-08-31 00:52:20 +03:00
|
|
|
+ mnt.mountpoint + "<br>Mountopts: "
|
|
|
|
+ mnt.mountopts + "<br>Fstype: "
|
|
|
|
+ mnt.fstype +
|
|
|
|
"<br>Pool: " + mnt.pool +
|
|
|
|
"<br>Image: " + mnt.image +
|
|
|
|
"<br>Block: " + mnt.block +"<br>";
|
|
|
|
}
|
|
|
|
$("#mon").html(mnt_block);
|
|
|
|
}
|
|
|
|
else { $("#mon").html("")}
|
|
|
|
}
|
2017-09-01 17:42:27 +03:00
|
|
|
if (selected_node =='dead') {
|
2017-08-31 00:52:20 +03:00
|
|
|
var t, up_formatted
|
|
|
|
if (a.deadlyreason["updated"] != 0) {
|
|
|
|
t = new Date(a.deadlyreason["updated"] * 1000)
|
|
|
|
up_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
|
|
|
|
} else { up_formatted=0 }
|
|
|
|
deadNode = a.deadlyreason["node"];
|
|
|
|
$("#name").html(a.deadlyreason["node"]);
|
|
|
|
$("#ipv4").html(a.deadlyreason["ip"]["v4"].join("<br>"));
|
|
|
|
$("#ipv6").html(a.deadlyreason["ip"]["v6"].join("<br>"));
|
|
|
|
$("#updated").html(up_formatted);
|
|
|
|
if (a.deadlyreason["mounts"] != null) {
|
|
|
|
var mnt_block = "";
|
|
|
|
for (i in a.deadlyreason.mounts) {
|
|
|
|
var mnt = a.deadlyreason.mounts[i];
|
|
|
|
mnt_block += mnt.mountpoint + "<br>" + mnt.mountopts + "<br>" + mnt.fstype + "<br>" + mnt.pool + "<br>" + mnt.image + "<br><br>";
|
|
|
|
}
|
|
|
|
$("#mon").html(mnt_block);
|
|
|
|
} else { $("#mon").html("") }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function openNode(evt, nodeName) {
|
|
|
|
var i, x, tablinks;
|
2017-09-01 17:42:27 +03:00
|
|
|
selected_node = nodeName;
|
2017-08-31 00:52:20 +03:00
|
|
|
x = document.getElementsByClassName("node");
|
|
|
|
tablinks = document.getElementsByClassName("tablink");
|
2017-09-01 17:42:27 +03:00
|
|
|
if (selected_node == 'dead') {
|
2017-08-31 00:52:20 +03:00
|
|
|
$('#details').css("border", "2px solid #f44336");
|
|
|
|
if ($('#showDeadlyDetails').html() == "Show details") {
|
|
|
|
$('#details').css("display", "block");
|
|
|
|
$('#showDeadlyDetails').text('Hide details');
|
|
|
|
} else {
|
|
|
|
$('#details').css("display", "none");
|
|
|
|
$('#showDeadlyDetails').text('Show details');
|
|
|
|
}
|
|
|
|
} else {$('#details').css("border", "").css("display", "block") }
|
|
|
|
}
|