diff --git a/app/components/Network/PeersList.js b/app/components/Network/PeersList.js new file mode 100644 index 00000000..f9f57771 --- /dev/null +++ b/app/components/Network/PeersList.js @@ -0,0 +1,22 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './PeersList.scss' + +const PeersList = ({ peers }) => ( + +) + +PeersList.propTypes = { + peers: PropTypes.array.isRequired +} + +export default PeersList diff --git a/app/components/Network/PeersList.scss b/app/components/Network/PeersList.scss new file mode 100644 index 00000000..cda8f8d3 --- /dev/null +++ b/app/components/Network/PeersList.scss @@ -0,0 +1,18 @@ +@import '../../variables.scss'; + +.peer { + margin: 20px 0; + cursor: pointer; + + &:hover { + opacity: 0.5; + } + + h1 { + margin-bottom: 5px; + } + + h4 { + font-size: 10px; + } +} \ No newline at end of file diff --git a/app/reducers/network.js b/app/reducers/network.js index ff8417dc..aad9a9c7 100644 --- a/app/reducers/network.js +++ b/app/reducers/network.js @@ -14,6 +14,10 @@ export const SET_CURRENT_ROUTE = 'SET_CURRENT_ROUTE' export const SET_CURRENT_CHANNEL = 'SET_CURRENT_CHANNEL' +export const SET_CURRENT_TAB = 'SET_CURRENT_TAB' + +export const SET_CURRENT_PEER = 'SET_CURRENT_PEER' + // ------------------------------------ // Actions // ------------------------------------ @@ -44,6 +48,20 @@ export function setCurrentChannel(selectedChannel) { } } +export function setCurrentTab(currentTab) { + return { + type: SET_CURRENT_TAB, + currentTab + } +} + +export function setCurrentPeer(currentPeer) { + return { + type: SET_CURRENT_PEER, + currentPeer + } +} + // Send IPC event for describeNetwork export const fetchDescribeNetwork = () => (dispatch) => { dispatch(getDescribeNetwork()) @@ -83,7 +101,11 @@ const ACTION_HANDLERS = { } ), - [SET_CURRENT_CHANNEL]: (state, { selectedChannel }) => ({ ...state, selectedChannel }) + [SET_CURRENT_CHANNEL]: (state, { selectedChannel }) => ({ ...state, selectedChannel }), + + [SET_CURRENT_TAB]: (state, { currentTab }) => ({ ...state, currentTab }), + + [SET_CURRENT_PEER]: (state, { currentPeer }) => ({ ...state, currentPeer }) } // ------------------------------------ @@ -115,7 +137,11 @@ const initialState = { routes: [], currentRoute: {} }, - selectedChannel: {} + selectedChannel: {}, + + currentTab: 1, + + currentPeer: {} } diff --git a/app/routes/network/components/Network.js b/app/routes/network/components/Network.js index 7e623287..d40b175c 100644 --- a/app/routes/network/components/Network.js +++ b/app/routes/network/components/Network.js @@ -2,20 +2,27 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { InteractiveForceGraph, ForceGraphNode, ForceGraphLink } from 'react-vis-force' -import LoadingBolt from '../../../components/LoadingBolt' +import LoadingBolt from 'components/LoadingBolt' +import PeersList from 'components/Network/PeersList' import styles from './Network.scss' class Network extends Component { componentWillMount() { - const { fetchDescribeNetwork } = this.props + const { fetchDescribeNetwork, fetchPeers, fetchChannels } = this.props fetchDescribeNetwork() + fetchPeers() + fetchChannels() } render() { const { - network: { nodes, edges, selectedNode, networkLoading }, + setCurrentTab, + + network: { nodes, edges, selectedNode, networkLoading, currentTab }, + peers: { peers }, + channels, identity_pubkey } = this.props @@ -23,6 +30,20 @@ class Network extends Component { if (networkLoading) return + const renderTab = () => { + switch(currentTab) { + case 1: + return + break + case 2: + return

channels

+ break + case 3: + return

transaction

+ break + } + } + return (
@@ -30,7 +51,7 @@ class Network extends Component { simulationOptions={ { height: 1000, - width: 1000, + width: 800, strength: { charge: -750 }, @@ -76,6 +97,29 @@ class Network extends Component { }
+
+
+

Toolbox

+
+ +
    +
  • setCurrentTab(1)}> +

    Peers

    +
  • +
  • setCurrentTab(2)}> +

    Channels

    +
  • +
  • setCurrentTab(3)}> +

    Transaction

    +
  • +
+ +
+ { + renderTab() + } +
+
) } diff --git a/app/routes/network/components/Network.scss b/app/routes/network/components/Network.scss index 2bfd4972..236c5765 100644 --- a/app/routes/network/components/Network.scss +++ b/app/routes/network/components/Network.scss @@ -44,42 +44,51 @@ } .data { - width: 30%; - background: $black; + width: calc(30% - 1px); color: #00FF00; word-wrap: break-word; overflow-y: scroll; - - header, .routes { - padding: 10px; - } + border-left: 1px solid $darkgrey; + font-family: 'Courier New'; header { - margin-top: 50px; + margin: 20px 0; + padding: 20px; + border-bottom: 1px solid $darkgrey; - h1 span { - display: block; - margin: 5px 0; - - &:nth-child(2) { - font-size: 12px; - } + h1 { + font-weight: bold; + font-size: 30px; } } - .routes { - .route { + + .tabs { + padding: 0 20px; + display: flex; + flex-direction: row; + + .tab { + padding: 10px; cursor: pointer; - margin: 20px 0; + transition: all 0.25s; - &.active { + &:hover { background: #00FF00; - color: black; + color: $black; + opacity: 0.5; } - &:hover { - opacity: 0.5; + &.active { + background: #00FF00; + color: $black; } } + + } + + .currentTab { + margin-top: 20px; + padding: 20px; } -} \ No newline at end of file +} diff --git a/app/routes/network/containers/NetworkContainer.js b/app/routes/network/containers/NetworkContainer.js index c90d53e2..873d0998 100644 --- a/app/routes/network/containers/NetworkContainer.js +++ b/app/routes/network/containers/NetworkContainer.js @@ -1,16 +1,23 @@ import { withRouter } from 'react-router' import { connect } from 'react-redux' -import { fetchDescribeNetwork } from 'reducers/network' +import { fetchDescribeNetwork, setCurrentTab } from 'reducers/network' +import { fetchPeers } from 'reducers/peers' +import { fetchChannels } from 'reducers/channels' import Network from '../components/Network' const mapDispatchToProps = { - fetchDescribeNetwork + setCurrentTab, + fetchDescribeNetwork, + fetchPeers, + fetchChannels } const mapStateToProps = state => ({ network: state.network, + peers: state.peers, + channels: state.channels, identity_pubkey: state.info.data.identity_pubkey })