diff --git a/endpoint.js b/endpoint.js index b6b61410e52c1b4593f291668c0f4a75769c7dc5..53600d88e2d6867fcc56462dc306739d4ffc3f25 100644 --- a/endpoint.js +++ b/endpoint.js @@ -178,7 +178,6 @@ class BMAEndpoint{ is_member = async function() { let url = this.url_protocol + this.url_root + '/wot/identity-of/' + this.pubkey - console.log(url) return fetch(url) .then(response => response.json()) .then(data => { diff --git a/node.js b/node.js index 4ed6dd2c8c5859a8c9def2a468daaabb456e7be8..c01afc916ef6d516b9779b70589682caa9efb90e 100644 --- a/node.js +++ b/node.js @@ -2,6 +2,7 @@ class DuniterNodes { constructor (peers) { this.fields = ['url_root', 'head_block', 'type', 'speed', 'version', 'member'] + this.forget_versions = ['ø', '1.9.0'] this.ep_body = document.createElement('tbody') this.draw() @@ -98,31 +99,47 @@ class DuniterNodes this.ep_table.appendChild(this.ep_body) let consensus_block = this.getConsensusBlock() + let last_version = this.getLastVersion() let rows = this.ep_body.childNodes rows.forEach(row => { let cells = row.childNodes switch (cells[1].innerText) { case consensus_block: - cells[1].setAttribute('class', 'consensus') + cells[1].setAttribute('class', 'ok') break case 'undefined': - cells[1].setAttribute('class', 'unreachable') + cells[1].setAttribute('class', 'empty') break case 'ø': - cells[1].setAttribute('class', 'unreachable') + cells[1].setAttribute('class', 'empty') break default: - cells[1].setAttribute('class', 'desynchronized') + cells[1].setAttribute('class', 'warn') break } switch(cells[5].innerText) { case 'Oui': - cells[5].setAttribute('class', 'consensus') + cells[5].setAttribute('class', 'ok') break case 'Non': - cells[5].setAttribute('class', 'desynchronized') + cells[5].setAttribute('class', 'warn') + break + } + + switch(cells[4].innerText) { + case last_version: + cells[4].setAttribute('class', 'ok') + break + case 'undefined': + cells[4].setAttribute('class', 'empty') + break + case 'ø': + cells[4].setAttribute('class', 'empty') + break + default: + cells[4].setAttribute('class', 'warn') break } }) @@ -144,4 +161,20 @@ class DuniterNodes return consensus_block } + + getLastVersion() { + if (this.count_blocks == undefined) { + return 0 + } + + let max_version = '' + this.endpoints.forEach((ep) => { + if (ep.version > max_version && ! this.forget_versions.find( elt => elt == ep.version)) { + max_version = ep.version + } + }) + + console.log('max version', max_version) + return String(max_version) + } } \ No newline at end of file diff --git a/style.css b/style.css index 2c7e1a656431bcd8f41e0bc03014a8d588776b20..b775353db17b1426c7e428df00ae530fd0b506d5 100644 --- a/style.css +++ b/style.css @@ -86,13 +86,13 @@ table, td, th { background-color: rgba(255, 255, 255, 0.5); } -.consensus { +.ok { background-color: lightgreen; } -.unreachable { +.empty { } -.desynchronized { +.warn { background-color: orange; }