From f815dda94928d977655cd3d5d2fe1abc86242141 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 29 Aug 2012 18:01:27 +0200 Subject: [PATCH] =?utf8?q?Controller=20f=C3=BCr=20Task-Server-Steuerung?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/TaskServer.pm | 87 +++++++++++++++++++ css/lx-office-erp/background_jobs.css | 8 +- locale/de/all | 15 +++- .../webpages/background_job_history/list.html | 2 +- .../webpages/background_job_history/show.html | 2 +- templates/webpages/task_server/show.html | 37 ++++++++ 6 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 SL/Controller/TaskServer.pm create mode 100644 templates/webpages/task_server/show.html diff --git a/SL/Controller/TaskServer.pm b/SL/Controller/TaskServer.pm new file mode 100644 index 000000000..2649f5fb0 --- /dev/null +++ b/SL/Controller/TaskServer.pm @@ -0,0 +1,87 @@ +package SL::Controller::TaskServer; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::Helper::Flash; +use SL::System::TaskServer; + +use Rose::Object::MakeMethods::Generic +( + 'scalar --get_set_init' => [ qw(task_server) ], +); + +__PACKAGE__->run_before('check_auth'); + +# +# actions +# + +sub action_show { + my ($self) = @_; + + $::form->use_stylesheet('lx-office-erp/background_jobs.css'); + + flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running; + + $self->render('task_server/show', + title => $::locale->text('Task server status'), + last_command_output => $::auth->get_session_value('TaskServer::last_command_output')); +} + +sub action_start { + my ($self) = @_; + + if ($self->task_server->is_running) { + flash_later('error', $::locale->text('The task server is already running.')); + + } else { + if ($self->task_server->start) { + flash_later('info', $::locale->text('The task server was started successfully.')); + } else { + flash_later('error', $::locale->text('Starting the task server failed.')); + } + + $::auth->set_session_value('TaskServer::last_command_output' => $self->task_server->last_command_output); + } + + $self->redirect_to(action => 'show'); +} + +sub action_stop { + my ($self) = @_; + + if (!$self->task_server->is_running) { + flash_later('error', $::locale->text('The task server is not running.')); + + } else { + if ($self->task_server->stop) { + flash_later('info', $::locale->text('The task server was stopped successfully.')); + } else { + flash_later('error', $::locale->text('Stopping the task server failed. Output:')); + } + + $::auth->set_session_value('TaskServer::last_command_output' => $self->task_server->last_command_output); + } + + $self->redirect_to(action => 'show'); +} + +# +# filters +# + +sub check_auth { + $::auth->assert('admin'); +} + +# +# helpers +# + +sub init_task_server { + return SL::System::TaskServer->new; +} + +1; diff --git a/css/lx-office-erp/background_jobs.css b/css/lx-office-erp/background_jobs.css index 9aa8271ab..e390bb5a4 100644 --- a/css/lx-office-erp/background_jobs.css +++ b/css/lx-office-erp/background_jobs.css @@ -1,14 +1,14 @@ /* Jobverwaltung */ -.background_job_history_list tbody pre, -.background_job_history_details tbody pre { +.background_job_list tbody pre, +.background_job_details tbody pre { margin: 0px; } -.background_job_history_details tbody th { +.background_job_details tbody th { text-align: right; vertical-align: top; } -.background_job_history_details tbody td { +.background_job_details tbody td { vertical-align: top; } diff --git a/locale/de/all b/locale/de/all index e7f142a2c..b4b66284b 100644 --- a/locale/de/all +++ b/locale/de/all @@ -505,6 +505,7 @@ $self->{texts} = { 'Current Earnings' => 'Gewinn', 'Current assets account' => 'Konto für Umlaufvermögen', 'Current profile' => 'Aktuelles Profil', + 'Current status' => 'Aktueller Status', 'Current unit' => 'Aktuelle Einheit', 'Current value:' => 'Aktueller Wert:', 'Custom Variables' => 'Benutzerdefinierte Variablen', @@ -1078,6 +1079,7 @@ $self->{texts} = { 'Last Service Number' => 'Letzte Dienstleistungsnr.', 'Last Transaction' => 'Letzte Buchung', 'Last Vendor Number' => 'Letzte Lieferantennummer', + 'Last command output' => 'Ausgabe des letzten Befehls', 'Last run at' => 'Zeitpunkt letzter Ausführung', 'Lastcost (with X being a number)' => 'Einkaufspreis (X ist eine fortlaufende Zahl)', 'Lead' => 'Kundenquelle', @@ -1716,9 +1718,11 @@ $self->{texts} = { 'Start Dunning Process' => 'Mahnprozess starten', 'Start analysis' => 'Analyse beginnen', 'Start date' => 'Startdatum', + 'Start task server' => 'Task-Server starten', 'Start the correction assistant' => 'Korrekturassistenten starten', 'Startdate_coa' => 'Gültig ab', 'Starting Balance' => 'Eröffnungsbilanzwerte', + 'Starting the task server failed.' => 'Das Starten des Task-Servers schlug fehl.', 'Starting with version 2.6.3 the configuration files in "config" have been consolidated.' => 'Ab Version 2.6.3 wurden die Konfiguration vereinfacht und es gibt nur noch eine Konfigurationsdatei im Verzeichnis config', 'Statement' => 'Sammelrechnung', 'Statement Balance' => 'Sammelrechnungsbilanz', @@ -1735,6 +1739,8 @@ $self->{texts} = { 'Stock Qty for Date' => 'Lagerbestand am', 'Stock value' => 'Bestandswert', 'Stocked Qty' => 'Lagermenge', + 'Stop task server' => 'Task-Server beenden', + 'Stopping the task server failed. Output:' => 'Das Beenden des Task-Servers schlug fehl.', 'Storno' => 'Storno', 'Storno (one letter abbreviation)' => 'S', 'Storno Invoice' => 'Stornorechnung', @@ -1763,6 +1769,7 @@ $self->{texts} = { 'Target bank account' => 'Zielkonto', 'Target table' => 'Zieltabelle', 'Task server control' => 'Task-Server-Steuerung', + 'Task server status' => 'Task-Server-Status', 'Tax' => 'Steuer', 'Tax Consultant' => 'Steuerberater/-in', 'Tax Included' => 'Steuer im Preis inbegriffen', @@ -1948,6 +1955,10 @@ $self->{texts} = { 'The tables for user management and authentication do not exist. They will be created in the next step in the following database:' => 'Die Tabellen zum Speichern der Benutzerdaten und zur Benutzerauthentifizierung wurden nicht gefunden. Sie werden in der folgenden Datenbank angelegt:', 'The tabulator character' => 'Das Tabulator-Symbol', 'The task server does not appear to be running.' => 'Der Task-Server scheint nicht zu laufen.', + 'The task server is already running.' => 'Der Task-Server läuft bereits.', + 'The task server is not running.' => 'Der Task-Server läuft nicht.', + 'The task server was started successfully.' => 'Der Task-Server wurde erfolgreich gestartet.', + 'The task server was stopped successfully.' => 'Der Task-Server wurde erfolgreich beendet.', 'The third way is to download the module from the above mentioned URL and to install the module manually following the installations instructions contained in the source archive.' => 'Die dritte Variante besteht darin, das Paket von der oben genannten URL herunterzuladen und es manuell zu installieren. Beachten Sie dabei die im Paket enthaltenen Installationsanweisungen.', 'The transaction is shown below in its current state.' => 'Nachfolgend wird angezeigt, wie die Buchung momentan aussieht.', 'The unit has been saved.' => 'Die Einheit wurde gespeichert.', @@ -2129,7 +2140,7 @@ $self->{texts} = { '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 background jobs' => 'Hintergrund-Jobs anzeigen', 'View warehouse content' => 'Lagerbestand ansehen', 'View/edit all employees sales documents' => 'Bearbeiten/ansehen der Verkaufsdokumente aller Mitarbeiter', 'Von Konto: ' => 'von Konto: ', @@ -2323,6 +2334,7 @@ $self->{texts} = { 'not delivered' => 'nicht geliefert', 'not executed' => 'nicht ausgeführt', 'not logged in' => 'nicht eingeloggt', + 'not running' => 'läuft nicht', 'not set' => 'nicht gesetzt', 'not transferred in yet' => 'noch nicht eingelagert', 'not transferred out yet' => 'noch nicht ausgelagert', @@ -2364,6 +2376,7 @@ $self->{texts} = { 'reset' => 'zurücksetzen', 'return_material' => 'Materialrückgabe', 'rfq_list' => 'anfragenliste', + 'running' => 'läuft', 'sales tax identification number' => 'USt-IdNr.', 'sales_delivery_order_list' => 'lieferscheinliste_verkauf', 'sales_order' => 'Kundenauftrag', diff --git a/templates/webpages/background_job_history/list.html b/templates/webpages/background_job_history/list.html index f88a44533..83c8dae1d 100644 --- a/templates/webpages/background_job_history/list.html +++ b/templates/webpages/background_job_history/list.html @@ -12,7 +12,7 @@

