Merge pull request #5243 from solgenomics/topic/observations_upload_catch_error
[sgn.git] / mason / breeders_toolbox / drone_imagery / raw_image_section.mas
blob8dc26a41b61ff5a2f2babca321687a87ac455380
1 <%args>
2 </%args>
4 <table class="table table-bordered table-hover" id="raw_drone_image_datatable">
5     <thead>
6         <tr>
7             <th>Field Trials -> Imaging Events</th>
8         </tr>
9     </thead>
10 </table>
12 <script>
13 jQuery(document).ready(function(){
15     var raw_drone_imagery_table = jQuery('#raw_drone_image_datatable').DataTable( {
16         'ajax': '/api/drone_imagery/raw_drone_imagery_top',
17         'paging': false
18     });
19     
20     raw_drone_imagery_table.on( 'draw', function () {
21         jQuery.ajax({
22             url : '/api/drone_imagery/raw_drone_imagery_plot_image_count',
23             success: function(response){
24                 //console.log(response);
25                 jQuery('div[name="drone_run_band_total_plot_image_div"]').html('<div class="panel-group"><div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" >No Plot Images Saved</a></h4></div></div></div>');
26                 for (drone_run_project_id in response.data) {
27                     var html = '<div class="panel-group" id="drone_run_plot_polygons_table_accordion_'+drone_run_project_id+'" ><div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#drone_run_plot_polygons_table_accordion_'+drone_run_project_id+'" href="#drone_run_plot_polygons_table_accordion_one_'+drone_run_project_id+'" >View Plot Images Summary ('+response.data[drone_run_project_id]['total_plot_image_count']+')</a></h4></div><div id="drone_run_plot_polygons_table_accordion_one_'+drone_run_project_id+'" class="panel-collapse collapse"><div class="panel-body">';
28                     delete response.data[drone_run_project_id]['total_plot_image_count'];
29                     html = html + "<table class='table table-bordered table-sm'><thead><tr><th>Plot Image Type</th><th>Count</th></tr></thead><tbody>";
30                     for (plot_image_type in response.data[drone_run_project_id]) {
31                         html = html + "<tr><td>" + plot_image_type + "</td><td>" + response.data[drone_run_project_id][plot_image_type] + "</td></tr>";
32                     }
33                     html = html + "</tbody></table>";
34                     html = html + '</div></div></div></div>';
35                     jQuery('#drone_run_band_total_plot_image_count_div_'+drone_run_project_id).html(html);
36                 }
37             },
38             error: function(response){
39                 //alert('Error getting plot image count!')
40             }
41         });
42     });
44     jQuery(document).on('click', 'span[name="drone_image_remove"]', function(){
45         var image_id = jQuery(this).data('image_id');
46         if (confirm("Are you sure you want to remove this image?")) {
47             jQuery.ajax({
48                 url : '/api/drone_imagery/remove_image?image_id='+image_id,
49                 beforeSend: function() {
50                     jQuery("#working_modal").modal("show");
51                 },
52                 success: function(response){
53                     console.log(response);
54                     jQuery("#working_modal").modal("hide");
55                     location.reload();
56                 },
57                 error: function(response){
58                     jQuery("#working_modal").modal("hide");
59                     alert('Error removing drone image!')
60                 }
61             });
62         }
63     });
65 });
67 function manageDroneImageryDroneRunBandDisplay(project_drone_run_band_id){
68     jQuery.ajax({
69         url : '/api/drone_imagery/raw_drone_imagery_drone_run_band?drone_run_band_project_id='+project_drone_run_band_id,
70         beforeSend: function() {
71             jQuery("#working_modal").modal("show");
72         },
73         success: function(response){
74             console.log(response);
75             jQuery('#drone_run_band_accordian_drone_run_band_div_'+project_drone_run_band_id).html(response.data[0]);
76             jQuery("#working_modal").modal("hide");
77         },
78         error: function(response){
79             jQuery("#working_modal").modal("hide");
80             alert('Error getting drone run band summary images!');
81         }
82     });
85 </script>