import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import Group from '../common/group.component' import Param from '../common/param.component' import * as systemActions from './system.actions' import * as taskActions from '../task/task.actions' const cpu_test_task = { activity: 'cpu', library: 'test', dataset: 'test', epochs: 1, opt: {} } const gpu_test_task = { activity: 'gpu', library: 'test', dataset: 'test', epochs: 1, opt: {} } const live_test_task = { activity: 'live', library: 'test', dataset: 'test', epochs: 1, opt: {} } class System extends Component { constructor(props){ super() } render(){ const { site, server, relay, rpc, actions } = this.props return (

{site.name} System

{server.status} {server.error && {server.error.message} } {relay.status} {rpc.status} {rpc.cpu_cmd} {rpc.gpu_cmd} train samplernn
{this.renderCommandOutput()}
) } renderCommandOutput(){ const { cmd } = this.props let output if (cmd.loading) { output = 'Loading: ' + cmd.name } else if (cmd.loaded) { if (cmd.error) { output = 'Error: ' + cmd.name + '\n\n' + JSON.stringify(cmd.error, null, 2) } else { output = cmd.stdout if (cmd.stderr) { output += '\n\n_________________________________\n\n' output += cmd.stderr } } } return (
{output}
) } } const mapStateToProps = state => ({ ...state.system }) const mapDispatchToProps = (dispatch, ownProps) => ({ actions: { system: bindActionCreators(systemActions, dispatch), task: bindActionCreators(taskActions, dispatch), }, }) export default connect(mapStateToProps, mapDispatchToProps)(System)