[%- ELSE %] - +
diff --git a/templates/webpages/background_job_history/show.html b/templates/webpages/background_job_history/show.html index e8054d3f4..0a0584fbc 100644 --- a/templates/webpages/background_job_history/show.html +++ b/templates/webpages/background_job_history/show.html @@ -5,7 +5,7 @@ [%- INCLUDE 'common/flash.html' %] -
[%- LxERP.t8('Package name') %]
+
diff --git a/templates/webpages/task_server/show.html b/templates/webpages/task_server/show.html new file mode 100644 index 000000000..2b1c279a0 --- /dev/null +++ b/templates/webpages/task_server/show.html @@ -0,0 +1,37 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + + +
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + +
[%- LxERP.t8('Package name') %]
+ + + + + + +[%- IF last_command_output %] + + + + +[%- END %] + + +
[%- LxERP.t8('Current status') %][% IF SELF.task_server.is_running %][%- LxERP.t8('running') %][%- ELSE %][%- LxERP.t8('not running') %][%- END %]
[%- LxERP.t8('Last command output') %]
[% HTML.escape(last_command_output) %]
+ +

+[% IF SELF.task_server.is_running %] + [%- LxERP.t8('Stop task server') %] +[%- ELSE %] + [%- LxERP.t8('Start task server') %] +[%- END %] + | + [%- LxERP.t8('View background jobs') %] + | + [%- LxERP.t8('View background job history') %] +

+ + -- 2.20.1