Merge pull request #4106 from solgenomics/topic/wishlist
[sgn.git] / mason / brapiclient / studies_observations.mas
blobaec5d916cf8b7abd0eb7dc0db93f8d72eada7245
1 <%args>
2 </%args>
4 <div id="brapi_home_study_observations_div">
6     <h4>Study Observations</h4>
7     <input name="brapi_home_studyobservationsdbid" id="brapi_home_studyobservationsdbid" class="form-control" type="text" placeholder="StudyDbId e.g. 139" value="139"/>
8     <input name="brapi_home_studyobservationdbid1" id="brapi_home_studyobservationdbid1" class="form-control" type="text" placeholder="ObservationDbId e.g. 70741" value="70741"/>
9     <input name="brapi_home_studyobservationdbid2" id="brapi_home_studyobservationdbid2" class="form-control" type="text" placeholder="ObservationDbId e.g. 70666" value="70666"/>
10     <select name="brapi_home_studyobservations_level" id="brapi_home_studyobservations_level" class="form-control" />
11         <option value="all">All</option>
12         <option value="plot">Plot</option>
13         <option value="plant">Plant</option>
14     </select>
15     <button class="btn btn-primary" name="brapi_home_studyobservations_submit" id="brapi_home_studyobservations_submit">Get Observations</button>
16     <br/><br/>
17     <div id="brapi_studyobservations_data_result_div">
18     </div>
20 </div>
22 <script>
24 jQuery(document).ready(function() {
25     jQuery("#brapi_home_studyobservations_submit").click(function() {
26         jQuery.ajax( {
27           'url': jQuery('#brapi_home_url_select').val()+'/brapi/v1/studies/'+jQuery('#brapi_home_studyobservationsdbid').val()+'/observations?observationVariableDbId='+jQuery('#brapi_home_studyobservationdbid1').val()+'&observationVariableDbId='+jQuery('#brapi_home_studyobservationdbid2').val()+'&observationLevel='+jQuery('#brapi_home_studyobservations_level').val(),
28           'method': 'GET',
29           'beforeSend': function() {
30             jQuery('#working_modal').modal('show');
31           },
32           'success': function(response) {
33             jQuery('#working_modal').modal('hide');
34             console.log(response);
35             brapi_create_paginated_table(response.result.data, response.metadata.pagination, 'brapi_studyobservations_data_result_div', jQuery('#brapi_home_url_select').val()+'/brapi/v1/studies/'+jQuery('#brapi_home_studyobservationsdbid').val()+'/observations?observationVariableDbId='+jQuery('#brapi_home_studyobservationdbid1').val()+'&observationVariableDbId='+jQuery('#brapi_home_studyobservationdbid2').val()+'&observationLevel='+jQuery('#brapi_home_studyobservations_level').val(), undefined);
37           },
38           error: function(response) {
39             jQuery('#working_modal').modal('hide');
40             alert('An error occurred');
41           }
42         });
43     });
44 });
46 </script>