58 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
import ReactDOM from 'react-dom';
import { Tabs, Tab } from 'react-bootstrap';
2018-01-03 12:42:48 -05:00
import EmbarkJS from 'Embark/EmbarkJS';
import Blockchain from './components/blockchain';
import Whisper from './components/whisper';
2018-04-24 16:21:33 -04:00
import Storage from './components/storage';
2018-01-03 12:42:48 -05:00
2018-01-12 16:33:16 -05:00
import './dapp.css';
class App extends React.Component {
constructor(props) {
super(props);
2015-05-24 09:07:19 -04:00
this.state = {
2018-04-24 16:21:33 -04:00
whisperEnabled: false,
storageEnabled: false
2017-10-25 06:19:24 -04:00
}
}
2017-10-25 06:19:24 -04:00
componentDidMount(){
2018-04-24 16:21:33 -04:00
// TODO Verify if whisper & swarm/ipfs are available
this.setState({
2018-04-24 16:21:33 -04:00
whisperEnabled: false,
storageEnabled: false
2017-01-26 06:29:17 -05:00
});
}
2017-01-26 06:29:17 -05:00
_renderStatus(title, available){
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
return <React.Fragment>
{title}
<span className={className}></span>
</React.Fragment>;
2017-10-25 06:19:24 -04:00
}
2017-01-26 06:29:17 -05:00
render(){
return (<div><h3>Embark - Usage Example</h3>
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
<Tab eventKey={1} title="Blockchain">
<Blockchain />
</Tab>
2018-04-24 16:21:33 -04:00
<Tab eventKey={2} title={this._renderStatus('Decentralized Storage', this.state.storageEnabled)}>
<Storage />
</Tab>
<Tab eventKey={3} title={this._renderStatus('P2P communication (Whisper/Orbit)', this.state.whisperEnabled)}>
<Whisper enabled={this.state.whisperEnabled} />
</Tab>
</Tabs>
</div>);
}
}
2017-01-26 06:29:17 -05:00
ReactDOM.render(<App></App>, document.getElementById('app'));