mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
blur nodes that not selected nor adjacent
This commit is contained in:
@@ -51,18 +51,26 @@ const Edge = React.createClass({
|
||||
},
|
||||
|
||||
render: function() {
|
||||
const className = this.props.highlighted ? 'edge highlighted' : 'edge';
|
||||
const classNames = ['edge'];
|
||||
const points = flattenPoints(this.props.points);
|
||||
const props = this.props;
|
||||
const handleMouseEnter = this.handleMouseEnter;
|
||||
const handleMouseLeave = this.handleMouseLeave;
|
||||
|
||||
if (this.props.highlighted) {
|
||||
classNames.push('highlighted');
|
||||
}
|
||||
if (this.props.blurred) {
|
||||
classNames.push('blurred');
|
||||
}
|
||||
const classes = classNames.join(' ');
|
||||
|
||||
return (
|
||||
<Spring endValue={points}>
|
||||
{function(interpolated) {
|
||||
const path = line(extractPoints(interpolated));
|
||||
return (
|
||||
<g className={className} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} id={props.id}>
|
||||
<g className={classes} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} id={props.id}>
|
||||
<path d={path} className="shadow" />
|
||||
<path d={path} className="link" />
|
||||
</g>
|
||||
|
||||
@@ -26,17 +26,20 @@ const Node = React.createClass({
|
||||
if (this.props.highlighted) {
|
||||
classNames.push('highlighted');
|
||||
}
|
||||
|
||||
if (this.props.blurred) {
|
||||
classNames.push('blurred');
|
||||
}
|
||||
if (this.props.pseudo) {
|
||||
classNames.push('pseudo');
|
||||
}
|
||||
const classes = classNames.join(' ');
|
||||
|
||||
return (
|
||||
<Spring endValue={{x: {val: this.props.dx, config: animConfig}, y: {val: this.props.dy, config: animConfig}}}>
|
||||
{function(interpolated) {
|
||||
const transform = 'translate(' + interpolated.x.val + ',' + interpolated.y.val + ')';
|
||||
return (
|
||||
<g className={classNames.join(' ')} transform={transform} id={props.id}
|
||||
<g className={classes} transform={transform} id={props.id}
|
||||
onClick={onClick} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
|
||||
{props.highlighted && <circle r={scale(0.7)} className="highlighted"></circle>}
|
||||
<circle r={scale(0.5)} className="border" stroke={color}></circle>
|
||||
|
||||
@@ -82,11 +82,18 @@ const NodesChart = React.createClass({
|
||||
},
|
||||
|
||||
renderGraphNodes: function(nodes, scale) {
|
||||
const hasSelectedNode = this.props.selectedNodeId && this.props.nodes.has(this.props.selectedNodeId);
|
||||
const adjacency = hasSelectedNode ? this.props.nodes.get(this.props.selectedNodeId).get('adjacency') : null;
|
||||
return _.map(nodes, function(node) {
|
||||
const highlighted = _.includes(this.props.highlightedNodeIds, node.id)
|
||||
|| this.props.selectedNodeId === node.id;
|
||||
const blurred = hasSelectedNode
|
||||
&& this.props.selectedNodeId !== node.id
|
||||
&& !adjacency.includes(node.id);
|
||||
|
||||
return (
|
||||
<Node
|
||||
blurred={blurred}
|
||||
highlighted={highlighted}
|
||||
onClick={this.props.onNodeClick}
|
||||
key={node.id}
|
||||
@@ -104,10 +111,17 @@ const NodesChart = React.createClass({
|
||||
},
|
||||
|
||||
renderGraphEdges: function(edges) {
|
||||
const selectedNodeId = this.props.selectedNodeId;
|
||||
const hasSelectedNode = selectedNodeId && this.props.nodes.has(selectedNodeId);
|
||||
|
||||
return _.map(edges, function(edge) {
|
||||
const highlighted = _.includes(this.props.highlightedEdgeIds, edge.id);
|
||||
const blurred = hasSelectedNode
|
||||
&& edge.source.id !== selectedNodeId
|
||||
&& edge.target.id !== selectedNodeId;
|
||||
return (
|
||||
<Edge key={edge.id} id={edge.id} points={edge.points} highlighted={highlighted} />
|
||||
<Edge key={edge.id} id={edge.id} points={edge.points} blurred={blurred}
|
||||
highlighted={highlighted} />
|
||||
);
|
||||
}, this);
|
||||
},
|
||||
@@ -200,7 +214,7 @@ const NodesChart = React.createClass({
|
||||
return;
|
||||
}
|
||||
|
||||
const adjacency = props.nodes.get(props.selectedNodeId).get('adjacency');
|
||||
const adjacency = this.props.nodes.get(props.selectedNodeId).get('adjacency');
|
||||
const adjacentLayoutNodes = [];
|
||||
|
||||
adjacency.forEach(function(adjacentId) {
|
||||
|
||||
@@ -93,6 +93,12 @@ const AppStore = assign({}, EventEmitter.prototype, {
|
||||
return activeTopologyOptions;
|
||||
},
|
||||
|
||||
getAdjacentNodes: function() {
|
||||
if (nodes.has(selectedNodeId)) {
|
||||
return nodes.get(selectedNodeId).get('adjacency');
|
||||
}
|
||||
},
|
||||
|
||||
getCurrentTopology: function() {
|
||||
if (!currentTopology) {
|
||||
currentTopology = setTopology(currentTopologyId);
|
||||
|
||||
@@ -176,6 +176,11 @@ body {
|
||||
|
||||
g.node {
|
||||
cursor: pointer;
|
||||
transition: opacity .5s ease-in-out;
|
||||
|
||||
&.blurred {
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
&.pseudo {
|
||||
opacity: 0.8;
|
||||
@@ -197,6 +202,12 @@ body {
|
||||
}
|
||||
|
||||
.edge {
|
||||
transition: opacity .5s ease-in-out;
|
||||
|
||||
&.blurred {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.link {
|
||||
stroke: @text-secondary-color;
|
||||
stroke-width: 1.5px;
|
||||
|
||||
Reference in New Issue
Block a user