From 6c95694d277337d4d4723cc279341e5222b9ef3e Mon Sep 17 00:00:00 2001 From: baxy Date: Mon, 18 Feb 2019 21:15:16 +0200 Subject: [PATCH 1/3] Show correct min/max values for BigChart component --- app/components/NetStats/BigChart/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/components/NetStats/BigChart/index.js b/app/components/NetStats/BigChart/index.js index 9b3417f..e7a1e76 100644 --- a/app/components/NetStats/BigChart/index.js +++ b/app/components/NetStats/BigChart/index.js @@ -33,6 +33,7 @@ class BigChart extends Component { let data = []; let RoundedBar; let min; + let min2; let max; let avg = 0; let sum = 0; @@ -53,13 +54,13 @@ class BigChart extends Component { ); }; if (hasDomain && chartStateData) { - min = Math.min(...data.map(item => item[dataKey])); + min = min2 = Math.min(...data.map(item => item[dataKey])); max = Math.max(...data.map(item => item[dataKey])); if (min === max) { min = 0; } if (dataKey === 'ethstats:blockTime') { - minValueString = min + 's'; + minValueString = min2 + 's'; maxValueString = max + 's'; sum = 0; for (let i = 0; i < chartStateData.length; i++) { @@ -68,7 +69,7 @@ class BigChart extends Component { avg = sum / chartStateData.length; chartColor = '#2774FE'; } else if (dataKey === 'ethon:blockDifficulty') { - minValueString = convertHashes(min, 4); + minValueString = convertHashes(min2, 4); maxValueString = convertHashes(max, 4); sum = new BigNumber(0); for (let i = 0; i < data.length; i++) { @@ -78,7 +79,7 @@ class BigChart extends Component { avg = avg.toString(); chartColor = '#EFC865'; } else if (dataKey === 'ethon:blockGasLimit') { - minValueString = numberWithCommas(min) + 'gas'; + minValueString = numberWithCommas(min2) + 'gas'; maxValueString = numberWithCommas(max) + 'gas'; sum = new BigNumber(0); for (let i = 0; i < data.length; i++) { From 08917b829e4e686b4d0a88a427b18bb17e8e4fa3 Mon Sep 17 00:00:00 2001 From: baxy Date: Mon, 18 Feb 2019 22:55:13 +0200 Subject: [PATCH 2/3] Added config AVG_GAS_PRICE_ENABLED --- .../NetStats/BigChartsSectionItem/index.js | 3 ++- app/components/NetStats/NodeItem/index.js | 2 +- app/routes/pages/NetworkStatistics/index.js | 17 +++++++++++------ app/utils/helpers.js | 2 +- config.js.example | 3 ++- set-env-vars.js | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/components/NetStats/BigChartsSectionItem/index.js b/app/components/NetStats/BigChartsSectionItem/index.js index efbabf6..4a25241 100644 --- a/app/components/NetStats/BigChartsSectionItem/index.js +++ b/app/components/NetStats/BigChartsSectionItem/index.js @@ -11,6 +11,7 @@ import PropTypes from 'prop-types'; import RightContainer from './RightContainer'; import TopLeft from './TopLeft/index'; import TopRight from './TopRight/index'; +import { AVG_GAS_PRICE_ENABLED } from 'config'; class BigChartsSectionItem extends React.Component { render() { @@ -26,7 +27,7 @@ class BigChartsSectionItem extends React.Component { - + {(topRightReducer !== 'pendingLastBlock' || (topRightReducer === 'pendingLastBlock' && AVG_GAS_PRICE_ENABLED)) && } diff --git a/app/components/NetStats/NodeItem/index.js b/app/components/NetStats/NodeItem/index.js index d7e0108..5db0f76 100644 --- a/app/components/NetStats/NodeItem/index.js +++ b/app/components/NetStats/NodeItem/index.js @@ -231,7 +231,7 @@ class NodeItem extends React.Component { {lastBlockUnclesCount} diff --git a/app/routes/pages/NetworkStatistics/index.js b/app/routes/pages/NetworkStatistics/index.js index 3cbe85e..f0b950b 100644 --- a/app/routes/pages/NetworkStatistics/index.js +++ b/app/routes/pages/NetworkStatistics/index.js @@ -19,6 +19,7 @@ import { loadBlockPropagation as loadBlockPropagationAction } from 'actions/bloc import { loadMinersTop as loadMinersTopAction } from 'actions/minersTop'; import { loadPendingLastBlock as loadPendingLastBlockAction } from 'actions/pendingLastBlock'; import { startTickTimer, stopTickTimer } from 'actions/global'; +import { AVG_GAS_PRICE_ENABLED } from 'config'; class NetworkStatistics extends React.Component { componentDidMount() { @@ -40,9 +41,11 @@ class NetworkStatistics extends React.Component { }); }); }); - DsService.getRawRecord('pending/v2/lastBlockData').then( ( record ) => { - record.subscribe(this.handlePendingLastBlockSubscribe.bind(this), true); - }); + if (AVG_GAS_PRICE_ENABLED) { + DsService.getRawRecord('pending/v2/lastBlockData').then((record) => { + record.subscribe(this.handlePendingLastBlockSubscribe.bind(this), true); + }); + } } componentWillUnmount() { this.props.dispatch(stopTickTimer()); @@ -63,9 +66,11 @@ class NetworkStatistics extends React.Component { } }); }); - DsService.getRawRecord('pending/lastBlockData').then( ( record ) => { - record.unsubscribe(); - }); + if (AVG_GAS_PRICE_ENABLED) { + DsService.getRawRecord('pending/v2/lastBlockData').then((record) => { + record.unsubscribe(); + }); + } } handlePendingLastBlockSubscribe(data) { this.props.dispatch(loadPendingLastBlockAction(data)); diff --git a/app/utils/helpers.js b/app/utils/helpers.js index a235f69..60aaf79 100644 --- a/app/utils/helpers.js +++ b/app/utils/helpers.js @@ -130,7 +130,7 @@ export function convertHashes(hashes, decimals = 2) { let unit = ''; if(hashes !== 0 && hashes < 1000) { - result = hashes; + result = parseInt(hashes, 10); unit = ''; } diff --git a/config.js.example b/config.js.example index f363a22..af803a3 100644 --- a/config.js.example +++ b/config.js.example @@ -5,5 +5,6 @@ const config = { DS_PASS: '', DS_NAMESPACE: 'ethstats/', EXPLORER_URL: '', - PRIVACY_POLICY: false + PRIVACY_POLICY: false, + AVG_GAS_PRICE_ENABLED: true }; diff --git a/set-env-vars.js b/set-env-vars.js index f57df4b..da1496d 100755 --- a/set-env-vars.js +++ b/set-env-vars.js @@ -25,7 +25,7 @@ config = JSON.parse(config); Object.keys(config).forEach(item => { if (process.env[item]) { - if (item === 'PRIVACY_POLICY') { + if (item === 'PRIVACY_POLICY' || item === 'AVG_GAS_PRICE_ENABLED') { config[item] = process.env[item] === 'true'; } else { config[item] = process.env[item]; From 88c785e38d79a2111580df4dc8395c55c4466230 Mon Sep 17 00:00:00 2001 From: baxy Date: Mon, 18 Feb 2019 22:57:25 +0200 Subject: [PATCH 3/3] v1.1.6 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fdd64b..75395d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## [1.1.6] - 2019-02-18 +- Show correct min/max values for the big charts +- Added config AVG_GAS_PRICE_ENABLED + ## [1.1.5] - 2019-02-16 - If all bars in a chart have the same value the domain "min" value should be 0 - Fixed "Last Miners" chart diff --git a/package.json b/package.json index 4b1b2bc..c4027f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ethstats-network-dashboard", - "version": "1.1.5", + "version": "1.1.6", "description": "EthStats - Network Monitor - Dashboard (net.ethstats.io)", "homepage": "https://github.com/alethio/ethstats-network-dashboard", "repository": "git@github.com:alethio/ethstats-network-dashboard.git",