fix test with new description field.
[sgn.git] / mason / about / audit.mas
blob66462e4d8d74c74216573e1d31388dc97225bb91
1 <%doc>
2 =head1 NAME
4 /about/audit.mas- display organism search results and search form
6 =head1 ARGS
8 <!--
10 =head2 results
12 optional L<DBIx::Class::ResultSet> object for the set of results to
13 display.  if not set or not passed, only the search form will be
14 displayed.
16 =head2 form 
18 required L<HTML::FormFu> form object for the search form.  will call
19 C<$form->render> on this.
21 =head2 pagination_link_maker
23 subroutine reference that takes a single integer page number for the
24 results and returns the appropriate URL for going to that page of results
26 --> 
28 =cut
30 </%doc>
32 <%args>
33 </%args>
36 <& /page/page_title.mas, title=>"Database Audit Tables" &>
38 <div class="container-fluid">
40 <style>
41 </style>
43 </div>
46 <!--here is where I pasted in the drop down and search code -->
48 <& /util/import_javascript.mas, classes => [ 'jquery', 'jquery.dataTables' ] &>
50 <div class="well well-sm">
51     <div class="panel panel-default">
52         <div class="panel-body">
53           <div class="col-sm-1">
54             </div>
55             <div class="row">
56                 <div class="col-sm-11">
57                    <div class="form-horizontal">
58                         <div class="form-group">
59                             <label class="control-label col-sm-4">Select a database table to see audits:</label>
60                             <div class="col-sm-8" >
61                                 <div class="input-group">
62                                     <select class="form-control" id="db_table_list_select">
63                                     </select>
64                                     <div class="input-group-btn">
65                                         <button class="btn btn-info" id="search_audit_button"><i class="glyphicon glyphicon-search"></i> View audits </button>
66                                     </div>
67                                 </div>
68                             </div>
69                         </div>
70                    </div>
71                </div>
72             </div>
73         </div>
74     </div>
75     <div class="panel panel-default">
76         <div class="panel-body">
77             <&| /page/info_section.mas, title=>"Audit table", is_subsection => 1, collapsible=>1, collapsed=>0 &>
78                 <table class="table table-hover table-bordered" id="audit_results">
79                 </table>
80             </&>
81         </div>
82     </div>
83 </div>
85 <script>
89 jQuery(document).ready(function(){
91     jQuery.ajax({
92         url: '/ajax/audit/retrieve_table_names',
93         success: function(response){
94             var json_names = JSON.parse(response.result1);
95             for (var i=0; i<json_names.length; i++){
96                 var opt = json_names[i];
97                 var displayname = opt.replace("_audit","");
98                 jQuery("select#db_table_list_select").append(jQuery("<option>")
99                     .val(opt)
100                     .html(displayname)
101                     );
102                 }
103         }
104     });
105     jQuery("#search_audit_button").click(function(){
106         if ( jQuery.fn.dataTable.isDataTable( '#audit_results' ) ) {
107             table = jQuery('#audit_results').DataTable();
108             table.destroy();
109         }
110         var db_table_list_id = jQuery('#db_table_list_select').find(":selected").val();
111         jQuery.ajax({
112             url: '/ajax/audit/retrieve_results',
113             data: {'db_table_list_id':db_table_list_id},
114             timeout: 300000,
115             success: function(response){
117             var all_audits = response.result;
118             
120         var json_object = JSON.parse(all_audits);
121         
122             jQuery('#audit_results').DataTable({
123                 data: json_object,
124                 columns: [
125                     { title: 'Timestamp' },
126                     { title: 'Operation' },
127                     { title: 'Username' },
128                     { title: 'Logged in User' },
129                     { title: 'Before' },
130                     { title: 'After' },
131                     { title: 'Transaction Code'},
132                     { title: 'Primary Key'},
133                     { title: 'Is Undo'},
134                 ],
135                 "rowCallback" : function (row, data, index){
136                     if(data[1] == "INSERT"){
137                         jQuery('td', row).css('background-color', 'HoneyDew');
138                     }
139                     if(data[1] == "UPDATE"){
140                         jQuery('td',row).css('background-color', 'LightCyan');
141                     }
142                     if(data[1] == "DELETE"){
143                         jQuery('td',row).css('background-color', 'LightSalmon');
144                     }
146                 }
147                 
148             });
150             
151             }
152         });
153         
154         });
157 </script>
160 <%init>
161   use Number::Format;
162   use CXGN::Page::FormattingHelpers qw/ columnar_table_html /;
164 </%init>