Skip to content

Commit 59bb6c4

Browse files
committed
Improve ability to edit jbrowse track JSON
1 parent f98e0dc commit 59bb6c4

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

jbrowse/resources/web/jbrowse/window/ModifyJsonConfigWindow.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,52 @@ Ext4.define('JBrowse.window.ModifyJsonConfigWindow', {
176176
});
177177

178178
this.callParent(arguments);
179+
180+
if (this.jsonFiles.length === 1) {
181+
Ext4.Msg.wait('Loading...');
182+
LABKEY.Query.selectRows({
183+
schemaName: 'jbrowse',
184+
queryName: 'jsonfiles',
185+
filterArray: [
186+
LABKEY.Filter.create('objectid', this.jsonFiles.join(';'), LABKEY.Filter.Types.EQUALS_ONE_OF)
187+
],
188+
columns: 'objectid,trackjson',
189+
scope: this,
190+
success: this.onSelectLoad,
191+
failure: LDK.Utils.getErrorCallback()
192+
});
193+
}
194+
},
195+
196+
onSelectLoad: function(results){
197+
Ext4.Msg.hide();
198+
if (results.rows && results.rows.length) {
199+
if (!results.rows[0].trackJson) {
200+
return;
201+
}
202+
203+
var json = JSON.parse(results.rows[0].trackJson);
204+
var store = this.down('ldk-gridpanel').store;
205+
for (var attribute in json) {
206+
var val = json[attribute];
207+
var dataType = 'STRING';
208+
if (typeof val === 'number' && !isNaN(val)){
209+
dataType = Number.isInteger(val) ? 'INT' : 'FLOAT';
210+
}
211+
else if (typeof val === 'string') {
212+
dataType = 'STRING';
213+
}
214+
else if (typeof val === 'boolean') {
215+
dataType = 'BOOLEAN';
216+
}
217+
218+
store.add(store.createModel({
219+
attribute: attribute,
220+
value: val,
221+
dataType: dataType
222+
}));
223+
}
224+
}
179225
},
180226

181227
addAttribute: function(attribute, value, dataType){

jbrowse/src/org/labkey/jbrowse/model/JsonFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ public File prepareResource(Logger log, boolean throwIfNotPrepared, boolean forc
837837
{
838838
if (!targetFile.getParentFile().equals(finalLocation.getParentFile()))
839839
{
840-
// Make local copy so we dont delete the original
840+
log.debug("Creating local copy of: " + targetFile.getPath());
841841
File local = new File(finalLocation.getParentFile(), targetFile.getName());
842842
if (local.exists())
843843
{

0 commit comments

Comments
 (0)