package SGN::View::Mason::Commands;
use strict;
use vars qw($m $c);
HTML::Mason::Component::FileBased->new(
'code' => sub {
use utf8; local $SGN::View::Mason::Commands::m = $HTML::Mason::Commands::m;
HTML::Mason::Exception::Params->throw
    ( error =>
      "Odd number of parameters passed to component expecting name/value pairs"
    ) if @_ % 2;
my ( $trial_id, $project_id );
{
    my %pos;
    for ( my $x = 0; $x < @_; $x += 2 )
    {
        $pos{ $_[$x] } = $x + 1;
    }

    foreach my $arg ( qw( trial_id project_id ) )
    {
        HTML::Mason::Exception::Params->throw
            ( error => "no value sent for required parameter '$arg'" )
                unless exists $pos{$arg};
    }
#line 2 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
    $trial_id = $_[ $pos{'trial_id'} ];
#line 3 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
    $project_id = $_[ $pos{'project_id'} ];
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 5 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
$m->print( '
' );
#line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
$m->comp(   '/util/import_javascript.mas', classes => [ 'jquery', 'jquery.dataTables' ]   
); #line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
$m->print( '

' );
#line 8 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
$m->comp(   '/util/import_css.mas', paths => ['/documents/inc/datatables/jquery.dataTables.css']   
); #line 8 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
$m->print( '

<table class="table table-hover table-bordered" id="audit_results">

</table>

<script> 
    jQuery(document).ready(function () {
      var trial_id = "' );
#line 16 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
$m->print(  $trial_id  );
#line 16 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_audit.mas"
$m->print( '";
      jQuery.ajax({
        url: \'/ajax/audit/retrieve_trial_audits\',
        data: {\'trial_id\':trial_id},
        timeout: 300000,
          success: function(response){
            var json_object = JSON.parse(response.match_project);
            var datastring;
            for (var row = 0; row < json_object.length; row++){
                for (var column = 4; column <= 5; column++){
                    datastring = json_object[row][column];
                    if(datastring != null){
                        for(var character = 0; character < datastring.length; character++){
                            if(datastring[character] == \'{\' || datastring[character] == \'}\' || datastring[character] == \'"\' || datastring[character] == \',\'){
                                if(datastring[character] == \',\'){
                                    datastring = datastring.replace(datastring[character],\'\\n\');
                                }else{
                                    datastring = datastring.replace(datastring[character],\'\');
                                    character --;
                                }
                            }
                        }
                    }
                    json_object[row][column] = datastring;
                }
            }
            jQuery(\'#audit_results\').DataTable({
              data: json_object,
              columns: [
                  { title: \'Timestamp\' },
                    { title: \'Operation\' },
                    { title: \'Username\' },
                    { title: \'Logged in User\' },
                    { title: \'Before\' },
                    { title: \'After\' },
                    { title: \'Transaction Code\'},
                    { title: \'Primary Key\'},
                    { title: \'Is Undo\'},
              ],
              "rowCallback" : function (row, data, index){
                    if(data[1] == "INSERT"){
                        jQuery(\'td\', row).css(\'background-color\', \'HoneyDew\');
                    }
                    if(data[1] == "UPDATE"){
                        jQuery(\'td\',row).css(\'background-color\', \'LightCyan\');
                    }
                    if(data[1] == "DELETE"){
                        jQuery(\'td\',row).css(\'background-color\', \'LightSalmon\');
                    }

                }
                
          });

          },
        
      });
    });

</script>
' );
;return;
},
'declared_args' => {
  '$project_id' => { default => undef },
  '$trial_id' => { default => undef }
},
'load_time' => 1763102299,

)
;