Let shape be determined by backend

This commit is contained in:
David Kaltschmidt
2016-02-05 15:07:50 +01:00
committed by Simon Howe
parent 3f7f55e87e
commit 476b7917e4
3 changed files with 15 additions and 16 deletions

View File

@@ -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) {
return NodeShapeCircle;
function getNodeShape({shape, stack}) {
const nodeShape = nodeShapes[shape];
if (!nodeShape) {
throw new Error(`Unkown shape: ${shape}!`);
}
return nodeShapes[topologyId];
return stack ? stackedShape(nodeShape) : nodeShape;
}
export default class Node extends React.Component {

View File

@@ -143,6 +143,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')}
@@ -245,6 +247,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
});

View File

@@ -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
};
}