Changed trials-in-common page to use a single database query to get analyses. Changed...
[sgn.git] / mason / dbstats / recent_activity.mas
blobb6eaa178a107eec0875d8e4056e2e936a5bad148
2 <%args>
4 </%args>
6 <& /util/import_javascript.mas, entries => [ 'recent_activity' ], classes => [ 'jquery' ]  &>
8 <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
9 <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
11 <& /page/page_title.mas, title => 'Recent activity' &>
13 Start Date: <input type="text" id="dbstats_start_date" title="dbstats_start_date"  />
14 <td>&nbsp;</td></td><td>
16 End Date: <input type="text" id="dbstats_end_date" title="dbstats_end_date"  />
17 </td><td>
18 &nbsp;
19 </td><td>
20 <input type="checkbox" id="include_dateless_items" checked="1" > include items without a date</input>
21 </td><td>
22 &nbsp;
23 </td><td>
24 <button id="update_dbstats_by_date">Update</button>
25 <br /><br />
26 <div id="dbstats_message"></div>
28 <h3>Trials</h3>
29 <div id="recent_activity_trials_div">
30   <table id="recent_activity_trials" width="600">
31   <thead>
32     <tr><th width="200">Breeding Program</th><th width="200">Trials</th></tr>
33     </thead>
34   </table>
35 </div>
37 <h3>Phenotypes</h3>
38 <div id="recent_activity_phenotypes_div">
39   <table id="recent_activity_phenotypes" width="600">
40   <thead>
41     <tr><th width="200">Breeding Program</th><th width="200">Phenotypes</th></tr>
42     </thead>
43   </table>
44 </div>
46 <h3>Accessions</h3>
47 <div id="recent_activity_accessions_div">
48   <table id="recent_activity_accessions" width="600">
49   <thead>
50     <tr><th width="200">Breeding Program</th><th width="200">Accessions</th></tr>
51     </thead>
52   </table>
53 </div>
55 <h3>Plots</h3>
56 <div id="recent_activity_plots_div">
57   <table id="recent_activity_plots" width="600">
58   <thead>
59     <tr><th width="200">Breeding Program</th><th width="200">Plots</th></tr>
60     </thead>
61   </table>
62 </div>
64 <script>
66     jQuery(document).ready( function() {
67         update_dbstats_tables();
68     });
70     jQuery('#update_dbstats_by_date').click( function() {
71         update_dbstats_tables();
72     });
75 function update_dbstats_tables(start_date, end_date, include_dateless_items) { 
76     var start_date = jQuery('#dbstats_start_date').val();
77     var end_date = jQuery('#dbstats_end_date').val();
78     var include_dateless_items = jQuery('#include_dateless_items').prop('checked');
79     
80     var html = "Showing database items generated from date: "+start_date+" to date: "+end_date;
81     if (include_dateless_items === true) { html += '. Including data items that do not have an associated date.'; }
82     jQuery('#dbstats_message').html(html);
84     jQuery('#recent_activity_trials').dataTable( {
85         ajax : '/ajax/dbstats/trials_by_breeding_program?start_date='+start_date+'&end_date='+end_date+'&include_dateless_items='+include_dateless_items,
86         destroy: true,
87         searching: false,
88         paginate: false,
89         info:false
90         
91     }
92     );
94     jQuery('#recent_activity_phenotypes').dataTable({
95         ajax : '/ajax/dbstats/phenotypes_by_breeding_program?start_date='+start_date+'&end_date='+end_date+'&include_dateless_items='+include_dateless_items,
96         destroy: true,
97         searching: false,
98         paginate: false,
99         info: false,
100     });
102     jQuery('#recent_activity_accessions').dataTable({
103         ajax : '/ajax/dbstats/accessions_by_breeding_program?start_date='+start_date+'&end_date='+end_date+'&include_dateless_items='+include_dateless_items,
104         destroy: true,
105         searching: false,
106         paginate: false,
107         info: false
108         
109     }
110         
111     );
114     jQuery('#recent_activity_plots').dataTable({
115         ajax : '/ajax/dbstats/plots_by_breeding_program?start_date='+start_date+'&end_date='+end_date+'&include_dateless_items='+include_dateless_items,
116         destroy: true,
117         searching: false,
118         paginate: false,
119         info: false
120     }
121         
122     );
126 jQuery('input[title="dbstats_start_date"]').daterangepicker(
127    {
128        "singleDatePicker": true,
129        "showDropdowns": true,
130        "autoUpdateInput": true,
131        "startDate": "1960-01-01",
132        "yearSelect" : true,
133        "minDate": "1960-01-01",
134        "maxDate": "2030-12-31",
135        locale: { 
136         format: 'YYYY-MM-DD'
137       }
138    },
142 var dbstats_end_date_element = jQuery("#dbstats_end_date");
144 jQuery('input[title="dbstats_end_date"]').daterangepicker(
145     {
146        "singleDatePicker": true,
147        "autoUpdateInput": true,
148        "minDate": "1960-01-01",
149        "maxYear" : "2030-12-31", 
150        "yearSelect" : true,
151        locale: { 
152            format: 'YYYY-MM-DD'
153        },
154        "showDropdowns": true,
155     },
160 </script>