render grouped topologies menu sent by backend

This commit is contained in:
David Kaltschmidt
2015-06-15 10:37:24 +02:00
parent 3e8bdcc854
commit cdccd5d2c0
2 changed files with 11 additions and 46 deletions

View File

@@ -14,10 +14,12 @@ const Topologies = React.createClass({
renderSubTopology: function(subTopology) {
const isActive = subTopology.name === this.props.currentTopology.name;
const topologyId = AppStore.getTopologyIdForUrl(subTopology.url);
const title = this.renderTitle(subTopology);
const className = isActive ? 'topologies-sub-item topologies-sub-item-active' : 'topologies-sub-item';
return (
<div className={className} key={topologyId} rel={topologyId} onClick={this.onTopologyClick}>
<div className={className} title={title} key={topologyId} rel={topologyId}
onClick={this.onTopologyClick}>
<div className="topologies-sub-item-label">
{subTopology.name}
</div>
@@ -25,13 +27,16 @@ const Topologies = React.createClass({
);
},
renderTitle: function(topology) {
return ['Nodes: ' + topology.stats.node_count,
'Connections: ' + topology.stats.node_count].join('\n');
},
renderTopology: function(topology) {
const isActive = topology.name === this.props.currentTopology.name;
const className = isActive ? 'topologies-item-main topologies-item-main-active' : 'topologies-item-main';
const topologyId = AppStore.getTopologyIdForUrl(topology.url);
const title = ['Topology: ' + topology.name,
'Nodes: ' + topology.stats.node_count,
'Connections: ' + topology.stats.node_count].join('\n');
const title = this.renderTitle(topology);
return (
<div className="topologies-item" key={topologyId}>

View File

@@ -39,50 +39,10 @@ function createWebsocket(topologyUrl) {
currentUrl = topologyUrl;
}
const TOPOLOGIES = [
{
'name': 'Applications',
'url': '/api/topology/applications',
'stats': {
'node_count': 12,
'nonpseudo_node_count': 10,
'edge_count': 13
},
'sub_topologies': [
{
'name': 'by name',
'url': '/api/topology/applications-grouped'
}
]
},
{
'name': 'Containers',
'url': '/api/topology/containers',
'grouped_url': '/api/topology/containers-grouped',
'stats': {
'node_count': 2,
'nonpseudo_node_count': 1,
'edge_count': 2
}
},
{
'name': 'Hosts',
'url': '/api/topology/hosts',
'stats': {
'node_count': 2,
'nonpseudo_node_count': 1,
'edge_count': 2
}
}
];
function getTopologies() {
clearTimeout(topologyTimer);
reqwest('/api/topology', function() {
// injecting static topos
AppActions.receiveTopologies(TOPOLOGIES);
reqwest('/api/topology', function(res) {
AppActions.receiveTopologies(res);
topologyTimer = setTimeout(getTopologies, 10000);
});
}