From 0a7fe8226a4ffda125d1e26c564d3c78cd133bb2 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Sat, 9 May 2020 12:53:21 +0200 Subject: [PATCH] [add] network: heads: explicitely show prefered/privileged nodes we don't have HEAD information yet --- .../home/tabs/HomeConnectionsController.js | 37 ++++++++++++++++++- app/styles/main.styl | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app/js/controllers/main/home/tabs/HomeConnectionsController.js b/app/js/controllers/main/home/tabs/HomeConnectionsController.js index 1509e8c..2991c1b 100644 --- a/app/js/controllers/main/home/tabs/HomeConnectionsController.js +++ b/app/js/controllers/main/home/tabs/HomeConnectionsController.js @@ -1,7 +1,9 @@ "use strict"; module.exports = ($scope, Webmin, heads, info, conf, ws) => { - + + const SPECIFIC_SUFFIX = '--------' + const UNKNOWN_VALUE = '-' $scope.discriminateNodes = (info) => { info.connections.level1.concat(info.connections.level2).forEach(c => { c.prefered = (conf.preferedNodes || []).indexOf(c.pubkey) !== -1 @@ -15,6 +17,34 @@ module.exports = ($scope, Webmin, heads, info, conf, ws) => { const headsMap = {} + $scope.removeBlanks = (confPrefPriv, headsMap) => { + for (const pp of confPrefPriv) { + const ws2pFullId = pp + '-' + SPECIFIC_SUFFIX + if (headsMap[ws2pFullId]) { + delete headsMap[ws2pFullId] + } + } + } + + $scope.addBlanks = (confPrefPriv, headsMap) => { + const pubkeys = Object.keys(headsMap).map(k => k.split('-')[0]) + const unknown = confPrefPriv.filter(pub => !pubkeys.includes(pub)) + for (const pp of unknown) { + const ws2pFullId = pp + '-' + SPECIFIC_SUFFIX + headsMap[ws2pFullId] = { + api: UNKNOWN_VALUE, + blockstamp: UNKNOWN_VALUE, + uid: UNKNOWN_VALUE, + ws2pId: UNKNOWN_VALUE, + software: UNKNOWN_VALUE, + softVersion: UNKNOWN_VALUE, + prefix: UNKNOWN_VALUE, + freeRooms: UNKNOWN_VALUE, + step: UNKNOWN_VALUE + } + } + } + $scope.headsIntoMap = (heads) => { for (const value of heads) { const sp = value.message.split(':') @@ -48,6 +78,11 @@ module.exports = ($scope, Webmin, heads, info, conf, ws) => { api, blockstamp, uid, ws2pId, software, softVersion, prefix, freeRooms, step } } + + const confPreferedPrivileged = conf.preferedNodes.concat(conf.privilegedNodes) + $scope.removeBlanks(confPreferedPrivileged, headsMap) + $scope.addBlanks(confPreferedPrivileged, headsMap) + $scope.heads = Object.keys(headsMap).map(k => { const pubkey = k.split('-')[0] return { diff --git a/app/styles/main.styl b/app/styles/main.styl index b4245ed..8f49354 100644 --- a/app/styles/main.styl +++ b/app/styles/main.styl @@ -413,7 +413,7 @@ blockquote.info } .legend span { - width: 500px; + width: 100%; display: block; margin-bottom: 4px; } \ No newline at end of file -- GitLab