Ui 2 pubsub components (#6152)
* Remove Application.orig from merge * Disable i18n extraction for development * Retrieve blockNumber via pubsub * Chain via pubsub * StatusIndicator with health * WIP * WIP * s/BlockStatus/BlockNumber/ * Adjust BlockNumber display * Cleanup debug * Fix statusbar indicator * NetPeers component * Add BlockTimestamp * Export statics on observer * Cleanup debug logs * Update references
This commit is contained in:
@@ -29,10 +29,6 @@ import { statusBlockNumber, statusCollection } from './statusActions';
|
||||
const log = getLogger(LOG_KEYS.Signer);
|
||||
let instance = null;
|
||||
|
||||
const STATUS_OK = 'ok';
|
||||
const STATUS_WARN = 'needsAttention';
|
||||
const STATUS_BAD = 'bad';
|
||||
|
||||
export default class Status {
|
||||
_apiStatus = {};
|
||||
_status = {};
|
||||
@@ -207,19 +203,13 @@ export default class Status {
|
||||
|
||||
const statusPromises = [
|
||||
this._api.eth.syncing(),
|
||||
this._api.parity.netPeers(),
|
||||
this._fetchHealth()
|
||||
this._api.parity.netPeers()
|
||||
];
|
||||
|
||||
return Promise
|
||||
.all(statusPromises)
|
||||
.then(([ syncing, netPeers, health ]) => {
|
||||
const status = { netPeers, syncing, health };
|
||||
|
||||
health.overall = this._overallStatus(health);
|
||||
health.peers = health.peers || {};
|
||||
health.sync = health.sync || {};
|
||||
health.time = health.time || {};
|
||||
.then(([ syncing, netPeers ]) => {
|
||||
const status = { netPeers, syncing };
|
||||
|
||||
if (!isEqual(status, this._status)) {
|
||||
this._store.dispatch(statusCollection(status));
|
||||
@@ -234,43 +224,6 @@ export default class Status {
|
||||
});
|
||||
}
|
||||
|
||||
_overallStatus = (health) => {
|
||||
const all = [health.peers, health.sync, health.time].filter(x => x);
|
||||
const statuses = all.map(x => x.status);
|
||||
const bad = statuses.find(x => x === STATUS_BAD);
|
||||
const needsAttention = statuses.find(x => x === STATUS_WARN);
|
||||
const message = all.map(x => x.message).filter(x => x);
|
||||
|
||||
if (all.length) {
|
||||
return {
|
||||
status: bad || needsAttention || STATUS_OK,
|
||||
message
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: STATUS_BAD,
|
||||
message: ['Unable to fetch node health.']
|
||||
};
|
||||
}
|
||||
|
||||
_fetchHealth = () => {
|
||||
// Support Parity-Extension.
|
||||
const uiUrl = this._api.transport.uiUrlWithProtocol || '';
|
||||
|
||||
return fetch(`${uiUrl}/api/health`)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return response.json();
|
||||
})
|
||||
.catch(() => {
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The data fetched here should not change
|
||||
* unless Parity is restarted. They are thus
|
||||
|
||||
Reference in New Issue
Block a user