Skip to content

Commit

Permalink
persist trice filter disablings; change major timeline label to MTicks
Browse files Browse the repository at this point in the history
See block comments on TriceLog._applyDiskState for limitations of the
persistence.  In general it should work as long as it's actually the
same JSON file we're loading each time.  But if we get a truncated
file, data could get lost.

The timeline major label was a date before, which was confusing because
the timescale is entirely synthetic.  Now it's also MTicks which is not
an exceedingly useful scale, but is at least consistent.
  • Loading branch information
asutherland committed May 28, 2018
1 parent 7de529d commit 83705ec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"space-before-function-paren": 0,
"space-in-parens": 0,
"strict": 0,
"quotes": [2, "single", "avoid-escape"],
"quotes": [0, "single", "avoid-escape"],
"valid-jsdoc": [0, {
"prefer": {
"return": "returns"
Expand Down
1 change: 1 addition & 0 deletions src/grok-ui/components/dirtying_component.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class DirtyingComponent extends React.PureComponent {
if (this._extraEvents) {
for (const eventName of this._extraEvents) {
const methodName = eventName[0].toUpperCase() + eventName.slice(1);
console.log('BINDING', eventName, methodName);
this.repObj.on(eventName, this[methodName], this);
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/grok-ui/components/sheets/trice_timeline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TriceTimelineVis from '../trice_timeline/timeline_vis.jsx';
*/
export default class TriceTimelineSheet extends React.PureComponent {
constructor(props) {
super(props, 'triceLog', ['persistedStateDirty']);
super(props);

const triceLog = this.props.triceLog;
const sessionThing = this.props.sessionThing;
Expand Down Expand Up @@ -47,10 +47,16 @@ export default class TriceTimelineSheet extends React.PureComponent {
componentWillMount() {
this.props.sessionThing.handleSlotMessage(
'triceLog:vis:seek', this.onSeekRequest);

this.props.triceLog.on(
'persistedStateDirty', this.onPersistedStateDirty, this);
}

componentWillUnmount() {
this.props.sessionThing.stopHandlingSlotMessage('triceLog:vis:seek');

this.props.triceLog.removeListener(
'persistedStateDirty', this.onPersistedStateDirty, this);
}

onPersistedStateDirty() {
Expand All @@ -60,6 +66,7 @@ export default class TriceTimelineSheet extends React.PureComponent {
const newState = Object.assign({}, oldState, {
logPersisted: triceLog.toPersisted()
});
console.log("updating persisted state", newState, "from", oldState);
sessionThing.updatePersistedState(newState);
}

Expand Down
6 changes: 5 additions & 1 deletion src/grok-ui/components/trice_timeline/timeline_vis.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ export default class TriceTimelineVis extends DirtyingComponent {
zoomMin: 10,
zoomMax: 1 * 1000 * 1000,
format: {
minorLabels: function(date, scale/*, step*/) {
minorLabels: function(date/*, scale/*, step*/) {
const relTicks = Math.floor(date * triceLog.SCALE / 1000000);
return `${relTicks} MTicks`;
},
majorLabels: function(date/*, scale/*, step*/) {
const relTicks = Math.floor(date * triceLog.SCALE / 1000000);
return `${relTicks} MTicks`;
}
Expand Down
4 changes: 2 additions & 2 deletions src/grokysis/frontend/trice_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default class TriceLog extends EE {
* potentially be further grouped into "network" and "graphics".
*/
_applyDiskState(diskRep) {
function traverseFacet(diskFacet, facet) {
const traverseFacet = (diskFacet, facet) => {
// Toggle if we don't match.
if (diskFacet.included !== facet.included) {
this.toggleFilteringOutFacet(facet, true);
Expand All @@ -200,7 +200,7 @@ export default class TriceLog extends EE {

traverseFacet(kidDisk, kidFacet);
}
}
};

for (const diskFacet of diskRep.facets) {
const facet = this.facetsByName.get(diskFacet.name);
Expand Down

0 comments on commit 83705ec

Please sign in to comment.