mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 03:01:11 +00:00
- Change scrolling behaviour to lock headers in place
- Enable filtering (hitting enter in the search bar) in grid-mode
- Little more top-margin for k8s (can have 3 topos) + taller rows.
- Trying out rank-color + node.relatives in the grid-mode
- First pass at selecting rows.
- Needs a bit more a fiddle, colors + click areas
- Store grid sort direction (asc/desc) in url state
- Simplify node selection to one method. (over-ride existing card)
- Remove clicking on name directly (links) to overlay new cards for now.
- Playing w/ grid-mode-toggle icons and labels
- Improves rendering in ff, change of shortcut keys for grid-mode-toggle
- Playing w/ clearer selection colors for grid-mode
- Slight change to selection-ui
- Fixes showNodeInTopology button visibility on the details-panel
- Was using an old heuristic. Table-mode allows you to open child cards
before the parent.
- Make it clear what the default sort is in tables
- E.g. always show a sorting caret
- Sort grid-mode columns, first meta then metrics
- dancing-nodes rememdy #1: pause updates onRowHover
- Splits relatives out into their own columns
- Take into account scrollbar width for grid-mode col header position
- Tooltips on table column headers
- grid-mode: fixes first column headers (proc/container/c-by-image)
- Disable pause-on-hover, too aggresive
- reduce label column width a bit (33pc -> 25pc) for big tables
- Filter grid-mode onSearchChange
- Rather than previous behaviour of waiting for an <enter>
- Show label_minor on pseudo nodes, that might not have much other info
- grid-mode: further reduce width of id column.
- Fixes go tests, properly moves parents into node-summary
- Fixes sorting of string columns w/ missing fields.
- E.g. uptime. Where -1e-10 > '3days' doesn't work.
158 lines
4.6 KiB
JavaScript
158 lines
4.6 KiB
JavaScript
import _ from 'lodash';
|
|
import { is as isDeepEqual, Map as makeMap, Set as makeSet } from 'immutable';
|
|
|
|
/**
|
|
* Returns a cache ID based on the topologyId and optionsQuery
|
|
* @param {String} topologyId
|
|
* @param {object} topologyOptions (optional)
|
|
* @return {String}
|
|
*/
|
|
export function buildTopologyCacheId(topologyId, topologyOptions) {
|
|
let id = '';
|
|
if (topologyId) {
|
|
id = topologyId;
|
|
if (topologyOptions) {
|
|
id += JSON.stringify(topologyOptions);
|
|
}
|
|
}
|
|
return id;
|
|
}
|
|
|
|
/**
|
|
* Returns a topology object from the topology tree
|
|
* @param {List} subTree
|
|
* @param {String} topologyId
|
|
* @return {Map} topology if found
|
|
*/
|
|
export function findTopologyById(subTree, topologyId) {
|
|
let foundTopology;
|
|
|
|
subTree.forEach(topology => {
|
|
if (_.endsWith(topology.get('url'), topologyId)) {
|
|
foundTopology = topology;
|
|
}
|
|
if (!foundTopology && topology.has('sub_topologies')) {
|
|
foundTopology = findTopologyById(topology.get('sub_topologies'), topologyId);
|
|
}
|
|
});
|
|
|
|
return foundTopology;
|
|
}
|
|
|
|
export function updateNodeDegrees(nodes, edges) {
|
|
return nodes.map(node => {
|
|
const nodeId = node.get('id');
|
|
const degree = edges.count(edge => edge.get('source') === nodeId
|
|
|| edge.get('target') === nodeId);
|
|
return node.set('degree', degree);
|
|
});
|
|
}
|
|
|
|
/* set topology.id and parentId for sub-topologies in place */
|
|
export function updateTopologyIds(topologies, parentId) {
|
|
return topologies.map(topology => {
|
|
const result = Object.assign({}, topology);
|
|
result.id = topology.url.split('/').pop();
|
|
if (parentId) {
|
|
result.parentId = parentId;
|
|
}
|
|
if (topology.sub_topologies) {
|
|
result.sub_topologies = updateTopologyIds(topology.sub_topologies, result.id);
|
|
}
|
|
return result;
|
|
});
|
|
}
|
|
|
|
export function addTopologyFullname(topologies) {
|
|
return topologies.map(t => {
|
|
if (!t.sub_topologies) {
|
|
return Object.assign({}, t, {fullName: t.name});
|
|
}
|
|
return Object.assign({}, t, {
|
|
fullName: t.name,
|
|
sub_topologies: t.sub_topologies.map(st => (
|
|
Object.assign({}, st, {fullName: `${t.name} ${st.name}`})
|
|
))
|
|
});
|
|
});
|
|
}
|
|
|
|
// adds ID field to topology (based on last part of URL path) and save urls in
|
|
// map for easy lookup
|
|
export function setTopologyUrlsById(topologyUrlsById, topologies) {
|
|
let urlMap = topologyUrlsById;
|
|
if (topologies) {
|
|
topologies.forEach(topology => {
|
|
urlMap = urlMap.set(topology.id, topology.url);
|
|
if (topology.sub_topologies) {
|
|
topology.sub_topologies.forEach(subTopology => {
|
|
urlMap = urlMap.set(subTopology.id, subTopology.url);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
return urlMap;
|
|
}
|
|
|
|
export function filterHiddenTopologies(topologies) {
|
|
return topologies.filter(t => (!t.hide_if_empty || t.stats.node_count > 0 ||
|
|
t.stats.filtered_nodes > 0));
|
|
}
|
|
|
|
export function getActiveTopologyOptions(state) {
|
|
// options for current topology, sub-topologies share options with parent
|
|
const parentId = state.getIn(['currentTopology', 'parentId']);
|
|
if (parentId) {
|
|
return state.getIn(['topologyOptions', parentId]);
|
|
}
|
|
return state.getIn(['topologyOptions', state.get('currentTopologyId')]);
|
|
}
|
|
|
|
export function getCurrentTopologyOptions(state) {
|
|
return state.getIn(['currentTopology', 'options']);
|
|
}
|
|
|
|
export function isTopologyEmpty(state) {
|
|
return state.getIn(['currentTopology', 'stats', 'node_count'], 0) === 0
|
|
&& state.get('nodes').size === 0;
|
|
}
|
|
|
|
export function getAdjacentNodes(state, originNodeId) {
|
|
let adjacentNodes = makeSet();
|
|
const nodeId = originNodeId || state.get('selectedNodeId');
|
|
|
|
if (nodeId) {
|
|
if (state.hasIn(['nodes', nodeId])) {
|
|
adjacentNodes = makeSet(state.getIn(['nodes', nodeId, 'adjacency']));
|
|
// fill up set with reverse edges
|
|
state.get('nodes').forEach((node, id) => {
|
|
if (node.get('adjacency') && node.get('adjacency').includes(nodeId)) {
|
|
adjacentNodes = adjacentNodes.add(id);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
return adjacentNodes;
|
|
}
|
|
|
|
export function hasSelectedNode(state) {
|
|
const selectedNodeId = state.get('selectedNodeId');
|
|
return state.hasIn(['nodes', selectedNodeId]);
|
|
}
|
|
|
|
export function getCurrentTopologyUrl(state) {
|
|
return state.getIn(['currentTopology', 'url']);
|
|
}
|
|
|
|
export function isSameTopology(nodes, nextNodes) {
|
|
const mapper = node => makeMap({id: node.get('id'), adjacency: node.get('adjacency')});
|
|
const topology = nodes.map(mapper);
|
|
const nextTopology = nextNodes.map(mapper);
|
|
return isDeepEqual(topology, nextTopology);
|
|
}
|
|
|
|
export function isNodeMatchingQuery(node, query) {
|
|
return node.get('label').includes(query) || node.get('subLabel').includes(query);
|
|
}
|