From 23a8d2c0fb26571db4c5776d3572eb6b3356338b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 29 Aug 2012 16:06:06 +0200 Subject: [PATCH] =?utf8?q?Controller=20zur=20Verwaltung=20von=20Background?= =?utf8?q?JobHistory-Eintr=C3=A4gen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/BackgroundJob.pm | 5 +- SL/Controller/BackgroundJobHistory.pm | 69 +++++++++++++++++++ SL/DB/BackgroundJobHistory.pm | 4 +- SL/DB/Manager/BackgroundJobHistory.pm | 19 +++++ css/Mobile/background_jobs.css | 1 + css/Win2000/background_jobs.css | 1 + css/kivitendo/background_jobs.css | 1 + css/lx-office-erp/background_jobs.css | 14 ++++ locale/de/all | 11 +++ templates/webpages/background_job/form.html | 12 ++-- templates/webpages/background_job/list.html | 19 ++--- .../webpages/background_job_history/list.html | 61 ++++++++++++++++ .../webpages/background_job_history/show.html | 54 +++++++++++++++ 13 files changed, 253 insertions(+), 18 deletions(-) create mode 100644 SL/Controller/BackgroundJobHistory.pm create mode 100644 SL/DB/Manager/BackgroundJobHistory.pm create mode 120000 css/Mobile/background_jobs.css create mode 120000 css/Win2000/background_jobs.css create mode 120000 css/kivitendo/background_jobs.css create mode 100644 css/lx-office-erp/background_jobs.css create mode 100644 templates/webpages/background_job_history/list.html create mode 100644 templates/webpages/background_job_history/show.html diff --git a/SL/Controller/BackgroundJob.pm b/SL/Controller/BackgroundJob.pm index 3176eb66d..57ec5c377 100644 --- a/SL/Controller/BackgroundJob.pm +++ b/SL/Controller/BackgroundJob.pm @@ -83,7 +83,10 @@ sub action_execute { flash_later('error', $::locale->text('There was an error executing the background job.')); } - $self->redirect_to(controller => 'BackgroundJobHistory', action => 'show', id => $history->id); + $self->redirect_to(controller => 'BackgroundJobHistory', + action => 'show', + id => $history->id, + back_to => $self->url_for(action => 'edit', id => $self->background_job->id)); } # diff --git a/SL/Controller/BackgroundJobHistory.pm b/SL/Controller/BackgroundJobHistory.pm new file mode 100644 index 000000000..54d733808 --- /dev/null +++ b/SL/Controller/BackgroundJobHistory.pm @@ -0,0 +1,69 @@ +package SL::Controller::BackgroundJobHistory; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::DB::BackgroundJobHistory; +use SL::Helper::Flash; +use SL::System::TaskServer; + +use Rose::Object::MakeMethods::Generic +( + scalar => [ qw(history) ], + 'scalar --get_set_init' => [ qw(task_server) ], +); + +__PACKAGE__->run_before('check_auth'); +__PACKAGE__->run_before('add_stylesheet'); +__PACKAGE__->run_before('check_task_server'); + +# +# actions +# + +sub action_list { + my ($self) = @_; + + $self->render('background_job_history/list', + title => $::locale->text('Background job history'), + ENTRIES => SL::DB::Manager::BackgroundJobHistory->get_all_sorted); +} + +sub action_show { + my ($self) = @_; + + my $back_to = $::form->{back_to} || $self->url_for(action => 'list'); + + $self->history(SL::DB::BackgroundJobHistory->new(id => $::form->{id})->load); + $self->render('background_job_history/show', + title => $::locale->text('View background job execution result'), + back_to => $back_to); +} + +# +# filters +# + +sub check_auth { + $::auth->assert('admin'); +} + +# +# helpers +# + +sub init_task_server { + return SL::System::TaskServer->new; +} + +sub check_task_server { + my ($self) = @_; + flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running; +} + +sub add_stylesheet { + $::form->use_stylesheet('lx-office-erp/background_jobs.css'); +} + +1; diff --git a/SL/DB/BackgroundJobHistory.pm b/SL/DB/BackgroundJobHistory.pm index f8e08f8d9..4be8f66c3 100644 --- a/SL/DB/BackgroundJobHistory.pm +++ b/SL/DB/BackgroundJobHistory.pm @@ -6,8 +6,6 @@ package SL::DB::BackgroundJobHistory; use strict; use SL::DB::MetaSetup::BackgroundJobHistory; - -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->make_manager_class; +use SL::DB::Manager::BackgroundJobHistory; 1; diff --git a/SL/DB/Manager/BackgroundJobHistory.pm b/SL/DB/Manager/BackgroundJobHistory.pm new file mode 100644 index 000000000..132188f3c --- /dev/null +++ b/SL/DB/Manager/BackgroundJobHistory.pm @@ -0,0 +1,19 @@ +package SL::DB::Manager::BackgroundJobHistory; + +use strict; + +use SL::DB::Helper::Manager; +use base qw(SL::DB::Helper::Manager); + +use SL::DB::Helper::Sorted; + +sub object_class { 'SL::DB::BackgroundJobHistory' } + +__PACKAGE__->make_manager_methods; + +sub _sort_spec { + return ( default => [ 'run_at', 1 ], + columns => { SIMPLE => 'ALL' } ); +} + +1; diff --git a/css/Mobile/background_jobs.css b/css/Mobile/background_jobs.css new file mode 120000 index 000000000..8031c949e --- /dev/null +++ b/css/Mobile/background_jobs.css @@ -0,0 +1 @@ +../lx-office-erp/background_jobs.css \ No newline at end of file diff --git a/css/Win2000/background_jobs.css b/css/Win2000/background_jobs.css new file mode 120000 index 000000000..8031c949e --- /dev/null +++ b/css/Win2000/background_jobs.css @@ -0,0 +1 @@ +../lx-office-erp/background_jobs.css \ No newline at end of file diff --git a/css/kivitendo/background_jobs.css b/css/kivitendo/background_jobs.css new file mode 120000 index 000000000..8031c949e --- /dev/null +++ b/css/kivitendo/background_jobs.css @@ -0,0 +1 @@ +../lx-office-erp/background_jobs.css \ No newline at end of file diff --git a/css/lx-office-erp/background_jobs.css b/css/lx-office-erp/background_jobs.css new file mode 100644 index 000000000..9aa8271ab --- /dev/null +++ b/css/lx-office-erp/background_jobs.css @@ -0,0 +1,14 @@ +/* Jobverwaltung */ +.background_job_history_list tbody pre, +.background_job_history_details tbody pre { + margin: 0px; +} + +.background_job_history_details tbody th { + text-align: right; + vertical-align: top; +} + +.background_job_history_details tbody td { + vertical-align: top; +} diff --git a/locale/de/all b/locale/de/all index 932db27cf..e7f142a2c 100644 --- a/locale/de/all +++ b/locale/de/all @@ -819,6 +819,7 @@ $self->{texts} = { 'Execution date from' => 'Ausführungsdatum von', 'Execution date to' => 'Ausführungsdatum bis', 'Execution schedule' => 'Ausführungszeitplan', + 'Execution status' => 'Ausführungsstatus', 'Execution type' => 'Ausführungsart', 'Existing Buchungsgruppen' => 'Existierende Buchungsgruppen', 'Existing Datasets' => 'Existierende Datenbanken', @@ -1560,12 +1561,14 @@ $self->{texts} = { 'Required by' => 'Lieferdatum', 'Reset' => 'Zurücksetzen', 'Restore Dataset' => 'Datenbank wiederherstellen', + 'Result' => 'Ergebnis', 'Revenue' => 'Erlöskonto', 'Revenue Account' => 'Erlöskonto', 'Revenues EU with UStId' => 'Erlöse EU m. UStId', 'Revenues EU without UStId' => 'Erlöse EU o. UStId', 'Review of Aging list' => 'Altersstrukturliste', 'Right' => 'Rechts', + 'Run at' => 'Ausgeführt um', 'SAVED' => 'Gespeichert', 'SAVED FOR DUNNING' => 'Gespeichert', 'SCREENED' => 'Angezeigt', @@ -1825,6 +1828,7 @@ $self->{texts} = { 'The background job has been created.' => 'Der Hintergrund-Job wurden angelegt.', 'The background job has been deleted.' => 'Der Hintergrund-Job wurde gelöscht.', 'The background job has been saved.' => 'Der Hintergrund-Job wurde gespeichert.', + 'The background job was executed successfully.' => 'Der Hintergrund-Job wurde erfolgreich ausgeführt.', 'The backup you upload here has to be a file created with "pg_dump -o -Ft".' => 'Die von Ihnen hochzuladende Sicherungsdatei muss mit dem Programm und den Parametern "pg_dump -o -Ft" erstellt worden sein.', 'The bank information must not be empty.' => 'Die Bankinformationen müssen vollständig ausgefüllt werden.', 'The base unit does not exist or it is about to be deleted in row %d.' => 'Die Basiseinheit in Zeile %d existiert nicht oder soll gelöscht werden.', @@ -1964,6 +1968,7 @@ $self->{texts} = { 'There are #1 unfinished follow-ups of which #2 are due.' => 'Es gibt #1 Wiedervorlage(n), von denen #2 fällig ist/sind.', 'There are bookings to the account 3803 after 01.01.2007. If you didn\'t change this account manually to 19% the bookings are probably incorrect.' => 'Das Konto 3803 wurde nach dem 01.01.2007 bebucht. Falls Sie dieses Konto nicht manuell auf 19% gestellt haben sind die Buchungen wahrscheinlich mit falscher Umsatzsteuer gebucht worden.', 'There are four tax zones.' => 'Es gibt vier Steuerzonen.', + 'There are no entries in the background job history.' => 'Es gibt keine Einträge im Hintergrund-Job-Verlauf.', 'There are no items in stock.' => 'Dieser Artikel ist nicht eingelagert.', 'There are no items on your TODO list at the moment.' => 'Ihre Aufgabenliste enthält momentan keine Einträge.', 'There are still entries in the database for which no unit has been assigned.' => 'Es gibt noch Einträge in der Datenbank, für die keine Einheit zugeordnet ist.', @@ -1975,6 +1980,7 @@ $self->{texts} = { 'There is not enough available of \'#1\' at warehouse \'#2\', bin \'#3\', #4, for the transfer of #5.' => 'Von \'#1\' ist in Lager \'#2\', Lagerplatz \'#3\', #4 nicht genügend eingelagert, um insgesamt #5 auszulagern.', 'There is not enough left of \'#1\' in bin \'#2\' for the removal of #3.' => 'In Lagerplatz \'#2\' ist nicht genug von \'#1\' vorhanden, um #3 zu entnehmen.', 'There is nothing to do in this step.' => 'In diesem Schritt gibt es nichts mehr zu tun.', + 'There was an error executing the background job.' => 'Bei der Ausführung des Hintergrund-Jobs trat ein Fehler auf.', 'Therefore the definition of "kg" with the base unit "g" and a factor of 1000 is valid while defining "g" with a base unit of "kg" and a factor of "0.001" is not.' => 'So ist die Definition von "kg" mit der Basiseinheit "g" und dem Faktor 1000 zulässig, die Definition von "g" mit der Basiseinheit "kg" und dem Faktor "0,001" hingegen nicht.', 'Therefore there\'s no need to create the same article more than once if it is sold or bought in/from another tax zone.' => 'Deswegen muss man den gleichen Artikel nicht mehr mehrmals anlegen, wenn er in verschiedenen Steuerzonen gehandelt werden soll.', 'These units can be based on other units so that kivitendo can convert prices when the user switches from one unit to another.' => 'Einheiten können auf anderen Einheiten basieren, sodass kivitendo Preise automatisch umrechnen kann, wenn die Benutzer zwischen solchen Einheiten umschalten.', @@ -2121,6 +2127,9 @@ $self->{texts} = { 'Version' => 'Version', 'Version 2.4.0 introduces two new concepts: tax zones and Buchungsgruppen.' => 'Version 2.4.0 hat zwei neue Konzepte eingeführt: Steuerzonen und Buchungsgruppen.', 'View SEPA export' => 'SEPA-Export-Details ansehen', + 'View background job execution result' => 'Verlauf der Hintergrund-Job-Ausführungen anzeigen', + 'View background job history' => 'Hintergrund-Job-Verlauf anzeigen', + 'View background jobs' => '', 'View warehouse content' => 'Lagerbestand ansehen', 'View/edit all employees sales documents' => 'Bearbeiten/ansehen der Verkaufsdokumente aller Mitarbeiter', 'Von Konto: ' => 'von Konto: ', @@ -2268,6 +2277,7 @@ $self->{texts} = { 'emailed to' => 'gemailt an', 'empty' => 'leer', 'executed' => 'ausgeführt', + 'failed' => 'fehlgeschlagen', 'female' => 'weiblich', 'follow_up_list' => 'wiedervorlageliste', 'for' => 'für', @@ -2369,6 +2379,7 @@ $self->{texts} = { 'soldtotal' => 'Verkaufte Anzahl', 'stock' => 'Einlagerung', 'submit' => 'abschicken', + 'succeeded' => 'erfolgreich', 'tax_chartaccno' => 'Automatikkonto', 'tax_percent' => 'Prozentsatz', 'tax_rate' => 'Prozent', diff --git a/templates/webpages/background_job/form.html b/templates/webpages/background_job/form.html index c3d784c9d..a4753bb41 100644 --- a/templates/webpages/background_job/form.html +++ b/templates/webpages/background_job/form.html @@ -8,29 +8,29 @@ - + - + - + - + - - + +
[%- LxERP.t8('Active') %][%- LxERP.t8('Active') %] [% L.yes_no_tag("background_job.active", SELF.background_job.active) %]
[%- LxERP.t8('Execution type') %][%- LxERP.t8('Execution type') %] [% L.select_tag("background_job.type", L.options_for_select([ [ 'once', LxERP.t8('one-time execution') ], [ 'interval', LxERP.t8('repeated execution') ] ], 'default' => SELF.background_job.type)) %]
[%- LxERP.t8('Package name') %][%- LxERP.t8('Package name') %] [% L.input_tag("background_job.package_name", SELF.background_job.package_name, 'size' => 40) %]
[%- LxERP.t8('Execution schedule') %][%- LxERP.t8('Execution schedule') %] [% L.input_tag("background_job.cron_spec", SELF.background_job.cron_spec, 'size' => 40) %]
[%- LxERP.t8('Data') %][% L.textarea_tag("background_job.data", SELF.background_job.data, 'cols' => 80, 'rows' => 10) %][%- LxERP.t8('Data') %][% L.textarea_tag("background_job.data", SELF.background_job.data, 'cols' => 80, 'rows' => 10) %]
diff --git a/templates/webpages/background_job/list.html b/templates/webpages/background_job/list.html index c0ef9993d..9f4422d99 100644 --- a/templates/webpages/background_job/list.html +++ b/templates/webpages/background_job/list.html @@ -14,14 +14,14 @@ [%- ELSE %] - - - - - - - - + + + + + + + + @@ -35,6 +35,7 @@ [% ELSE %] [%- HTML.escape(background_job.type) %] [%- END %] +
[%- LxERP.t8('Execution type') %][%- LxERP.t8('Package name') %][%- LxERP.t8('Active') %][%- LxERP.t8('Execution schedule') %][%- LxERP.t8('Last run at') %][%- LxERP.t8('Next run at') %]
[%- LxERP.t8('Execution type') %][%- LxERP.t8('Package name') %][%- LxERP.t8('Active') %][%- LxERP.t8('Execution schedule') %][%- LxERP.t8('Last run at') %][%- LxERP.t8('Next run at') %]
[%- HTML.escape(background_job.package_name) %] @@ -68,6 +69,8 @@

