Skip to content

Commit

Permalink
Autosave configs on publish events
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 26, 2018
1 parent 1c966bf commit 18cefef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
7 changes: 4 additions & 3 deletions src/JBrowse/Browser.js
Expand Up @@ -1976,7 +1976,7 @@ _calculateClientStats: function() {

publish: function() {
if( this.config.logMessages )
console.log( arguments );
console.log( arguments )

return topic.publish.apply( topic, arguments );
},
Expand Down Expand Up @@ -2197,6 +2197,7 @@ _replaceTrackConfigs: function( /**Array*/ newConfigs ) {

this.trackConfigsByName[conf.label] =
dojo.mixin( this.trackConfigsByName[ conf.label ] || {}, conf );
this.saveConfig(conf);
},this);
},
/**
Expand Down Expand Up @@ -3426,12 +3427,12 @@ teardown: function() {
}
},

saveConfig(name, config) {
saveConfig(config) {
const c = Object.assign({}, config)
delete c.store
delete c.menuTemplate
delete c.events
this.cookie('track-' + name, JSON.stringify(c));
this.cookie('track-' + config.label + '-config', JSON.stringify(c));
}

});
Expand Down
15 changes: 1 addition & 14 deletions src/JBrowse/View/Track/Alignments2.js
Expand Up @@ -84,7 +84,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
checked: this.config.glyph == 'JBrowse/View/FeatureGlyph/Alignment',
onClick: function(event) {
thisB.config.glyph = 'JBrowse/View/FeatureGlyph/Alignment'
thisB.browser.cookie('track-' + thisB.name, JSON.stringify(thisB.config));
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -95,7 +94,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
checked: this.config.glyph == 'JBrowse/View/FeatureGlyph/PairedAlignment',
onClick: function(event) {
thisB.config.glyph = 'JBrowse/View/FeatureGlyph/PairedAlignment'
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -106,7 +104,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
checked: this.config.glyph == 'JBrowse/View/FeatureGlyph/PairedArc',
onClick: function(event) {
thisB.config.glyph = 'JBrowse/View/FeatureGlyph/PairedArc'
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -116,7 +113,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
checked: this.config.glyph == 'JBrowse/View/FeatureGlyph/PairedReadCloud',
onClick: function(event) {
thisB.config.glyph = 'JBrowse/View/FeatureGlyph/PairedReadCloud'
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -129,7 +125,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
thisB.config.type = 'JBrowse/View/Track/SNPCoverage'
thisB.config._oldAlignmentsHeight = thisB.config.style.height
thisB.config.style.height = thisB.config._oldSnpCoverageHeight
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -141,7 +136,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.defaultColor = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -152,7 +146,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.useXS = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -164,7 +157,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.useTS = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -175,7 +167,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.useReverseTemplate = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -187,7 +178,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.colorByMAPQ = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -198,7 +188,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.colorByOrientation = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -209,7 +198,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.colorBySize = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -220,7 +208,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
onClick: function(event) {
thisB.clearColorConfig()
thisB.config.colorByOrientationAndSize = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand All @@ -230,7 +217,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
checked: !!this.config.showInterchromosomalArcs,
onClick: function(event) {
thisB.config.showInterchromosomalArcs = this.get('checked');
thisB.browser.saveConfig(thisB.config, thisB.name);
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
Expand Down Expand Up @@ -345,6 +331,7 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
if(none) {
this.config.defaultColor = true
}

},

renderClickMap() {
Expand Down
3 changes: 1 addition & 2 deletions src/JBrowse/View/Track/BlockBased.js
Expand Up @@ -81,7 +81,7 @@ return declare( [Component,DetailsMixin,FeatureFiltererMixin,Destroyable],

this.refSeq = args.refSeq;
this.name = args.label || this.config.label;
var cookie = this.browser.cookie("track-" + this.name);
var cookie = this.browser.cookie("track-" + this.name + '-config');
if (cookie) {
cookie = JSON.parse(cookie)
Object.assign(this.config, cookie)
Expand Down Expand Up @@ -957,7 +957,6 @@ return declare( [Component,DetailsMixin,FeatureFiltererMixin,Destroyable],
new TrackConfigEditor( that.config )
.show( function( result ) {
// replace this track's configuration
that.browser.saveConfig(result.conf, that.name);
that.browser.publish( '/jbrowse/v1/v/tracks/replace', [result.conf] );
});
}
Expand Down

0 comments on commit 18cefef

Please sign in to comment.