2017-12-21 17:54:38 +02:00
|
|
|
// @flow
|
|
|
|
|
2017-11-14 19:34:00 +02:00
|
|
|
// Copyright 2017 The go-ethereum Authors
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
|
|
2019-03-13 14:53:52 +02:00
|
|
|
import withStyles from '@material-ui/core/styles/withStyles';
|
2017-11-14 19:34:00 +02:00
|
|
|
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 13:13:13 +02:00
|
|
|
import Chain from 'Chain';
|
2019-03-13 14:53:52 +02:00
|
|
|
import Network from 'Network';
|
|
|
|
import Logs from 'Logs';
|
|
|
|
import Footer from 'Footer';
|
2018-01-23 22:51:04 +02:00
|
|
|
import {MENU} from '../common';
|
2017-12-21 17:54:38 +02:00
|
|
|
import type {Content} from '../types/content';
|
2017-11-14 19:34:00 +02:00
|
|
|
|
2018-01-23 22:51:04 +02:00
|
|
|
// styles contains the constant styles of the component.
|
|
|
|
const styles = {
|
|
|
|
wrapper: {
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
content: {
|
2019-03-13 14:53:52 +02:00
|
|
|
flex: 1,
|
2018-01-23 22:51:04 +02:00
|
|
|
overflow: 'auto',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
// themeStyles returns the styles generated from the theme for the component.
|
|
|
|
const themeStyles = theme => ({
|
2017-12-21 17:54:38 +02:00
|
|
|
content: {
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
padding: theme.spacing.unit * 3,
|
|
|
|
},
|
2017-11-14 19:34:00 +02:00
|
|
|
});
|
2018-01-23 22:51:04 +02:00
|
|
|
|
2017-12-21 17:54:38 +02:00
|
|
|
export type Props = {
|
cmd, dashboard, log: log collection and exploration (#17097)
* cmd, dashboard, internal, log, node: logging feature
* cmd, dashboard, internal, log: requested changes
* dashboard, vendor: gofmt, govendor, use vendored file watcher
* dashboard, log: gofmt -s -w, goimports
* dashboard, log: gosimple
2018-07-11 10:59:04 +03:00
|
|
|
classes: Object,
|
|
|
|
active: string,
|
|
|
|
content: Content,
|
2017-12-21 17:54:38 +02:00
|
|
|
shouldUpdate: Object,
|
cmd, dashboard, log: log collection and exploration (#17097)
* cmd, dashboard, internal, log, node: logging feature
* cmd, dashboard, internal, log: requested changes
* dashboard, vendor: gofmt, govendor, use vendored file watcher
* dashboard, log: gofmt -s -w, goimports
* dashboard, log: gosimple
2018-07-11 10:59:04 +03:00
|
|
|
send: string => void,
|
2017-12-21 17:54:38 +02:00
|
|
|
};
|
2018-01-23 22:51:04 +02:00
|
|
|
|
2019-03-13 14:53:52 +02:00
|
|
|
type State = {};
|
|
|
|
|
2017-12-21 17:54:38 +02:00
|
|
|
// Main renders the chosen content.
|
2019-03-13 14:53:52 +02:00
|
|
|
class Main extends Component<Props, State> {
|
cmd, dashboard, log: log collection and exploration (#17097)
* cmd, dashboard, internal, log, node: logging feature
* cmd, dashboard, internal, log: requested changes
* dashboard, vendor: gofmt, govendor, use vendored file watcher
* dashboard, log: gofmt -s -w, goimports
* dashboard, log: gosimple
2018-07-11 10:59:04 +03:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.container = React.createRef();
|
|
|
|
this.content = React.createRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
|
|
if (this.content && typeof this.content.didUpdate === 'function') {
|
|
|
|
this.content.didUpdate(prevProps, prevState, snapshot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onScroll = () => {
|
|
|
|
if (this.content && typeof this.content.onScroll === 'function') {
|
|
|
|
this.content.onScroll();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-13 14:53:52 +02:00
|
|
|
getSnapshotBeforeUpdate(prevProps: Readonly<P>, prevState: Readonly<S>) {
|
|
|
|
if (this.content && typeof this.content.beforeUpdate === 'function') {
|
|
|
|
return this.content.beforeUpdate();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:54:38 +02:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
classes, active, content, shouldUpdate,
|
|
|
|
} = this.props;
|
2017-11-14 19:34:00 +02:00
|
|
|
|
2017-12-21 17:54:38 +02:00
|
|
|
let children = null;
|
|
|
|
switch (active) {
|
|
|
|
case MENU.get('home').id:
|
2019-03-13 14:53:52 +02:00
|
|
|
children = <div>Work in progress.</div>;
|
|
|
|
break;
|
2017-12-21 17:54:38 +02:00
|
|
|
case MENU.get('chain').id:
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 13:13:13 +02:00
|
|
|
children = <Chain
|
|
|
|
content={this.props.content.chain}
|
|
|
|
/>;
|
2019-03-13 14:53:52 +02:00
|
|
|
break;
|
2017-12-21 17:54:38 +02:00
|
|
|
case MENU.get('txpool').id:
|
2019-03-13 14:53:52 +02:00
|
|
|
children = <div>Work in progress.</div>;
|
|
|
|
break;
|
2017-12-21 17:54:38 +02:00
|
|
|
case MENU.get('network').id:
|
2019-03-13 14:53:52 +02:00
|
|
|
children = <Network
|
|
|
|
content={this.props.content.network}
|
|
|
|
container={this.container}
|
|
|
|
/>;
|
|
|
|
break;
|
2017-12-21 17:54:38 +02:00
|
|
|
case MENU.get('system').id:
|
|
|
|
children = <div>Work in progress.</div>;
|
|
|
|
break;
|
|
|
|
case MENU.get('logs').id:
|
cmd, dashboard, log: log collection and exploration (#17097)
* cmd, dashboard, internal, log, node: logging feature
* cmd, dashboard, internal, log: requested changes
* dashboard, vendor: gofmt, govendor, use vendored file watcher
* dashboard, log: gofmt -s -w, goimports
* dashboard, log: gosimple
2018-07-11 10:59:04 +03:00
|
|
|
children = (
|
|
|
|
<Logs
|
|
|
|
ref={(ref) => { this.content = ref; }}
|
|
|
|
container={this.container}
|
|
|
|
send={this.props.send}
|
|
|
|
content={this.props.content}
|
|
|
|
shouldUpdate={shouldUpdate}
|
|
|
|
/>
|
|
|
|
);
|
2017-12-21 17:54:38 +02:00
|
|
|
}
|
2017-11-14 19:34:00 +02:00
|
|
|
|
2018-01-23 22:51:04 +02:00
|
|
|
return (
|
|
|
|
<div style={styles.wrapper}>
|
cmd, dashboard, log: log collection and exploration (#17097)
* cmd, dashboard, internal, log, node: logging feature
* cmd, dashboard, internal, log: requested changes
* dashboard, vendor: gofmt, govendor, use vendored file watcher
* dashboard, log: gofmt -s -w, goimports
* dashboard, log: gosimple
2018-07-11 10:59:04 +03:00
|
|
|
<div
|
|
|
|
className={classes.content}
|
|
|
|
style={styles.content}
|
|
|
|
ref={(ref) => { this.container = ref; }}
|
|
|
|
onScroll={this.onScroll}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
2018-01-23 22:51:04 +02:00
|
|
|
<Footer
|
2018-03-08 10:22:21 +02:00
|
|
|
general={content.general}
|
|
|
|
system={content.system}
|
2018-01-23 22:51:04 +02:00
|
|
|
shouldUpdate={shouldUpdate}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2017-12-21 17:54:38 +02:00
|
|
|
}
|
2017-11-14 19:34:00 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 22:51:04 +02:00
|
|
|
export default withStyles(themeStyles)(Main);
|