2017-12-21 09:54:38 -06:00
|
|
|
// @flow
|
|
|
|
|
2017-11-14 11:34:00 -06: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 07:53:52 -05:00
|
|
|
import withStyles from '@material-ui/core/styles/withStyles';
|
2017-11-14 11:34:00 -06:00
|
|
|
|
2019-03-13 07:53:52 -05:00
|
|
|
import Network from 'Network';
|
|
|
|
import Logs from 'Logs';
|
|
|
|
import Footer from 'Footer';
|
2018-01-23 14:51:04 -06:00
|
|
|
import {MENU} from '../common';
|
2017-12-21 09:54:38 -06:00
|
|
|
import type {Content} from '../types/content';
|
2017-11-14 11:34:00 -06:00
|
|
|
|
2018-01-23 14:51:04 -06:00
|
|
|
// styles contains the constant styles of the component.
|
|
|
|
const styles = {
|
|
|
|
wrapper: {
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
content: {
|
2019-03-13 07:53:52 -05:00
|
|
|
flex: 1,
|
2018-01-23 14:51:04 -06:00
|
|
|
overflow: 'auto',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
// themeStyles returns the styles generated from the theme for the component.
|
|
|
|
const themeStyles = theme => ({
|
2017-12-21 09:54:38 -06:00
|
|
|
content: {
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
padding: theme.spacing.unit * 3,
|
|
|
|
},
|
2017-11-14 11:34:00 -06:00
|
|
|
});
|
2018-01-23 14:51:04 -06:00
|
|
|
|
2017-12-21 09:54:38 -06: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 02:59:04 -05:00
|
|
|
classes: Object,
|
|
|
|
active: string,
|
|
|
|
content: Content,
|
2017-12-21 09:54:38 -06: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 02:59:04 -05:00
|
|
|
send: string => void,
|
2017-12-21 09:54:38 -06:00
|
|
|
};
|
2018-01-23 14:51:04 -06:00
|
|
|
|
2019-03-13 07:53:52 -05:00
|
|
|
type State = {};
|
|
|
|
|
2017-12-21 09:54:38 -06:00
|
|
|
// Main renders the chosen content.
|
2019-03-13 07:53:52 -05: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 02:59:04 -05: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 07:53:52 -05: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 09:54:38 -06:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
classes, active, content, shouldUpdate,
|
|
|
|
} = this.props;
|
2017-11-14 11:34:00 -06:00
|
|
|
|
2017-12-21 09:54:38 -06:00
|
|
|
let children = null;
|
|
|
|
switch (active) {
|
|
|
|
case MENU.get('home').id:
|
2019-03-13 07:53:52 -05:00
|
|
|
children = <div>Work in progress.</div>;
|
|
|
|
break;
|
2017-12-21 09:54:38 -06:00
|
|
|
case MENU.get('chain').id:
|
2019-03-13 07:53:52 -05:00
|
|
|
children = <div>Work in progress.</div>;
|
|
|
|
break;
|
2017-12-21 09:54:38 -06:00
|
|
|
case MENU.get('txpool').id:
|
2019-03-13 07:53:52 -05:00
|
|
|
children = <div>Work in progress.</div>;
|
|
|
|
break;
|
2017-12-21 09:54:38 -06:00
|
|
|
case MENU.get('network').id:
|
2019-03-13 07:53:52 -05:00
|
|
|
children = <Network
|
|
|
|
content={this.props.content.network}
|
|
|
|
container={this.container}
|
|
|
|
/>;
|
|
|
|
break;
|
2017-12-21 09:54:38 -06: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 02:59:04 -05:00
|
|
|
children = (
|
|
|
|
<Logs
|
|
|
|
ref={(ref) => { this.content = ref; }}
|
|
|
|
container={this.container}
|
|
|
|
send={this.props.send}
|
|
|
|
content={this.props.content}
|
|
|
|
shouldUpdate={shouldUpdate}
|
|
|
|
/>
|
|
|
|
);
|
2017-12-21 09:54:38 -06:00
|
|
|
}
|
2017-11-14 11:34:00 -06:00
|
|
|
|
2018-01-23 14:51:04 -06: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 02:59:04 -05:00
|
|
|
<div
|
|
|
|
className={classes.content}
|
|
|
|
style={styles.content}
|
|
|
|
ref={(ref) => { this.container = ref; }}
|
|
|
|
onScroll={this.onScroll}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
2018-01-23 14:51:04 -06:00
|
|
|
<Footer
|
2018-03-08 02:22:21 -06:00
|
|
|
general={content.general}
|
|
|
|
system={content.system}
|
2018-01-23 14:51:04 -06:00
|
|
|
shouldUpdate={shouldUpdate}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2017-12-21 09:54:38 -06:00
|
|
|
}
|
2017-11-14 11:34:00 -06:00
|
|
|
}
|
|
|
|
|
2018-01-23 14:51:04 -06:00
|
|
|
export default withStyles(themeStyles)(Main);
|