github.com/SmartMeshFoundation/Spectrum@v0.0.0-20220621030607-452a266fee1e/dashboard/assets/components/Main.jsx (about) 1 // @flow 2 3 // Copyright 2017 The Spectrum Authors 4 // This file is part of the Spectrum library. 5 // 6 // The Spectrum library is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU Lesser General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // The Spectrum library is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU Lesser General Public License for more details. 15 // 16 // You should have received a copy of the GNU Lesser General Public License 17 // along with the Spectrum library. If not, see <http://www.gnu.org/licenses/>. 18 19 import React, {Component} from 'react'; 20 21 import withStyles from 'material-ui/styles/withStyles'; 22 23 import Home from './Home'; 24 import {MENU} from './Common'; 25 import type {Content} from '../types/content'; 26 27 // Styles for the Content component. 28 const styles = theme => ({ 29 content: { 30 flexGrow: 1, 31 backgroundColor: theme.palette.background.default, 32 padding: theme.spacing.unit * 3, 33 overflow: 'auto', 34 }, 35 }); 36 export type Props = { 37 classes: Object, 38 active: string, 39 content: Content, 40 shouldUpdate: Object, 41 }; 42 // Main renders the chosen content. 43 class Main extends Component<Props> { 44 render() { 45 const { 46 classes, active, content, shouldUpdate, 47 } = this.props; 48 49 let children = null; 50 switch (active) { 51 case MENU.get('home').id: 52 children = <Home memory={content.home.memory} traffic={content.home.traffic} shouldUpdate={shouldUpdate} />; 53 break; 54 case MENU.get('chain').id: 55 case MENU.get('txpool').id: 56 case MENU.get('network').id: 57 case MENU.get('system').id: 58 children = <div>Work in progress.</div>; 59 break; 60 case MENU.get('logs').id: 61 children = <div>{content.logs.log.map((log, index) => <div key={index}>{log}</div>)}</div>; 62 } 63 64 return <div className={classes.content}>{children}</div>; 65 } 66 } 67 68 export default withStyles(styles)(Main);