1 import { connect } from 'react-redux'
2 import {DropdownButton, MenuItem} from 'react-bootstrap'
3 import componentClassNames from 'utility/componentClassNames'
4 import { PageContent, PageTitle, ConsoleSection } from 'features/shared/components'
5 import React from 'react'
6 import styles from './CoreIndex.scss'
7 import actions from 'actions'
8 import {withNamespaces} from 'react-i18next'
11 class CoreIndex extends React.Component {
17 this.handleMiningState = this.handleMiningState.bind(this)
18 this.handleAdvancedOptionChange = this.handleAdvancedOptionChange.bind(this)
19 this.changeBTMamount = this.changeBTMamount.bind(this)
20 this.consolePopup = this.consolePopup.bind(this)
24 if(window.ipcRenderer){
25 window.ipcRenderer.on('btmAmountUnitState', (event, arg) => {
26 this.props.uptdateBtmAmountUnit(arg)
31 changeBTMamount(value) {
32 this.setState({ btmAmountUnit: value })
33 this.props.uptdateBtmAmountUnit(value)
36 handleAdvancedOptionChange(event) {
37 const target = event.target
39 this.props.showNavAdvanced()
41 this.props.hideNavAdvanced()
45 handleMiningState(event){
46 const target = event.target
48 this.props.updateMiningState(true)
50 this.props.updateMiningState(false)
64 let navState = this.props.navAdvancedState === 'advance'
65 let miningState = this.props.core.mingStatus
66 let coreData = this.props.core.coreData
68 const t = this.props.t
71 <div className={[styles.left, styles.col].join(' ')}>
73 <h4>{t('coreIndex.configuration')}</h4>
74 <table className={styles.table}>
76 <tr className={styles.row}>
77 <td className={styles.row_label}>{t('coreIndex.version')}:</td>
78 <td><code>{coreData? coreData['versionInfo']['version']: null}</code></td>
80 <tr className={styles.row}>
81 <td className={styles.row_label}>{t('commonWords.language')}:</td>
82 <td>{t('languageFull')}</td>
84 <tr className={styles.row}>
85 <td colSpan={2}><hr /></td>
87 <tr className={styles.row}>
88 <td className={styles.row_label}>{t('coreIndex.advanced')}: </td>
90 <label className={styles.switch}>
93 onChange={this.handleAdvancedOptionChange}
96 <span className={styles.slider}></span>
100 <tr className={styles.row}>
101 <td className={styles.row_label} >{t('coreIndex.unit')} </td>
105 id='input-dropdown-amount'
106 title={this.props.core.btmAmountUnit || this.state.btmAmountUnit}
107 onSelect={this.changeBTMamount}
109 <MenuItem eventKey='BTM'>BTM</MenuItem>
110 <MenuItem eventKey='mBTM'>mBTM</MenuItem>
111 <MenuItem eventKey='NEU'>NEU</MenuItem>
121 let requestStatusBlock
125 requestStatusBlock = (<div>loading...</div>)
127 requestStatusBlock = (
129 <h4>{t('coreIndex.networkStatus')}</h4>
130 <table className={styles.table}>
132 <tr className={styles.row} key={'core-listening'}>
133 <td className={styles.row_label}> {t('coreIndex.listening')}:</td>
134 <td className={styles.row_value}><code>{(coreData['listening'])? t('coreIndex.connect'): t('coreIndex.disConnect')}</code></td>
136 <tr className={styles.row} key={'core-syncing'}>
137 <td className={styles.row_label}> {t('coreIndex.syncStatus')}:</td>
138 <td className={styles.row_value}><code>{(coreData['syncing'])? t('coreIndex.synchronizing'): t('coreIndex.synced')}</code></td>
140 <tr className={styles.row} key={'core-peerCount'}>
141 <td className={styles.row_label}> {t('coreIndex.peer')}:</td>
142 <td className={styles.row_value}><code>{String(coreData['peerCount'])}</code></td>
144 <tr className={styles.row} key={'core-currentBlock'}>
145 <td className={styles.row_label}> {t('coreIndex.currentBlock')}:</td>
146 <td className={styles.row_value}><code>{String(coreData['currentBlock'])}</code></td>
148 <tr className={styles.row} key={'core-highestBlock'}>
149 <td className={styles.row_label}> {t('coreIndex.highestBlock')}:</td>
150 <td className={styles.row_value}><code>{String(coreData['highestBlock'])}</code></td>
152 <tr className={styles.row} key={'core-networkID'}>
153 <td className={styles.row_label}> {t('coreIndex.networkId')}:</td>
154 <td className={styles.row_value}><code>{String(coreData['networkId'])}</code></td>
162 let networkStatusBlock = (
163 <div className={[styles.right, styles.col].join(' ')}>
164 {/*<div ref='requestComponent'>*/}
171 <div className={componentClassNames(this, 'flex-container')}>
173 title={t('coreIndex.coreStatus')}
175 <button className='btn btn-link' onClick={this.consolePopup}>
176 <img src={require('images/console-window.svg')}/>
182 <div className={`${styles.flex} ${styles.mainContainer}`}>
192 const mapStateToProps = (state) => ({
194 navAdvancedState: state.app.navAdvancedState,
197 const mapDispatchToProps = (dispatch) => ({
198 showNavAdvanced: () => dispatch(actions.app.showNavAdvanced),
199 hideNavAdvanced: () => dispatch(actions.app.hideNavAdvanced),
200 uptdateBtmAmountUnit: (param) => dispatch(actions.core.updateBTMAmountUnit(param)),
201 updateMiningState: (param) => dispatch(actions.core.updateMiningState(param)),
202 showModal: (body) => dispatch(actions.app.showModal(
204 actions.app.hideModal,
212 cmd: (data) => dispatch(actions.app.cmd(data))
215 export default connect(
218 )( withNamespaces('translations') (CoreIndex) )