Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Cleanup the Status View (#5317)
Browse files Browse the repository at this point in the history
* Better view of Settings and Mining Settings

* Cleanup Status view

* Node Logs refactoring

* Cleanup Status

* Move RPC Calls files

* Basic Peers view

* Add Peers table

* style table header
  • Loading branch information
ngotchac authored and gavofyork committed Mar 29, 2017
1 parent 8930f51 commit 5fa0881
Show file tree
Hide file tree
Showing 101 changed files with 771 additions and 869 deletions.
4 changes: 1 addition & 3 deletions js/src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
import { newError } from '~/ui/Errors/actions';
import { setAddressImage } from './providers/imagesActions';
import { openSnackbar, showSnackbar } from './providers/snackbarActions';
import { clearStatusLogs, toggleStatusLogs, toggleStatusRefresh } from './providers/statusActions';
import { toggleStatusRefresh } from './providers/statusActions';
import { toggleView } from '~/views/Settings/actions';

export {
newError,
clearStatusLogs,
setAddressImage,
openSnackbar,
showSnackbar,
toggleStatusLogs,
toggleStatusRefresh,
toggleView
};
4 changes: 1 addition & 3 deletions js/src/redux/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import ErrorsMiddleware from '~/ui/Errors/middleware';
import SettingsMiddleware from '~/views/Settings/middleware';
import SignerMiddleware from './providers/signerMiddleware';

import statusMiddleware from '~/views/Status/middleware';
import CertificationsMiddleware from './providers/certifications/middleware';
import ChainMiddleware from './providers/chainMiddleware';
import RegistryMiddleware from './providers/registry/middleware';
Expand All @@ -44,8 +43,7 @@ export default function (api, browserHistory, forEmbed = false) {
middleware.push(certifications, registry);
}

const status = statusMiddleware();
const routeMiddleware = browserHistory ? routerMiddleware(browserHistory) : [];

return middleware.concat(status, routeMiddleware, thunk);
return middleware.concat(routeMiddleware, thunk);
}
117 changes: 15 additions & 102 deletions js/src/redux/providers/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { LOG_KEYS, getLogger } from '~/config';
import UpgradeStore from '~/modals/UpgradeParity/store';

import BalancesProvider from './balances';
import { statusBlockNumber, statusCollection, statusLogs } from './statusActions';
import { statusBlockNumber, statusCollection } from './statusActions';

const log = getLogger(LOG_KEYS.Signer);
let instance = null;
Expand Down Expand Up @@ -59,14 +59,21 @@ export default class Status {
return instance;
}

static get () {
if (!instance) {
throw new Error('The Status Provider has not been initialized yet');
}

return instance;
}

