2694 |
24 Sep 14 |
nicklas |
var RnaQcExport = function() |
2694 |
24 Sep 14 |
nicklas |
2 |
{ |
2694 |
24 Sep 14 |
nicklas |
var rnaqc = {}; |
2694 |
24 Sep 14 |
nicklas |
4 |
|
2694 |
24 Sep 14 |
nicklas |
5 |
|
2694 |
24 Sep 14 |
nicklas |
// Page initialization |
2694 |
24 Sep 14 |
nicklas |
rnaqc.initPage = function() |
2694 |
24 Sep 14 |
nicklas |
8 |
{ |
2694 |
24 Sep 14 |
nicklas |
// Navigation |
2694 |
24 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2694 |
24 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2694 |
24 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2694 |
24 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2694 |
24 Sep 14 |
nicklas |
14 |
|
2694 |
24 Sep 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2694 |
24 Sep 14 |
nicklas |
url += '&cmd=GetActiveRnaQcBioPlates&numFreeWells=0&bioPlateType=CALIPER_RNAQC'; |
2694 |
24 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading RNAQC plates...'); |
2694 |
24 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.qcPlatesLoaded); |
2694 |
24 Sep 14 |
nicklas |
19 |
|
2694 |
24 Sep 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2694 |
24 Sep 14 |
nicklas |
url += '&cmd=GetConfigurationsForRunParametersExporter'; |
2694 |
24 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.configurationsLoaded); |
2694 |
24 Sep 14 |
nicklas |
23 |
} |
2694 |
24 Sep 14 |
nicklas |
24 |
|
2694 |
24 Sep 14 |
nicklas |
25 |
|
2694 |
24 Sep 14 |
nicklas |
rnaqc.qcPlatesLoaded = function(response) |
2694 |
24 Sep 14 |
nicklas |
27 |
{ |
2694 |
24 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2694 |
24 Sep 14 |
nicklas |
var qcPlates = response.plates; |
2694 |
24 Sep 14 |
nicklas |
30 |
|
2694 |
24 Sep 14 |
nicklas |
for (var i = 0; i < qcPlates.length; i++) |
2694 |
24 Sep 14 |
nicklas |
32 |
{ |
2694 |
24 Sep 14 |
nicklas |
var plate = qcPlates[i]; |
2694 |
24 Sep 14 |
nicklas |
if (plate.usedWells > 0) |
2694 |
24 Sep 14 |
nicklas |
35 |
{ |
2694 |
24 Sep 14 |
nicklas |
frm.bioPlates[frm.bioPlates.length] = new Option(plate.name + ' -- ' + plate.usedWells + ' used wells', plate.id); |
2694 |
24 Sep 14 |
nicklas |
37 |
} |
2694 |
24 Sep 14 |
nicklas |
38 |
} |
2694 |
24 Sep 14 |
nicklas |
39 |
|
2694 |
24 Sep 14 |
nicklas |
if (frm.bioPlates.length == 0) |
2694 |
24 Sep 14 |
nicklas |
41 |
{ |
2694 |
24 Sep 14 |
nicklas |
Wizard.setFatalError('Could not find any bioplates to export.'); |
2694 |
24 Sep 14 |
nicklas |
return; |
2694 |
24 Sep 14 |
nicklas |
44 |
} |
2694 |
24 Sep 14 |
nicklas |
45 |
|
2694 |
24 Sep 14 |
nicklas |
Doc.show('step-1'); |
2694 |
24 Sep 14 |
nicklas |
47 |
} |
2694 |
24 Sep 14 |
nicklas |
48 |
|
2694 |
24 Sep 14 |
nicklas |
rnaqc.configurationsLoaded = function(response) |
2694 |
24 Sep 14 |
nicklas |
50 |
{ |
2694 |
24 Sep 14 |
nicklas |
var configurations = response.configurations; |
2694 |
24 Sep 14 |
nicklas |
52 |
|
2694 |
24 Sep 14 |
nicklas |
var html = rnaqc.makeExportLink('Sample names (csv)', 'SAMPLE_NAMES'); |
2694 |
24 Sep 14 |
nicklas |
for (var i = 0; i < configurations.length; i++) |
2694 |
24 Sep 14 |
nicklas |
55 |
{ |
2694 |
24 Sep 14 |
nicklas |
var config = configurations[i]; |
2694 |
24 Sep 14 |
nicklas |
html += rnaqc.makeExportLink('Run parameters: '+Strings.encodeTags(config.name) + ' (xml)', config.id); |
2694 |
24 Sep 14 |
nicklas |
58 |
} |
2694 |
24 Sep 14 |
nicklas |
59 |
|
2694 |
24 Sep 14 |
nicklas |
Doc.element('export').innerHTML = html; |
2694 |
24 Sep 14 |
nicklas |
var links = Doc.element('export').getElementsByClassName('link'); |
2694 |
24 Sep 14 |
nicklas |
for (var linkNo = 0; linkNo < links.length; linkNo++) |
2694 |
24 Sep 14 |
nicklas |
63 |
{ |
2694 |
24 Sep 14 |
nicklas |
Events.addEventHandler(links[linkNo], 'click', rnaqc.exportFile); |
2694 |
24 Sep 14 |
nicklas |
65 |
} |
2694 |
24 Sep 14 |
nicklas |
66 |
} |
2694 |
24 Sep 14 |
nicklas |
67 |
|
2694 |
24 Sep 14 |
nicklas |
rnaqc.makeExportLink = function(title, exporter) |
2694 |
24 Sep 14 |
nicklas |
69 |
{ |
2694 |
24 Sep 14 |
nicklas |
var btn = ''; |
2694 |
24 Sep 14 |
nicklas |
btn += '<span class="link" data-exporter="'+exporter+'">'; |
2694 |
24 Sep 14 |
nicklas |
btn += '<img src="../images/export.png"> '; |
2694 |
24 Sep 14 |
nicklas |
btn += title+'</span><br>\n'; |
2694 |
24 Sep 14 |
nicklas |
return btn; |
2694 |
24 Sep 14 |
nicklas |
75 |
} |
2694 |
24 Sep 14 |
nicklas |
76 |
|
2694 |
24 Sep 14 |
nicklas |
rnaqc.exportFile = function(event) |
2694 |
24 Sep 14 |
nicklas |
78 |
{ |
2694 |
24 Sep 14 |
nicklas |
var exporter = Data.get(event.currentTarget, 'exporter'); |
2694 |
24 Sep 14 |
nicklas |
80 |
|
2694 |
24 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2694 |
24 Sep 14 |
nicklas |
var bioPlateId = frm.bioPlates.value; |
2694 |
24 Sep 14 |
nicklas |
83 |
|
2694 |
24 Sep 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2694 |
24 Sep 14 |
nicklas |
if (exporter == 'SAMPLE_NAMES') |
2694 |
24 Sep 14 |
nicklas |
86 |
{ |
2694 |
24 Sep 14 |
nicklas |
url += '&cmd=ExportSampleNamesForCaliper&bioPlateId='+bioPlateId; |
2694 |
24 Sep 14 |
nicklas |
88 |
} |
2694 |
24 Sep 14 |
nicklas |
else |
2694 |
24 Sep 14 |
nicklas |
90 |
{ |
2694 |
24 Sep 14 |
nicklas |
url += '&cmd=ExportRunParameters&bioPlateId='+bioPlateId+'&configurationId='+exporter; |
2694 |
24 Sep 14 |
nicklas |
92 |
} |
2694 |
24 Sep 14 |
nicklas |
window.location = url; |
2694 |
24 Sep 14 |
nicklas |
94 |
} |
2694 |
24 Sep 14 |
nicklas |
95 |
|
2694 |
24 Sep 14 |
nicklas |
96 |
|
2694 |
24 Sep 14 |
nicklas |
return rnaqc; |
2694 |
24 Sep 14 |
nicklas |
98 |
}(); |
2694 |
24 Sep 14 |
nicklas |
99 |
|
2694 |
24 Sep 14 |
nicklas |
Doc.onLoad(RnaQcExport.initPage); |
2694 |
24 Sep 14 |
nicklas |
101 |
|