Skip to content

Commit

Permalink
Let shape be determined by backend
Browse files Browse the repository at this point in the history
  • Loading branch information
davkal committed Feb 5, 2016
1 parent f03afc3 commit 6032d95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
23 changes: 8 additions & 15 deletions client/app/scripts/charts/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions client/app/scripts/charts/nodes-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')}
Expand Down Expand Up @@ -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
});
Expand Down
2 changes: 2 additions & 0 deletions client/app/scripts/stores/app-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
Expand Down

0 comments on commit 6032d95

Please sign in to comment.