6178 |
23 Mar 21 |
nicklas |
var ImportSpecimen = function() |
6178 |
23 Mar 21 |
nicklas |
2 |
{ |
6178 |
23 Mar 21 |
nicklas |
var specimen = {}; |
7235 |
07 Jun 23 |
nicklas |
var debug = 0; |
6178 |
23 Mar 21 |
nicklas |
var importItems; |
6178 |
23 Mar 21 |
nicklas |
6 |
|
6211 |
14 Apr 21 |
nicklas |
var autoAnalyzeIsValid = false; |
6178 |
23 Mar 21 |
nicklas |
8 |
|
6178 |
23 Mar 21 |
nicklas |
specimen.initPage = function() |
6178 |
23 Mar 21 |
nicklas |
10 |
{ |
6178 |
23 Mar 21 |
nicklas |
// Step 1 |
6178 |
23 Mar 21 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', specimen.validateStep1); |
6899 |
29 Nov 22 |
nicklas |
Events.addEventHandler('validate-all', 'click', specimen.fullyValidateAll); |
6901 |
29 Nov 22 |
nicklas |
Events.addEventHandler('lessMessages', 'change', specimen.showLessMessages); |
6198 |
07 Apr 21 |
nicklas |
// Step 2 |
6178 |
23 Mar 21 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', specimen.initializeStep2); |
6178 |
23 Mar 21 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', specimen.validateStep2); |
6178 |
23 Mar 21 |
nicklas |
Events.addEventHandler('clusters', 'change', specimen.clusterOnChange); |
6211 |
14 Apr 21 |
nicklas |
Events.addEventHandler('autoAnalyzeYes', 'click', specimen.autoAnalyzeOnChange); |
6211 |
14 Apr 21 |
nicklas |
Events.addEventHandler('autoAnalyzeNo', 'click', specimen.autoAnalyzeOnChange); |
6178 |
23 Mar 21 |
nicklas |
21 |
|
6178 |
23 Mar 21 |
nicklas |
// Navigation |
6178 |
23 Mar 21 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
6178 |
23 Mar 21 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
6178 |
23 Mar 21 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
6178 |
23 Mar 21 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
6178 |
23 Mar 21 |
nicklas |
27 |
|
6178 |
23 Mar 21 |
nicklas |
// Final registration |
6178 |
23 Mar 21 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', specimen.submit); |
6898 |
29 Nov 22 |
nicklas |
30 |
|
6898 |
29 Nov 22 |
nicklas |
Wizard.showLoadingAnimation('Scanning for JSON files...', 'scan-json-progress'); |
6510 |
03 Dec 21 |
nicklas |
var url = '../ExternalSpecimen.servlet?ID='+App.getSessionId(); |
6178 |
23 Mar 21 |
nicklas |
url += '&cmd=GetImportInformation'; |
6178 |
23 Mar 21 |
nicklas |
Wizard.asyncJsonRequest(url, specimen.initializeStep1); |
6178 |
23 Mar 21 |
nicklas |
35 |
} |
6178 |
23 Mar 21 |
nicklas |
36 |
|
6178 |
23 Mar 21 |
nicklas |
// --- Step 1 ----------------------------------- |
6178 |
23 Mar 21 |
nicklas |
specimen.initializeStep1 = function(response) |
6178 |
23 Mar 21 |
nicklas |
39 |
{ |
6178 |
23 Mar 21 |
nicklas |
importItems = response.importItems; |
6178 |
23 Mar 21 |
nicklas |
if (importItems.length == 0) |
6178 |
23 Mar 21 |
nicklas |
42 |
{ |
6178 |
23 Mar 21 |
nicklas |
Wizard.setFatalError('No items available for importing.'); |
6178 |
23 Mar 21 |
nicklas |
return; |
6178 |
23 Mar 21 |
nicklas |
45 |
} |
6178 |
23 Mar 21 |
nicklas |
46 |
|
6897 |
29 Nov 22 |
nicklas |
importItems.sort(specimen.sortByValidatedAndFileDate); |
6353 |
18 Aug 21 |
nicklas |
48 |
|
6899 |
29 Nov 22 |
nicklas |
var numJsonFiles = 0; |
6924 |
02 Dec 22 |
nicklas |
var numNoJsonFiles = 0; |
6929 |
02 Dec 22 |
nicklas |
var numStrayFastq = 0; |
6899 |
29 Nov 22 |
nicklas |
var numValidated = 0; |
6895 |
25 Nov 22 |
nicklas |
var numImportable = 0; |
6915 |
01 Dec 22 |
nicklas |
var numWithWarnings = 0; |
6921 |
02 Dec 22 |
nicklas |
var numNew = 0; |
6921 |
02 Dec 22 |
nicklas |
var numConvertToSpecimen = 0; |
7230 |
02 Jun 23 |
nicklas |
var numMergeWithExisting = 0; |
6899 |
29 Nov 22 |
nicklas |
var numFlowCells = 0; |
6897 |
29 Nov 22 |
nicklas |
var lastFlowCellId = null; |
6901 |
29 Nov 22 |
nicklas |
var html = ''; |
6178 |
23 Mar 21 |
nicklas |
for (var itemNo = 0; itemNo < importItems.length; itemNo++) |
6178 |
23 Mar 21 |
nicklas |
62 |
{ |
6178 |
23 Mar 21 |
nicklas |
var item = importItems[itemNo]; |
6897 |
29 Nov 22 |
nicklas |
var rowClass = 'highlight'; |
6899 |
29 Nov 22 |
nicklas |
if (item.jsonFile) |
6897 |
29 Nov 22 |
nicklas |
66 |
{ |
6899 |
29 Nov 22 |
nicklas |
numJsonFiles++; |
6899 |
29 Nov 22 |
nicklas |
if (item.jsonFile.fullyValidated) numValidated++; |
6899 |
29 Nov 22 |
nicklas |
if (item.jsonFile.flowCellId != lastFlowCellId) |
6899 |
29 Nov 22 |
nicklas |
70 |
{ |
6899 |
29 Nov 22 |
nicklas |
numFlowCells++; |
6899 |
29 Nov 22 |
nicklas |
if (lastFlowCellId) rowClass += ' newflowcell'; |
6899 |
29 Nov 22 |
nicklas |
lastFlowCellId = item.jsonFile.flowCellId; |
6899 |
29 Nov 22 |
nicklas |
74 |
} |
6897 |
29 Nov 22 |
nicklas |
75 |
} |
6929 |
02 Dec 22 |
nicklas |
else if (item.itemType == 'StrayFastq') |
6929 |
02 Dec 22 |
nicklas |
77 |
{ |
6929 |
02 Dec 22 |
nicklas |
numStrayFastq++; |
6929 |
02 Dec 22 |
nicklas |
79 |
} |
6924 |
02 Dec 22 |
nicklas |
else |
6924 |
02 Dec 22 |
nicklas |
81 |
{ |
6924 |
02 Dec 22 |
nicklas |
numNoJsonFiles++; |
6924 |
02 Dec 22 |
nicklas |
83 |
} |
6897 |
29 Nov 22 |
nicklas |
rowClass += (numFlowCells % 2 == 0 ? ' evenflowcell': ' oddflowcell') |
6897 |
29 Nov 22 |
nicklas |
html += '<tr class="'+rowClass+'" id="itemRow.'+itemNo+'">'; |
6896 |
28 Nov 22 |
nicklas |
html += specimen.createTableRowColumns(item, itemNo); |
6896 |
28 Nov 22 |
nicklas |
html += '</tr>'; |
6915 |
01 Dec 22 |
nicklas |
if (item.canImport) |
6915 |
01 Dec 22 |
nicklas |
89 |
{ |
6915 |
01 Dec 22 |
nicklas |
numImportable++; |
6915 |
01 Dec 22 |
nicklas |
if (item.jsonFile && item.jsonFile.warnings) numWithWarnings++; |
6921 |
02 Dec 22 |
nicklas |
if (!item.id) numNew++; |
6921 |
02 Dec 22 |
nicklas |
if (item.convertToSpecimen) numConvertToSpecimen++; |
7230 |
02 Jun 23 |
nicklas |
if (item.mergeWithExisting) numMergeWithExisting++; |
6915 |
01 Dec 22 |
nicklas |
95 |
} |
6896 |
28 Nov 22 |
nicklas |
96 |
} |
6178 |
23 Mar 21 |
nicklas |
97 |
|
6896 |
28 Nov 22 |
nicklas |
html += '</tbody>'; |
6896 |
28 Nov 22 |
nicklas |
html += '</table>'; |
6896 |
28 Nov 22 |
nicklas |
Doc.element('itemTable').innerHTML = html; |
6896 |
28 Nov 22 |
nicklas |
101 |
|
6896 |
28 Nov 22 |
nicklas |
specimen.addEventHandlers(Doc.element('itemTable')); |
6896 |
28 Nov 22 |
nicklas |
103 |
|
6899 |
29 Nov 22 |
nicklas |
Doc.element('num-json-files').innerHTML = numJsonFiles; |
6924 |
02 Dec 22 |
nicklas |
Doc.element('num-no-json-files').innerHTML = numNoJsonFiles; |
6899 |
29 Nov 22 |
nicklas |
Doc.element('num-validated-files').innerHTML = numValidated; |
6899 |
29 Nov 22 |
nicklas |
Doc.element('num-importable').innerHTML = numImportable; |
6915 |
01 Dec 22 |
nicklas |
Doc.element('num-importable-with-warnings').innerHTML = numWithWarnings; |
6921 |
02 Dec 22 |
nicklas |
Doc.element('num-importable-new').innerHTML = numNew; |
6921 |
02 Dec 22 |
nicklas |
Doc.element('num-importable-convert').innerHTML = numConvertToSpecimen; |
7230 |
02 Jun 23 |
nicklas |
Doc.element('num-importable-merge').innerHTML = numMergeWithExisting; |
6929 |
02 Dec 22 |
nicklas |
Doc.element('num-stray-fastq-files').innerHTML = numStrayFastq; |
6899 |
29 Nov 22 |
nicklas |
if (numValidated < numJsonFiles) Doc.show('validate-all', 'inline'); |
6899 |
29 Nov 22 |
nicklas |
114 |
|
6896 |
28 Nov 22 |
nicklas |
Doc.show('step-1'); |
6896 |
28 Nov 22 |
nicklas |
Doc.show('gonext'); |
6896 |
28 Nov 22 |
nicklas |
if (numImportable == 0) |
6896 |
28 Nov 22 |
nicklas |
118 |
{ |
6896 |
28 Nov 22 |
nicklas |
Wizard.showGoNextConfirmation(false, 'There are no JSON files that can be imported'); |
6896 |
28 Nov 22 |
nicklas |
Doc.addClass('gonext', 'disabled'); |
6896 |
28 Nov 22 |
nicklas |
121 |
} |
6896 |
28 Nov 22 |
nicklas |
else |
6896 |
28 Nov 22 |
nicklas |
123 |
{ |
6896 |
28 Nov 22 |
nicklas |
Wizard.hideGoNextConfirmation(); |
6896 |
28 Nov 22 |
nicklas |
Doc.removeClass('gonext', 'disabled'); |
6896 |
28 Nov 22 |
nicklas |
126 |
} |
6896 |
28 Nov 22 |
nicklas |
127 |
} |
6896 |
28 Nov 22 |
nicklas |
128 |
|
6896 |
28 Nov 22 |
nicklas |
specimen.createTableRowColumns = function(item, itemNo) |
6896 |
28 Nov 22 |
nicklas |
130 |
{ |
6896 |
28 Nov 22 |
nicklas |
var jsonFile = item.jsonFile; |
6929 |
02 Dec 22 |
nicklas |
item.isStrayFastq = item.itemType == 'StrayFastq'; |
6896 |
28 Nov 22 |
nicklas |
item.canImport = item.name && jsonFile && jsonFile.fullyValidated && !jsonFile.errors; |
6896 |
28 Nov 22 |
nicklas |
134 |
|
6896 |
28 Nov 22 |
nicklas |
var html = ''; |
6896 |
28 Nov 22 |
nicklas |
var icon = null; |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile) |
6896 |
28 Nov 22 |
nicklas |
138 |
{ |
6896 |
28 Nov 22 |
nicklas |
icon = 'ok.png'; |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile.warnings) icon = 'warning.png'; |
6896 |
28 Nov 22 |
nicklas |
if (!jsonFile.fullyValidated) icon = 'info.png'; |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile.errors) icon = 'error.png'; |
6896 |
28 Nov 22 |
nicklas |
143 |
} |
6896 |
28 Nov 22 |
nicklas |
144 |
|
6896 |
28 Nov 22 |
nicklas |
html += '<th>'+(itemNo+1)+'</th>'; |
6896 |
28 Nov 22 |
nicklas |
html += '<td class="dottedleft">'; |
6929 |
02 Dec 22 |
nicklas |
if (item.isStrayFastq) |
6896 |
28 Nov 22 |
nicklas |
148 |
{ |
6929 |
02 Dec 22 |
nicklas |
html += item.itemType; |
6929 |
02 Dec 22 |
nicklas |
150 |
} |
6929 |
02 Dec 22 |
nicklas |
else if (item.name) |
6929 |
02 Dec 22 |
nicklas |
152 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += Strings.encodeTags(item.name); |
6896 |
28 Nov 22 |
nicklas |
if (!item.id) html += ' <img src="../images/new.png" title="This item will be created by the importer">'; |
6896 |
28 Nov 22 |
nicklas |
if (item.itemType) html += ' <span class="itemsubtype">('+Strings.encodeTags(item.itemType)+')</span>'; |
6896 |
28 Nov 22 |
nicklas |
156 |
} |
6896 |
28 Nov 22 |
nicklas |
else |
6896 |
28 Nov 22 |
nicklas |
158 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '-'; |
6896 |
28 Nov 22 |
nicklas |
160 |
} |
6896 |
28 Nov 22 |
nicklas |
html += '<td class="dottedleft">'; |
6896 |
28 Nov 22 |
nicklas |
if (item.currentCase) |
6896 |
28 Nov 22 |
nicklas |
163 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += Strings.encodeTags(item.currentCase.name); |
6896 |
28 Nov 22 |
nicklas |
html += '<img src="../images/case_summary.png" class="link case-summary" data-name="'+Strings.encodeTags(item.currentCase.name)+'" title="Show case summary (popup window)">'; |
6896 |
28 Nov 22 |
nicklas |
166 |
} |
6896 |
28 Nov 22 |
nicklas |
else |
6896 |
28 Nov 22 |
nicklas |
168 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '-'; |
6896 |
28 Nov 22 |
nicklas |
170 |
} |
6896 |
28 Nov 22 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile) |
6896 |
28 Nov 22 |
nicklas |
173 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<td class="dottedleft" style="white-space: nowrap;">'; |
6896 |
28 Nov 22 |
nicklas |
html += Strings.encodeTags(jsonFile.name); |
6896 |
28 Nov 22 |
nicklas |
html += ' <span class="link download-file" data-file-no="'+itemNo+'" title="Download and view this file"><img src="../images/download.png"></span>'; |
6897 |
29 Nov 22 |
nicklas |
html += '<br><span class="file-data">('+Numbers.formatBytes(jsonFile.size)+'; '+Reggie.reformatDate(jsonFile.lastModified)+')</span>'; |
6896 |
28 Nov 22 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
html += '<td style="white-space: nowrap;">'; |
6911 |
30 Nov 22 |
nicklas |
html += Strings.encodeTags(jsonFile.flowCellId); |
6911 |
30 Nov 22 |
nicklas |
html += '<br><span class="file-data">('+Strings.encodeTags(jsonFile.sequencingStartDate)+')</span>'; |
6896 |
28 Nov 22 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
html += '<td>'; |
6896 |
28 Nov 22 |
nicklas |
html += Reggie.formatCount(jsonFile.PF_READS, '-'); |
6896 |
28 Nov 22 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
html += '<td class="fastq" style="white-space: nowrap;">'; |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile && jsonFile.fastq && jsonFile.fastq.length) |
6510 |
03 Dec 21 |
nicklas |
188 |
{ |
6896 |
28 Nov 22 |
nicklas |
for (var fqNo = 0; fqNo < jsonFile.fastq.length; fqNo++) |
6896 |
28 Nov 22 |
nicklas |
190 |
{ |
6896 |
28 Nov 22 |
nicklas |
var fq = jsonFile.fastq[fqNo]; |
6896 |
28 Nov 22 |
nicklas |
html += Strings.encodeTags(fq.name); |
6896 |
28 Nov 22 |
nicklas |
html += ' <span class="file-data">(' |
6896 |
28 Nov 22 |
nicklas |
if (fq.size > 0) |
6896 |
28 Nov 22 |
nicklas |
195 |
{ |
6897 |
29 Nov 22 |
nicklas |
html += Numbers.formatBytes(fq.size); |
6896 |
28 Nov 22 |
nicklas |
197 |
} |
6896 |
28 Nov 22 |
nicklas |
else |
6896 |
28 Nov 22 |
nicklas |
199 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += 'missing'; |
6896 |
28 Nov 22 |
nicklas |
201 |
} |
6896 |
28 Nov 22 |
nicklas |
html += ')</span><br>'; |
6896 |
28 Nov 22 |
nicklas |
203 |
} |
6510 |
03 Dec 21 |
nicklas |
204 |
} |
6896 |
28 Nov 22 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
206 |
} |
6929 |
02 Dec 22 |
nicklas |
else if (item.isStrayFastq) |
6929 |
02 Dec 22 |
nicklas |
208 |
{ |
6929 |
02 Dec 22 |
nicklas |
html += '<td class="dottedleft" colspan="4" style="text-align: left;">'; |
6929 |
02 Dec 22 |
nicklas |
html += Strings.encodeTags(item.name); |
6929 |
02 Dec 22 |
nicklas |
html += ' <span class="file-data">(' |
6929 |
02 Dec 22 |
nicklas |
html += Numbers.formatBytes(item.size); |
6929 |
02 Dec 22 |
nicklas |
html += '; '+ Reggie.reformatDate(item.lastModified); |
6929 |
02 Dec 22 |
nicklas |
html += ')</span>'; |
6929 |
02 Dec 22 |
nicklas |
html += '</td>'; |
6929 |
02 Dec 22 |
nicklas |
216 |
} |
6896 |
28 Nov 22 |
nicklas |
else |
6896 |
28 Nov 22 |
nicklas |
218 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<td class="dottedleft" colspan="4" style="text-align: left;">'; |
6896 |
28 Nov 22 |
nicklas |
if (item.externalSpecimenExists) |
6510 |
03 Dec 21 |
nicklas |
221 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<b>Specimen exists:</b> '+Strings.encodeTags(item.externalSpecimenExists); |
6896 |
28 Nov 22 |
nicklas |
if (item.externalOperator) html += '/'+Strings.encodeTags(item.externalOperator); |
6510 |
03 Dec 21 |
nicklas |
224 |
} |
6896 |
28 Nov 22 |
nicklas |
if (item.samplingDate) |
6510 |
03 Dec 21 |
nicklas |
226 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '; <b>Sampling date:</b> '+Reggie.reformatDate(item.samplingDate); |
6510 |
03 Dec 21 |
nicklas |
228 |
} |
6896 |
28 Nov 22 |
nicklas |
if (item.registered) |
6510 |
03 Dec 21 |
nicklas |
230 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '; <b>Registration date:</b> '+Reggie.reformatDate(item.registered); |
6510 |
03 Dec 21 |
nicklas |
232 |
} |
6924 |
02 Dec 22 |
nicklas |
if (item.otherPathNote) |
6924 |
02 Dec 22 |
nicklas |
234 |
{ |
6924 |
02 Dec 22 |
nicklas |
html += '; <b>Other path note:</b> '+Strings.encodeTags(item.otherPathNote); |
6924 |
02 Dec 22 |
nicklas |
236 |
} |
6510 |
03 Dec 21 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
238 |
} |
6896 |
28 Nov 22 |
nicklas |
html += '<td class="icon">'; |
6896 |
28 Nov 22 |
nicklas |
if (icon) html+= '<img src="../images/'+icon+'">'; |
6896 |
28 Nov 22 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
html += '<td class="valid dottedleft">'; |
6896 |
28 Nov 22 |
nicklas |
if (item.canImport) |
6896 |
28 Nov 22 |
nicklas |
244 |
{ |
6901 |
29 Nov 22 |
nicklas |
html += '<div class="action">'; |
6896 |
28 Nov 22 |
nicklas |
html += '<label><input type="checkbox" id="import.'+itemNo+'" class="import-action" data-item-no="'+itemNo+'">'; |
7229 |
02 Jun 23 |
nicklas |
var importOrMerge = item.mergeWithExisting ? 'Merge with' : 'Import to'; |
7229 |
02 Jun 23 |
nicklas |
importOrMerge += (item.id ? ' existing' : ' new'); |
6896 |
28 Nov 22 |
nicklas |
if (item.endPoint.id == 'SPECIMEN' && item.itemType == 'Specimen') |
6208 |
12 Apr 21 |
nicklas |
250 |
{ |
7229 |
02 Jun 23 |
nicklas |
html += importOrMerge+' <b>Specimen</b> only</label>'; |
6198 |
07 Apr 21 |
nicklas |
252 |
} |
6582 |
11 Feb 22 |
nicklas |
else |
6582 |
11 Feb 22 |
nicklas |
254 |
{ |
7229 |
02 Jun 23 |
nicklas |
html += importOrMerge+' <b>'+Strings.encodeTags(item.itemType) + '</b> ›› <b>'+item.endPoint.name+'</b></label>'; |
6582 |
11 Feb 22 |
nicklas |
256 |
} |
6896 |
28 Nov 22 |
nicklas |
if (item.endPoint.id != 'DEMUX' && item.endPoint.ordinal >= item.endPointRNA.ordinal) |
6212 |
14 Apr 21 |
nicklas |
258 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<br><label><input type="checkbox" id="flagrna.'+itemNo+'" disabled>Flag RNA</label>'; |
6896 |
28 Nov 22 |
nicklas |
260 |
} |
6901 |
29 Nov 22 |
nicklas |
html += '</div>'; |
6896 |
28 Nov 22 |
nicklas |
262 |
} |
6896 |
28 Nov 22 |
nicklas |
var startNo = 1; |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile) |
6896 |
28 Nov 22 |
nicklas |
265 |
{ |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile.errors) |
6896 |
28 Nov 22 |
nicklas |
267 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<div class="messagecontainer error"><ol start="'+startNo+'">'; |
6896 |
28 Nov 22 |
nicklas |
for (var errNo = 0; errNo < jsonFile.errors.length; errNo++) |
6738 |
10 May 22 |
nicklas |
270 |
{ |
6896 |
28 Nov 22 |
nicklas |
var msg = jsonFile.errors[errNo]; |
6896 |
28 Nov 22 |
nicklas |
if (msg.indexOf('[HTML]')==0) |
6896 |
28 Nov 22 |
nicklas |
273 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<li>'+msg.replace('[HTML]', ''); |
6896 |
28 Nov 22 |
nicklas |
275 |
} |
6896 |
28 Nov 22 |
nicklas |
else |
6896 |
28 Nov 22 |
nicklas |
277 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<li>'+Strings.encodeTags(msg); |
6896 |
28 Nov 22 |
nicklas |
279 |
} |
6738 |
10 May 22 |
nicklas |
280 |
} |
6896 |
28 Nov 22 |
nicklas |
html += '</ol></div>'; |
6896 |
28 Nov 22 |
nicklas |
startNo += jsonFile.errors.length; |
6212 |
14 Apr 21 |
nicklas |
283 |
} |
6896 |
28 Nov 22 |
nicklas |
else if (!jsonFile.fullyValidated) |
6734 |
09 May 22 |
nicklas |
285 |
{ |
6901 |
29 Nov 22 |
nicklas |
html += '<div class="action">'; |
6896 |
28 Nov 22 |
nicklas |
html += 'This JSON file has not been fully validated.'; |
6896 |
28 Nov 22 |
nicklas |
html += '<span class="fully-validate link" data-item-no="'+itemNo+'">Validate it!</span>'; |
6901 |
29 Nov 22 |
nicklas |
html += '</div>'; |
6734 |
09 May 22 |
nicklas |
290 |
} |
6924 |
02 Dec 22 |
nicklas |
if (jsonFile.fullyValidated && (item.otherPathNote || item.liasonComment)) |
6924 |
02 Dec 22 |
nicklas |
292 |
{ |
6924 |
02 Dec 22 |
nicklas |
html += '<div class="notes">'; |
6924 |
02 Dec 22 |
nicklas |
html += Strings.encodeTags(item.otherPathNote); |
6924 |
02 Dec 22 |
nicklas |
html += (item.otherPathNote && item.liasonComment ? '; ' : '')+Strings.encodeTags(item.liasonComment); |
6924 |
02 Dec 22 |
nicklas |
html += '</div>'; |
6924 |
02 Dec 22 |
nicklas |
297 |
} |
6896 |
28 Nov 22 |
nicklas |
if (jsonFile.warnings && jsonFile.fullyValidated) |
6198 |
07 Apr 21 |
nicklas |
299 |
{ |
6905 |
30 Nov 22 |
nicklas |
var allVisible = jsonFile.warnings.length < 6 ?' allvisible':''; |
6905 |
30 Nov 22 |
nicklas |
html += '<div class="messagecontainer note minimal '+allVisible+'" id="warnings.'+itemNo+'">'; |
6901 |
29 Nov 22 |
nicklas |
html += '<ol start="'+startNo+'">'; |
6896 |
28 Nov 22 |
nicklas |
for (var warnNo = 0; warnNo < jsonFile.warnings.length; warnNo++) |
6205 |
12 Apr 21 |
nicklas |
304 |
{ |
6896 |
28 Nov 22 |
nicklas |
var msg = jsonFile.warnings[warnNo]; |
6896 |
28 Nov 22 |
nicklas |
if (msg.indexOf('[HTML]')==0) |
6573 |
07 Feb 22 |
nicklas |
307 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<li>'+msg.replace('[HTML]', ''); |
6573 |
07 Feb 22 |
nicklas |
309 |
} |
6896 |
28 Nov 22 |
nicklas |
else |
6896 |
28 Nov 22 |
nicklas |
311 |
{ |
6896 |
28 Nov 22 |
nicklas |
html += '<li>'+Strings.encodeTags(msg); |
6896 |
28 Nov 22 |
nicklas |
313 |
} |
6205 |
12 Apr 21 |
nicklas |
314 |
} |
6901 |
29 Nov 22 |
nicklas |
html += '</ol>'; |
6901 |
29 Nov 22 |
nicklas |
html += '</div>'; |
6905 |
30 Nov 22 |
nicklas |
html += '<div class="morewarnings'+allVisible+'">'+jsonFile.warnings.length+' warnings - <span class="showmore-warnings link" data-item-no="'+itemNo+'">Show more...</span></div>'; |
6901 |
29 Nov 22 |
nicklas |
startNo += jsonFile.warnings.length; |
6198 |
07 Apr 21 |
nicklas |
319 |
} |
6178 |
23 Mar 21 |
nicklas |
320 |
} |
6896 |
28 Nov 22 |
nicklas |
html += '</td>'; |
6896 |
28 Nov 22 |
nicklas |
return html; |
6896 |
28 Nov 22 |
nicklas |
323 |
} |
6896 |
28 Nov 22 |
nicklas |
324 |
|
6896 |
28 Nov 22 |
nicklas |
specimen.addEventHandlers = function(topElement) |
6896 |
28 Nov 22 |
nicklas |
326 |
{ |
6896 |
28 Nov 22 |
nicklas |
Forms.linkCheckboxesWithLabels(topElement); |
6896 |
28 Nov 22 |
nicklas |
var checkboxes = topElement.getElementsByClassName('import-action'); |
6736 |
10 May 22 |
nicklas |
for (var chkNo = 0; chkNo < checkboxes.length; chkNo++) |
6736 |
10 May 22 |
nicklas |
330 |
{ |
6736 |
10 May 22 |
nicklas |
Events.addEventHandler(checkboxes[chkNo], 'click', specimen.toggleImport); |
6736 |
10 May 22 |
nicklas |
332 |
} |
6178 |
23 Mar 21 |
nicklas |
333 |
|
6896 |
28 Nov 22 |
nicklas |
var downloadable = topElement.getElementsByClassName('download-file'); |
6208 |
12 Apr 21 |
nicklas |
for (var fileNo = 0; fileNo < downloadable.length; fileNo++) |
6208 |
12 Apr 21 |
nicklas |
336 |
{ |
6208 |
12 Apr 21 |
nicklas |
Events.addEventHandler(downloadable[fileNo], 'click', specimen.downloadJsonFile); |
6208 |
12 Apr 21 |
nicklas |
338 |
} |
6208 |
12 Apr 21 |
nicklas |
339 |
|
6896 |
28 Nov 22 |
nicklas |
var showMoreWarnings = topElement.getElementsByClassName('showmore-warnings'); |
6510 |
03 Dec 21 |
nicklas |
for (var itemNo = 0; itemNo < showMoreWarnings.length; itemNo++) |
6510 |
03 Dec 21 |
nicklas |
342 |
{ |
6510 |
03 Dec 21 |
nicklas |
Events.addEventHandler(showMoreWarnings[itemNo], 'click', specimen.toggleWarnings); |
6510 |
03 Dec 21 |
nicklas |
344 |
} |
6895 |
25 Nov 22 |
nicklas |
345 |
|
6896 |
28 Nov 22 |
nicklas |
var validateFile = topElement.getElementsByClassName('fully-validate'); |
6895 |
25 Nov 22 |
nicklas |
for (var itemNo = 0; itemNo < validateFile.length; itemNo++) |
6895 |
25 Nov 22 |
nicklas |
348 |
{ |
6895 |
25 Nov 22 |
nicklas |
Events.addEventHandler(validateFile[itemNo], 'click', specimen.fullyValidate); |
6895 |
25 Nov 22 |
nicklas |
350 |
} |
6510 |
03 Dec 21 |
nicklas |
351 |
|
6896 |
28 Nov 22 |
nicklas |
var cs = topElement.getElementsByClassName('case-summary'); |
6510 |
03 Dec 21 |
nicklas |
for (var i = 0; i < cs.length; i++) |
6510 |
03 Dec 21 |
nicklas |
354 |
{ |
6510 |
03 Dec 21 |
nicklas |
Events.addEventHandler(cs[i], 'click', Reggie.openCaseSummaryPopupOnEvent); |
6510 |
03 Dec 21 |
nicklas |
356 |
} |
6178 |
23 Mar 21 |
nicklas |
357 |
} |
6510 |
03 Dec 21 |
nicklas |
358 |
|
6899 |
29 Nov 22 |
nicklas |
specimen.fullyValidateAll = function(event) |
6899 |
29 Nov 22 |
nicklas |
360 |
{ |
6899 |
29 Nov 22 |
nicklas |
Doc.element('itemTable').innerHTML = ''; |
6899 |
29 Nov 22 |
nicklas |
Doc.hide('validate-all'); |
6899 |
29 Nov 22 |
nicklas |
Doc.hide('step-1'); |
6899 |
29 Nov 22 |
nicklas |
Doc.hide('gonext'); |
6899 |
29 Nov 22 |
nicklas |
365 |
|
6899 |
29 Nov 22 |
nicklas |
Wizard.showLoadingAnimation('Validating all...', 'scan-json-progress'); |
6899 |
29 Nov 22 |
nicklas |
var url = '../ExternalSpecimen.servlet?ID='+App.getSessionId(); |
6899 |
29 Nov 22 |
nicklas |
url += '&cmd=GetImportInformation'; |
6899 |
29 Nov 22 |
nicklas |
url += '&validateAll=1'; |
6899 |
29 Nov 22 |
nicklas |
Wizard.asyncJsonRequest(url, specimen.initializeStep1); |
6899 |
29 Nov 22 |
nicklas |
371 |
} |
6899 |
29 Nov 22 |
nicklas |
372 |
|
6895 |
25 Nov 22 |
nicklas |
specimen.fullyValidate = function(event) |
6895 |
25 Nov 22 |
nicklas |
374 |
{ |
6896 |
28 Nov 22 |
nicklas |
var itemNo = Data.get(event.currentTarget, 'item-no'); |
6896 |
28 Nov 22 |
nicklas |
var file = importItems[itemNo].jsonFile; |
6896 |
28 Nov 22 |
nicklas |
377 |
|
6896 |
28 Nov 22 |
nicklas |
Wizard.showLoadingAnimation('Validating '+file.name+'...'); |
6896 |
28 Nov 22 |
nicklas |
var url = '../ExternalSpecimen.servlet?ID='+App.getSessionId(); |
6896 |
28 Nov 22 |
nicklas |
url += '&cmd=GetImportInformation'; |
6896 |
28 Nov 22 |
nicklas |
url += '&file='+encodeURIComponent(file.name); |
6896 |
28 Nov 22 |
nicklas |
url += '&itemNo='+itemNo; |
6896 |
28 Nov 22 |
nicklas |
Wizard.asyncJsonRequest(url, specimen.singleFileValidated); |
6895 |
25 Nov 22 |
nicklas |
384 |
} |
6895 |
25 Nov 22 |
nicklas |
385 |
|
6896 |
28 Nov 22 |
nicklas |
specimen.singleFileValidated = function(response) |
6896 |
28 Nov 22 |
nicklas |
387 |
{ |
6896 |
28 Nov 22 |
nicklas |
var items = response.importItems; |
6896 |
28 Nov 22 |
nicklas |
if (items.length != 1) |
6896 |
28 Nov 22 |
nicklas |
390 |
{ |
6896 |
28 Nov 22 |
nicklas |
Wizard.setFatalError('Expected information about a single JSON file: '+items.length); |
6896 |
28 Nov 22 |
nicklas |
return; |
6896 |
28 Nov 22 |
nicklas |
393 |
} |
6896 |
28 Nov 22 |
nicklas |
394 |
|
6896 |
28 Nov 22 |
nicklas |
var item = items[0]; |
6896 |
28 Nov 22 |
nicklas |
var itemNo = item.itemNo; |
6896 |
28 Nov 22 |
nicklas |
importItems[itemNo] = item; |
6896 |
28 Nov 22 |
nicklas |
398 |
|
6896 |
28 Nov 22 |
nicklas |
html = specimen.createTableRowColumns(item, itemNo); |
6896 |
28 Nov 22 |
nicklas |
var rowElement = Doc.element('itemRow.'+itemNo); |
6896 |
28 Nov 22 |
nicklas |
rowElement.innerHTML = html; |
6896 |
28 Nov 22 |
nicklas |
specimen.addEventHandlers(rowElement); |
6896 |
28 Nov 22 |
nicklas |
403 |
|
6896 |
28 Nov 22 |
nicklas |
if (item.canImport) |
6896 |
28 Nov 22 |
nicklas |
405 |
{ |
6896 |
28 Nov 22 |
nicklas |
Wizard.hideGoNextConfirmation(); |
6896 |
28 Nov 22 |
nicklas |
Doc.removeClass('gonext', 'disabled'); |
6896 |
28 Nov 22 |
nicklas |
408 |
} |
6896 |
28 Nov 22 |
nicklas |
409 |
|
6896 |
28 Nov 22 |
nicklas |
410 |
} |
6896 |
28 Nov 22 |
nicklas |
411 |
|
6896 |
28 Nov 22 |
nicklas |
412 |
|
6510 |
03 Dec 21 |
nicklas |
specimen.toggleWarnings = function(event) |
6510 |
03 Dec 21 |
nicklas |
414 |
{ |
6510 |
03 Dec 21 |
nicklas |
var itemNo = Data.get(event.currentTarget, 'item-no'); |
6510 |
03 Dec 21 |
nicklas |
var warningsDiv = Doc.element('warnings.'+itemNo); |
6510 |
03 Dec 21 |
nicklas |
Doc.addOrRemoveClass(warningsDiv, 'minimal'); |
6510 |
03 Dec 21 |
nicklas |
event.currentTarget.innerHTML = warningsDiv.classList.contains('minimal') ? 'Show more...' : 'Show less...'; |
6510 |
03 Dec 21 |
nicklas |
419 |
} |
6178 |
23 Mar 21 |
nicklas |
420 |
|
6736 |
10 May 22 |
nicklas |
specimen.toggleImport = function(event) |
6736 |
10 May 22 |
nicklas |
422 |
{ |
6736 |
10 May 22 |
nicklas |
var itemNo = Data.get(event.currentTarget, 'item-no'); |
6736 |
10 May 22 |
nicklas |
var flag = Doc.element('flagrna.'+itemNo); |
6736 |
10 May 22 |
nicklas |
if (flag) flag.disabled = !event.currentTarget.checked; |
6736 |
10 May 22 |
nicklas |
426 |
} |
6901 |
29 Nov 22 |
nicklas |
427 |
|
6901 |
29 Nov 22 |
nicklas |
specimen.showLessMessages = function(event) |
6901 |
29 Nov 22 |
nicklas |
429 |
{ |
6901 |
29 Nov 22 |
nicklas |
Doc.addOrRemoveClass('importItemsTable', 'less-messages', event.currentTarget.checked); |
6901 |
29 Nov 22 |
nicklas |
431 |
} |
6736 |
10 May 22 |
nicklas |
432 |
|
6208 |
12 Apr 21 |
nicklas |
specimen.downloadJsonFile = function(event) |
6208 |
12 Apr 21 |
nicklas |
434 |
{ |
6208 |
12 Apr 21 |
nicklas |
var itemNo = Data.get(event.currentTarget, 'file-no'); |
6208 |
12 Apr 21 |
nicklas |
var file = importItems[itemNo].jsonFile; |
6208 |
12 Apr 21 |
nicklas |
437 |
|
6510 |
03 Dec 21 |
nicklas |
var url = '../ExternalSpecimen.servlet?ID='+App.getSessionId(); |
6208 |
12 Apr 21 |
nicklas |
url += '&cmd=DownloadJsonFile'; |
6208 |
12 Apr 21 |
nicklas |
url += '&file='+encodeURIComponent(file.name); |
6208 |
12 Apr 21 |
nicklas |
441 |
|
6208 |
12 Apr 21 |
nicklas |
Dialogs.openPopup(url, file.name, 800, 800); |
6208 |
12 Apr 21 |
nicklas |
443 |
} |
6208 |
12 Apr 21 |
nicklas |
444 |
|
6178 |
23 Mar 21 |
nicklas |
specimen.validateStep1 = function(event) |
6178 |
23 Mar 21 |
nicklas |
446 |
{ |
6211 |
14 Apr 21 |
nicklas |
Wizard.hideGoNextConfirmation(); |
6211 |
14 Apr 21 |
nicklas |
var frm = document.forms['reggie']; |
6211 |
14 Apr 21 |
nicklas |
for (var itemNo = 0; itemNo < importItems.length; itemNo++) |
6211 |
14 Apr 21 |
nicklas |
450 |
{ |
6212 |
14 Apr 21 |
nicklas |
var chk = frm['import.'+itemNo]; |
6212 |
14 Apr 21 |
nicklas |
if (chk && chk.checked) return; |
6211 |
14 Apr 21 |
nicklas |
453 |
} |
6211 |
14 Apr 21 |
nicklas |
Wizard.showGoNextConfirmation(false, 'Please select at least one item!'); |
6211 |
14 Apr 21 |
nicklas |
event.preventDefault(); |
6178 |
23 Mar 21 |
nicklas |
456 |
} |
6178 |
23 Mar 21 |
nicklas |
457 |
|
6178 |
23 Mar 21 |
nicklas |
// --- Step 2 ----------------------------------- |
6178 |
23 Mar 21 |
nicklas |
specimen.initializeStep2 = function() |
6178 |
23 Mar 21 |
nicklas |
460 |
{ |
6178 |
23 Mar 21 |
nicklas |
Wizard.setCurrentStep(2); |
6178 |
23 Mar 21 |
nicklas |
462 |
|
6178 |
23 Mar 21 |
nicklas |
// Check debug by default if debug is set or not on a secure server (=production server) |
6178 |
23 Mar 21 |
nicklas |
var frm = document.forms['reggie']; |
6178 |
23 Mar 21 |
nicklas |
frm.debug.checked = debug || location.protocol != 'https:'; |
6178 |
23 Mar 21 |
nicklas |
466 |
|
6213 |
15 Apr 21 |
nicklas |
Reggie.loadProtocols('MERGE_PROTOCOL', 'mergeProtocol', 'PIPELINE,MERGE_TYPE', 'RNAseq,Import'); |
6213 |
15 Apr 21 |
nicklas |
Reggie.loadSoftware('MERGE_SOFTWARE', 'mergeSoftware', 'PIPELINE,MERGE_TYPE,PARAMETER_SET', 'RNAseq,Import'); |
6211 |
14 Apr 21 |
nicklas |
469 |
|
6735 |
09 May 22 |
nicklas |
// Load clusters |
6693 |
22 Apr 22 |
nicklas |
var url = '../OpenGrid.servlet?ID='+App.getSessionId() + '&cmd=GetHostInfo&config=demux/execute-import'; |
6178 |
23 Mar 21 |
nicklas |
Doc.addClass('clusters', 'list-loading'); |
6178 |
23 Mar 21 |
nicklas |
frm.clusters[0] = new Option('loading...'); |
6178 |
23 Mar 21 |
nicklas |
Wizard.asyncJsonRequest(url, specimen.clustersLoaded); |
6178 |
23 Mar 21 |
nicklas |
475 |
|
6178 |
23 Mar 21 |
nicklas |
Doc.show('goregister'); |
6178 |
23 Mar 21 |
nicklas |
Doc.show('gocancel'); |
6178 |
23 Mar 21 |
nicklas |
478 |
} |
6178 |
23 Mar 21 |
nicklas |
479 |
|
6178 |
23 Mar 21 |
nicklas |
specimen.validateStep2 = function(event) |
6178 |
23 Mar 21 |
nicklas |
481 |
{ |
6211 |
14 Apr 21 |
nicklas |
if (!autoAnalyzeIsValid) event.preventDefault(); |
6178 |
23 Mar 21 |
nicklas |
483 |
} |
6178 |
23 Mar 21 |
nicklas |
484 |
|
6178 |
23 Mar 21 |
nicklas |
specimen.clustersLoaded = function(response) |
6178 |
23 Mar 21 |
nicklas |
486 |
{ |
6178 |
23 Mar 21 |
nicklas |
Doc.removeClass('clusters', 'list-loading'); |
6178 |
23 Mar 21 |
nicklas |
var frm = document.forms['reggie']; |
6211 |
14 Apr 21 |
nicklas |
frm.clusters.length = 0; |
6178 |
23 Mar 21 |
nicklas |
var clusters = response.hosts; |
6736 |
10 May 22 |
nicklas |
Doc.element('autoAnalyzeNo').disabled = false; |
6211 |
14 Apr 21 |
nicklas |
if (clusters.length == 0) |
6211 |
14 Apr 21 |
nicklas |
493 |
{ |
6211 |
14 Apr 21 |
nicklas |
Doc.element('autoAnalyzeNo').checked = true; |
6211 |
14 Apr 21 |
nicklas |
autoAnalyzeIsValid = true; |
6736 |
10 May 22 |
nicklas |
Wizard.setInputStatus('autoAnalyze', 'valid'); |
6736 |
10 May 22 |
nicklas |
Wizard.setInputStatus('clusters', 'warning', 'No available clusters'); |
6211 |
14 Apr 21 |
nicklas |
return; |
6211 |
14 Apr 21 |
nicklas |
499 |
} |
6211 |
14 Apr 21 |
nicklas |
500 |
|
6211 |
14 Apr 21 |
nicklas |
Doc.element('autoAnalyzeYes').disabled = false; |
6178 |
23 Mar 21 |
nicklas |
for (var i = 0; i < clusters.length; i++) |
6178 |
23 Mar 21 |
nicklas |
503 |
{ |
6178 |
23 Mar 21 |
nicklas |
var cl = clusters[i]; |
6178 |
23 Mar 21 |
nicklas |
var option = new Option(cl.connection.name, cl.id); |
6178 |
23 Mar 21 |
nicklas |
option.cluster = cl; |
6178 |
23 Mar 21 |
nicklas |
frm.clusters[frm.clusters.length] = option; |
6178 |
23 Mar 21 |
nicklas |
508 |
} |
6211 |
14 Apr 21 |
nicklas |
specimen.autoAnalyzeOnChange(); |
6211 |
14 Apr 21 |
nicklas |
510 |
} |
6211 |
14 Apr 21 |
nicklas |
511 |
|
6211 |
14 Apr 21 |
nicklas |
specimen.autoAnalyzeOnChange = function() |
6211 |
14 Apr 21 |
nicklas |
513 |
{ |
6211 |
14 Apr 21 |
nicklas |
Wizard.setInputStatus('autoAnalyze'); |
6211 |
14 Apr 21 |
nicklas |
autoAnalyzeIsValid = false; |
6211 |
14 Apr 21 |
nicklas |
516 |
|
6211 |
14 Apr 21 |
nicklas |
var frm = document.forms['reggie']; |
6211 |
14 Apr 21 |
nicklas |
var yesChecked = Doc.element('autoAnalyzeYes').checked; |
6211 |
14 Apr 21 |
nicklas |
var noChecked = Doc.element('autoAnalyzeNo').checked; |
6211 |
14 Apr 21 |
nicklas |
520 |
|
6211 |
14 Apr 21 |
nicklas |
frm.mergeProtocol.disabled = !yesChecked; |
6211 |
14 Apr 21 |
nicklas |
frm.mergeSoftware.disabled = !yesChecked; |
6211 |
14 Apr 21 |
nicklas |
frm.clusters.disabled = !yesChecked; |
6211 |
14 Apr 21 |
nicklas |
frm.priority.disabled = !yesChecked; |
6980 |
17 Jan 23 |
nicklas |
frm.partition.disabled = !yesChecked; |
6211 |
14 Apr 21 |
nicklas |
frm.autoConfirm.disabled = !yesChecked; |
6211 |
14 Apr 21 |
nicklas |
frm.debug.disabled = !yesChecked; |
6211 |
14 Apr 21 |
nicklas |
528 |
|
6211 |
14 Apr 21 |
nicklas |
if (!yesChecked && !noChecked) |
6178 |
23 Mar 21 |
nicklas |
530 |
{ |
6211 |
14 Apr 21 |
nicklas |
Wizard.setInputStatus('autoAnalyze', 'invalid', 'Must select Yes or No'); |
6211 |
14 Apr 21 |
nicklas |
return; |
6178 |
23 Mar 21 |
nicklas |
533 |
} |
6211 |
14 Apr 21 |
nicklas |
534 |
|
6211 |
14 Apr 21 |
nicklas |
autoAnalyzeIsValid = true; |
6211 |
14 Apr 21 |
nicklas |
Wizard.setInputStatus('autoAnalyze', 'valid'); |
6211 |
14 Apr 21 |
nicklas |
537 |
|
6211 |
14 Apr 21 |
nicklas |
if (yesChecked) specimen.clusterOnChange(); |
6178 |
23 Mar 21 |
nicklas |
539 |
} |
6211 |
14 Apr 21 |
nicklas |
540 |
|
6178 |
23 Mar 21 |
nicklas |
541 |
|
6178 |
23 Mar 21 |
nicklas |
specimen.clusterOnChange = function() |
6178 |
23 Mar 21 |
nicklas |
543 |
{ |
6178 |
23 Mar 21 |
nicklas |
var frm = document.forms['reggie']; |
6178 |
23 Mar 21 |
nicklas |
var cluster = frm.clusters[frm.clusters.selectedIndex].cluster; |
6178 |
23 Mar 21 |
nicklas |
if (cluster.priorities && cluster.priorities.length > 0) |
6178 |
23 Mar 21 |
nicklas |
547 |
{ |
6178 |
23 Mar 21 |
nicklas |
frm.priority.length = 0; |
6178 |
23 Mar 21 |
nicklas |
for (var pNo = 0; pNo < cluster.priorities.length; pNo++) |
6178 |
23 Mar 21 |
nicklas |
550 |
{ |
6178 |
23 Mar 21 |
nicklas |
var p = cluster.priorities[pNo]; |
6178 |
23 Mar 21 |
nicklas |
frm.priority[frm.priority.length] = new Option(p.name + ' ('+p.value+')', p.value, p['default'], p['default']); |
6178 |
23 Mar 21 |
nicklas |
553 |
} |
6178 |
23 Mar 21 |
nicklas |
Doc.show('job-priority'); |
6178 |
23 Mar 21 |
nicklas |
555 |
} |
6178 |
23 Mar 21 |
nicklas |
else |
6178 |
23 Mar 21 |
nicklas |
557 |
{ |
6178 |
23 Mar 21 |
nicklas |
Doc.hide('job-priority'); |
6178 |
23 Mar 21 |
nicklas |
559 |
} |
6980 |
17 Jan 23 |
nicklas |
if (cluster.partitions && cluster.partitions.length > 0) |
6980 |
17 Jan 23 |
nicklas |
561 |
{ |
6980 |
17 Jan 23 |
nicklas |
frm.partition.length = 0; |
6980 |
17 Jan 23 |
nicklas |
for (var pNo = 0; pNo < cluster.partitions.length; pNo++) |
6980 |
17 Jan 23 |
nicklas |
564 |
{ |
6980 |
17 Jan 23 |
nicklas |
var p = cluster.partitions[pNo]; |
6980 |
17 Jan 23 |
nicklas |
var title = p.name; |
6980 |
17 Jan 23 |
nicklas |
if (p.description) title += ' ('+p.description+')'; |
6980 |
17 Jan 23 |
nicklas |
frm.partition[frm.partition.length] = new Option(title, p.value, p['default'], p['default']); |
6980 |
17 Jan 23 |
nicklas |
569 |
} |
6980 |
17 Jan 23 |
nicklas |
Doc.show('job-partition'); |
6980 |
17 Jan 23 |
nicklas |
571 |
} |
6980 |
17 Jan 23 |
nicklas |
else |
6980 |
17 Jan 23 |
nicklas |
573 |
{ |
6980 |
17 Jan 23 |
nicklas |
Doc.hide('job-partition'); |
6980 |
17 Jan 23 |
nicklas |
575 |
} |
6178 |
23 Mar 21 |
nicklas |
576 |
} |
6178 |
23 Mar 21 |
nicklas |
577 |
|
6353 |
18 Aug 21 |
nicklas |
578 |
/** |
6582 |
11 Feb 22 |
nicklas |
Sort by file date of JSON files. Items without a file are sorted last by registration date and name. |
6353 |
18 Aug 21 |
nicklas |
580 |
*/ |
6897 |
29 Nov 22 |
nicklas |
specimen.sortByValidatedAndFileDate = function(a, b) |
6353 |
18 Aug 21 |
nicklas |
582 |
{ |
6353 |
18 Aug 21 |
nicklas |
var fa = a.jsonFile; |
6353 |
18 Aug 21 |
nicklas |
var fb = b.jsonFile; |
6353 |
18 Aug 21 |
nicklas |
585 |
|
6353 |
18 Aug 21 |
nicklas |
if (fa && fb) |
6353 |
18 Aug 21 |
nicklas |
587 |
{ |
6897 |
29 Nov 22 |
nicklas |
if (fa.fullyValidated != fb.fullyValidated) |
6897 |
29 Nov 22 |
nicklas |
589 |
{ |
6897 |
29 Nov 22 |
nicklas |
return fa.fullyValidated ? -1 : 1; |
6897 |
29 Nov 22 |
nicklas |
591 |
} |
6911 |
30 Nov 22 |
nicklas |
if (fa.sequencingStartDate != fb.sequencingStartDate) |
6911 |
30 Nov 22 |
nicklas |
593 |
{ |
6911 |
30 Nov 22 |
nicklas |
return fa.sequencingStartDate < fb.sequencingStartDate ? -1 : 1; |
6911 |
30 Nov 22 |
nicklas |
595 |
} |
6897 |
29 Nov 22 |
nicklas |
if (fa.flowCellId != fb.flowCellId) |
6897 |
29 Nov 22 |
nicklas |
597 |
{ |
6897 |
29 Nov 22 |
nicklas |
return fa.flowCellId < fb.flowCellId ? -1 : 1; |
6897 |
29 Nov 22 |
nicklas |
599 |
} |
6582 |
11 Feb 22 |
nicklas |
if (fa.lastModified != fb.lastModified) |
6582 |
11 Feb 22 |
nicklas |
601 |
{ |
6582 |
11 Feb 22 |
nicklas |
return fa.lastModified < fb.lastModified ? -1 : 1; |
6582 |
11 Feb 22 |
nicklas |
603 |
} |
6897 |
29 Nov 22 |
nicklas |
return fa.name < fb.name ? -1 : 1; |
6353 |
18 Aug 21 |
nicklas |
605 |
} |
6353 |
18 Aug 21 |
nicklas |
else if (fa) |
6353 |
18 Aug 21 |
nicklas |
607 |
{ |
6353 |
18 Aug 21 |
nicklas |
return -1; |
6353 |
18 Aug 21 |
nicklas |
609 |
} |
6353 |
18 Aug 21 |
nicklas |
else if (fb) |
6353 |
18 Aug 21 |
nicklas |
611 |
{ |
6353 |
18 Aug 21 |
nicklas |
return 1; |
6353 |
18 Aug 21 |
nicklas |
613 |
} |
6929 |
02 Dec 22 |
nicklas |
if (a.itemType == 'StrayFastq' && b.itemType == 'StrayFastq') |
6929 |
02 Dec 22 |
nicklas |
615 |
{ |
6929 |
02 Dec 22 |
nicklas |
if (a.lastModified != b.lastModified) |
6929 |
02 Dec 22 |
nicklas |
617 |
{ |
6929 |
02 Dec 22 |
nicklas |
return a.lastModified < b.lastModified ? -1 : 1; |
6929 |
02 Dec 22 |
nicklas |
619 |
} |
6929 |
02 Dec 22 |
nicklas |
620 |
} |
6582 |
11 Feb 22 |
nicklas |
return specimen.sortBySamplingDate(a, b); |
6582 |
11 Feb 22 |
nicklas |
622 |
} |
6582 |
11 Feb 22 |
nicklas |
623 |
|
6582 |
11 Feb 22 |
nicklas |
// Sort entries by sampling date or registered date |
6582 |
11 Feb 22 |
nicklas |
specimen.sortBySamplingDate = function(a, b) |
6582 |
11 Feb 22 |
nicklas |
626 |
{ |
6582 |
11 Feb 22 |
nicklas |
var ra = a.samplingDate || a.registered; |
6582 |
11 Feb 22 |
nicklas |
var rb = b.samplingDate || b.registered; |
6582 |
11 Feb 22 |
nicklas |
if (ra && rb) |
6582 |
11 Feb 22 |
nicklas |
630 |
{ |
6582 |
11 Feb 22 |
nicklas |
if (ra != rb) return ra < rb ? -1 : 1; |
6582 |
11 Feb 22 |
nicklas |
632 |
} |
6582 |
11 Feb 22 |
nicklas |
else if (ra) |
6582 |
11 Feb 22 |
nicklas |
634 |
{ |
6582 |
11 Feb 22 |
nicklas |
return -1; |
6582 |
11 Feb 22 |
nicklas |
636 |
} |
6582 |
11 Feb 22 |
nicklas |
else if (rb) |
6582 |
11 Feb 22 |
nicklas |
638 |
{ |
6582 |
11 Feb 22 |
nicklas |
return 1; |
6582 |
11 Feb 22 |
nicklas |
640 |
} |
6353 |
18 Aug 21 |
nicklas |
return specimen.sortByName(a, b); |
6353 |
18 Aug 21 |
nicklas |
642 |
} |
6178 |
23 Mar 21 |
nicklas |
643 |
|
6353 |
18 Aug 21 |
nicklas |
// Sort entries by name |
6353 |
18 Aug 21 |
nicklas |
specimen.sortByName = function(a, b) |
6353 |
18 Aug 21 |
nicklas |
646 |
{ |
6353 |
18 Aug 21 |
nicklas |
return a.name == b.name ? 0 : (a.name < b.name ? -1 : 1); |
6353 |
18 Aug 21 |
nicklas |
648 |
} |
6353 |
18 Aug 21 |
nicklas |
649 |
|
6178 |
23 Mar 21 |
nicklas |
specimen.submit = function() |
6178 |
23 Mar 21 |
nicklas |
651 |
{ |
6178 |
23 Mar 21 |
nicklas |
var frm = document.forms['reggie']; |
6178 |
23 Mar 21 |
nicklas |
var submitInfo = {}; |
6212 |
14 Apr 21 |
nicklas |
submitInfo.operator = frm.operator.value; |
6914 |
01 Dec 22 |
nicklas |
submitInfo.getDebugMessages = debug ? true : false; |
6178 |
23 Mar 21 |
nicklas |
656 |
|
6178 |
23 Mar 21 |
nicklas |
var items = []; |
6178 |
23 Mar 21 |
nicklas |
submitInfo.items = items; |
6178 |
23 Mar 21 |
nicklas |
for (var itemNo = 0; itemNo < importItems.length; itemNo++) |
6178 |
23 Mar 21 |
nicklas |
660 |
{ |
6212 |
14 Apr 21 |
nicklas |
var chk = frm['import.'+itemNo]; |
6736 |
10 May 22 |
nicklas |
var flagRNA = frm['flagrna.'+itemNo]; |
6212 |
14 Apr 21 |
nicklas |
if (chk && chk.checked) |
6178 |
23 Mar 21 |
nicklas |
664 |
{ |
6198 |
07 Apr 21 |
nicklas |
var item = importItems[itemNo] |
6198 |
07 Apr 21 |
nicklas |
var tmp = {}; |
6198 |
07 Apr 21 |
nicklas |
tmp.id = item.id; |
6198 |
07 Apr 21 |
nicklas |
tmp.jsonFile = item.jsonFile.name; |
6736 |
10 May 22 |
nicklas |
tmp.flagRNA = flagRNA && flagRNA.checked; |
6198 |
07 Apr 21 |
nicklas |
items[items.length] = tmp; |
6178 |
23 Mar 21 |
nicklas |
671 |
} |
6178 |
23 Mar 21 |
nicklas |
672 |
} |
6178 |
23 Mar 21 |
nicklas |
673 |
|
6211 |
14 Apr 21 |
nicklas |
if (Doc.element('autoAnalyzeYes').checked) |
6211 |
14 Apr 21 |
nicklas |
675 |
{ |
6211 |
14 Apr 21 |
nicklas |
var autoAnalyze = {}; |
6211 |
14 Apr 21 |
nicklas |
autoAnalyze.mergeSoftware = parseInt(frm.mergeSoftware.value); |
6211 |
14 Apr 21 |
nicklas |
autoAnalyze.mergeProtocol = parseInt(frm.mergeProtocol.value); |
6211 |
14 Apr 21 |
nicklas |
autoAnalyze.cluster = frm.clusters.value; |
6211 |
14 Apr 21 |
nicklas |
autoAnalyze.priority = parseInt(frm.priority.value); |
6980 |
17 Jan 23 |
nicklas |
if (frm.partition.selectedIndex >= 0) |
6980 |
17 Jan 23 |
nicklas |
682 |
{ |
6980 |
17 Jan 23 |
nicklas |
autoAnalyze.partition = frm.partition.value; |
6980 |
17 Jan 23 |
nicklas |
684 |
} |
6211 |
14 Apr 21 |
nicklas |
autoAnalyze.debug = frm.debug.checked; |
6211 |
14 Apr 21 |
nicklas |
autoAnalyze.autoConfirm = frm.autoConfirm.checked; |
6211 |
14 Apr 21 |
nicklas |
submitInfo.autoAnalyze = autoAnalyze; |
6211 |
14 Apr 21 |
nicklas |
688 |
} |
6211 |
14 Apr 21 |
nicklas |
689 |
|
6510 |
03 Dec 21 |
nicklas |
var url = '../ExternalSpecimen.servlet?ID='+App.getSessionId(); |
6178 |
23 Mar 21 |
nicklas |
url += '&cmd=ImportFromJSON'; |
6178 |
23 Mar 21 |
nicklas |
692 |
|
6913 |
30 Nov 22 |
nicklas |
Wizard.showLoadingAnimation('Importing external specimen...', 'import-json-progress'); |
6178 |
23 Mar 21 |
nicklas |
Wizard.asyncJsonRequest(url, specimen.submissionResults, 'POST', JSON.stringify(submitInfo)); |
6178 |
23 Mar 21 |
nicklas |
695 |
} |
6178 |
23 Mar 21 |
nicklas |
696 |
|
6178 |
23 Mar 21 |
nicklas |
specimen.submissionResults = function(response) |
6178 |
23 Mar 21 |
nicklas |
698 |
{ |
6178 |
23 Mar 21 |
nicklas |
Wizard.showFinalMessage(response.messages); |
6178 |
23 Mar 21 |
nicklas |
Doc.show('gorestart'); |
6178 |
23 Mar 21 |
nicklas |
701 |
} |
6178 |
23 Mar 21 |
nicklas |
702 |
|
6178 |
23 Mar 21 |
nicklas |
return specimen; |
6178 |
23 Mar 21 |
nicklas |
704 |
}(); |
6178 |
23 Mar 21 |
nicklas |
705 |
|
6178 |
23 Mar 21 |
nicklas |
Doc.onLoad(ImportSpecimen.initPage); |