5763 |
29 Nov 19 |
nicklas |
var VCall = function() |
5763 |
29 Nov 19 |
nicklas |
2 |
{ |
5763 |
29 Nov 19 |
nicklas |
var vcall = {}; |
5763 |
29 Nov 19 |
nicklas |
var debug = 0; |
5763 |
29 Nov 19 |
nicklas |
var selectionIsValid = false; |
5763 |
29 Nov 19 |
nicklas |
var subtypeAlignedSequences = null; |
5763 |
29 Nov 19 |
nicklas |
7 |
|
5763 |
29 Nov 19 |
nicklas |
var clusterIsValid = false; |
5763 |
29 Nov 19 |
nicklas |
9 |
|
5763 |
29 Nov 19 |
nicklas |
// Page initialization |
5763 |
29 Nov 19 |
nicklas |
vcall.initPage = function() |
5763 |
29 Nov 19 |
nicklas |
12 |
{ |
5763 |
29 Nov 19 |
nicklas |
13 |
|
5763 |
29 Nov 19 |
nicklas |
// Step 1 |
5763 |
29 Nov 19 |
nicklas |
Buttons.addClickHandler('btnSelectList', vcall.selectList); |
5763 |
29 Nov 19 |
nicklas |
Events.addEventHandler('itemList', 'base-selected', Items.onItemSelected); |
5763 |
29 Nov 19 |
nicklas |
Events.addEventHandler('itemList', 'change', vcall.itemListOnChange); |
5763 |
29 Nov 19 |
nicklas |
Events.doOnEnter('itemList', vcall.selectList); |
5763 |
29 Nov 19 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', vcall.validateStep1); |
5763 |
29 Nov 19 |
nicklas |
20 |
|
5763 |
29 Nov 19 |
nicklas |
// Step 2 |
5763 |
29 Nov 19 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', vcall.initializeStep2); |
5763 |
29 Nov 19 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', vcall.validateStep2); |
5763 |
29 Nov 19 |
nicklas |
Events.addEventHandler('clusters', 'change', vcall.clusterOnChange); |
5763 |
29 Nov 19 |
nicklas |
25 |
|
5763 |
29 Nov 19 |
nicklas |
// Navigation |
5763 |
29 Nov 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5763 |
29 Nov 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5763 |
29 Nov 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5763 |
29 Nov 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5763 |
29 Nov 19 |
nicklas |
31 |
|
5763 |
29 Nov 19 |
nicklas |
// Final registration |
5763 |
29 Nov 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', vcall.submit); |
5763 |
29 Nov 19 |
nicklas |
34 |
|
5763 |
29 Nov 19 |
nicklas |
Doc.show('step-1'); |
5763 |
29 Nov 19 |
nicklas |
Doc.show('gonext'); |
5763 |
29 Nov 19 |
nicklas |
37 |
|
5763 |
29 Nov 19 |
nicklas |
var frm = document.forms['reggie']; |
5763 |
29 Nov 19 |
nicklas |
frm.itemList.focus(); |
5763 |
29 Nov 19 |
nicklas |
40 |
} |
5763 |
29 Nov 19 |
nicklas |
41 |
|
5763 |
29 Nov 19 |
nicklas |
// --- Step 1 ----------------------------------- |
5763 |
29 Nov 19 |
nicklas |
43 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.validateStep1 = function(event) |
5763 |
29 Nov 19 |
nicklas |
45 |
{ |
5763 |
29 Nov 19 |
nicklas |
if (!selectionIsValid) |
5763 |
29 Nov 19 |
nicklas |
47 |
{ |
5763 |
29 Nov 19 |
nicklas |
Wizard.setInputStatus('itemList', 'invalid', 'A list must be selected'); |
5763 |
29 Nov 19 |
nicklas |
event.preventDefault(); |
5763 |
29 Nov 19 |
nicklas |
50 |
} |
5763 |
29 Nov 19 |
nicklas |
51 |
} |
5763 |
29 Nov 19 |
nicklas |
52 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.selectList = function() |
5763 |
29 Nov 19 |
nicklas |
54 |
{ |
5763 |
29 Nov 19 |
nicklas |
if (subtypeAlignedSequences == null) |
5763 |
29 Nov 19 |
nicklas |
56 |
{ |
5763 |
29 Nov 19 |
nicklas |
subtypeAlignedSequences = Reggie.getSubtypeInfo('ALIGNED_SEQUENCES'); |
5763 |
29 Nov 19 |
nicklas |
58 |
} |
5763 |
29 Nov 19 |
nicklas |
59 |
|
5763 |
29 Nov 19 |
nicklas |
// Reset list |
5763 |
29 Nov 19 |
nicklas |
var url = '&resetTemporary=1'; |
5763 |
29 Nov 19 |
nicklas |
url += '&tmpfilter:INT:memberType=268'; // 268=DERIVEDBIOASSAY |
5763 |
29 Nov 19 |
nicklas |
url += '&tmpfilter:INT:itemSubtype='+subtypeAlignedSequences.id; |
5763 |
29 Nov 19 |
nicklas |
Dialogs.selectItem('ITEMLIST', 'itemList', 0, url); |
5763 |
29 Nov 19 |
nicklas |
65 |
} |
5763 |
29 Nov 19 |
nicklas |
66 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.itemListOnChange = function() |
5763 |
29 Nov 19 |
nicklas |
68 |
{ |
5763 |
29 Nov 19 |
nicklas |
var frm = document.forms['reggie']; |
5763 |
29 Nov 19 |
nicklas |
selectionIsValid = false; |
5763 |
29 Nov 19 |
nicklas |
71 |
|
5763 |
29 Nov 19 |
nicklas |
if (!frm.itemList.value) |
5763 |
29 Nov 19 |
nicklas |
73 |
{ |
5763 |
29 Nov 19 |
nicklas |
Wizard.setInputStatus('itemList', 'invalid', 'A list must be selected'); |
5763 |
29 Nov 19 |
nicklas |
return; |
5763 |
29 Nov 19 |
nicklas |
76 |
} |
5764 |
29 Nov 19 |
nicklas |
77 |
|
5764 |
29 Nov 19 |
nicklas |
// Make some minor and quick checks on the selected list |
5764 |
29 Nov 19 |
nicklas |
Wizard.setInputStatus('itemList', 'checking', 'Checking...'); |
5764 |
29 Nov 19 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
5764 |
29 Nov 19 |
nicklas |
url += '&cmd=PreValidateItemListForStatistics'; |
5764 |
29 Nov 19 |
nicklas |
url += '&listId='+frm.itemList.value; |
5764 |
29 Nov 19 |
nicklas |
Wizard.asyncJsonRequest(url, vcall.itemListValidated); |
5764 |
29 Nov 19 |
nicklas |
84 |
} |
5764 |
29 Nov 19 |
nicklas |
85 |
|
5764 |
29 Nov 19 |
nicklas |
vcall.itemListValidated = function(response) |
5764 |
29 Nov 19 |
nicklas |
87 |
{ |
5764 |
29 Nov 19 |
nicklas |
if (response.message) |
5764 |
29 Nov 19 |
nicklas |
89 |
{ |
5764 |
29 Nov 19 |
nicklas |
selectionIsValid = false; |
5764 |
29 Nov 19 |
nicklas |
Wizard.setInputStatus('itemList', 'invalid', response.message); |
5764 |
29 Nov 19 |
nicklas |
92 |
} |
5764 |
29 Nov 19 |
nicklas |
else |
5764 |
29 Nov 19 |
nicklas |
94 |
{ |
5764 |
29 Nov 19 |
nicklas |
selectionIsValid = true; |
5764 |
29 Nov 19 |
nicklas |
Wizard.setInputStatus('itemList', 'valid'); |
5764 |
29 Nov 19 |
nicklas |
97 |
} |
5763 |
29 Nov 19 |
nicklas |
98 |
|
5763 |
29 Nov 19 |
nicklas |
99 |
} |
5763 |
29 Nov 19 |
nicklas |
100 |
|
5763 |
29 Nov 19 |
nicklas |
// --- Step 2 ----------------------------------- |
5763 |
29 Nov 19 |
nicklas |
vcall.initializeStep2 = function() |
5763 |
29 Nov 19 |
nicklas |
103 |
{ |
5763 |
29 Nov 19 |
nicklas |
Wizard.setCurrentStep(2); |
5763 |
29 Nov 19 |
nicklas |
105 |
|
5763 |
29 Nov 19 |
nicklas |
// Check debug by default if debug is set or not on a secure server (=production server) |
5763 |
29 Nov 19 |
nicklas |
var frm = document.forms['reggie']; |
5763 |
29 Nov 19 |
nicklas |
frm.debug.checked = debug || location.protocol != 'https:'; |
5763 |
29 Nov 19 |
nicklas |
109 |
|
6735 |
09 May 22 |
nicklas |
// Load clusters |
5763 |
29 Nov 19 |
nicklas |
var url = '../OpenGrid.servlet?ID='+App.getSessionId() + '&cmd=GetHostInfo'; |
5763 |
29 Nov 19 |
nicklas |
Doc.addClass('clusters', 'list-loading'); |
5763 |
29 Nov 19 |
nicklas |
frm.clusters[0] = new Option('loading...'); |
5763 |
29 Nov 19 |
nicklas |
Wizard.asyncJsonRequest(url, vcall.clustersLoaded); |
5763 |
29 Nov 19 |
nicklas |
115 |
|
5763 |
29 Nov 19 |
nicklas |
Doc.show('goregister'); |
5763 |
29 Nov 19 |
nicklas |
Doc.show('gocancel'); |
5763 |
29 Nov 19 |
nicklas |
118 |
} |
5763 |
29 Nov 19 |
nicklas |
119 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.validateStep2 = function(event) |
5763 |
29 Nov 19 |
nicklas |
121 |
{ |
5763 |
29 Nov 19 |
nicklas |
if (!clusterIsValid) event.preventDefault(); |
5763 |
29 Nov 19 |
nicklas |
123 |
} |
5763 |
29 Nov 19 |
nicklas |
124 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.clustersLoaded = function(response) |
5763 |
29 Nov 19 |
nicklas |
126 |
{ |
5763 |
29 Nov 19 |
nicklas |
Doc.removeClass('clusters', 'list-loading'); |
5763 |
29 Nov 19 |
nicklas |
var frm = document.forms['reggie']; |
5763 |
29 Nov 19 |
nicklas |
var clusters = response.hosts; |
5763 |
29 Nov 19 |
nicklas |
frm.clusters.length = 0; |
5763 |
29 Nov 19 |
nicklas |
for (var i = 0; i < clusters.length; i++) |
5763 |
29 Nov 19 |
nicklas |
132 |
{ |
5763 |
29 Nov 19 |
nicklas |
var cl = clusters[i]; |
5763 |
29 Nov 19 |
nicklas |
var option = new Option(cl.connection.name, cl.id); |
5763 |
29 Nov 19 |
nicklas |
option.cluster = cl; |
5763 |
29 Nov 19 |
nicklas |
frm.clusters[frm.clusters.length] = option; |
5763 |
29 Nov 19 |
nicklas |
Wizard.setInputStatus('clusters', 'valid'); |
5763 |
29 Nov 19 |
nicklas |
clusterIsValid = true; |
5763 |
29 Nov 19 |
nicklas |
139 |
} |
5763 |
29 Nov 19 |
nicklas |
if (frm.clusters.length == 0) |
5763 |
29 Nov 19 |
nicklas |
141 |
{ |
6735 |
09 May 22 |
nicklas |
Wizard.setInputStatus('clusters', 'invalid', 'No available clusters'); |
5763 |
29 Nov 19 |
nicklas |
clusterIsValid = false; |
5763 |
29 Nov 19 |
nicklas |
144 |
} |
5763 |
29 Nov 19 |
nicklas |
else |
5763 |
29 Nov 19 |
nicklas |
146 |
{ |
5763 |
29 Nov 19 |
nicklas |
vcall.clusterOnChange(); |
5763 |
29 Nov 19 |
nicklas |
148 |
} |
5763 |
29 Nov 19 |
nicklas |
149 |
} |
5763 |
29 Nov 19 |
nicklas |
150 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.clusterOnChange = function() |
5763 |
29 Nov 19 |
nicklas |
152 |
{ |
5763 |
29 Nov 19 |
nicklas |
var frm = document.forms['reggie']; |
5763 |
29 Nov 19 |
nicklas |
var cluster = frm.clusters[frm.clusters.selectedIndex].cluster; |
5763 |
29 Nov 19 |
nicklas |
if (cluster.priorities && cluster.priorities.length > 0) |
5763 |
29 Nov 19 |
nicklas |
156 |
{ |
5763 |
29 Nov 19 |
nicklas |
frm.priority.length = 0; |
5763 |
29 Nov 19 |
nicklas |
for (var pNo = 0; pNo < cluster.priorities.length; pNo++) |
5763 |
29 Nov 19 |
nicklas |
159 |
{ |
5763 |
29 Nov 19 |
nicklas |
var p = cluster.priorities[pNo]; |
5763 |
29 Nov 19 |
nicklas |
frm.priority[frm.priority.length] = new Option(p.name + ' ('+p.value+')', p.value, p['default'], p['default']); |
5763 |
29 Nov 19 |
nicklas |
162 |
} |
5763 |
29 Nov 19 |
nicklas |
Doc.show('job-priority'); |
5763 |
29 Nov 19 |
nicklas |
164 |
} |
5763 |
29 Nov 19 |
nicklas |
else |
5763 |
29 Nov 19 |
nicklas |
166 |
{ |
5763 |
29 Nov 19 |
nicklas |
Doc.hide('job-priority'); |
5763 |
29 Nov 19 |
nicklas |
168 |
} |
6980 |
17 Jan 23 |
nicklas |
if (cluster.partitions && cluster.partitions.length > 0) |
6980 |
17 Jan 23 |
nicklas |
170 |
{ |
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 |
173 |
{ |
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 |
178 |
} |
6980 |
17 Jan 23 |
nicklas |
Doc.show('job-partition'); |
6980 |
17 Jan 23 |
nicklas |
180 |
} |
6980 |
17 Jan 23 |
nicklas |
else |
6980 |
17 Jan 23 |
nicklas |
182 |
{ |
6980 |
17 Jan 23 |
nicklas |
Doc.hide('job-partition'); |
6980 |
17 Jan 23 |
nicklas |
184 |
} |
5763 |
29 Nov 19 |
nicklas |
185 |
} |
5763 |
29 Nov 19 |
nicklas |
186 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.submit = function() |
5763 |
29 Nov 19 |
nicklas |
188 |
{ |
5763 |
29 Nov 19 |
nicklas |
var frm = document.forms['reggie']; |
5763 |
29 Nov 19 |
nicklas |
190 |
|
5763 |
29 Nov 19 |
nicklas |
var submitInfo = {}; |
5765 |
29 Nov 19 |
nicklas |
submitInfo.itemList = parseInt(frm.itemList.value); |
5763 |
29 Nov 19 |
nicklas |
submitInfo.cluster = frm.clusters.value; |
5815 |
24 Jan 20 |
nicklas |
submitInfo.sampleType = frm.sampleType.value; |
5763 |
29 Nov 19 |
nicklas |
if (frm.priority.selectedIndex >= 0) |
5763 |
29 Nov 19 |
nicklas |
196 |
{ |
5763 |
29 Nov 19 |
nicklas |
submitInfo.priority = parseInt(frm.priority.value); |
5763 |
29 Nov 19 |
nicklas |
198 |
} |
6980 |
17 Jan 23 |
nicklas |
if (frm.partition.selectedIndex >= 0) |
6980 |
17 Jan 23 |
nicklas |
200 |
{ |
6980 |
17 Jan 23 |
nicklas |
submitInfo.partition = frm.partition.value; |
6980 |
17 Jan 23 |
nicklas |
202 |
} |
5763 |
29 Nov 19 |
nicklas |
submitInfo.debug = frm.debug.checked; |
5763 |
29 Nov 19 |
nicklas |
204 |
|
5763 |
29 Nov 19 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
5763 |
29 Nov 19 |
nicklas |
url += '&cmd=BuildVariantStatistics'; |
5763 |
29 Nov 19 |
nicklas |
207 |
|
5766 |
02 Dec 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...', 'variant-statistics-progress'); |
5763 |
29 Nov 19 |
nicklas |
Wizard.asyncJsonRequest(url, vcall.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5763 |
29 Nov 19 |
nicklas |
210 |
} |
5763 |
29 Nov 19 |
nicklas |
211 |
|
5763 |
29 Nov 19 |
nicklas |
vcall.submissionResults = function(response) |
5763 |
29 Nov 19 |
nicklas |
213 |
{ |
5763 |
29 Nov 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5763 |
29 Nov 19 |
nicklas |
Doc.show('gorestart'); |
5763 |
29 Nov 19 |
nicklas |
216 |
} |
5763 |
29 Nov 19 |
nicklas |
217 |
|
5763 |
29 Nov 19 |
nicklas |
return vcall; |
5763 |
29 Nov 19 |
nicklas |
219 |
}(); |
5763 |
29 Nov 19 |
nicklas |
220 |
|
5763 |
29 Nov 19 |
nicklas |
Doc.onLoad(VCall.initPage); |
5763 |
29 Nov 19 |
nicklas |
222 |
|