mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 18:51:17 +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.
97 lines
2.9 KiB
JavaScript
97 lines
2.9 KiB
JavaScript
import page from 'page';
|
|
|
|
import { route } from '../actions/app-actions';
|
|
|
|
//
|
|
// page.js won't match the routes below if ":state" has a slash in it, so replace those before we
|
|
// load the state into the URL.
|
|
//
|
|
const SLASH = '/';
|
|
const SLASH_REPLACEMENT = '<SLASH>';
|
|
const PERCENT = '%';
|
|
const PERCENT_REPLACEMENT = '<PERCENT>';
|
|
|
|
function encodeURL(url) {
|
|
return url
|
|
.replace(new RegExp(PERCENT, 'g'), PERCENT_REPLACEMENT)
|
|
.replace(new RegExp(SLASH, 'g'), SLASH_REPLACEMENT);
|
|
}
|
|
|
|
function decodeURL(url) {
|
|
return decodeURIComponent(url.replace(new RegExp(SLASH_REPLACEMENT, 'g'), SLASH))
|
|
.replace(new RegExp(PERCENT_REPLACEMENT, 'g'), PERCENT);
|
|
}
|
|
|
|
function shouldReplaceState(prevState, nextState) {
|
|
// Opening a new terminal while an existing one is open.
|
|
const terminalToTerminal = (prevState.controlPipe && nextState.controlPipe);
|
|
// Closing a terminal.
|
|
const closingTheTerminal = (prevState.controlPipe && !nextState.controlPipe);
|
|
|
|
return terminalToTerminal || closingTheTerminal;
|
|
}
|
|
|
|
export function getUrlState(state) {
|
|
const cp = state.get('controlPipes').last();
|
|
const nodeDetails = state.get('nodeDetails').toIndexedSeq().map(details => ({
|
|
id: details.id, label: details.label, topologyId: details.topologyId
|
|
}));
|
|
|
|
const urlState = {
|
|
controlPipe: cp ? cp.toJS() : null,
|
|
mode: state.get('gridMode') ? 'grid' : 'topo',
|
|
nodeDetails: nodeDetails.toJS(),
|
|
pinnedMetricType: state.get('pinnedMetricType'),
|
|
pinnedSearches: state.get('pinnedSearches').toJS(),
|
|
searchQuery: state.get('searchQuery'),
|
|
selectedNodeId: state.get('selectedNodeId'),
|
|
gridSortBy: state.get('gridSortBy'),
|
|
gridSortedDesc: state.get('gridSortedDesc'),
|
|
topologyId: state.get('currentTopologyId'),
|
|
topologyOptions: state.get('topologyOptions').toJS() // all options
|
|
};
|
|
|
|
if (state.get('showingNetworks')) {
|
|
urlState.showingNetworks = true;
|
|
if (state.get('pinnedNetwork')) {
|
|
urlState.pinnedNetwork = state.get('pinnedNetwork');
|
|
}
|
|
}
|
|
|
|
return urlState;
|
|
}
|
|
|
|
export function updateRoute(getState) {
|
|
const state = getUrlState(getState());
|
|
const stateUrl = encodeURL(JSON.stringify(state));
|
|
const dispatch = false;
|
|
const urlStateString = window.location.hash
|
|
.replace('#!/state/', '')
|
|
.replace('#!/', '') || '{}';
|
|
const prevState = JSON.parse(decodeURL(urlStateString));
|
|
|
|
if (shouldReplaceState(prevState, state)) {
|
|
// Replace the top of the history rather than pushing on a new item.
|
|
page.replace(`/state/${stateUrl}`, state, dispatch);
|
|
} else {
|
|
page.show(`/state/${stateUrl}`, state, dispatch);
|
|
}
|
|
}
|
|
|
|
|
|
export function getRouter(dispatch, initialState) {
|
|
// strip any trailing '/'s.
|
|
page.base(window.location.pathname.replace(/\/$/, ''));
|
|
|
|
page('/', () => {
|
|
dispatch(route(initialState));
|
|
});
|
|
|
|
page('/state/:state', (ctx) => {
|
|
const state = JSON.parse(decodeURL(ctx.params.state));
|
|
dispatch(route(state));
|
|
});
|
|
|
|
return page;
|
|
}
|