diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 1b799642e..e1ec2eca5 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -18,10 +18,12 @@ export function showHelp() { return {type: ActionTypes.SHOW_HELP}; } + export function hideHelp() { return {type: ActionTypes.HIDE_HELP}; } + export function toggleHelp() { return (dispatch, getState) => { if (getState().get('showingHelp')) { @@ -32,6 +34,20 @@ export function toggleHelp() { }; } + +export function toggleGridMode(enabled) { + return {type: ActionTypes.SET_GRID_MODE, enabled}; +} + + +export function sortOrderChanged(newOrder) { + return { + type: ActionTypes.SORT_ORDER_CHANGED, + newOrder + }; +} + + // // Networks // @@ -78,18 +94,12 @@ export function unpinNetwork(networkId) { }; } -export function sortOrderChanged(newOrder) { - AppDispatcher.dispatch({ - type: ActionTypes.SORT_ORDER_CHANGED, - newOrder - }); -} - // // Metrics // + export function selectMetric(metricId) { return { type: ActionTypes.SELECT_METRIC, diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index 41a70a047..c248cf972 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -5,7 +5,6 @@ import React from 'react'; import { connect } from 'react-redux'; import { Map as makeMap, fromJS, is as isDeepEqual } from 'immutable'; import timely from 'timely'; -import { Set as makeSet } from 'immutable'; import { clickBackground } from '../actions/app-actions'; import { EDGE_ID_SEPARATOR } from '../constants/naming'; @@ -13,8 +12,7 @@ import { DETAILS_PANEL_WIDTH } from '../constants/styles'; import Logo from '../components/logo'; import { doLayout } from './nodes-layout'; import NodesChartElements from './nodes-chart-elements'; -import { getActiveTopologyOptions, getAdjacentNodes, - isSameTopology } from '../utils/topology-utils'; +import { getActiveTopologyOptions, getAdjacentNodes } from '../utils/topology-utils'; const log = debug('scope:nodes-chart'); @@ -62,7 +60,7 @@ class NodesChart extends React.Component { // re-apply cached canvas zoom/pan to d3 behavior (or set defaul values) const defaultZoom = { scale: 1, panTranslateX: 0, panTranslateY: 0, hasZoomed: false }; const nextZoom = this.state.zoomCache[nextProps.topologyId] || defaultZoom; - if (nextZoom && this.zoom) { + if (this.zoom && nextZoom) { this.zoom.scale(nextZoom.scale); this.zoom.translate([nextZoom.panTranslateX, nextZoom.panTranslateY]); } @@ -80,13 +78,15 @@ class NodesChart extends React.Component { } // reset layout dimensions only when forced - state.height = nextProps.height; - state.width = nextProps.width; + // state.height = nextProps.height; + // state.width = nextProps.width; + state.height = nextProps.forceRelayout ? nextProps.height : (state.height || nextProps.height); + state.width = nextProps.forceRelayout ? nextProps.width : (state.width || nextProps.width); - _.assign(state, this.updateGraphState(nextProps, state)); - // if (nextProps.forceRelayout || nextProps.nodes !== this.props.nodes) { - // _.assign(state, this.updateGraphState(nextProps, state)); - // } + // _.assign(state, this.updateGraphState(nextProps, state)); + if (nextProps.forceRelayout || nextProps.nodes !== this.props.nodes) { + _.assign(state, this.updateGraphState(nextProps, state)); + } if (this.props.selectedNodeId !== nextProps.selectedNodeId) { _.assign(state, this.restoreLayout(state)); @@ -326,7 +326,6 @@ class NodesChart extends React.Component { const stateEdges = this.initEdges(props.nodes, stateNodes); const nodeScale = this.getNodeScale(props.nodes, state.width, state.height); const nextState = { nodeScale }; - console.log(props.nodeOrder); const nodeOrder = props.nodeOrder || makeMap(stateNodes .toList() .sortBy(n => n.get('label')) @@ -343,7 +342,6 @@ class NodesChart extends React.Component { nodeOrder }; - console.log('nodes-chart', state.height); const timedLayouter = timely(doLayout); const graph = timedLayouter(stateNodes, stateEdges, options); @@ -370,6 +368,7 @@ class NodesChart extends React.Component { if (!this.props.noZoom && !state.hasZoomed && zoomFactor > 0 && zoomFactor < 1) { zoomScale = zoomFactor; + console.log(zoomScale); // saving in d3's behavior cache if (this.zoom) { this.zoom.scale(zoomFactor); diff --git a/client/app/scripts/charts/nodes-grid.js b/client/app/scripts/charts/nodes-grid.js index 771f74407..91b20458f 100644 --- a/client/app/scripts/charts/nodes-grid.js +++ b/client/app/scripts/charts/nodes-grid.js @@ -2,21 +2,10 @@ import React from 'react'; import { Set as makeSet, List as makeList, Map as makeMap } from 'immutable'; -import NodesChart from './nodes-chart'; import NodeDetailsTable from '../components/node-details/node-details-table'; import { enterNode, leaveNode } from '../actions/app-actions'; -function MiniChart(props) { - const {width, height} = props; - return ( -