Files
weave-scope/client/app/scripts/components/nodes.js
2015-09-16 12:53:33 +02:00

61 lines
1.4 KiB
JavaScript

const React = require('react');
const NodesChart = require('../charts/nodes-chart');
const AppActions = require('../actions/app-actions');
const navbarHeight = 160;
const marginTop = 0;
const Nodes = React.createClass({
getInitialState: function() {
return {
width: window.innerWidth,
height: window.innerHeight - navbarHeight - marginTop
};
},
componentDidMount: function() {
window.addEventListener('resize', this.handleResize);
},
componentWillUnmount: function() {
window.removeEventListener('resize', this.handleResize);
},
onNodeClick: function(ev) {
AppActions.clickNode(ev.currentTarget.id);
},
render: function() {
return (
<NodesChart
highlightedEdgeIds={this.props.highlightedEdgeIds}
highlightedNodeIds={this.props.highlightedNodeIds}
selectedNodeId={this.props.selectedNodeId}
nodes={this.props.nodes}
onNodeClick={this.onNodeClick}
width={this.state.width}
height={this.state.height}
topologyId={this.props.topologyId}
detailsWidth={this.props.detailsWidth}
topMargin={this.props.topMargin}
/>
);
},
handleResize: function() {
this.setDimensions();
},
setDimensions: function() {
this.setState({
height: window.innerHeight - navbarHeight - marginTop,
width: window.innerWidth
});
}
});
module.exports = Nodes;