$(function() { $('#mountFormTrigger').click(function(event){ $.ajax({ url:"get_status.php", success:function(data){ var status = JSON.parse(data); var htmlSelect = ''; for (n in status["quorum"]) { htmlSelect += "";} $('#selectNode').html(htmlSelect); console.log(htmlSelect);} }) }) }); $('#mountFormTrigger').click(function(event){ $.ajax({ url:"get_status.php", success:function(data){ var status = JSON.parse(data); var htmlSelect = ''; for (n in status["quorum"]) { htmlSelect += "";} $('#selectNode').html(htmlSelect); console.log(htmlSelect);} }) }) $(function() { console.log( "ready!" ); }); function resolve() { $.ajax({ url:"resolve.php", 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({ url:"unmount.php", data:{"node":a, "mountpoint":b, "block":c}, success:function(data){ var res = JSON.parse(data); message = "

" + res["state"] + "

"+ res["message"] +"

"; $("#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("

"+a.health+"

"); 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'); if (n != undefined && n != 'dead'){ var t = new Date(a.quorum[n]["updated"] * 1000) var up_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds(); $("#name").html(n); $("#ipv4").html(a.quorum[n]["ip"]["v4"].join("
")); $("#ipv6").html(a.quorum[n]["ip"]["v6"].join("
")); $("#updated").html(up_formatted); if (a.quorum[n]["mounts"] != null) { var mnt_block = ""; for (i in a.quorum[n].mounts) { var mnt = a.quorum[n].mounts[i]; mnt_block += "unmount
Mountpoint: " + mnt.mountpoint + "
Mountopts: " + mnt.mountopts + "
Fstype: " + mnt.fstype + "
Pool: " + mnt.pool + "
Image: " + mnt.image + "
Block: " + mnt.block +"
"; } $("#mon").html(mnt_block); } else { $("#mon").html("")} } if (n =='dead') { 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("
")); $("#ipv6").html(a.deadlyreason["ip"]["v6"].join("
")); $("#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 + "
" + mnt.mountopts + "
" + mnt.fstype + "
" + mnt.pool + "
" + mnt.image + "

"; } $("#mon").html(mnt_block); } else { $("#mon").html("") } } } function openNode(evt, nodeName) { var i, x, tablinks; n = nodeName; x = document.getElementsByClassName("node"); tablinks = document.getElementsByClassName("tablink"); if (n == 'dead') { $('#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") } }