From f3dcba2cf77804dfc5abc5becda7743ed88d923b Mon Sep 17 00:00:00 2001 From: Anna Date: Tue, 27 Mar 2018 14:03:54 +0300 Subject: [PATCH] upd --- static/rbmd/script.js | 100 ++++++++++---------------------------- templates/rbmd/index.html | 2 +- 2 files changed, 27 insertions(+), 75 deletions(-) diff --git a/static/rbmd/script.js b/static/rbmd/script.js index 54b4618..842c70c 100644 --- a/static/rbmd/script.js +++ b/static/rbmd/script.js @@ -1,5 +1,5 @@ - var a, selected_node, deadNode, node2; + $(function() { var url = "ws://" + location.host + "/socket"; var ws = new WebSocket(url); @@ -10,30 +10,27 @@ $(function() { displayData(a); }; -$('#mountForm').submit(function(event){ - event.preventDefault(); - $.ajax({ - url:"mount", - data:$(this).serialize(), - method:'POST', - success:function(data){ - $('#mount').css('display', 'none'); - $('input[type = "text"]').val(''); - 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" ) - } - } + $('#mountForm').submit(function(event){ + event.preventDefault(); + $.ajax({url:"mount", data:$(this).serialize(), method:'POST', + success:function(data){ + $('#mount').css('display', 'none'); + $('input[type = "text"]').val(''); + 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" ) + } + } + }) }) -}) - $('.tablink').css('display', 'block'); + $('.tablink').css('display', 'block'); $('#mountFormTrigger').click(function(event){ var htmlSelect = ''; @@ -41,54 +38,7 @@ $('#mountForm').submit(function(event){ htmlSelect += ""; }) $('#selectNode').html(htmlSelect); - /* - $.ajax({ - url:"status", - success:function(data){ - var status = JSON.parse(data); - var htmlSelect = ''; - for (n in status["quorum"]) { htmlSelect += "";} - $('#selectNode').html(htmlSelect); - } - }) - */ - }) - - - // var ws = new WebSocket('{{escape(ws)}}'); - // var cluster, selected_node, deadNode, node2; - // ws.onopen = function() {ws.send(""); }; - // ws.onmessage = function (evt) { - // cluster = JSON.parse(evt.data); - // displayData(cluster); - // }; - - // $('#mountForm').submit(function(event){ - // - // event.preventDefault(); - // $.ajax({ - // url:"mount", - // data:$(this).serialize(), - // method:'POST', - // success:function(data){ - // console.log(data); - // $('#mount').css('display', 'none'); - // $('input[type = "text"]').val(''); - // 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 resolve() { @@ -101,12 +51,12 @@ function resolve() { }) } -function unmount(a, b, c) { //selected_node, mountpoint, block - var u = confirm(a + ": confirm unmount of " + b); +function unmount(node, mountpoint, block) { //selected_node, mountpoint, block + var u = confirm(node + ": confirm unmount of " + mountpoint); if (u == true) { $.ajax({ url:"unmount", - data:{"node":a, "mountpoint":b, "block":c}, + data:{"node": node, "mountpoint": mountpoint, "block": block}, success:function(data){ var res = JSON.parse(data); message = "

" + res["state"] + "

"+ res["message"] +"

"; @@ -229,11 +179,13 @@ function displayData(a){ } function openNode(evt, nodeName) { -// console.log(nodeName); var i, x, tablinks; selected_node = nodeName; x = document.getElementsByClassName("node"); tablinks = document.getElementsByClassName("tablink"); + if (selected_node != deadNode) { + $('#details').css("border", "2px solid #f44336"); + } // if (selected_node == 'dead') { // // if (selected_node == deadNode) { // $('#details').css("border", "2px solid #f44336"); diff --git a/templates/rbmd/index.html b/templates/rbmd/index.html index c761664..716bb96 100644 --- a/templates/rbmd/index.html +++ b/templates/rbmd/index.html @@ -29,7 +29,7 @@

Leader:

Nodes:

- + {{!node}}

Metrics: