Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarl committed Mar 20, 2017
1 parent 786795a commit 2b92f25
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 48 deletions.
7 changes: 6 additions & 1 deletion client/app/scripts/actions/app-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
} from '../constants/naming';

const log = debug('scope:app-actions');
// const MULTIPLE_TOPOLOGIES_FETCH_DELAY_MS = 1200;

export function showHelp() {
return {type: ActionTypes.SHOW_HELP};
Expand Down Expand Up @@ -367,6 +368,8 @@ export function clickShowTopologyForNode(topologyId, nodeId) {
activeTopologyOptionsSelector(state),
dispatch
);
// Update the nodes for all topologies that appear in the current resource view.
getResourceViewNodesSnapshot(getState, dispatch);
};
}

Expand All @@ -385,6 +388,8 @@ export function clickTopology(topologyId) {
activeTopologyOptionsSelector(state),
dispatch
);
// Update the nodes for all topologies that appear in the current resource view.
getResourceViewNodesSnapshot(getState, dispatch);
};
}

Expand Down Expand Up @@ -733,7 +738,7 @@ export function route(urlState) {
// the layers in the resource view.
if (isResourceViewModeSelector(state)) {
// Get all the nodes for the current resource view layout in the next run-cycle.
setTimeout(() => { getResourceViewNodesSnapshot(getState, dispatch); }, 0);
setTimeout(() => { getResourceViewNodesSnapshot(getState, dispatch); }, 100);
}
};
}
Expand Down
1 change: 0 additions & 1 deletion client/app/scripts/charts/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class Node extends React.Component {
exportingGraph, showingNetworks, stack, id, metric } = this.props;
const { hovered } = this.state;

// console.log(metric && metric.toJS());
const color = getNodeColor(rank, label, pseudo);
const truncate = !focused && !hovered;
const labelOffsetY = (showingNetworks && networks) ? 40 : 28;
Expand Down
59 changes: 30 additions & 29 deletions client/app/scripts/charts/nodes-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,53 @@ import CachableZoomWrapper from '../components/cachable-zoom-wrapper';
import { clickBackground } from '../actions/app-actions';


const EdgeMarkerDefinition = ({ selectedNodeId }) => {
const markerOffset = selectedNodeId ? '35' : '40';
const markerSize = selectedNodeId ? '10' : '30';
return (
<defs>
<marker
className="edge-marker"
id="end-arrow"
viewBox="1 0 10 10"
refX={markerOffset}
refY="3.5"
markerWidth={markerSize}
markerHeight={markerSize}
orient="auto">
<polygon className="link" points="0 0, 10 3.5, 0 7" />
</marker>
</defs>
);
};

