2017-12-21 15:54:38 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-11-14 17:34:00 +00: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';
|
|
|
|
|
2017-12-21 15:54:38 +00:00
|
|
|
import withStyles from 'material-ui/styles/withStyles';
|
2017-11-14 17:34:00 +00:00
|
|
|
|
2018-01-23 20:51:04 +00:00
|
|
|
import {MENU} from '../common';
|
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 07:59:04 +00:00
|
|
|
import Logs from './Logs';
|
2018-01-23 20:51:04 +00:00
|
|
|
import Footer from './Footer';
|
2017-12-21 15:54:38 +00:00
|
|
|
import type {Content} from '../types/content';
|
2017-11-14 17:34:00 +00:00
|
|
|
|
2018-01-23 20:51:04 +00:00
|
|
|
// styles contains the constant styles of the component.
|
|
|
|
const styles = {
|
|
|
|
wrapper: {
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
content: {
|
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 07:59:04 +00:00
|
|
|
flex: 1,
|
2018-01-23 20:51:04 +00:00
|
|
|
overflow: 'auto',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
// themeStyles returns the styles generated from the theme for the component.
|
|
|
|
const themeStyles = theme => ({
|
2017-12-21 15:54:38 +00:00
|
|
|
content: {
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
padding: theme.spacing.unit * 3,
|
|
|
|
},
|
2017-11-14 17:34:00 +00:00
|
|
|
});
|
2018-01-23 20:51:04 +00:00
|
|
|
|
2017-12-21 15:54:38 +00: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 07:59:04 +00:00
|
|
|
classes: Object,
|
|
|
|
active: string,
|
|
|
|
content: Content,
|
2017-12-21 15:54:38 +00: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 07:59:04 +00:00
|
|
|
send: string => void,
|
2017-12-21 15:54:38 +00:00
|
|
|
};
|
2018-01-23 20:51:04 +00:00
|
|
|
|
2017-12-21 15:54:38 +00:00
|
|
|
// Main renders the chosen content.
|
|
|
|
class Main extends Component<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 07:59:04 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.container = React.createRef();
|
|
|
|
this.content = React.createRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
getSnapshotBeforeUpdate() {
|
|
|
|
if (this.content && typeof this.content.beforeUpdate === 'function') {
|
|
|
|
return this.content.beforeUpdate();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-21 15:54:38 +00:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
classes, active, content, shouldUpdate,
|
|
|
|
} = this.props;
|
2017-11-14 17:34:00 +00:00
|
|
|
|
2017-12-21 15:54:38 +00:00
|
|
|
let children = null;
|
|
|
|
switch (active) {
|
|
|
|
case MENU.get('home').id:
|
|
|
|
case MENU.get('chain').id:
|
|
|
|
case MENU.get('txpool').id:
|
|
|
|
case MENU.get('network').id:
|
|
|
|
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 07:59:04 +00:00
|
|
|
children = (
|
|
|
|
<Logs
|
|
|
|
ref={(ref) => { this.content = ref; }}
|
|
|
|
container={this.container}
|
|
|
|
send={this.props.send}
|
|
|
|
content={this.props.content}
|
|
|
|
shouldUpdate={shouldUpdate}
|
|
|
|
/>
|
|
|
|
);
|
2017-12-21 15:54:38 +00:00
|
|
|
}
|
2017-11-14 17:34:00 +00:00
|
|
|
|
2018-01-23 20:51:04 +00: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 07:59:04 +00:00
|
|
|
<div
|
|
|
|
className={classes.content}
|
|
|
|
style={styles.content}
|
|
|
|
ref={(ref) => { this.container = ref; }}
|
|
|
|
onScroll={this.onScroll}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
2018-01-23 20:51:04 +00:00
|
|
|
<Footer
|
2018-03-08 08:22:21 +00:00
|
|
|
general={content.general}
|
|
|
|
system={content.system}
|
2018-01-23 20:51:04 +00:00
|
|
|
shouldUpdate={shouldUpdate}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2017-12-21 15:54:38 +00:00
|
|
|
}
|
2017-11-14 17:34:00 +00:00
|
|
|
}
|
|
|
|
|
2018-01-23 20:51:04 +00:00
|
|
|
export default withStyles(themeStyles)(Main);
|