7395 |
06 Nov 23 |
nicklas |
var PoN = function() |
7395 |
06 Nov 23 |
nicklas |
2 |
{ |
7395 |
06 Nov 23 |
nicklas |
var pon = {}; |
7395 |
06 Nov 23 |
nicklas |
var debug = 0; |
7395 |
06 Nov 23 |
nicklas |
var selectionIsValid = false; |
7395 |
06 Nov 23 |
nicklas |
var subtypePanelOfNormals = null; |
7395 |
06 Nov 23 |
nicklas |
7 |
|
7395 |
06 Nov 23 |
nicklas |
var clusterIsValid = false; |
7395 |
06 Nov 23 |
nicklas |
9 |
|
7395 |
06 Nov 23 |
nicklas |
// Page initialization |
7395 |
06 Nov 23 |
nicklas |
pon.initPage = function() |
7395 |
06 Nov 23 |
nicklas |
12 |
{ |
7395 |
06 Nov 23 |
nicklas |
13 |
|
7395 |
06 Nov 23 |
nicklas |
// Step 1 |
7395 |
06 Nov 23 |
nicklas |
Buttons.addClickHandler('btnSelectList', pon.selectList); |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('itemList', 'base-selected', Items.onItemSelected); |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('itemList', 'change', pon.itemListOnChange); |
7395 |
06 Nov 23 |
nicklas |
Events.doOnEnter('itemList', pon.selectList); |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', pon.validateStep1); |
7395 |
06 Nov 23 |
nicklas |
20 |
|
7395 |
06 Nov 23 |
nicklas |
// Step 2 |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', pon.initializeStep2); |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', pon.validateStep2); |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('clusters', 'change', pon.clusterOnChange); |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('debug', 'change', pon.debugOnChange); |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('override', 'change', pon.overrideOnChange); |
7395 |
06 Nov 23 |
nicklas |
27 |
|
7395 |
06 Nov 23 |
nicklas |
// Navigation |
7395 |
06 Nov 23 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
7395 |
06 Nov 23 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
7395 |
06 Nov 23 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
7395 |
06 Nov 23 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
7395 |
06 Nov 23 |
nicklas |
33 |
|
7395 |
06 Nov 23 |
nicklas |
// Final registration |
7395 |
06 Nov 23 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', pon.submit); |
7395 |
06 Nov 23 |
nicklas |
36 |
|
7395 |
06 Nov 23 |
nicklas |
Doc.show('step-1'); |
7395 |
06 Nov 23 |
nicklas |
Doc.show('gonext'); |
7395 |
06 Nov 23 |
nicklas |
39 |
|
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
frm.itemList.focus(); |
7395 |
06 Nov 23 |
nicklas |
42 |
} |
7395 |
06 Nov 23 |
nicklas |
43 |
|
7395 |
06 Nov 23 |
nicklas |
// --- Step 1 ----------------------------------- |
7395 |
06 Nov 23 |
nicklas |
45 |
|
7395 |
06 Nov 23 |
nicklas |
pon.validateStep1 = function(event) |
7395 |
06 Nov 23 |
nicklas |
47 |
{ |
7395 |
06 Nov 23 |
nicklas |
if (!selectionIsValid) |
7395 |
06 Nov 23 |
nicklas |
49 |
{ |
7395 |
06 Nov 23 |
nicklas |
Wizard.setInputStatus('itemList', 'invalid', 'A list must be selected'); |
7395 |
06 Nov 23 |
nicklas |
event.preventDefault(); |
7395 |
06 Nov 23 |
nicklas |
52 |
} |
7395 |
06 Nov 23 |
nicklas |
53 |
} |
7395 |
06 Nov 23 |
nicklas |
54 |
|
7395 |
06 Nov 23 |
nicklas |
pon.selectList = function() |
7395 |
06 Nov 23 |
nicklas |
56 |
{ |
7395 |
06 Nov 23 |
nicklas |
if (subtypePanelOfNormals == null) |
7395 |
06 Nov 23 |
nicklas |
58 |
{ |
7395 |
06 Nov 23 |
nicklas |
subtypePanelOfNormals = Reggie.getSubtypeInfo('PANEL_OF_NORMAL'); |
7395 |
06 Nov 23 |
nicklas |
60 |
} |
7395 |
06 Nov 23 |
nicklas |
61 |
|
7395 |
06 Nov 23 |
nicklas |
// Reset list |
7395 |
06 Nov 23 |
nicklas |
var url = '&resetTemporary=1'; |
7395 |
06 Nov 23 |
nicklas |
url += '&tmpfilter:INT:memberType=268'; // 268=DERIVEDBIOASSAY |
7395 |
06 Nov 23 |
nicklas |
url += '&tmpfilter:INT:itemSubtype='+subtypePanelOfNormals.id; |
7395 |
06 Nov 23 |
nicklas |
Dialogs.selectItem('ITEMLIST', 'itemList', 0, url); |
7395 |
06 Nov 23 |
nicklas |
67 |
} |
7395 |
06 Nov 23 |
nicklas |
68 |
|
7395 |
06 Nov 23 |
nicklas |
pon.itemListOnChange = function() |
7395 |
06 Nov 23 |
nicklas |
70 |
{ |
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
selectionIsValid = false; |
7395 |
06 Nov 23 |
nicklas |
73 |
|
7395 |
06 Nov 23 |
nicklas |
if (!frm.itemList.value) |
7395 |
06 Nov 23 |
nicklas |
75 |
{ |
7395 |
06 Nov 23 |
nicklas |
Wizard.setInputStatus('itemList', 'invalid', 'A list must be selected'); |
7395 |
06 Nov 23 |
nicklas |
return; |
7395 |
06 Nov 23 |
nicklas |
78 |
} |
7395 |
06 Nov 23 |
nicklas |
79 |
|
7395 |
06 Nov 23 |
nicklas |
// Make some minor and quick checks on the selected list |
7395 |
06 Nov 23 |
nicklas |
Wizard.setInputStatus('itemList', 'checking', 'Checking...'); |
7395 |
06 Nov 23 |
nicklas |
var url = '../WgsVariantCalling.servlet?ID='+App.getSessionId(); |
7395 |
06 Nov 23 |
nicklas |
url += '&cmd=PreValidateItemListForPanelOfNormals'; |
7395 |
06 Nov 23 |
nicklas |
url += '&listId='+frm.itemList.value; |
7395 |
06 Nov 23 |
nicklas |
Wizard.asyncJsonRequest(url, pon.itemListValidated); |
7395 |
06 Nov 23 |
nicklas |
86 |
} |
7395 |
06 Nov 23 |
nicklas |
87 |
|
7395 |
06 Nov 23 |
nicklas |
pon.itemListValidated = function(response) |
7395 |
06 Nov 23 |
nicklas |
89 |
{ |
7442 |
17 Nov 23 |
nicklas |
Doc.element('externalOperator').innerHTML=Strings.encodeTags(response.ExternalOperator); |
7442 |
17 Nov 23 |
nicklas |
if (response.errorMessage) |
7395 |
06 Nov 23 |
nicklas |
92 |
{ |
7395 |
06 Nov 23 |
nicklas |
selectionIsValid = false; |
7442 |
17 Nov 23 |
nicklas |
Wizard.setInputStatus('itemList', 'invalid', response.errorMessage); |
7395 |
06 Nov 23 |
nicklas |
95 |
} |
7442 |
17 Nov 23 |
nicklas |
else if (response.warningMessage) |
7442 |
17 Nov 23 |
nicklas |
97 |
{ |
7442 |
17 Nov 23 |
nicklas |
selectionIsValid = true; |
7442 |
17 Nov 23 |
nicklas |
Wizard.setInputStatus('itemList', 'warning', response.warningMessage); |
7442 |
17 Nov 23 |
nicklas |
100 |
} |
7395 |
06 Nov 23 |
nicklas |
else |
7395 |
06 Nov 23 |
nicklas |
102 |
{ |
7395 |
06 Nov 23 |
nicklas |
selectionIsValid = true; |
7395 |
06 Nov 23 |
nicklas |
Wizard.setInputStatus('itemList', 'valid'); |
7395 |
06 Nov 23 |
nicklas |
105 |
} |
7395 |
06 Nov 23 |
nicklas |
106 |
} |
7395 |
06 Nov 23 |
nicklas |
107 |
|
7395 |
06 Nov 23 |
nicklas |
// --- Step 2 ----------------------------------- |
7395 |
06 Nov 23 |
nicklas |
pon.initializeStep2 = function() |
7395 |
06 Nov 23 |
nicklas |
110 |
{ |
7395 |
06 Nov 23 |
nicklas |
Wizard.setCurrentStep(2); |
7395 |
06 Nov 23 |
nicklas |
112 |
|
7395 |
06 Nov 23 |
nicklas |
// Check debug by default if debug is set or not on a secure server (=production server) |
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
frm.debug.checked = debug || location.protocol != 'https:'; |
7395 |
06 Nov 23 |
nicklas |
116 |
|
7395 |
06 Nov 23 |
nicklas |
// Load clusters |
7395 |
06 Nov 23 |
nicklas |
var url = '../OpenGrid.servlet?ID='+App.getSessionId() + '&cmd=GetHostInfo&config=wgs-variant-call'; |
7395 |
06 Nov 23 |
nicklas |
Doc.addClass('clusters', 'list-loading'); |
7395 |
06 Nov 23 |
nicklas |
frm.clusters[0] = new Option('loading...'); |
7395 |
06 Nov 23 |
nicklas |
Wizard.asyncJsonRequest(url, pon.clustersLoaded); |
7395 |
06 Nov 23 |
nicklas |
122 |
|
7395 |
06 Nov 23 |
nicklas |
Doc.show('goregister'); |
7395 |
06 Nov 23 |
nicklas |
Doc.show('gocancel'); |
7395 |
06 Nov 23 |
nicklas |
125 |
} |
7395 |
06 Nov 23 |
nicklas |
126 |
|
7395 |
06 Nov 23 |
nicklas |
pon.validateStep2 = function(event) |
7395 |
06 Nov 23 |
nicklas |
128 |
{ |
7395 |
06 Nov 23 |
nicklas |
if (!clusterIsValid) event.preventDefault(); |
7395 |
06 Nov 23 |
nicklas |
130 |
} |
7395 |
06 Nov 23 |
nicklas |
131 |
|
7395 |
06 Nov 23 |
nicklas |
pon.clustersLoaded = function(response) |
7395 |
06 Nov 23 |
nicklas |
133 |
{ |
7395 |
06 Nov 23 |
nicklas |
Doc.removeClass('clusters', 'list-loading'); |
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
var clusters = response.hosts; |
7395 |
06 Nov 23 |
nicklas |
frm.clusters.length = 0; |
7395 |
06 Nov 23 |
nicklas |
for (var i = 0; i < clusters.length; i++) |
7395 |
06 Nov 23 |
nicklas |
139 |
{ |
7395 |
06 Nov 23 |
nicklas |
var cl = clusters[i]; |
7395 |
06 Nov 23 |
nicklas |
var option = new Option(cl.connection.name, cl.id); |
7395 |
06 Nov 23 |
nicklas |
option.cluster = cl; |
7395 |
06 Nov 23 |
nicklas |
frm.clusters[frm.clusters.length] = option; |
7395 |
06 Nov 23 |
nicklas |
Wizard.setInputStatus('clusters', 'valid'); |
7395 |
06 Nov 23 |
nicklas |
clusterIsValid = true; |
7395 |
06 Nov 23 |
nicklas |
146 |
} |
7395 |
06 Nov 23 |
nicklas |
if (frm.clusters.length == 0) |
7395 |
06 Nov 23 |
nicklas |
148 |
{ |
7395 |
06 Nov 23 |
nicklas |
Wizard.setInputStatus('clusters', 'invalid', 'No available clusters'); |
7395 |
06 Nov 23 |
nicklas |
clusterIsValid = false; |
7395 |
06 Nov 23 |
nicklas |
151 |
} |
7395 |
06 Nov 23 |
nicklas |
else |
7395 |
06 Nov 23 |
nicklas |
153 |
{ |
7395 |
06 Nov 23 |
nicklas |
pon.clusterOnChange(); |
7395 |
06 Nov 23 |
nicklas |
155 |
} |
7395 |
06 Nov 23 |
nicklas |
156 |
} |
7395 |
06 Nov 23 |
nicklas |
157 |
|
7395 |
06 Nov 23 |
nicklas |
pon.clusterOnChange = function() |
7395 |
06 Nov 23 |
nicklas |
159 |
{ |
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
var cluster = frm.clusters[frm.clusters.selectedIndex].cluster; |
7395 |
06 Nov 23 |
nicklas |
if (cluster.priorities && cluster.priorities.length > 0) |
7395 |
06 Nov 23 |
nicklas |
163 |
{ |
7395 |
06 Nov 23 |
nicklas |
frm.priority.length = 0; |
7395 |
06 Nov 23 |
nicklas |
for (var pNo = 0; pNo < cluster.priorities.length; pNo++) |
7395 |
06 Nov 23 |
nicklas |
166 |
{ |
7395 |
06 Nov 23 |
nicklas |
var p = cluster.priorities[pNo]; |
7395 |
06 Nov 23 |
nicklas |
frm.priority[frm.priority.length] = new Option(p.name + ' ('+p.value+')', p.value, p['default'], p['default']); |
7395 |
06 Nov 23 |
nicklas |
169 |
} |
7395 |
06 Nov 23 |
nicklas |
Doc.show('job-priority'); |
7395 |
06 Nov 23 |
nicklas |
171 |
} |
7395 |
06 Nov 23 |
nicklas |
else |
7395 |
06 Nov 23 |
nicklas |
173 |
{ |
7395 |
06 Nov 23 |
nicklas |
Doc.hide('job-priority'); |
7395 |
06 Nov 23 |
nicklas |
175 |
} |
7395 |
06 Nov 23 |
nicklas |
if (cluster.partitions && cluster.partitions.length > 0) |
7395 |
06 Nov 23 |
nicklas |
177 |
{ |
7395 |
06 Nov 23 |
nicklas |
frm.partition.length = 0; |
7395 |
06 Nov 23 |
nicklas |
for (var pNo = 0; pNo < cluster.partitions.length; pNo++) |
7395 |
06 Nov 23 |
nicklas |
180 |
{ |
7395 |
06 Nov 23 |
nicklas |
var p = cluster.partitions[pNo]; |
7395 |
06 Nov 23 |
nicklas |
var title = p.name; |
7395 |
06 Nov 23 |
nicklas |
if (p.description) title += ' ('+p.description+')'; |
7395 |
06 Nov 23 |
nicklas |
frm.partition[frm.partition.length] = new Option(title, p.value, p['default'], p['default']); |
7395 |
06 Nov 23 |
nicklas |
185 |
} |
7395 |
06 Nov 23 |
nicklas |
Doc.show('job-partition'); |
7395 |
06 Nov 23 |
nicklas |
187 |
} |
7395 |
06 Nov 23 |
nicklas |
else |
7395 |
06 Nov 23 |
nicklas |
189 |
{ |
7395 |
06 Nov 23 |
nicklas |
Doc.hide('job-partition'); |
7395 |
06 Nov 23 |
nicklas |
191 |
} |
7395 |
06 Nov 23 |
nicklas |
pon.updateSubmitOptions(); |
7395 |
06 Nov 23 |
nicklas |
193 |
} |
7395 |
06 Nov 23 |
nicklas |
194 |
|
7395 |
06 Nov 23 |
nicklas |
pon.debugOnChange = function() |
7395 |
06 Nov 23 |
nicklas |
196 |
{ |
7395 |
06 Nov 23 |
nicklas |
pon.updateSubmitOptions(); |
7395 |
06 Nov 23 |
nicklas |
198 |
} |
7395 |
06 Nov 23 |
nicklas |
199 |
|
7395 |
06 Nov 23 |
nicklas |
pon.updateSubmitOptions = function() |
7395 |
06 Nov 23 |
nicklas |
201 |
{ |
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
var config = frm.clusters[frm.clusters.selectedIndex]?.cluster?.config?.['wgs-variant-call']; |
7395 |
06 Nov 23 |
nicklas |
if (config) |
7395 |
06 Nov 23 |
nicklas |
205 |
{ |
7395 |
06 Nov 23 |
nicklas |
Doc.element('submitOptions').innerHTML = Reggie.getSubmitOptions(config, frm.debug.checked); |
7395 |
06 Nov 23 |
nicklas |
frm.override.disabled = false; |
7395 |
06 Nov 23 |
nicklas |
208 |
} |
7395 |
06 Nov 23 |
nicklas |
209 |
} |
7395 |
06 Nov 23 |
nicklas |
210 |
|
7395 |
06 Nov 23 |
nicklas |
pon.overrideOnChange = function() |
7395 |
06 Nov 23 |
nicklas |
212 |
{ |
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
Doc.showHide('submitOptions', !frm.override.checked); |
7395 |
06 Nov 23 |
nicklas |
Doc.showHide('submitOptionsOverride', frm.override.checked); |
7395 |
06 Nov 23 |
nicklas |
if (frm.submitOptionsOverride.value=='') |
7395 |
06 Nov 23 |
nicklas |
217 |
{ |
7395 |
06 Nov 23 |
nicklas |
frm.submitOptionsOverride.value = Doc.element('submitOptions').innerHTML; |
7395 |
06 Nov 23 |
nicklas |
219 |
} |
7395 |
06 Nov 23 |
nicklas |
220 |
} |
7395 |
06 Nov 23 |
nicklas |
221 |
|
7395 |
06 Nov 23 |
nicklas |
222 |
|
7395 |
06 Nov 23 |
nicklas |
pon.submit = function() |
7395 |
06 Nov 23 |
nicklas |
224 |
{ |
7395 |
06 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7395 |
06 Nov 23 |
nicklas |
226 |
|
7395 |
06 Nov 23 |
nicklas |
var submitInfo = {}; |
7395 |
06 Nov 23 |
nicklas |
submitInfo.itemList = parseInt(frm.itemList.value); |
7395 |
06 Nov 23 |
nicklas |
submitInfo.cluster = frm.clusters.value; |
7395 |
06 Nov 23 |
nicklas |
if (frm.priority.selectedIndex >= 0) |
7395 |
06 Nov 23 |
nicklas |
231 |
{ |
7395 |
06 Nov 23 |
nicklas |
submitInfo.priority = parseInt(frm.priority.value); |
7395 |
06 Nov 23 |
nicklas |
233 |
} |
7395 |
06 Nov 23 |
nicklas |
if (frm.partition.selectedIndex >= 0) |
7395 |
06 Nov 23 |
nicklas |
235 |
{ |
7395 |
06 Nov 23 |
nicklas |
submitInfo.partition = frm.partition.value; |
7395 |
06 Nov 23 |
nicklas |
237 |
} |
7395 |
06 Nov 23 |
nicklas |
if (frm.override.checked) |
7395 |
06 Nov 23 |
nicklas |
239 |
{ |
7395 |
06 Nov 23 |
nicklas |
submitInfo.submitOptionsOverride = frm.submitOptionsOverride.value; |
7395 |
06 Nov 23 |
nicklas |
241 |
} |
7395 |
06 Nov 23 |
nicklas |
submitInfo.debug = frm.debug.checked; |
7395 |
06 Nov 23 |
nicklas |
243 |
|
7395 |
06 Nov 23 |
nicklas |
var url = '../WgsVariantCalling.servlet?ID='+App.getSessionId(); |
7395 |
06 Nov 23 |
nicklas |
url += '&cmd=BuildPanelOfNormals'; |
7395 |
06 Nov 23 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
7395 |
06 Nov 23 |
nicklas |
Wizard.asyncJsonRequest(url, pon.submissionResults, 'POST', JSON.stringify(submitInfo)); |
7395 |
06 Nov 23 |
nicklas |
248 |
} |
7395 |
06 Nov 23 |
nicklas |
249 |
|
7395 |
06 Nov 23 |
nicklas |
pon.submissionResults = function(response) |
7395 |
06 Nov 23 |
nicklas |
251 |
{ |
7395 |
06 Nov 23 |
nicklas |
Wizard.showFinalMessage(response.messages); |
7395 |
06 Nov 23 |
nicklas |
Doc.show('gorestart'); |
7395 |
06 Nov 23 |
nicklas |
254 |
} |
7395 |
06 Nov 23 |
nicklas |
255 |
|
7395 |
06 Nov 23 |
nicklas |
return pon; |
7395 |
06 Nov 23 |
nicklas |
257 |
}(); |
7395 |
06 Nov 23 |
nicklas |
258 |
|
7395 |
06 Nov 23 |
nicklas |
Doc.onLoad(PoN.initPage); |
7395 |
06 Nov 23 |
nicklas |
260 |
|