diff options
author | Kurkó Mihály <kurkomisi@users.noreply.github.com> | 2018-07-11 15:59:04 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-07-11 15:59:04 +0800 |
commit | a9835c1816bc49ee54c82b4f2a5b05cbcd89881b (patch) | |
tree | e1badefd627aa3a7c4e1937eab22b8fe3eb204d1 /dashboard/assets/components/Main.jsx | |
parent | 2eedbe799f5eb8766e4808d8a1810cc1c90c4b93 (diff) | |
download | dexon-a9835c1816bc49ee54c82b4f2a5b05cbcd89881b.tar dexon-a9835c1816bc49ee54c82b4f2a5b05cbcd89881b.tar.gz dexon-a9835c1816bc49ee54c82b4f2a5b05cbcd89881b.tar.bz2 dexon-a9835c1816bc49ee54c82b4f2a5b05cbcd89881b.tar.lz dexon-a9835c1816bc49ee54c82b4f2a5b05cbcd89881b.tar.xz dexon-a9835c1816bc49ee54c82b4f2a5b05cbcd89881b.tar.zst dexon-a9835c1816bc49ee54c82b4f2a5b05cbcd89881b.zip |
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
Diffstat (limited to 'dashboard/assets/components/Main.jsx')
-rw-r--r-- | dashboard/assets/components/Main.jsx | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/dashboard/assets/components/Main.jsx b/dashboard/assets/components/Main.jsx index fba8ca1f6..0018aaf75 100644 --- a/dashboard/assets/components/Main.jsx +++ b/dashboard/assets/components/Main.jsx @@ -21,6 +21,7 @@ import React, {Component} from 'react'; import withStyles from 'material-ui/styles/withStyles'; import {MENU} from '../common'; +import Logs from './Logs'; import Footer from './Footer'; import type {Content} from '../types/content'; @@ -32,7 +33,7 @@ const styles = { width: '100%', }, content: { - flex: 1, + flex: 1, overflow: 'auto', }, }; @@ -46,14 +47,40 @@ const themeStyles = theme => ({ }); export type Props = { - classes: Object, - active: string, - content: Content, + classes: Object, + active: string, + content: Content, shouldUpdate: Object, + send: string => void, }; // Main renders the chosen content. class Main extends Component<Props> { + 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(); + } + }; + render() { const { classes, active, content, shouldUpdate, @@ -69,12 +96,27 @@ class Main extends Component<Props> { children = <div>Work in progress.</div>; break; case MENU.get('logs').id: - children = <div>{content.logs.log.map((log, index) => <div key={index}>{log}</div>)}</div>; + children = ( + <Logs + ref={(ref) => { this.content = ref; }} + container={this.container} + send={this.props.send} + content={this.props.content} + shouldUpdate={shouldUpdate} + /> + ); } return ( <div style={styles.wrapper}> - <div className={classes.content} style={styles.content}>{children}</div> + <div + className={classes.content} + style={styles.content} + ref={(ref) => { this.container = ref; }} + onScroll={this.onScroll} + > + {children} + </div> <Footer general={content.general} system={content.system} |