4 <& /util/import_javascript.mas, classes => [ 'brapi.Table' ] &>
6 <& /page/page_title.mas, title=>"Phenotyping Handhelds" &>
8 <h4>Database Select</h4>
9 <select name="brapi_phenotyping_handhelds_url_select" id="brapi_phenotyping_handhelds_url_select" class="form-control" />
10 <option value="">local</option>
11 <option value="https://cassbase.org">cassbase.org</option>
12 <option value="https://cassavabase.org">cassavabase.org</option>
13 <option value="https://musabase.org">musabase.org</option>
14 <option value="https://sweetpotatobase.org">sweetpotatobase.org</option>
15 <option value="https://yambase.org">yambase.org</option>
16 <option value="https://fernbase.org">fernbase.org</option>
17 <option value="https://solgenomics.net">solgenomics.net</option>
22 <div id="brapi_phenotyping_handhelds_layout_div" class="well">
24 <h3>Get Trial Layout(s)</h3>
26 <select name="brapi_phenotyping_handhelds_layout_format" id="brapi_phenotyping_handhelds_layout_format" class="form-control" />
27 <option value="json">JSON</option>
28 <option value="csv">CSV</option>
29 <option value="tsv">TSV</option>
30 <option value="xls">Excel (xls)</option>
33 <div id="brapi_phenotyping_handhelds_studies_div">
36 <div id="brapi_phenotyping_handhelds_layout_results_div">
41 <div id="brapi_phenotyping_handhelds_traits_div" class="well">
43 <h3>Get Observation Variables</h3>
45 <div id="brapi_phenotyping_handhelds_traits_div">
48 <div id="brapi_phenotyping_handhelds_traits_results_div">
53 <div id="brapi_phenotyping_handhelds_upload_div" class="well">
55 <h3>Upload Phenotypes Using POST brapi/v1/studies/studyId/observationunits?observationLevel=observationLevel</h3>
57 <h4>Not yet implemented</h4>
59 <h3>Upload Phenotypes Using POST brapi/v1/studies/studyId/table</h3>
61 <h4>Not yet implemented</h4>
67 var selected_results = [];
68 var studies_return_url;
69 var traits_return_url;
71 jQuery(document).ready(function() {
73 brapi_phenotyping_handhelds_get_studies(jQuery('#brapi_phenotyping_handhelds_url_select').val());
74 brapi_phenotyping_handhelds_get_traits(jQuery('#brapi_phenotyping_handhelds_url_select').val());
76 jQuery('#brapi_phenotyping_handhelds_url_select').change(function(){
77 brapi_phenotyping_handhelds_get_studies(jQuery('#brapi_phenotyping_handhelds_url_select').val());
78 brapi_phenotyping_handhelds_get_traits(jQuery('#brapi_phenotyping_handhelds_url_select').val());
81 jQuery(document).on('click', '#brapi_table_select_submit_brapi_phenotyping_handhelds_studies_div', function(){
82 jQuery.each(jQuery('input[name="brapi_table_select_'+studies_return_url+'"]:checked'), function(){
83 if (jQuery.inArray(jQuery(this).val(), selected_results) == -1){
84 selected_results.push(jQuery(this).val());
87 console.log(selected_results);
88 var format = jQuery('#brapi_phenotyping_handhelds_layout_format').val();
89 var url = jQuery('#brapi_phenotyping_handhelds_url_select').val();
91 for (var i=0; i<selected_results.length; i++){
92 var return_url = url+'/brapi/v1/studies/'+selected_results[i]+'/layout?format='+format;
95 'beforeSend': function(){
96 jQuery('#working_modal').modal('show');
98 'success': function(response) {
99 //console.log(response);
100 if (response.metadata.datafiles.length > 0){
101 var html = "<h4>Download Layout File(s) From Here: <br/>";
102 for (var j=0; j<response.metadata.datafiles.length; j++){
103 html = html + "<a href='"+response.metadata.datafiles[j]+"'>"+response.metadata.datafiles[j]+"</a><br/>";
105 jQuery('#brapi_phenotyping_handhelds_layout_results_div').html(html);
107 brapi_create_paginated_table(response.result.data, response.metadata.pagination, 'brapi_phenotyping_handhelds_layout_results_div', return_url, undefined, {}, ['observationUnitName','replicate','germplasmName','blockNumber', 'X', 'Y', 'entryType', 'additionalInfo'], 'observationUnitName', []);
109 jQuery('#working_modal').modal('hide');
111 error: function(response) {
112 jQuery('#working_modal').modal('hide');
113 alert('An error occurred');
121 function brapi_phenotyping_handhelds_get_studies(url) {
122 studies_return_url = url+'/brapi/v1/studies-search';
124 'url': url+'/brapi/v1/studies-search',
125 'beforeSend': function(){
126 jQuery('#working_modal').modal('show');
128 'success': function(response) {
129 //console.log(response);
130 brapi_create_paginated_table(response.result.data, response.metadata.pagination, 'brapi_phenotyping_handhelds_studies_div', studies_return_url, undefined, {}, ['studyName','trialName','programName','locationName'], 'studyDbId', []);
131 jQuery('#working_modal').modal('hide');
133 error: function(response) {
134 jQuery('#working_modal').modal('hide');
135 alert('An error occurred');
140 function brapi_phenotyping_handhelds_get_traits(url) {
141 traits_return_url = url+'/brapi/v1/variables';
143 'url': url+'/brapi/v1/variables',
144 'beforeSend': function(){
145 jQuery('#working_modal').modal('show');
147 'success': function(response) {
148 //console.log(response);
149 brapi_create_paginated_table(response.result.data, response.metadata.pagination, 'brapi_phenotyping_handhelds_traits_div', traits_return_url, undefined, {}, ['observationVariableDbId','name','ontologyName','trait','method','scale'], 'name', []);
150 jQuery('#working_modal').modal('hide');
152 error: function(response) {
153 jQuery('#working_modal').modal('hide');
154 alert('An error occurred');