added the list of management factor types in controllers
[sgn.git] / mason / breeders_toolbox / download.mas
blobea327b17e48854ca9bba2184157d8d8319f341b9
1 <%args>
3 </%args>
5 <& /util/import_javascript.mas, classes => [ 'jqueryui', 'jquery.cookie', 'CXGN.BreederSearch', 'CXGN.List', 'CXGN.BreedersToolbox.HTMLSelect', 'spin_min', 'ladda_min' ] &>
7 <& /page/page_title.mas, title=>"Download Using Lists" &>
9 <div class="container-fluid">
11 <div class="well">
12 Choose a list for each parameter and click "Download".
13 </div>
15 <div class="well well-sm">
16 <h4>Download Phenotypes Using Lists</h4><p>Select Parameters:</p>
17 <form id="download_form" action="/breeders/download_action" method="POST" >
18 <table class="table table-bordered" >
19   <thead>
20   <tr>
21     <th>
22       Accessions
23     </th>
24     <th>
25       Trials
26     </th>
27     <th>
28       Traits
29     </th>
30     <th>
31         Options
32     </th>
33     <th>
34       Action
35     </th>
36   </tr>
37   </thead>
38   <tbody>
39   <tr>
40     <td>
41       <div id="accession_list">
42       </div>
43     </td>
44     <td>
45       <div id="trial_list">
46       </div>
47     </td>
48     <td>
49       <div id="trait_list">
50       </div>
51    </td>
52     <td>
53     <b>Format:</b><br/>
54     <select class="form-control" id="format" name="format">
55         <option value=".csv">CSV</option>
56         <option value=".xls">XLS</option>
57         <option value="html">HTML</option>
58     </select>
59     <br/>
60     <b>Data Level:</b><br/>
61     <select class="form-control" id="phenotype_datalevel" name="phenotype_datalevel">
62         <option value="all">All</option>
63         <option value="plot">Plot</option>
64         <option value="plant">Plant</option>
65     </select>
66     <br/>
67     <b>Timestamp:</b><br/>
68     <select class="form-control" id="timestamp" name="timestamp">
69         <option value="0">No</option>
70         <option value="1">Yes</option>
71     </select>
72     <br/>
73     <b>Exclude Phenotype Outliers:</b><br/>
74     <select class="form-control" id="exclude_phenotype_outlier" name="exclude_phenotype_outlier">
75         <option value="0">No</option>
76         <option value="1">Yes</option>
77     </select>
78     </td>
79     <td>
80       <button class="btn btn-primary" type="button" id="phenotype">Download</button>
81       <input type="hidden" id="phenotype_download_token" name="phenotype_download_token"/>
82     </td>
83   </tr>
84   </tbody>
85   </table>
86 </form>
87 </div>
89 <div class="well well-sm">
90 <h4>Inspect Datasets</h4>
91 <table class="table table-bordered" >
92   <thead>
93   <tr>
94     <th>
95       Datasets
96     </th>
97   </tr>
98   </thead>
99   <tbody>
100   <tr>
101     <td>
102       <div id="phenotype_download_dataset_list">
103       </div>
104     </td>
105   </tr>
106   </tbody>
107   </table>
108 </div>
110 <div class="well well-sm">
111 <h4>Download Metadata</h4><p>Select Parameters:</p>
112 <form id="download_metadata_form" action="/breeders/download_action" method="POST" >
113 <table class="table table-bordered" >
114   <thead>
115   <tr>
116     <th>
117       Trials
118     </th>
119     <th>
120         Options
121     </th>
122     <th>
123       Action
124     </th>
125   </tr>
126   </thead>
127   <tbody>
128   <tr>
129     <td>
130       <div id="trial_metadata_list">
131       </div>
132     </td>
133     <td>
134     <b>Format:</b><br/>
135     <select class="form-control" id="metadata_format" name="metadata_format">
136         <option value=".xls">XLS</option>
137         <option value=".csv">CSV</option>
138         <option value="html">HTML</option>
139     </select>
140     <br/>
141     <div id="datalevel" style="display:none">
142       <select class="form-control" id="metadata_datalevel" name="metadata_datalevel">
143           <option value="metadata">Metadata</option>
144       </select>
145     </div>
146     </td>
147     <td>
148       <button class="btn btn-primary" type="button" id="metadata">Download</button>
149       <input type="hidden" id="metadata_download_token" name="metadata_download_token"/>
150     </td>
151   </tr>
152   </tbody>
153   </table>
154 </form>
155 </div>
157 <script>
158 $(document).ready(function() {
160     var lo = new CXGN.List();
162     $('#accession_list').html(lo.listSelect('accession_list', [ 'accessions' ], 'select', undefined, undefined));
163     $('#trial_list').html(lo.listSelect('trial_list', [ 'trials' ], 'select', undefined, undefined ));
164     $('#trait_list').html(lo.listSelect('trait_list', [ 'traits' ], 'select', undefined, undefined  ));
165     $('#trial_metadata_list').html(lo.listSelect('trial_metadata_list', ['trials'], 'select', undefined, undefined));
167     get_select_box('datasets', 'phenotype_download_dataset_list');
169     $('#metadata').click(function() { 
170       var trial_list_id = $('#trial_metadata_list_list_select').val();
171       var trial_validation = 1;
172       if (trial_list_id) { trial_validation = lo.validate(trial_list_id, 'trials', true); }
174       var problem_lists = new Array();
175       if (trial_validation != 1) {
176         problem_lists.push('trials');
177       }
179       if (problem_lists.length > 0) {
180           alert("The following lists did not pass validation: "+problem_lists.join(", ")+". Please correct the list(s) and try again");
181                 return;
182       }
184       var ladda = Ladda.create(this);
185       ladda.start();
186       var token = new Date().getTime(); //use the current timestamp as the token name and value
187       manage_dl_with_cookie(token, ladda);
188       jQuery('#metadata_download_token').val(token);
189       jQuery('#download_metadata_form').submit();
191     });
193     $('#phenotype').click(function() {
195       var accession_list_id = $('#accession_list_list_select').val();
196       var trial_list_id = $('#trial_list_list_select').val();
197       var trait_list_id = $('#trait_list_list_select').val();
199       var accession_validation = 1;
200       if (accession_list_id) { accession_validation = lo.validate(accession_list_id, 'accessions', true); }
202       var trial_validation = 1;
203       if (trial_list_id) { trial_validation = lo.validate(trial_list_id, 'trials', true); }
205       var trait_validation = 1;
206       if (trait_list_id) { trait_validation = lo.validate(trait_list_id, 'traits', true); }
208       var problem_lists = new Array();
210       if (accession_validation != 1) {
211         problem_lists.push('accessions');
212       }
213       if (trial_validation != 1) {
214         problem_lists.push('trials');
215       }
216       if (trait_validation != 1) {
217         problem_lists.push('trials');
218       }
220       if (problem_lists.length > 0) {
221          alert("The following lists did not pass validation: "+problem_lists.join(", ")+". Please correct the list(s) and try again");
222          return;
223       }
225       var ladda = Ladda.create(this);
226       ladda.start();
227       var token = new Date().getTime(); //use the current timestamp as the token name and value
228       manage_dl_with_cookie(token, ladda);
229       jQuery('#phenotype_download_token').val(token);
230       jQuery('#download_form').submit();
232         });
236 </script>
239 <!-- start of code for pedigree download -->
241 <div class="well well-sm">
242 <form id="download_pedigree" action="/breeders/download_pedigree_action" method="POST">
243 <table class="table"  cellpadding="10">
244   <thead>
245   <tr><td colspan="2"><h4>Download Pedigree </h4><p>Select parameter:</p></tr>
246   <tr>
247     <th>
248       Accessions
249     </th>
250     <th>
251       Format
252     </th>
253     <th>
254       Action
255     </th>
256   </tr>
257   </thead>
258   <tbody>
259   <tr>
260     <td>
261       <div id="accession_list4">
262       </div>
263     </td>
264     <td>
265  <div class="radio">
266   <label><input type="radio" id="ped_format" name="ped_format" value="parents_only" checked>Direct parents only</label>
267  </div>
268  <div class="radio">
269    <label><input type="radio" id="ped_format" name="ped_format" value="full">Full pedigrees</label>
270  </div>
271      </td>
272     <td>
273       <button class="btn btn-primary" type="button" id="pedigree">Download</button>
274       <input type="hidden" id="pedigree_download_token" name="pedigree_download_token"/>
275     </td>
276   </tr>
277   </tbody>
278   </table>
279 </form>
280 </div>
283 <script>
284 $(document).ready(function() {
286     var lo = new CXGN.List();
288     $('#accession_list4').html(lo.listSelect('pedigree_accession_list', [ 'accessions' ], 'select', undefined, undefined));
290     $('#pedigree').click(function() {
292         var accession_list_id = $('#pedigree_accession_list_list_select').val();
293         if (!accession_list_id) {
294             alert("You need to select an accession list!");
295             return;
296         }
298         var accession_validation = 1;
299         if (accession_list_id) {
300             accession_validation = lo.validate(accession_list_id, 'accessions', true);
302         }
304         if (accession_validation != 1) {
305             alert("The accession list did not pass validation. Please correct the list and try again");
306             return;
307         }
309         var ladda = Ladda.create(this);
310         ladda.start();
311         var token = new Date().getTime(); //use the current timestamp as the token name and value
312         manage_dl_with_cookie(token, ladda);
313         jQuery('#pedigree_download_token').val(token);
314         jQuery('#download_pedigree').submit();
316     });
319 </script>
321 <!-- end of code for pedigree download -->
324 <div class="well well-sm">
325 <form id="download_gbs" action="/breeders/download_gbs_action" method="POST">
326 <table class="table"  cellpadding="10">
327   <thead>
328   <tr><td colspan="2"><h4>Download GBS Genotype </h4><p>Select parameter:</p></tr>
329   <tr>
330     <th>
331       Accessions
332     </th>
333     <th>
334       Genotyping Protocol
335     </th>
336     <th>
337       Action
338     </th>
339   </tr>
340   </thead>
341   <tbody>
342   <tr>
343     <td>
344       <div id="accession_list2">
345       </div>
346     </td>
347     <td>
348       <div id="protocol_list">
349       </div>
350     </td>
351     <td>
352       <button class="btn btn-primary" type="button" id="genotype">Download</button>
353       <input type="hidden" id="gbs_download_token" name="gbs_download_token"/>
354     </td>
355   </tr>
356   </tbody>
357   </table>
358 </form>
359 </div>
361 <script>
362   $(document).ready(function() {
364       var lo = new CXGN.List();
366       $('#accession_list2').html(lo.listSelect('genotype_accession_list', [ 'accessions' ], 'select', undefined, undefined));
367       get_select_box("genotyping_protocol", "protocol_list");
369       $('#genotype').click(function() {
371       var accession_list_id = $('#genotype_accession_list_list_select').val();
372       var protocol_list_id = $('#protocol_list').val();
374       var accession_validation = 1;
375       if (accession_list_id) {
376         accession_validation = lo.validate(accession_list_id, 'accessions', true);
377       }
379       if (!( accession_list_id || protocol_list_id) ) {
380         alert("You need to select a list of accessions and a protocol !");
381         return;
382       }
384       var problem_lists = new Array();
386       if (accession_validation != 1) {
387         problem_lists.push('accessions');
388       }
391       console.log(problem_lists);
393       if (problem_lists.length > 0) {
394         alert("The following lists did not pass validation: "+problem_lists.join(", ")+". Please correct the list(s) and try again");
395         return;
396       }
398       var ladda = Ladda.create(this);
399       ladda.start();
400       var token = new Date().getTime(); //use the current timestamp as the token name and value
401       manage_dl_with_cookie(token, ladda);
402       jQuery('#gbs_download_token').val(token);
403       jQuery('#download_gbs').submit();
405     });
407   });
408 </script>
410 <div class="well well-sm">
411 <form id="gbs_qc" action="/breeders/gbs_qc_action" method="POST">
412 <table class="table" cellpadding="10">
413   <thead>
414   <tr><td colspan="3"><h4>GBS Genotype QC</h4><p>Select parameter:</p></tr>
415   <tr>
416     <th>
417       Trials
418     </th>
419     <th>
420       Accessions
421     </th>
422     <th>
423       Genotyping Protocol
424     </th>
425     <th>
426       Action
427     </th>
428   </tr>
429   </thead>
430   <tbody>
431   <tr>
432     <td>
433       <div id="trial_list3">
434       </div>
435     </td>
436     <td>
437       <div id="accession_list3">
438       </div>
439     </td>
440     <td>
441       <div id="protocol_list2">
442       </div>
443     </td>
444     <td>
445       <button class="btn btn-primary" type="button" id="genotype_qc">Download</button>
446       <input type="hidden" id="qc_download_token" name="qc_download_token"/>
447     </td>
448   </tr>
449   </tbody>
450   </table>
451 </form>
452 </div>
454 </div>
456 <script>
457   $(document).ready(function() {
459       var lo = new CXGN.List();
461       $('#accession_list3').html(lo.listSelect('genotype_qc_accession_list', [ 'accessions' ], 'select', undefined, undefined));
462       $('#trial_list3').html(lo.listSelect('genotype_trial_list', [ 'trials' ], 'select', undefined, undefined ));
463       get_select_box("genotyping_protocol", "protocol_list2", {'id':'protocol_list2_select', 'name':'protocol_list2_select'});
465       $('#genotype_qc').click(function() {
467         $('#working').dialog( {
468                 height: 100,
469                 width:  300,
470                 modal: true,
471                 autoOpen: false,
472                 closeOnEscape: true,
473                 draggable: true,
474                 resizable: true,
475                 open: function() { $(this).closest('.ui-dialog').find('.ui-dialog-titlebar-close').hide(); },
476                 title: 'Downloading genotype...'
477                 });
479       var accession_list_id = $('#genotype_qc_accession_list_list_select').val();
480       var trial_list_id = $('#genotype_trial_list_list_select').val();
482       var accession_validation = lo.validate(accession_list_id, 'accessions', true);
483       var trial_validation = lo.validate(trial_list_id, 'trials', true);
485       if (! (accession_list_id || trial_list_id) ) {
486         alert("You need to select an accession or a trail !");
487         return;
488       }
490       var problem_lists = new Array();
492       if (accession_validation != 1) {
493         problem_lists.push('accessions');
494       }
496       if (trial_validation != 1) {
497         problem_lists.push('trials');
498       }
501       //alert("problem_lists is " + problem_lists);
503       console.log(problem_lists);
505       if (problem_lists.length > 0) {
506         alert("The following lists did not pass validation: "+problem_lists.join(", ")+". Please correct the list(s) and try again");
507         return;
508       }
510       var ladda = Ladda.create(this);
511       ladda.start();
512       var token = new Date().getTime(); //use the current timestamp as the token name and value
513       manage_dl_with_cookie(token, ladda);
514       jQuery('#qc_download_token').val(token);
515       jQuery('#gbs_qc').submit();
517     });
519   });
520 </script>