From c18127bf000db83bade209a6054de2d8c6168625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 9 Nov 2019 18:51:04 +0100 Subject: [PATCH] townhall: More colors, weight/height diff --- cmd/lotus-townhall/townhall/src/App.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cmd/lotus-townhall/townhall/src/App.js b/cmd/lotus-townhall/townhall/src/App.js index 058e9e32b..aa6c78996 100644 --- a/cmd/lotus-townhall/townhall/src/App.js +++ b/cmd/lotus-townhall/townhall/src/App.js @@ -1,6 +1,15 @@ import React from 'react'; import './App.css'; +function colForH(besth, height) { + const diff = besth - height + if(diff === 0) return '#6f6' + if(diff === 1) return '#df4' + if(diff < 4) return '#ff0' + if(diff < 10) return '#f60' + return '#f00' +} + class App extends React.Component { constructor(props) { super(props); @@ -21,18 +30,18 @@ class App extends React.Component { } render() { - let best = Object.keys(this.state).map(k => this.state[k]).reduce((p, n) => p > n.Height ? p : n.Height, -1) - console.log(best) + let besth = Object.keys(this.state).map(k => this.state[k]).reduce((p, n) => p > n.Height ? p : n.Height, -1) + let bestw = Object.keys(this.state).map(k => this.state[k]).reduce((p, n) => p > n.Weight ? p : n.Weight, -1) return {Object.keys(this.state).map(k => [k, this.state[k]]).map(([k, v]) => { let mnrs = v.Blocks.map(b =>  m:{b.Miner}) - let l = [, , , ] - if (best !== v.Height) { - l = {l} - } else { + let l = [, + , + , + , + ] l = {l} - } return l })
{k}{v.NodeName}{v.Height}{mnrs}
{k}{v.NodeName}{v.Weight}({bestw - v.Weight}){v.Height}({besth - v.Height}){mnrs}