message dialog and js
[sgn.git] / mason / brapiclient / markerprofile_allelematrix.mas
blobdf4c56f343cee2e80c951bc93938725ab2402ca7
1 <%args>
2 </%args>
4 <& /util/import_javascript.mas, classes => [ 'brapi.Table' ] &>
6 <& /page/page_title.mas, title=>"Genotype Retrieval" &>
8 <h4>Database Select</h4>
9 <select name="brapi_home_genotypes_url_select" id="brapi_home_genotypes_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>
19 </select>
21 <div id="brapi_home_markerprofile_allelematrix_div">
23     <h4>MarkerProfile Details</h4>
24     <input name="brapi_home_markerprofiledbid1" id="brapi_home_markerprofiledbid1" class="form-control" type="text" placeholder="MarkerProfileDbId e.g. 1622" value="1622"/>
25     <input name="brapi_home_markerprofiledbid2" id="brapi_home_markerprofiledbid2" class="form-control" type="text" placeholder="MarkerProfileDbId e.g. 1623" value="1623"/>
26     <input name="brapi_home_markerprofiledbid3" id="brapi_home_markerprofiledbid3" class="form-control" type="text" placeholder="MarkerProfileDbId e.g. 1624" value="1624"/>
27     <input name="brapi_home_markerprofiledbid4" id="brapi_home_markerprofiledbid4" class="form-control" type="text" placeholder="MarkerProfileDbId e.g. 1625" value="1625"/>
28     <select name="brapi_home_allelematrix_format" id="brapi_home_allelematrix_format" class="form-control" />
29         <option value="json">JSON (transformed to HTML table)</option>
30         <option value="tsv">TSV</option>
31         <option value="csv">CSV</option>
32     </select>
33     <br/>
34     <button class="btn btn-primary" name="brapi_home_allelematrix_submit" id="brapi_home_allelematrix_submit">Get AlleleMatrix</button>
35     <br/><br/>
36     <div id="brapi_markerprofile_allelematrix_div">
37     </div>
39 </div>
41 <script>
43 jQuery(document).ready(function() {
44     jQuery("#brapi_home_allelematrix_submit").click(function() {
46         var return_url = jQuery('#brapi_home_genotypes_url_select').val()+'/brapi/v1/allelematrices-search?markerprofileDbId='+jQuery('#brapi_home_markerprofiledbid1').val()+'&markerprofileDbId='+jQuery('#brapi_home_markerprofiledbid2').val()+'&markerprofileDbId='+jQuery('#brapi_home_markerprofiledbid3').val()+'&markerprofileDbId='+jQuery('#brapi_home_markerprofiledbid4').val()+'&format='+jQuery('#brapi_home_allelematrix_format').val();
47         jQuery.ajax( {
48             'url': return_url,
49             'method': 'GET',
50             'success': function(response) {
51                 console.log(response);
52                 if (response.metadata.datafiles.length > 0){
53                     var html = "<h4>Download Study Phenotype File(s) From Here: <br/>";
54                     for (var j=0; j<response.metadata.datafiles.length; j++){
55                         html = html + "<a href='"+response.metadata.datafiles[j]+"'>"+response.metadata.datafiles[j]+"</a><br/>";
56                     }
57                     jQuery('#brapi_markerprofile_allelematrix_div').html(html);
58                 } else {
59                     var data = [];
60                     for (var i=0; i<response.result.data.length; i++) {
61                         data.push({'markerDbId':response.result.data[i][0], 'markerprofileDbId':response.result.data[i][1], 'alleleCall':response.result.data[i][2]});
62                     }
63                     brapi_create_paginated_table(data, response.metadata.pagination, 'brapi_markerprofile_allelematrix_div', return_url, undefined, {}, ['markerDbId','markerprofileDbId','alleleCall'], 'markerDbId', []);
64                 }
65             },
66             error: function(response) {
67                 alert('An error occurred');
68             }
69         });
71     });
72 });
74 </script>