From 6032d9592595b9b7aeb54d708375d062d588ec7e Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 5 Feb 2016 15:07:50 +0100 Subject: [PATCH] Let shape be determined by backend --- client/app/scripts/charts/node.js | 23 ++++++++--------------- client/app/scripts/charts/nodes-chart.js | 4 ++++ client/app/scripts/stores/app-store.js | 2 ++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/client/app/scripts/charts/node.js b/client/app/scripts/charts/node.js index b6e5618f93..c4b1721380 100644 --- a/client/app/scripts/charts/node.js +++ b/client/app/scripts/charts/node.js @@ -20,25 +20,18 @@ function stackedShape(Shape) { } const nodeShapes = { - 'hosts': NodeShapeCircle, - 'containers': NodeShapeHex, - 'containers-by-hostname': stackedShape(NodeShapeHex), - 'containers-by-image': stackedShape(NodeShapeHex), - 'applications': NodeShapeRoundedSquare, - 'applications-by-name': stackedShape(NodeShapeRoundedSquare) + 'circle': NodeShapeCircle, + 'hexagon': NodeShapeHex, + 'square': NodeShapeRoundedSquare, + 'cloud': NodeShapeCloud }; -function isTheInternet(id) { - return id === 'theinternet'; -} - -function getNodeShape({id, pseudo, topologyId}) { - if (isTheInternet(id)) { - return NodeShapeCloud; - } else if (pseudo) { +function getNodeShape({pseudo, shape, stack}) { + if (pseudo) { return NodeShapeCircle; } - return nodeShapes[topologyId]; + const nodeShape = nodeShapes[shape]; + return stack ? stackedShape(nodeShape) : nodeShape; } export default class Node extends React.Component { diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index 54c34fe766..c600923525 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -142,6 +142,8 @@ export default class NodesChart extends React.Component { focused={node.get('focused')} highlighted={node.get('highlighted')} topologyId={this.props.topologyId} + shape={node.get('shape')} + stack={node.get('stack')} onClick={onNodeClick} key={node.get('id')} id={node.get('id')} @@ -244,6 +246,8 @@ export default class NodesChart extends React.Component { pseudo: node.get('pseudo'), subLabel: node.get('label_minor'), rank: node.get('rank'), + shape: node.get('shape'), + stack: node.get('stack'), x: 0, y: 0 }); diff --git a/client/app/scripts/stores/app-store.js b/client/app/scripts/stores/app-store.js index f5428168a4..dc65a79996 100644 --- a/client/app/scripts/stores/app-store.js +++ b/client/app/scripts/stores/app-store.js @@ -41,6 +41,8 @@ function makeNode(node) { label_minor: node.label_minor, rank: node.rank, pseudo: node.pseudo, + stack: node.stack, + shape: node.shape, adjacency: node.adjacency }; }