start () {
log.debug('status::start');

Promise
.all([
this._subscribeBlockNumber(),

this._pollLogs(),
this._pollLongStatus(),
this._pollStatus()
])
Expand Down Expand Up @@ -187,25 +194,12 @@ export default class Status {
return Promise.resolve();
}

const { refreshStatus } = this._store.getState().nodeStatus;

const statusPromises = [ this._api.eth.syncing() ];

if (refreshStatus) {
statusPromises.push(this._api.parity.netPeers());
statusPromises.push(this._api.eth.hashrate());
}
const statusPromises = [ this._api.eth.syncing(), this._api.parity.netPeers() ];

return Promise
.all(statusPromises)
.then(([ syncing, ...statusResults ]) => {
const status = statusResults.length === 0
? { syncing }
: {
syncing,
netPeers: statusResults[0],
hashrate: statusResults[1]
};
.then(([ syncing, netPeers ]) => {
const status = { netPeers, syncing };

if (!isEqual(status, this._status)) {
this._store.dispatch(statusCollection(status));
Expand All @@ -220,39 +214,6 @@ export default class Status {
});
}

/**
* Miner settings should never changes unless
* Parity is restarted, or if the values are changed
* from the UI
*/
_pollMinerSettings = () => {
return Promise
.all([
this._api.eth.coinbase(),
this._api.parity.extraData(),
this._api.parity.minGasPrice(),
this._api.parity.gasFloorTarget()
])
.then(([
coinbase, extraData, minGasPrice, gasFloorTarget
]) => {
const minerSettings = {
coinbase,
extraData,
minGasPrice,
gasFloorTarget
};

if (!isEqual(minerSettings, this._minerSettings)) {
this._store.dispatch(statusCollection(minerSettings));
this._minerSettings = minerSettings;
}
})
.catch((error) => {
console.error('_pollMinerSettings', error);
});
}

/**
* The data fetched here should not change
* unless Parity is restarted. They are thus
Expand All @@ -272,23 +233,16 @@ export default class Status {
this._timeoutIds.longStatus = setTimeout(() => this._pollLongStatus(), timeout);
};

// Poll Miner settings just in case
const minerPromise = this._pollMinerSettings();

const mainPromise = Promise
return Promise
.all([
this._api.parity.netPeers(),
this._api.web3.clientVersion(),
this._api.net.version(),
this._api.parity.defaultExtraData(),
this._api.parity.netChain(),
this._api.parity.netPort(),
this._api.parity.rpcSettings(),
this._api.parity.enode().then((enode) => enode).catch(() => '-'),
this._upgradeStore.checkUpgrade()
])
.then(([
netPeers, clientVersion, netVersion, defaultExtraData, netChain, netPort, rpcSettings, enode, upgradeStatus
netPeers, clientVersion, netVersion, netChain, upgradeStatus
]) => {
const isTest = [
'2', // morden
Expand All @@ -299,13 +253,9 @@ export default class Status {
const longStatus = {
netPeers,
clientVersion,
defaultExtraData,
netChain,
netPort,
netVersion,
rpcSettings,
isTest,
enode
isTest
};

if (!isEqual(longStatus, this._longStatus)) {
Expand All @@ -319,42 +269,5 @@ export default class Status {
.then(() => {
nextTimeout(60000);
});

return Promise.all([ minerPromise, mainPromise ]);
}

_pollLogs = () => {
const nextTimeout = (timeout = 1000) => {
if (this._timeoutIds.logs) {
clearTimeout(this._timeoutIds.logs);
}

this._timeoutIds.logs = setTimeout(this._pollLogs, timeout);
};

const { devLogsEnabled } = this._store.getState().nodeStatus;

if (!devLogsEnabled) {
nextTimeout();
return Promise.resolve();
}

return Promise
.all([
this._api.parity.devLogs(),
this._api.parity.devLogsLevels()
])
.then(([devLogs, devLogsLevels]) => {
this._store.dispatch(statusLogs({
devLogs: devLogs.slice(-1024),
devLogsLevels
}));
})
.catch((error) => {
console.error('_pollLogs', error);
})
.then(() => {
return nextTimeout();
});
}
}
27 changes: 0 additions & 27 deletions js/src/redux/providers/statusActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,3 @@ export function statusCollection (collection) {
collection
};
}

export function statusLogs (logInfo) {
return {
type: 'statusLogs',
logInfo
};
}

export function toggleStatusLogs (devLogsEnabled) {
return {
type: 'toggleStatusLogs',
devLogsEnabled
};
}

export function clearStatusLogs () {
return {
type: 'clearStatusLogs'
};
}

export function toggleStatusRefresh (refreshStatus) {
return {
type: 'toggleStatusRefresh',
refreshStatus
};
}
38 changes: 2 additions & 36 deletions js/src/redux/providers/statusReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,20 @@ const DEFAULT_NETCHAIN = '(unknown)';
const initialState = {
blockNumber: new BigNumber(0),
blockTimestamp: new Date(),
devLogs: [],
devLogsLevels: null,
devLogsEnabled: false,
clientVersion: '',
coinbase: '',
defaultExtraData: '',
enode: '',
extraData: '',
gasFloorTarget: new BigNumber(0),
gasLimit: new BigNumber(0),
hashrate: new BigNumber(0),
minGasPrice: new BigNumber(0),
netChain: DEFAULT_NETCHAIN,
netPeers: {
active: new BigNumber(0),
connected: new BigNumber(0),
max: new BigNumber(0)
max: new BigNumber(0),
peers: []
},
netPort: new BigNumber(0),
netVersion: '0',
rpcSettings: {},
syncing: true,
isConnected: false,
isConnecting: false,
isTest: undefined,
refreshStatus: false,
traceMode: undefined
};

Expand All @@ -61,28 +49,6 @@ export default handleActions({
const { collection } = action;

return Object.assign({}, state, collection);
},

statusLogs (state, action) {
const { logInfo } = action;

return Object.assign({}, state, logInfo);
},

toggleStatusLogs (state, action) {
const { devLogsEnabled } = action;

return Object.assign({}, state, { devLogsEnabled });
},

clearStatusLogs (state, action) {
return Object.assign({}, state, { devLogs: [] });
},

toggleStatusRefresh (state, action) {
const { refreshStatus } = action;

return Object.assign({}, state, { refreshStatus });
}
}, initialState);

Expand Down
23 changes: 17 additions & 6 deletions js/src/ui/Form/AddressSelect/addressSelect.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,32 @@
}
}

.inputAddress {
.copy {
margin-right: 0.5em;
}

.inputAddressContainer {
display: flex;
flex-direction: row;
align-items: baseline;
position: relative;
}

.inputAddress {
flex: 1;

&:hover, *:hover {
&:focus {
outline: none;
}

> *:hover {
cursor: text !important;
}
}

.main {
position: relative;
left: 0;

&:focus {
outline: none;
}
}

.title {
Expand Down
Loading

0 comments on commit 5fa0881

Please sign in to comment.