Minimale Anzahl Parameter an make_sorted() übergeben
[kivitendo-erp.git] / SL / Controller / BackgroundJobHistory.pm
1 package SL::Controller::BackgroundJobHistory;
2
3 use strict;
4
5 use parent qw(SL::Controller::Base);
6
7 use SL::Controller::Helper::GetModels;
8 use SL::Controller::Helper::Sorted;
9 use SL::DB::BackgroundJobHistory;
10 use SL::Helper::Flash;
11 use SL::System::TaskServer;
12
13 use Rose::Object::MakeMethods::Generic
14 (
15   scalar                  => [ qw(history) ],
16   'scalar --get_set_init' => [ qw(task_server) ],
17 );
18
19 __PACKAGE__->run_before('check_auth');
20 __PACKAGE__->run_before('add_stylesheet');
21 __PACKAGE__->run_before('check_task_server');
22
23 __PACKAGE__->make_sorted(
24   ONLY         => [ qw(list) ],
25
26   package_name => $::locale->text('Package name'),
27   run_at       => $::locale->text('Run at'),
28   status       => $::locale->text('Execution status'),
29   result       => $::locale->text('Result'),
30   error        => $::locale->text('Error'),
31 );
32
33 #
34 # actions
35 #
36
37 sub action_list {
38   my ($self) = @_;
39
40   $self->render('background_job_history/list',
41                 title   => $::locale->text('Background job history'),
42                 ENTRIES => $self->get_models);
43 }
44
45 sub action_show {
46   my ($self) = @_;
47
48   my $back_to = $::form->{back_to} || $self->url_for(action => 'list');
49
50   $self->history(SL::DB::BackgroundJobHistory->new(id => $::form->{id})->load);
51   $self->render('background_job_history/show',
52                 title   => $::locale->text('View background job execution result'),
53                 back_to => $back_to);
54 }
55
56 #
57 # filters
58 #
59
60 sub check_auth {
61   $::auth->assert('admin');
62 }
63
64 #
65 # helpers
66 #
67
68 sub init_task_server {
69   return SL::System::TaskServer->new;
70 }
71
72 sub check_task_server {
73   my ($self) = @_;
74   flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running;
75 }
76
77 sub add_stylesheet {
78   $::form->use_stylesheet('lx-office-erp/background_jobs.css');
79 }
80
81 1;