Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 24 additions & 33 deletions signalData/resources/views/mockSignalDataWatch.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@
}
});

var dataRows = [],
dataInputs = [];
var dataRows = [], dataInputs = [];

Ext4.each(fileSet, function(file) {
var fileName = file['FileName'];
dataRows.push({
Name: file.text,
DataFile: SIGNAL_DATA_FILE_ROOT + file.text,
Name: fileName,
DataFile: SIGNAL_DATA_FILE_ROOT + fileName,
TestType: 'SMP'
});
dataInputs.push({
name: file.text,
dataFileURL: file.dataFileURL
name: fileName,
dataFileURL: file['DataFileUrl']
});
});

run.dataRows = dataRows;
run.dataInputs = dataInputs;

return run;
}

Expand Down Expand Up @@ -197,33 +197,24 @@
{
if (Ext4.isFunction(callback)) {

var received = 0;
var newFiles = [];

function done(file, results)
{
Ext4.each(files, function(f) {
if (f.text === file.text) {
f['dataFileURL'] = results['DataFileUrl'];
newFiles.push(f);
}
});
received++;

if (received == files.length) {
callback.call(scope || this, newFiles);
}
}
var paths = [];
var fileNames = [];
files.forEach(function (file) {
paths.push(decodeURIComponent(file.id));
fileNames.push(file.text);
}, this);

Ext4.each(files, function(file) {
LABKEY.Ajax.request({
url: LABKEY.ActionURL.buildURL('signaldata', 'getSignalDataResource.api'),
method: 'POST',
params: { path: decodeURIComponent(file.id), test: true },
success: function(response) {
done(file, Ext4.decode(response.responseText));
}
});
LABKEY.Ajax.request({
url: LABKEY.ActionURL.buildURL('SignalData', 'getSignalDataResource.api'),
method: 'POST',
jsonData: {
paths : paths,
files : fileNames
},
success: LABKEY.Utils.getCallbackWrapper(function(response) {
callback.call(scope || this, response.files);
}, this),
scope: this
});
}
}
Expand Down
18 changes: 11 additions & 7 deletions signalData/resources/web/signaldata/ResultUpdate/resultupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var getResultData = function(assay) {
requiredVersion: 13.2,
filterArray: [LABKEY.Filter.create('RowId', LABKEY.ActionURL.getParameter('rowId'))],
success: function(results){
if (results.length > 0) {
init(assay, results.getRow(0));
if (results.rowCount > 0) {
init(assay, results.rows[0]);
}
else {
// Use an ExtJS alert instead of a raw browser alert to avoid alarming the crawler
Expand Down Expand Up @@ -64,12 +64,16 @@ var init = function(assay, row){
LABKEY.Ajax.request({
url: LABKEY.ActionURL.buildURL('SignalData', 'getSignalDataResource.api'),
method: 'POST',
params: {path: decodeURIComponent(file.internalId), test: true},
success: function (response) {
var fileResource = Ext4.decode(response.responseText);
var updatedRow = setRunFields(form, fileResource);
updateRunResult(updatedRow, fileResource);
params: {
paths: [decodeURIComponent(file.internalId)],
files: [file.name]
},
success: LABKEY.Utils.getCallbackWrapper(function(response) {
Ext4.each(response.files, function(file) {
var updatedRow = setRunFields(form, file);
updateRunResult(updatedRow, file);
}, this);
}, this),
scope: this
});
}
Expand Down
119 changes: 80 additions & 39 deletions signalData/resources/web/signaldata/UploadView/UploadLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,56 @@ Ext4.define('LABKEY.SignalData.UploadLog', {
if (Ext4.isFunction(callback)) {
var me = this;
var destination = this.fileSystem.concatPaths(this.fileSystem.getBaseURL(), targetDirectory);
this.fileSystem.renamePath({
source: this.getWorkingPath(),
destination: destination,
isFile: false,
success: function () {
me.resolveFileResources(targetDirectory, callback, scope, runProperties);

const getResourcesCallback = function(files) {
if (files && files.length > 0) {
// files currently exist, validate and resolve before creating the run
me.resolveDataFileURL(files, callback, scope, runProperties);
}
});
else {
// files need to be moved to the target directory
this.fileSystem.renamePath({
source: this.getWorkingPath(),
destination: destination,
isFile: false,
success: function () {
me.resolveFileResources(targetDirectory, callback, scope, runProperties);
}
});
}
};

// get the list of files in the target directory (if any)
this.getTargetDirResources(targetDirectory, getResourcesCallback, this);
}
},

/**
* Returns the list of data files in the target directory. Uploaded run data files are moved from
* a temporary location to the target directory before the run is created.
*/
getTargetDirResources : function (targetDirectory, callback, callbackScope) {
var fileUri = this.fileSystem.concatPaths(this.fileSystem.getAbsoluteURL(), targetDirectory);
LABKEY.Ajax.request({
url: fileUri,
method: 'GET',
params: {method: 'JSON'},
success: function (response) {
var json = Ext4.decode(response.responseText);
var files = [];
if (Ext4.isDefined(json) && Ext4.isArray(json.files))
files = json.files;

callback.call(callbackScope, files);
},
failure: function() {
// this is normal in the case where the target directory does not yet exist or
// the files have not yet been moved there
callback.call(callbackScope, []);
}
});
},

resolveFileResources: function (targetDirectory, callback, callbackScope, runProperties) {
var fileUri = this.fileSystem.concatPaths(this.fileSystem.getAbsoluteURL(), targetDirectory);
LABKEY.Ajax.request({
Expand All @@ -269,9 +308,10 @@ Ext4.define('LABKEY.SignalData.UploadLog', {
}
}
},
failure: function () {
}
, scope: this
failure: LABKEY.Utils.getCallbackWrapper(function(json, response, opts) {
LABKEY.Utils.alert('Error', 'Unable to resolve file resources : ' + response.exception);
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous error message, this could display 'undefined' if response.exception is not set. Consider adding a fallback: 'Unable to resolve file resources: ' + (response.exception || 'Unknown error').

Suggested change
LABKEY.Utils.alert('Error', 'Unable to resolve file resources : ' + response.exception);
LABKEY.Utils.alert('Error', 'Unable to resolve file resources : ' + (response.exception || 'Unknown error'));

Copilot uses AI. Check for mistakes.
}, this, true),
scope: this
}, this);
},

Expand All @@ -281,41 +321,42 @@ Ext4.define('LABKEY.SignalData.UploadLog', {
resolveDataFileURL: function (files, callback, scope, runProperties) {
if (Ext4.isFunction(callback)) {

var received = 0;
var newFiles = [];

var me = this;
var paths = [];
var fileNames = [];
files.forEach(function (file) {
paths.push(decodeURIComponent(file.id));
fileNames.push(file.text);
}, this);

function done(file, results) {
LABKEY.Ajax.request({
url: LABKEY.ActionURL.buildURL('SignalData', 'getSignalDataResource.api'),
method: 'POST',
jsonData: {
paths : paths,
files : fileNames
},
success: function (response) {
let result = Ext4.decode(response.responseText);
let store = this.getStore();

var store = me.getStore();
var idx = store.find(me.DATA_FILE, file.text);
var process = store.getAt(idx);
Ext4.each(result.files, function(file) {

//Set upload time
process.set(me.FILENAME, results[me.DATA_FILE]);
process.set(me.FILE_URL, results['DataFileUrl']);
process.set('file', file);
newFiles.push(file);
received++;
var idx = store.find(this.DATA_FILE, file["FileName"]);
var rec = store.getAt(idx);

if (received == files.length) {
callback.call(scope || me, newFiles, runProperties);
}
}
if (rec) {
//Set upload time in the store record
rec.set(me.FILENAME, file[this.DATA_FILE]);
rec.set(me.FILE_URL, file['DataFileUrl']);
rec.set('file', true);
}
}, this);

//TODO: This should be refactored to use a single ajax call for the array
files.forEach(function (file) {
LABKEY.Ajax.request({
url: LABKEY.ActionURL.buildURL('SignalData', 'getSignalDataResource.api'),
method: 'POST',
params: {path: decodeURIComponent(file.id), test: true},
success: function (response) {
done(file, Ext4.decode(response.responseText));
},
scope: this
});
}, this);
callback.call(scope || me, runProperties);
},
scope: this
});
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ LABKEY.SignalData.initializeDataFileUploadForm = function (metadataFormId, eleme
window.location = returnUrl;
},this);
},
failure: function(response){
//TODO: Should probably do something here...
}
failure: LABKEY.Utils.getCallbackWrapper(function(json, response, opts) {
LABKEY.Utils.alert('Error', 'Unable to save run : ' + response.exception);
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message concatenation could result in 'Unable to save run : undefined' if response.exception is undefined. Consider using optional chaining or a fallback message like 'Unable to save run: ' + (response.exception || 'Unknown error').

Suggested change
LABKEY.Utils.alert('Error', 'Unable to save run : ' + response.exception);
LABKEY.Utils.alert('Error', 'Unable to save run : ' + (response.exception || 'Unknown error'));

Copilot uses AI. Check for mistakes.
}, this, true)
}, this);
}

var generateAndSaveRun = function(files, fieldValues) {
var generateAndSaveRun = function(fieldValues) {

var dataRows = [];
var dataInputs = [];
Expand Down
Loading