From 14dd54cc735c9d061d3cac2df008ac76b87b1787 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 29 Mar 2018 15:50:53 -0500 Subject: [PATCH] WebUI fixes to accommodate API changes --- webui/assets/main.js | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/webui/assets/main.js b/webui/assets/main.js index 6a4415a5c..d38da454c 100644 --- a/webui/assets/main.js +++ b/webui/assets/main.js @@ -254,12 +254,12 @@ function populate_version() { xhr.onload = function() { var version = JSON.parse(xhr.responseText)['version'] - var version_major_minor = /(v\d+\.\d+)/.exec(version)[0] + var version_major_minor = /v?(\d+\.\d+).*/.exec(version)[1] var doc_link = document.getElementById('nav-documentation') doc_link.onclick = function() { - window.open('https://www.pilosa.com/docs/' + version_major_minor + '/introduction/') + window.open('https://www.pilosa.com/docs/v' + version_major_minor + '/introduction/') } - node.innerHTML = version + node.innerHTML = "Pilosa v" + version } xhr.send(null) } @@ -295,12 +295,19 @@ function set_active_pane_by_name(name) { function update_cluster_status() { var xhr = new XMLHttpRequest(); xhr.open('GET', '/status') - status_node = document.getElementById('status') xhr.onload = function() { var status = JSON.parse(xhr.responseText) render_status(status) } xhr.send(null) + + var xhrSchema = new XMLHttpRequest(); + xhrSchema.open('GET', '/schema') + xhrSchema.onload = function() { + var schema = JSON.parse(xhrSchema.responseText) + render_schema(schema) + } + xhrSchema.send(null) } function render_status(status) { @@ -310,7 +317,7 @@ function render_status(status) { nodes_div.removeChild(nodes_div.firstChild); } - var nodes = status["status"]["Nodes"] + var nodes = status["nodes"] table = document.createElement("table") tbody = document.createElement("tbody") table.appendChild(tbody) @@ -320,31 +327,35 @@ function render_status(status) { var header = document.createElement('tr') markup = `Host - State` + ID + Coordinator` header.innerHTML = markup tbody.appendChild(header) for(var n=0; n${nodes[n]["Host"]} - ${nodes[n]["State"]}` + markup = `${nodes[n]["uri"]["host"]}:${nodes[n]["uri"]["port"]} + ${nodes[n]["id"]} + ${nodes[n]["isCoordinator"]}` row.innerHTML = markup tbody.appendChild(row) } nodes_div.appendChild(table) +} +function render_schema(schema) { // render index tables var indexes_div = document.getElementById("status-indexes") while (indexes_div.firstChild) { indexes_div.removeChild(indexes_div.firstChild); } - var indexes = nodes[0]["Indexes"] // TODO currently comes from only node 0 + var indexes = schema["indexes"] // TODO currently comes from only node 0 for(var n=0; n${frames[m]["Name"]} - ${frames[m]["Meta"]["CacheType"]} - ${frames[m]["Meta"]["CacheSize"]}` + row.innerHTML = `${frames[m]["name"]} + ${frames[m]["options"]["cacheType"]} + ${frames[m]["options"]["cacheSize"]}` tbody.appendChild(row) } } @@ -583,4 +594,4 @@ function parse_options(option_str) { } } return options; -} \ No newline at end of file +}