Files
weave-scope/client/app/scripts/selectors/topology.js
Filip Barl 69fd397217 Initial version of the resource view (#2296)
* Added resource view selector button

* Showing resource boxes in the resource view

* Crude CPU resource view prototype

* Improved the viewMode state logic

* Extracted zooming into a separate wrapper component

* Split the layout selectors between graph-view and resource-view

* Proper zooming logic for the resource view

* Moved all node networks utils to selectors

* Improved the zoom caching logic

* Further refactoring of selectors

* Added sticky labels to the resource boxes

* Added panning translation limits in the resource view

* Renamed GridModeSelector -> ViewModeSelector

* Polished the topology resource view selection logic

* Search bar hidden in the resource view

* Added per-layer topology names to the resource view

* Made metric selectors work for the resource view

* Adjusted the viewport selectors

* Renamed viewport selector to canvas (+ maximal zoom fix)

* Showing more useful metric info in the resource box labels

* Fetching only necessary nodes for the resource view

* Refactored the resource view layer component

* Addressed first batch UI comments (from the Scope meeting)

* Switch to deep zooming transform in the resource view to avoid SVG precision errors

* Renamed and moved resource view components

* Polished all the resource view components

* Changing the available metrics selection

* Improved and polished the state transition logic for the resource view

* Separated zoom limits from the zoom active state

* Renaming and bunch of comments

* Addressed all the UI comments (@davkal + @fons)

* Made graph view selectors independent from resource view selectors
2017-03-24 14:51:53 +01:00

54 lines
1.5 KiB
JavaScript

import { createSelector } from 'reselect';
import {
RESOURCE_VIEW_MODE,
GRAPH_VIEW_MODE,
TABLE_VIEW_MODE,
} from '../constants/naming';
// TODO: Consider moving more stuff from 'topology-utils' here.
export const isGraphViewModeSelector = createSelector(
[
state => state.get('topologyViewMode'),
],
viewMode => viewMode === GRAPH_VIEW_MODE
);
export const isTableViewModeSelector = createSelector(
[
state => state.get('topologyViewMode'),
],
viewMode => viewMode === TABLE_VIEW_MODE
);
export const isResourceViewModeSelector = createSelector(
[
state => state.get('topologyViewMode'),
],
viewMode => viewMode === RESOURCE_VIEW_MODE
);
// Checks if graph complexity is high. Used to trigger
// table view on page load and decide on animations.
export const graphExceedsComplexityThreshSelector = createSelector(
[
state => state.getIn(['currentTopology', 'stats', 'node_count']) || 0,
state => state.getIn(['currentTopology', 'stats', 'edge_count']) || 0,
],
(nodeCount, edgeCount) => (nodeCount + (2 * edgeCount)) > 1000
);
// Options for current topology, sub-topologies share options with parent
export const activeTopologyOptionsSelector = createSelector(
[
state => state.getIn(['currentTopology', 'parentId']),
state => state.get('currentTopologyId'),
state => state.get('topologyOptions'),
],
(parentTopologyId, currentTopologyId, topologyOptions) => (
topologyOptions.get(parentTopologyId || currentTopologyId)
)
);