OSDN Git Service

merge Dashboard into electron
authorZhiting Lin <zlin035@uottawa.ca>
Thu, 8 Nov 2018 10:46:22 +0000 (18:46 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Thu, 8 Nov 2018 10:46:22 +0000 (18:46 +0800)
1  2 
package-lock.json
package.json
src/features/app/components/Container.jsx
src/features/core/actions.js

      },
      "big.js": {
        "version": "3.2.0",
 -      "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz",
 -      "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==",
 +      "resolved": "http://registry.npm.taobao.org/big.js/download/big.js-3.2.0.tgz",
 +      "integrity": "sha1-pfwpi4G54Nyi5FiCR4S2XFK6WI4=",
        "dev": true
      },
+     "bignumber.js": {
+       "version": "7.2.1",
+       "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz",
+       "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ=="
+     },
      "bin-version": {
        "version": "1.0.4",
 -      "resolved": "https://registry.npmjs.org/bin-version/-/bin-version-1.0.4.tgz",
 +      "resolved": "http://registry.npm.taobao.org/bin-version/download/bin-version-1.0.4.tgz",
        "integrity": "sha1-nrSY7m/Xb3q5p8FgQ2+JV5Q1144=",
        "dev": true,
        "requires": {
diff --cc package.json
Simple merge
@@@ -22,55 -19,32 +22,72 @@@ class Container extends React.Componen
    redirectRoot(props) {
      const {
        authOk,
 -      configKnown,
        configured,
-       location
+       location,
+       accountInit
      } = props
  
 -    if (!authOk || !configKnown) {
 +    if (!authOk) {
        return
      }
  
-           location.pathname.indexOf('configuration') >= 0 || location.pathname.includes('index.html')) {
 +    if (configured) {
 +      if (location.pathname === '/' ||
++        location.pathname.indexOf('configuration') >= 0 || location.pathname.includes('index.html')) {
++        this.props.showRoot()
++        }
++      } else {
++        this.props.showInitialization()
++      }
++
+     if (accountInit || !this.state.noAccountItem) {
+       if (location.pathname === '/'|| location.pathname.indexOf('initialization') >= 0) {
          this.props.showRoot()
        }
      } else {
-       this.props.showConfiguration()
+       this.props.showInitialization()
      }
++
    }
    componentDidMount() {
 +    if(window.ipcRenderer){
 +      window.ipcRenderer.on('redirect', (event, arg) => {
 +        this.props.history.push(arg)
 +      })
 +      window.ipcRenderer.on('btmAmountUnitState', (event, arg) => {
 +        this.props.uptdateBtmAmountUnit(arg)
 +      })
 +      window.ipcRenderer.on('lang', (event, arg) => {
 +        this.props.uptdateLang(arg)
 +      })
 +      window.ipcRenderer.on('ConfiguredNetwork', (event, arg) => {
 +        if(arg === 'startNode'){
 +          this.props.fetchInfo().then(() => {
 +            this.props.fetchAccountItem().then(resp => {
 +              if (resp.data.length == 0) {
 +                this.setState({noAccountItem: true})
 +              }
 +            })
 +            this.props.showRoot()
 +          })
 +          setInterval(() => this.props.fetchInfo(), CORE_POLLING_TIME)
 +        }
 +        if(arg === 'init'){
 +          this.props.updateConfiguredStatus()
 +        }
 +      })
 +      window.ipcRenderer.on('mining', (event, arg) => {
 +        let isMining = (arg == 'true')
 +        this.props.updateMiningState(isMining)
 +      })
 +    }
+     this.props.fetchKeyItem().then(resp => {
+       if (resp.data.length == 0) {
+         this.setState({noAccountItem: true})
+         this.redirectRoot(this.props)
+       }
+     })
      if(this.props.lng === 'zh'){
        moment.locale('zh-cn')
      }else{
      }
    }
  
 -  componentWillMount() {
 -    this.props.fetchInfo().then(() => {
 -      this.redirectRoot(this.props)
 -    })
 -
 -    setInterval(() => this.props.fetchInfo(), CORE_POLLING_TIME)
 -  }
 -
    componentWillReceiveProps(nextProps) {
-     if (nextProps.authOk != this.props.authOk ||
-         nextProps.configKnown != this.props.configKnown ||
+     if (nextProps.accountInit != this.props.accountInit ||
          nextProps.configured != this.props.configured ||
          nextProps.location.pathname != this.props.location.pathname) {
        this.redirectRoot(nextProps)
  
      if (!this.props.authOk) {
        layout = <Login/>
 -    } else if (!this.props.configKnown) {
 -      return <Loading>Connecting to Bytom Core...</Loading>
      } else if (!this.props.configured) {
        layout = <Config>{this.props.children}</Config>
 +    } else if (!this.props.configKnown) {
 +      return <Loading>{lang === 'zh'?  '正在连接到Bytom Core...' : 'Connecting to Bytom Core...'}</Loading>
      } else if (!this.props.accountInit && this.state.noAccountItem){
-       layout = <Register>{this.props.children}</Register>
+       layout = <Config>{this.props.children}</Config>
      } else{
        layout = <Main>{this.props.children}</Main>
      }
@@@ -138,13 -116,8 +154,14 @@@ export default connect
    }),
    (dispatch) => ({
      fetchInfo: options => dispatch(actions.core.fetchCoreInfo(options)),
 +    updateMiningState: param => dispatch(actions.core.updateMiningState(param)),
      showRoot: () => dispatch(actions.app.showRoot),
-     uptdateLang: (param) => dispatch(actions.core.updateLang(param)),
 +    showConfiguration: () => dispatch(actions.app.showConfiguration()),
 +    uptdateBtmAmountUnit: (param) => dispatch(actions.core.updateBTMAmountUnit(param)),
-     fetchAccountItem: () => dispatch(actions.account.fetchItems())
 +    updateConfiguredStatus: () => dispatch(actions.core.updateConfiguredStatus),
 +    markFlashDisplayed: (key) => dispatch(actions.app.displayedFlash(key)),
++    fetchAccountItem: () => dispatch(actions.account.fetchItems()),
+     showInitialization: () => dispatch(actions.app.showInitialization()),
+     fetchKeyItem: () => dispatch(actions.key.fetchItems())
    })
  )( withI18n() (Container) )
Simple merge