CrashTest.pl
changeset 29 006e82a1bcd0
parent 24 b69b7aa98a1d
child 32 3e776f1b21d4
equal deleted inserted replaced
28:0df70b8735e3 29:006e82a1bcd0
    20 use Mojo::UserAgent;
    20 use Mojo::UserAgent;
    21 use lib 'lib';
    21 use lib 'lib';
    22 
    22 
    23 my @valid_params = qw/Add-ons Distributor ProductName ReleaseChannel StartupTime UserID Version BuildID CrashTime Comments/;
    23 my @valid_params = qw/Add-ons Distributor ProductName ReleaseChannel StartupTime UserID Version BuildID CrashTime Comments/;
    24 my $config = plugin 'Config';
    24 my $config = plugin 'Config';
       
    25 
       
    26 plugin 'TagHelpers::BootstrapPagination';
    25 
    27 
    26 app->attr(storage => sub {
    28 app->attr(storage => sub {
    27     my $self = shift;
    29     my $self = shift;
    28     eval "require $config->{Storage}->{Type}" or die "Loading module failed $@";
    30     eval "require $config->{Storage}->{Type}" or die "Loading module failed $@";
    29     return $config->{Storage}->{Type}->new($config->{Storage});
    31     return $config->{Storage}->{Type}->new($config->{Storage});
    76     return b($self->t(span => (title => $signature, class => "shortened-signature") => $short_signature));
    78     return b($self->t(span => (title => $signature, class => "shortened-signature") => $short_signature));
    77 };
    79 };
    78 
    80 
    79 get '/' => sub {
    81 get '/' => sub {
    80     my $self = shift;
    82     my $self = shift;
    81     $self->stash(files => $self->app->storage->index());
    83     my $page = 1;
       
    84     $self->validation->required('page')->like(qr/^[0-9]+$/);
       
    85     $page = scalar $self->validation->param("page") if $self->validation->is_valid('page');
       
    86 
       
    87     my $result = $self->app->storage->index($page, 20);
       
    88 
       
    89     $self->stash(files => $result->{crashs});
       
    90     $self->stash(pager => $result->{pager});
    82     $self->render('index');
    91     $self->render('index');
    83 } => 'index';
    92 } => 'index';
    84 
    93 
    85 get '/report/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ] => sub {
    94 get '/report/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ] => sub {
    86     my $self = shift;
    95     my $self = shift;