extensions/net.sf.basedb.reggie/trunk/resources/sampleproc/rnaqc_plate_export.js

Code
Comments
Other
Rev Date Author Line
2694 24 Sep 14 nicklas 1 var RnaQcExport = function()
2694 24 Sep 14 nicklas 2 {
2694 24 Sep 14 nicklas 3   var rnaqc = {};
2694 24 Sep 14 nicklas 4   
2694 24 Sep 14 nicklas 5   
2694 24 Sep 14 nicklas 6   // Page initialization
2694 24 Sep 14 nicklas 7   rnaqc.initPage = function()
2694 24 Sep 14 nicklas 8   {
2694 24 Sep 14 nicklas 9     // Navigation
2694 24 Sep 14 nicklas 10     Buttons.addClickHandler('gocancel', Wizard.cancelWizard);
2694 24 Sep 14 nicklas 11     Buttons.addClickHandler('gorestart', Wizard.restartWizard);
2694 24 Sep 14 nicklas 12     Buttons.addClickHandler('gonext', Wizard.goNextOnClick);
2694 24 Sep 14 nicklas 13     Buttons.addClickHandler('goregister', Wizard.goRegister);
2694 24 Sep 14 nicklas 14
2694 24 Sep 14 nicklas 15     var url = '../RnaQc.servlet?ID='+App.getSessionId();
2694 24 Sep 14 nicklas 16     url += '&cmd=GetActiveRnaQcBioPlates&numFreeWells=0&bioPlateType=CALIPER_RNAQC';
2694 24 Sep 14 nicklas 17     Wizard.showLoadingAnimation('Loading RNAQC plates...');
2694 24 Sep 14 nicklas 18     Wizard.asyncJsonRequest(url, rnaqc.qcPlatesLoaded);
2694 24 Sep 14 nicklas 19     
2694 24 Sep 14 nicklas 20     var url = '../RnaQc.servlet?ID='+App.getSessionId();
2694 24 Sep 14 nicklas 21     url += '&cmd=GetConfigurationsForRunParametersExporter';    
2694 24 Sep 14 nicklas 22     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 26   rnaqc.qcPlatesLoaded = function(response)
2694 24 Sep 14 nicklas 27   {
2694 24 Sep 14 nicklas 28     var frm = document.forms['reggie'];
2694 24 Sep 14 nicklas 29     var qcPlates = response.plates;
2694 24 Sep 14 nicklas 30     
2694 24 Sep 14 nicklas 31     for (var i = 0; i < qcPlates.length; i++)
2694 24 Sep 14 nicklas 32     {
2694 24 Sep 14 nicklas 33       var plate = qcPlates[i];
2694 24 Sep 14 nicklas 34       if (plate.usedWells > 0)
2694 24 Sep 14 nicklas 35       {
2694 24 Sep 14 nicklas 36         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 40     if (frm.bioPlates.length == 0)
2694 24 Sep 14 nicklas 41     {
2694 24 Sep 14 nicklas 42       Wizard.setFatalError('Could not find any bioplates to export.');
2694 24 Sep 14 nicklas 43       return;
2694 24 Sep 14 nicklas 44     }
2694 24 Sep 14 nicklas 45     
2694 24 Sep 14 nicklas 46     Doc.show('step-1');
2694 24 Sep 14 nicklas 47   }
2694 24 Sep 14 nicklas 48   
2694 24 Sep 14 nicklas 49   rnaqc.configurationsLoaded = function(response)
2694 24 Sep 14 nicklas 50   {
2694 24 Sep 14 nicklas 51     var configurations = response.configurations;
2694 24 Sep 14 nicklas 52
2694 24 Sep 14 nicklas 53     var html = rnaqc.makeExportLink('Sample names (csv)', 'SAMPLE_NAMES');
2694 24 Sep 14 nicklas 54     for (var i = 0; i < configurations.length; i++)
2694 24 Sep 14 nicklas 55     {
2694 24 Sep 14 nicklas 56       var config = configurations[i];
2694 24 Sep 14 nicklas 57       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 60     Doc.element('export').innerHTML = html;
2694 24 Sep 14 nicklas 61     var links = Doc.element('export').getElementsByClassName('link');
2694 24 Sep 14 nicklas 62     for (var linkNo = 0; linkNo < links.length; linkNo++)
2694 24 Sep 14 nicklas 63     {
2694 24 Sep 14 nicklas 64       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 68   rnaqc.makeExportLink = function(title, exporter)
2694 24 Sep 14 nicklas 69   {
2694 24 Sep 14 nicklas 70     var btn = '';
2694 24 Sep 14 nicklas 71     btn += '<span class="link" data-exporter="'+exporter+'">';
2694 24 Sep 14 nicklas 72     btn += '<img src="../images/export.png">&nbsp;';
2694 24 Sep 14 nicklas 73     btn += title+'</span><br>\n';
2694 24 Sep 14 nicklas 74     return btn;
2694 24 Sep 14 nicklas 75   }
2694 24 Sep 14 nicklas 76
2694 24 Sep 14 nicklas 77   rnaqc.exportFile = function(event)
2694 24 Sep 14 nicklas 78   {
2694 24 Sep 14 nicklas 79     var exporter = Data.get(event.currentTarget, 'exporter');
2694 24 Sep 14 nicklas 80     
2694 24 Sep 14 nicklas 81     var frm = document.forms['reggie'];  
2694 24 Sep 14 nicklas 82     var bioPlateId = frm.bioPlates.value;
2694 24 Sep 14 nicklas 83     
2694 24 Sep 14 nicklas 84     var url = '../RnaQc.servlet?ID='+App.getSessionId();
2694 24 Sep 14 nicklas 85     if (exporter == 'SAMPLE_NAMES')
2694 24 Sep 14 nicklas 86     {
2694 24 Sep 14 nicklas 87       url += '&cmd=ExportSampleNamesForCaliper&bioPlateId='+bioPlateId;
2694 24 Sep 14 nicklas 88     }
2694 24 Sep 14 nicklas 89     else
2694 24 Sep 14 nicklas 90     {
2694 24 Sep 14 nicklas 91       url += '&cmd=ExportRunParameters&bioPlateId='+bioPlateId+'&configurationId='+exporter;
2694 24 Sep 14 nicklas 92     }
2694 24 Sep 14 nicklas 93     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 97   return rnaqc;
2694 24 Sep 14 nicklas 98 }();
2694 24 Sep 14 nicklas 99
2694 24 Sep 14 nicklas 100 Doc.onLoad(RnaQcExport.initPage);
2694 24 Sep 14 nicklas 101