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>
18 <option value="https://www.crop-diversity.org/mgis">crop-diversity.org</option>
23 <div id="brapi_phenotyping_handhelds_layout_div" class="well">
25 <h3>Get Trial Layout(s)</h3>
27 <select name="brapi_phenotyping_handhelds_layout_format" id="brapi_phenotyping_handhelds_layout_format" class="form-control" />
28 <option value="json">JSON</option>
29 <option value="csv">CSV</option>
30 <option value="tsv">TSV</option>
31 <option value="xls">Excel (xls)</option>
34 <div id="brapi_phenotyping_handhelds_studies_div">
37 <div id="brapi_phenotyping_handhelds_layout_results_div">
42 <div id="brapi_phenotyping_handhelds_traits_div" class="well">
44 <h3>Get Observation Variables</h3>
46 <div id="brapi_phenotyping_handhelds_traits_div">
49 <div id="brapi_phenotyping_handhelds_traits_results_div">
54 <div id="brapi_phenotyping_handhelds_upload_div" class="well">
56 <h3>Upload Phenotypes Using POST brapi/v1/studies/studyId/observationunits?observationLevel=observationLevel</h3>
58 <h4>Not yet implemented</h4>
60 <h3>Upload Phenotypes Using POST brapi/v1/studies/studyId/table</h3>
62 <h4>Not yet implemented</h4>
68 var selected_results = [];
69 var studies_return_url;
70 var traits_return_url;
72 jQuery(document).ready(function() {
74 brapi_phenotyping_handhelds_get_studies(jQuery('#brapi_phenotyping_handhelds_url_select').val());
75 brapi_phenotyping_handhelds_get_traits(jQuery('#brapi_phenotyping_handhelds_url_select').val());
77 jQuery('#brapi_phenotyping_handhelds_url_select').change(function(){
78 brapi_phenotyping_handhelds_get_studies(jQuery('#brapi_phenotyping_handhelds_url_select').val());
79 brapi_phenotyping_handhelds_get_traits(jQuery('#brapi_phenotyping_handhelds_url_select').val());
82 jQuery(document).on('click', '#brapi_table_select_submit_brapi_phenotyping_handhelds_studies_div', function(){
83 jQuery.each(jQuery('input[name="brapi_table_select_'+studies_return_url+'"]:checked'), function(){
84 if (jQuery.inArray(jQuery(this).val(), selected_results) == -1){
85 selected_results.push(jQuery(this).val());
88 console.log(selected_results);
89 var format = jQuery('#brapi_phenotyping_handhelds_layout_format').val();
90 var url = jQuery('#brapi_phenotyping_handhelds_url_select').val();
92 for (var i=0; i<selected_results.length; i++){
93 var return_url = url+'/brapi/v1/studies/'+selected_results[i]+'/layout?format='+format;
96 'beforeSend': function(){
97 jQuery('#working_modal').modal('show');
99 'success': function(response) {
100 //console.log(response);
101 if (response.metadata.datafiles.length > 0){
102 var html = "<h4>Download Layout File(s) From Here: <br/>";
103 for (var j=0; j<response.metadata.datafiles.length; j++){
104 html = html + "<a href='"+response.metadata.datafiles[j]+"'>"+response.metadata.datafiles[j]+"</a><br/>";
106 jQuery('#brapi_phenotyping_handhelds_layout_results_div').html(html);
108 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', []);
110 jQuery('#working_modal').modal('hide');
112 error: function(response) {
113 jQuery('#working_modal').modal('hide');
114 alert('An error occurred');
122 function brapi_phenotyping_handhelds_get_studies(url) {
123 studies_return_url = url+'/brapi/v1/studies-search';
125 'url': url+'/brapi/v1/studies-search',
126 'beforeSend': function(){
127 jQuery('#working_modal').modal('show');
129 'success': function(response) {
130 //console.log(response);
131 brapi_create_paginated_table(response.result.data, response.metadata.pagination, 'brapi_phenotyping_handhelds_studies_div', studies_return_url, undefined, {}, ['studyName','trialName','programName','locationName'], 'studyDbId', []);
132 jQuery('#working_modal').modal('hide');
134 error: function(response) {
135 jQuery('#working_modal').modal('hide');
136 alert('An error occurred');
141 function brapi_phenotyping_handhelds_get_traits(url) {
142 traits_return_url = url+'/brapi/v1/variables';
144 'url': url+'/brapi/v1/variables',
145 'beforeSend': function(){
146 jQuery('#working_modal').modal('show');
148 'success': function(response) {
149 //console.log(response);
150 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', []);
151 jQuery('#working_modal').modal('hide');
153 error: function(response) {
154 jQuery('#working_modal').modal('hide');
155 alert('An error occurred');