[%- LxERP.t8('Create new background job') %] | + [%- LxERP.t8('View background job history') %] + | [%- LxERP.t8('Task server control') %]

diff --git a/templates/webpages/background_job_history/list.html b/templates/webpages/background_job_history/list.html new file mode 100644 index 000000000..f88a44533 --- /dev/null +++ b/templates/webpages/background_job_history/list.html @@ -0,0 +1,61 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + + +
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + +
+ [% IF !ENTRIES.size %] +

+ [%- LxERP.t8('There are no entries in the background job history.') %] +

+ + [%- ELSE %] + + + + + + + + + + + + + [%- FOREACH entry = ENTRIES %] + + + + + + + + [%- END %] + +
[%- LxERP.t8('Package name') %][%- LxERP.t8('Run at') %][%- LxERP.t8('Execution status') %][%- LxERP.t8('Result') %][%- LxERP.t8('Error') %]
+ + [%- HTML.escape(entry.package_name) %] + + [%- HTML.escape(entry.run_at.to_lxoffice('precision' => 'second')) %] + [%- IF entry.status == 'success' %] + [%- LxERP.t8('succeeded') %] + [%- ELSIF entry.status == 'failure' %] + [%- LxERP.t8('failed') %] + [%- ELSE %] + [%- HTML.escape(entry.status) %] + [%- END %] + [%- HTML.escape(entry.result) %][% IF entry.error_col %]
[%- HTML.escape(L.truncate(entry.error_col)) %]
[%- END %]
+ [%- END %] + +
+ +

