Skip to content

Commit

Permalink
Merge pull request #8 from Alethio/v.1.1.6
Browse files Browse the repository at this point in the history
V.1.1.6
  • Loading branch information
baxy authored Feb 18, 2019
2 parents 7b99cd0 + 88c785e commit 9667132
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions app/components/NetStats/BigChart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BigChart extends Component {
let data = [];
let RoundedBar;
let min;
let min2;
let max;
let avg = 0;
let sum = 0;
Expand All @@ -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++) {
Expand All @@ -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++) {
Expand All @@ -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++) {
Expand Down
3 changes: 2 additions & 1 deletion app/components/NetStats/BigChartsSectionItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -26,7 +27,7 @@ class BigChartsSectionItem extends React.Component {
<Icon name={iconName} />
</ChartIcon>
<FlexRow>
<TopRight color={color} mainTitle={thirdTitle} reducerName={topRightReducer}/>
{(topRightReducer !== 'pendingLastBlock' || (topRightReducer === 'pendingLastBlock' && AVG_GAS_PRICE_ENABLED)) && <TopRight color={color} mainTitle={thirdTitle} reducerName={topRightReducer}/>}
</FlexRow>
<BigChart valuePrefix={valuePrefix} labelPrefix={labelPrefix} color={color} dataKey={dataKey} measureUnit={measureUnit} tooltipKey={tooltipKey} hasDomain={hasDomain} chartReducer={chartReducer} hasNavigation/>
</RightContainer>
Expand Down
2 changes: 1 addition & 1 deletion app/components/NetStats/NodeItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class NodeItem extends React.Component {
<Detail width="55px" color={colors.nameColor} data-tip data-for={`viewDetails-${shortNodeName}`}>{lastBlockUnclesCount}</Detail>
<Counter
nodeIsActive={data['ethstats:nodeData']['ethstats:nodeIsActive']}
receivedTimestamp={data['ethstats:nodeBlockData'] && data['ethstats:nodeBlockData']['ethstats:receivedTimestamp']}
receivedTimestamp={data['ethstats:nodeBlockData'] && data['ethstats:nodeBlockData']['ethstats:receivedTimestamp'].toString()}
blockNumber={data['ethstats:nodeBlockData'] && parseInt(data['ethstats:nodeBlockData']['ethon:number'], 10)}
syncBlockNumber={data['ethstats:nodeSyncInfo'] && parseInt(data['ethstats:nodeSyncInfo']['ethstats:currentBlock'], 10)}
/>
Expand Down
17 changes: 11 additions & 6 deletions app/routes/pages/NetworkStatistics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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());
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion app/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function convertHashes(hashes, decimals = 2) {
let unit = '';

if(hashes !== 0 && hashes < 1000) {
result = hashes;
result = parseInt(hashes, 10);
unit = '';
}

Expand Down
3 changes: 2 additions & 1 deletion config.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ const config = {
DS_PASS: '',
DS_NAMESPACE: 'ethstats/',
EXPLORER_URL: '',
PRIVACY_POLICY: false
PRIVACY_POLICY: false,
AVG_GAS_PRICE_ENABLED: true
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]:alethio/ethstats-network-dashboard.git",
Expand Down
2 changes: 1 addition & 1 deletion set-env-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 9667132

Please sign in to comment.