Skip to content

Commit

Permalink
Key binding to clear metrics "q"
Browse files Browse the repository at this point in the history
Going w/ the `top` key mappings, needs discussion.
  • Loading branch information
foot committed Mar 14, 2016
1 parent e88322c commit 9fbcb5d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion client/app/scripts/charts/node-shape-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default function NodeShapeStack(props) {
<g transform={`translate(${dx * 1}, ${dy * 1})`}>
<Shape {...props} />
</g>
<Shape {...props} />
<g className="onlyMetrics">
<Shape {...props} />
</g>
</g>
);
}
11 changes: 10 additions & 1 deletion client/app/scripts/components/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import debug from 'debug';

import Logo from './logo';
import AppStore from '../stores/app-store';
Expand All @@ -8,7 +9,8 @@ import Status from './status.js';
import Topologies from './topologies.js';
import TopologyOptions from './topology-options.js';
import { getApiDetails, getTopologies } from '../utils/web-api-utils';
import { lockNextMetric, hitEsc } from '../actions/app-actions';
import { lockNextMetric, hitEsc, unlockMetric,
selectMetric } from '../actions/app-actions';
import Details from './details';
import Nodes from './nodes';
import MetricSelector from './metric-selector';
Expand All @@ -19,8 +21,10 @@ import { showingDebugToolbar, toggleDebugToolbar,

const ESC_KEY_CODE = 27;
const D_KEY_CODE = 68;
const Q_KEY_CODE = 81;
const RIGHT_ANGLE_KEY_IDENTIFIER = 'U+003C';
const LEFT_ANGLE_KEY_IDENTIFIER = 'U+003E';
const keyPressLog = debug('scope:app-key-press');

function getStateFromStores() {
return {
Expand Down Expand Up @@ -76,12 +80,17 @@ export default class App extends React.Component {
}

onKeyPress(ev) {
keyPressLog('onKeyPress',
'keyCode', ev.keyCode, 'keyIdentifier', ev.keyIdentifier);
if (ev.keyCode === ESC_KEY_CODE) {
hitEsc();
} else if (ev.keyIdentifier === RIGHT_ANGLE_KEY_IDENTIFIER) {
lockNextMetric(-1);
} else if (ev.keyIdentifier === LEFT_ANGLE_KEY_IDENTIFIER) {
lockNextMetric(1);
} else if (ev.keyCode === Q_KEY_CODE) {
unlockMetric();
selectMetric(null);
} else if (ev.keyCode === D_KEY_CODE) {
toggleDebugToolbar();
this.forceUpdate();
Expand Down
1 change: 1 addition & 0 deletions client/app/scripts/components/debug-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class DebugToolbar extends React.Component {
<label>Logging</label>
<button onClick={() => enableLog('*')}>scope:*</button>
<button onClick={() => enableLog('dispatcher')}>scope:dispatcher</button>
<button onClick={() => enableLog('app-key-press')}>scope:app-key-press</button>
<button onClick={() => disableLog()}>Disable log</button>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions client/app/styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ h2 {
.highlighted { display: inline; }
}

.stack .shape .metric-fill {
display: none;
}
.stack .onlyMetrics .shape .metric-fill {
display: inline-block;
}

.shape {
/* cloud paths have stroke-width set dynamically */
&:not(.shape-cloud) .border {
Expand Down

0 comments on commit 9fbcb5d

Please sign in to comment.