mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Let shape be determined by backend
This commit is contained in:
committed by
Simon Howe
parent
3f7f55e87e
commit
476b7917e4
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
});
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user