Bump API, Node info peer id displayed (#630)

* Node info peer id displayed

* Latest API

* Add peer best & countdown to nodeinfo
This commit is contained in:
Jaco Greeff 2019-01-21 12:06:18 +01:00 committed by GitHub
parent 4c301cebc0
commit 3061057e30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 121 additions and 105 deletions

View File

@ -50,7 +50,7 @@ class Peers extends React.PureComponent<Props> {
</tr>
</thead>
<tbody>
{peers.map(this.renderPeer)}
{peers.sort((a, b) => a.index.cmp(b.index)).map(this.renderPeer)}
</tbody>
</table>
</article>

View File

@ -5,23 +5,50 @@
import { I18nProps } from '@polkadot/ui-app/types';
import { Info } from './types';
import BN from 'bn.js';
import React from 'react';
import { CardSummary } from '@polkadot/ui-app/index';
import { BestNumber } from '@polkadot/ui-reactive/index';
import { BestNumber, Elapsed } from '@polkadot/ui-reactive/index';
import { numberFormat } from '@polkadot/ui-reactive/util';
import translate from './translate';
type Props = I18nProps & {
nextRefresh: number;
info: Info;
};
class Summary extends React.PureComponent<Props> {
type State = {
peerBest?: BN
};
class Summary extends React.PureComponent<Props, State> {
state: State = {};
static getDerivedStateFromProps ({ info = {} }: Props): State | null {
if (!info.peers) {
return null;
}
const bestPeer = info.peers.sort((a, b) => b.bestNumber.cmp(a.bestNumber))[0];
return {
peerBest: bestPeer
? bestPeer.bestNumber
: new BN(0)
};
}
render () {
const { info = {}, t } = this.props;
const { info = {}, nextRefresh, t } = this.props;
const { peerBest } = this.state;
return (
<summary>
<section>
<CardSummary label={t('refresh in')}>
<Elapsed value={nextRefresh} />
</CardSummary>
<CardSummary label={t('total peers')}>
{
info.health
@ -51,7 +78,10 @@ class Summary extends React.PureComponent<Props> {
</CardSummary>
</section>
<section>
<CardSummary label={t('best')}>
<CardSummary label={t('peer best')}>
{numberFormat(peerBest)}
</CardSummary>
<CardSummary label={t('our best')}>
<BestNumber />
</CardSummary>
</section>

View File

@ -24,6 +24,7 @@
}
&.peerid {
font-style: italic;
text-align: left;
}

View File

@ -7,12 +7,12 @@ import { AppProps, I18nProps } from '@polkadot/ui-app/types';
import { Info } from './types';
import React from 'react';
import Extrinsics from '@polkadot/app-explorer/BlockByHash/Extrinsics';
import { withApi, withMulti } from '@polkadot/ui-api/index';
import { Health, PeerInfo, PendingExtrinsics } from '@polkadot/types';
import './index.css';
import Extrinsics from '@polkadot/app-explorer/BlockByHash/Extrinsics';
import Peers from './Peers';
import Summary from './Summary';
import translate from './translate';
@ -23,12 +23,15 @@ type Props = ApiProps & AppProps & I18nProps;
type State = {
info?: Info,
nextRefresh: number,
timerId?: number;
};
class App extends React.PureComponent<Props, State> {
private isActive: boolean = true;
state: State = {};
state: State = {
nextRefresh: Date.now()
};
componentDidMount () {
this.getStatus().catch(() => {
@ -48,11 +51,14 @@ class App extends React.PureComponent<Props, State> {
render () {
const { t } = this.props;
const { info = {} } = this.state;
const { info = {}, nextRefresh } = this.state;
return (
<main className='status--App'>
<Summary info={info} />
<Summary
info={info}
nextRefresh={nextRefresh}
/>
<Peers peers={info.peers} />
<Extrinsics
label={t('pending extrinsics')}
@ -69,6 +75,7 @@ class App extends React.PureComponent<Props, State> {
this.setState({
info,
nextRefresh: (Date.now() + POLL_TIMEOUT),
timerId: window.setTimeout(this.getStatus, POLL_TIMEOUT)
});
}

View File

@ -13,17 +13,6 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/app-accounts": "^0.22.31",
"@polkadot/app-addresses": "^0.22.31",
"@polkadot/app-democracy": "^0.22.31",
"@polkadot/app-explorer": "^0.22.31",
"@polkadot/app-extrinsics": "^0.22.31",
"@polkadot/app-rpc": "^0.22.31",
"@polkadot/app-settings": "^0.22.31",
"@polkadot/app-staking": "^0.22.31",
"@polkadot/app-storage": "^0.22.31",
"@polkadot/app-toolbox": "^0.22.31",
"@polkadot/app-transfer": "^0.22.31",
"@polkadot/ui-app": "^0.22.31",
"@polkadot/ui-assets": "^0.25.7",
"@polkadot/ui-signer": "^0.22.31"

View File

@ -31,8 +31,8 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/api": "^0.40.8",
"@polkadot/types": "^0.40.8",
"@polkadot/api": "^0.40.11",
"@polkadot/types": "^0.40.11",
"rxjs-compat": "^6.3.2"
}
}

View File

@ -11,10 +11,10 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/extrinsics": "^0.40.8",
"@polkadot/extrinsics": "^0.40.11",
"@polkadot/keyring": "^0.33.35",
"@polkadot/storage": "^0.40.8",
"@polkadot/types": "^0.40.8",
"@polkadot/storage": "^0.40.11",
"@polkadot/types": "^0.40.11",
"@polkadot/ui-api": "^0.22.31",
"@polkadot/ui-identicon": "^0.25.7",
"@polkadot/ui-keyring": "^0.25.7",

View File

@ -31,8 +31,8 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/api": "^0.40.8",
"@polkadot/types": "^0.40.8",
"@polkadot/api": "^0.40.11",
"@polkadot/types": "^0.40.11",
"rxjs-compat": "^6.3.2"
}
}

View File

@ -8,7 +8,7 @@ import React from 'react';
import { Moment } from '@polkadot/types';
type Props = BareProps & {
value?: Moment | Date
value?: Moment | Date | number
};
type State = {
@ -59,13 +59,13 @@ export default class Elapsed extends React.PureComponent<Props, State> {
);
}
private getDisplayValue (now?: Date, value?: Moment | Date): string {
private getDisplayValue (now?: Date, value?: Moment | Date | number): string {
const tsNow = (now && now.getTime()) || 0;
const tsValue = (value && value.getTime()) || 0;
let display = '-';
const tsValue = (value && ((value as any).getTime ? (value as any).getTime() : value)) || 0;
let display = '0.0s';
if (tsNow && tsValue) {
const elapsed = Math.max(tsNow - tsValue, 0) / 1000;
const elapsed = Math.max(Math.abs(tsNow - tsValue), 0) / 1000;
if (elapsed < 15) {
display = `${elapsed.toFixed(1)}s`;

View File

@ -2,24 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import Balance from './Balance';
import BestFinalised from './BestFinalised';
import BestNumber from './BestNumber';
import Chain from './Chain';
import NodeName from './NodeName';
import NodeVersion from './NodeVersion';
import Nonce from './Nonce';
import TimeNow from './TimeNow';
import TimePeriod from './TimePeriod';
export {
Balance,
BestFinalised,
BestNumber,
Chain,
NodeName,
NodeVersion,
Nonce,
TimeNow,
TimePeriod
};
export { default as Balance } from './Balance';
export { default as BestFinalised } from './BestFinalised';
export { default as BestNumber } from './BestNumber';
export { default as Chain } from './Chain';
export { default as Elapsed } from './Elapsed';
export { default as NodeName } from './NodeName';
export { default as NodeVersion } from './NodeVersion';
export { default as Nonce } from './Nonce';
export { default as TimeNow } from './TimeNow';
export { default as TimePeriod } from './TimePeriod';

104
yarn.lock
View File

@ -1385,31 +1385,31 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
"@polkadot/api-derive@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.40.9.tgz#f9d4877772435751836a6006e5e2c9f7e973d95b"
integrity sha512-TCkRlJP4tjPkuk6RF9175KXjikQzrDgzkA1HjgJ6J63XldaMJVN+Z82LZPA5hwDsd9QwUA7mxIWfmPWK8bP4ig==
"@polkadot/api-derive@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.40.11.tgz#cbbf2e4d442e7ed251da290cea06978456e4bc4e"
integrity sha512-QGwupV2uVO2LJ6F3ZgAl7ntmnB0Fb4k3CdrXjZTYVm4OA+CWBixwEswvUCinRdN+pcNcoJdbzXkM4FcQItKLUw==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/api" "^0.40.9"
"@polkadot/types" "^0.40.9"
"@polkadot/api" "^0.40.11"
"@polkadot/types" "^0.40.11"
"@types/memoizee" "^0.4.2"
"@types/rx" "^4.1.1"
memoizee "^0.4.14"
rxjs "^6.3.3"
"@polkadot/api@^0.40.8", "@polkadot/api@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.40.9.tgz#276d7a02d933d8712719f08c7ee1528b05fb2ade"
integrity sha512-6FTYUUL2cYQO5eRYyuemQl245t8GKagX924wz8RvbURM/xHa3YrWdiDGzJN5p5ZN743SYmguQpxEGmPcg5bYKA==
"@polkadot/api@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.40.11.tgz#9c28f3c9559f3ce9dbfa6e431684efacee121f51"
integrity sha512-SNO3wpFye4PEb9GkNJFTNxZO3n1r/QTkduiOL8/lcb+J67NQr2cpe91ZTguyR0PHqg3/6P7enOmt4odkJKvO3w==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/api-derive" "^0.40.9"
"@polkadot/extrinsics" "^0.40.9"
"@polkadot/rpc-provider" "^0.40.9"
"@polkadot/rpc-rx" "^0.40.9"
"@polkadot/storage" "^0.40.9"
"@polkadot/types" "^0.40.9"
"@polkadot/api-derive" "^0.40.11"
"@polkadot/extrinsics" "^0.40.11"
"@polkadot/rpc-provider" "^0.40.11"
"@polkadot/rpc-rx" "^0.40.11"
"@polkadot/storage" "^0.40.11"
"@polkadot/types" "^0.40.11"
"@types/rx" "^4.1.1"
rxjs "^6.3.3"
@ -1489,19 +1489,19 @@
typedoc-plugin-no-inherit "^1.1.2"
typescript "^3.2.2"
"@polkadot/extrinsics@^0.40.8", "@polkadot/extrinsics@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.40.9.tgz#a3cdb9a9374425460e01656176dadbc1054cbbf7"
integrity sha512-VhtFhhLHLK5I4zfCBktF//U4vpD1SXDAbcAAxdJFqpGCZ+mYvCHW2iH9Q8clbqyX+sR+43riQhU+D+fPbNaxJQ==
"@polkadot/extrinsics@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.40.11.tgz#1b431acb6605abae68a2f0ab025b1797bffccb84"
integrity sha512-uZY+cwKVNosVh6kuJIO5nknuJKnGKUM46QHSLEareIph5cATMS+MTDJBLqY5OSebCYVrlRhA0ovSLUfZRhPrMA==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/types" "^0.40.9"
"@polkadot/types" "^0.40.11"
"@polkadot/util" "^0.33.35"
"@polkadot/jsonrpc@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.40.9.tgz#57b4cc3e3997f23aac10383c4ff3e745be71f345"
integrity sha512-pG7KntkBgPh6rc3elT7lb0xiuZs4GYTRtdYEn1hmCeKDewGP9XlMbisukwFdvJVj5wJy74XYXOKgunrUAVOU3Q==
"@polkadot/jsonrpc@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.40.11.tgz#e4f33c8df608871f6a2631a4bc902da38e7e60f7"
integrity sha512-rWdDV/rhPhch64w6eqhenSzPqrlfGSe7HRvtSyRRk7cQezg0bZFnlthDvbEWFOfU335ZqOxaMVYrXJwFYjFG4Q==
dependencies:
"@babel/runtime" "^7.2.0"
@ -1516,25 +1516,25 @@
"@types/bs58" "^4.0.0"
bs58 "^4.0.1"
"@polkadot/rpc-core@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.40.9.tgz#ba0a3b3ae0547faefbc17085a19cbea37c3085bd"
integrity sha512-wITrByI6d6yyGURvwqC8DgQoDyBtNKMDPlAxEIH0hRe9Q1wg6bF2HWS6l33sYptm5hQAR9/UqxRtyjKcaUYEHg==
"@polkadot/rpc-core@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.40.11.tgz#678fb10b0185a47258a49337b1e2135ba1ea1ebc"
integrity sha512-4M3MlAKxfPPChdluA0kYljAgJvwVLU1uRjwQq1HLB8CA4tuyTrpjklf0Zcw8GixVfyI9HP91R1lnFyvl0eo+ag==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/jsonrpc" "^0.40.9"
"@polkadot/rpc-provider" "^0.40.9"
"@polkadot/types" "^0.40.9"
"@polkadot/jsonrpc" "^0.40.11"
"@polkadot/rpc-provider" "^0.40.11"
"@polkadot/types" "^0.40.11"
"@polkadot/util" "^0.33.35"
"@polkadot/rpc-provider@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.40.9.tgz#e0dcf886df7b2bb3bf0b4b38b5028ddaec53ccb2"
integrity sha512-B48QHHdiVKEFJfeEQN19pJrWZEde7QpCL3lcZpTQrBj2FkF4/tD7YwQG0bmwHdrHcV5IvxxlFeE/vxrmfCWjCQ==
"@polkadot/rpc-provider@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.40.11.tgz#92f25badae7274fe79afe74c59ea654d6be64481"
integrity sha512-QB4L1GmYNhSxcY1C6jCrJxHMRF9O/yAZrlQ+Fkq4HEuMPG6brpz/KlmQokkBQLCqT6mm7yOS7TTjhvKLWRAtug==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/keyring" "^0.33.35"
"@polkadot/storage" "^0.40.9"
"@polkadot/storage" "^0.40.11"
"@polkadot/util" "^0.33.35"
"@polkadot/util-crypto" "^0.33.35"
"@types/nock" "^9.3.0"
@ -1542,25 +1542,25 @@
isomorphic-fetch "^2.2.1"
websocket "^1.0.28"
"@polkadot/rpc-rx@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-rx/-/rpc-rx-0.40.9.tgz#4cbecb2561833d4cbc32d9f730b10d15155bee5a"
integrity sha512-zAoX6oWje/TlOf9mXGQe8KjFbdcDut7zf2iG8hhAHJKA4JAB0y6+K/fSew9TCNilMIxPiEU/sN+Qp/8BbF5Zog==
"@polkadot/rpc-rx@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-rx/-/rpc-rx-0.40.11.tgz#7f97f1e6f47816d40dc982f93567c32bbbbacdd9"
integrity sha512-txxB7HxUNqmBF8a71ubkNQlqIbQY0/JgP8ORu9eKiPMSgHRcbv/IrByWNyV2TUVTsAZU7akNlB4V2ov2C/U1yg==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/rpc-core" "^0.40.9"
"@polkadot/rpc-provider" "^0.40.9"
"@polkadot/rpc-core" "^0.40.11"
"@polkadot/rpc-provider" "^0.40.11"
"@types/rx" "^4.1.1"
rxjs "^6.3.3"
"@polkadot/storage@^0.40.8", "@polkadot/storage@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.40.9.tgz#b8d631b2eaa8d639a5c16250900726d46e40cf0a"
integrity sha512-rOEEfVIEP2kg3nVyZTfMv+b89FLkyJCHdHW0d0SXhPr6cMX6qoKtfCGiQWzpaiGPY1wQiZbcQHetW3fZ/AEFaw==
"@polkadot/storage@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.40.11.tgz#e3b0a0b21b839a15383fa8f8828811dbd2b60c87"
integrity sha512-xy4Sv+0joHGBTYhPKDfenyt4qVuNmFnomTT2QXAB0I279EcDCo4CBNGPzbA8TLNkf/h1SMvTg4fljMRbyLgBwg==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/keyring" "^0.33.35"
"@polkadot/types" "^0.40.9"
"@polkadot/types" "^0.40.11"
"@polkadot/util" "^0.33.35"
"@polkadot/util-crypto" "^0.33.35"
@ -1569,10 +1569,10 @@
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.51.tgz#4ce26923b3d34c026e14081975718b716c988483"
integrity sha512-p+uQIZqxtlQGTQoNcd8mED66qfyPA4qy8HmCMpUYDaFHKNpZ7qun0dqSoT0NvUB32KTSQitKhf/N0att8sEdow==
"@polkadot/types@^0.40.8", "@polkadot/types@^0.40.9":
version "0.40.9"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.40.9.tgz#32f7df6895769a9da07e8dd2adacadbef729ccef"
integrity sha512-L6TuP8tdM/0AKpLnTsnBA1YBr69Oehiw+0f0Fdfgqr36DrdpdlGvp5CsArV8wbWFJkChecEtQwPQPqX9+fCczA==
"@polkadot/types@^0.40.11":
version "0.40.11"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.40.11.tgz#59c785fcdcf11030abf8e5f65108a225f1b696c7"
integrity sha512-vP+zFNAHfyUb989HelsXCrqxENTUAJuQVKiD9BzhtTfNt9OLVT4DhUmQsanpbCAgElT7ge+2OJWvZpThUxse9Q==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/keyring" "^0.33.35"