+ [%- LxERP.t8('View background jobs') %] + | + [%- LxERP.t8('Task server control') %] +

+
+ + diff --git a/templates/webpages/background_job_history/show.html b/templates/webpages/background_job_history/show.html new file mode 100644 index 000000000..e8054d3f4 --- /dev/null +++ b/templates/webpages/background_job_history/show.html @@ -0,0 +1,54 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + + +
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[%- LxERP.t8('Package name') %][%- HTML.escape(SELF.history.package_name) %]
[%- LxERP.t8('Run at') %][%- HTML.escape(SELF.history.run_at.to_lxoffice('precision' => 'second')) %]
[%- LxERP.t8('Execution status') %] + [%- IF SELF.history.status == 'success' %] + [%- LxERP.t8('succeeded') %] + [%- ELSIF SELF.history.status == 'failed' %] + [%- LxERP.t8('failed') %] + [%- ELSE %] + [%- HTML.escape(SELF.history.status) %] + [%- END %] +
[%- LxERP.t8('Result') %][%- HTML.escape(SELF.history.result) %]
[%- LxERP.t8('Error') %][% IF SELF.history.error_col %]
[%- HTML.escape(SELF.history.error_col) %]
[%- END %]
[%- LxERP.t8('Data') %][% IF SELF.history.data %]
[%- HTML.escape(SELF.history.data) %]
[%- END %]
+ +

+ [%- LxERP.t8('Back') %] +

+ + -- 2.20.1