class NodesChart extends React.Component {
constructor(props, context) {
super(props, context);

this.handleMouseClick = this.handleMouseClick.bind(this);
}

render() {
// TODO: What to do with empty?
const { isEmpty, selectedNodeId } = this.props;
const markerOffset = selectedNodeId ? '35' : '40';
const markerSize = selectedNodeId ? '10' : '30';
const svgClassNames = isEmpty ? 'hide' : '';
handleMouseClick() {
if (this.props.selectedNodeId) {
this.props.clickBackground();
}
}

render() {
const { selectedNodeId } = this.props;
return (
<div className="nodes-chart">
<svg
width="100%" height="100%" id="nodes-chart-canvas"
className={svgClassNames} onClick={this.handleMouseClick}>
<defs>
<marker
className="edge-marker"
id="end-arrow"
viewBox="1 0 10 10"
refX={markerOffset}
refY="3.5"
markerWidth={markerSize}
markerHeight={markerSize}
orient="auto">
<polygon className="link" points="0 0, 10 3.5, 0 7" />
</marker>
</defs>
<svg className="canvas" width="100%" height="100%" onClick={this.handleMouseClick}>
<Logo transform="translate(24,24) scale(0.25)" />
<CachableZoomWrapper disabled={selectedNodeId}>
<EdgeMarkerDefinition selectedNodeId={selectedNodeId} />
<CachableZoomWrapper svg="canvas" disabled={selectedNodeId}>
<NodesChartElements />
</CachableZoomWrapper>
</svg>
</div>
);
}

handleMouseClick() {
if (this.props.selectedNodeId) {
this.props.clickBackground();
}
}
}


Expand Down
3 changes: 1 addition & 2 deletions client/app/scripts/components/cachable-zoom-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class CachableZoomWrapper extends React.Component {
componentDidMount() {
this.zoomRestored = false;
this.zoom = zoom().on('zoom', this.zoomed);
// TODO: Make this correct
this.svg = select('.nodes-chart svg');
this.svg = select(`svg.${this.props.svg}`);

this.setZoomTriggers(!this.props.disabled);
this.restoreCachedZoom(this.props);
Expand Down
8 changes: 3 additions & 5 deletions client/app/scripts/components/nodes-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ class NodesResources extends React.Component {

render() {
return (
<div className="nodes-chart">
<svg
width="100%" height="100%"
id="nodes-chart-canvas">
<div className="nodes-resources">
<svg className="canvas" width="100%" height="100%">
<Logo transform="translate(24,24) scale(0.25)" />
<CachableZoomWrapper bounded forwardTransform fixVertical>
<CachableZoomWrapper svg="canvas" bounded forwardTransform fixVertical>
{transform => this.renderLayers(transform)}
</CachableZoomWrapper>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const transformedDimensions = (props) => {
const xStart = Math.max(RESOURCES_LAYER_TITLE_WIDTH, x);
const xEnd = Math.min(x + width, props.viewportWidth);

// Update the horizontal tranform with trimmed values.
// Update the horizontal transform with trimmed values.
return {
width: xEnd - xStart,
height,
Expand Down Expand Up @@ -74,7 +74,7 @@ class NodeResourcesMetricBox extends React.Component {
const { x, y, width } = this.state;

const showInfo = width >= RESOURCES_LABEL_MIN_SIZE;
const showNode = width >= 1;
const showNode = width >= 1; // px

// Don't display the nodes which are less than 1px wide.
// TODO: Show `+ 31 nodes` kind of tag in their stead.
Expand Down
5 changes: 3 additions & 2 deletions client/app/scripts/selectors/resource-view/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const decoratedNodesByTopologySelector = createSelector(
.map(nodeResourceBoxDecorator)
.map(nodeParentNodeDecorator);
const filteredTopologyNodes = decoratedTopologyNodes
.filter(node => node.get('parentNodeId') || index === 0)
.filter(node => nodesByTopology.hasIn([lastLayerTopologyId, node.get('parentNodeId')])
|| index === 0)
.filter(node => node.get('width'));

nodesByTopology = nodesByTopology.set(layerTopologyId, filteredTopologyNodes);
Expand Down Expand Up @@ -107,7 +108,7 @@ export const positionedNodesByTopologySelector = createSelector(
const parentWidth = result.getIn([parentTopologyId, parentNodeId, 'width'], offset);
const overhead = (offset - parentOffset) / parentWidth;
if (overhead > 1) {
console.log(overhead);
// console.log(overhead);
bucket.forEach((_, nodeId) => {
const node = result.getIn([layerTopologyId, nodeId]);
result = result.mergeIn([layerTopologyId, nodeId], makeMap({
Expand Down
7 changes: 1 addition & 6 deletions client/app/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@

}

.nodes-chart {
.nodes-chart, .nodes-resources {

&-error, &-loading {
@extend .hideable;
Expand Down Expand Up @@ -307,11 +307,6 @@
transition: opacity .2s $base-ease;
text-align: center;

.node-network {
// stroke: $background-lighter-color;
// stroke-width: 4px;
}

.node-label {
color: $text-color;
}
Expand Down

0 comments on commit 2b92f25

Please sign in to comment.