]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add option to show time in job log - idea proposed by Wanderlei Huttel
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 18 Apr 2020 19:07:25 +0000 (21:07 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Tue, 19 May 2020 18:46:11 +0000 (20:46 +0200)
14 files changed:
gui/baculum/protected/Web/Class/BaculumWebPage.php
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Pages/ApplicationSettings.page
gui/baculum/protected/Web/Pages/ApplicationSettings.php
gui/baculum/protected/Web/Pages/JobHistoryView.php
gui/baculum/protected/Web/Pages/Users.php
gui/baculum/protected/Web/Pages/WebConfigWizard.php

index 41e74aaad1684847cab529a6dba9c93288ac4a8e..75449e8ea953e76eadbc6494ee52c7ea7c3d334a 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2020 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -42,13 +42,13 @@ class BaculumWebPage extends BaculumPage {
         */
        const DEFAULT_AUTH_USER = 'admin';
 
-       private $config = array();
+       protected $web_config = array();
 
        public function onPreInit($param) {
                parent::onPreInit($param);
-               $this->config = $this->getModule('web_config')->getConfig();
+               $this->web_config = $this->getModule('web_config')->getConfig();
                $this->Application->getGlobalization()->Culture = $this->getLanguage();
-               if (count($this->config) === 0) {
+               if (count($this->web_config) === 0) {
                        if (isset($_SERVER['PHP_AUTH_USER'])) {
                                if ($this->Service->getRequestedPagePath() != 'WebConfigWizard') {
                                        $this->goToPage('WebConfigWizard');
@@ -59,7 +59,7 @@ class BaculumWebPage extends BaculumPage {
                                self::accessDenied();
                        }
                }
-               Logging::$debug_enabled = (isset($this->config['baculum']['debug']) && $this->config['baculum']['debug'] == 1);
+               Logging::$debug_enabled = (isset($this->web_config['baculum']['debug']) && $this->web_config['baculum']['debug'] == 1);
                if (!$this->IsPostBack && !$this->IsCallBack) {
                        $this->getModule('api')->initSessionCache(true);
                        $this->setSessionUserVars();
@@ -82,8 +82,8 @@ class BaculumWebPage extends BaculumPage {
                if (isset($_SESSION['language']) && !empty($_SESSION['language'])) {
                        $language =  $_SESSION['language'];
                } else {
-                       if (isset($this->config['baculum']) && key_exists('lang', $this->config['baculum'])) {
-                               $language = $this->config['baculum']['lang'];
+                       if (isset($this->web_config['baculum']) && key_exists('lang', $this->web_config['baculum'])) {
+                               $language = $this->web_config['baculum']['lang'];
                        }
                        if (is_null($language)) {
                                $language = WebConfig::DEFAULT_LANGUAGE;
@@ -100,13 +100,13 @@ class BaculumWebPage extends BaculumPage {
         */
        private function setSessionUserVars() {
                // NOTE. For oauth2 callback, the PHP_AUTH_USER is empty because no user/pass.
-               if (count($this->config) > 0 && isset($_SERVER['PHP_AUTH_USER'])) {
+               if (count($this->web_config) > 0 && isset($_SERVER['PHP_AUTH_USER'])) {
                        // Set administrator role
-                       $_SESSION['admin'] = ($_SERVER['PHP_AUTH_USER'] === $this->config['baculum']['login']);
+                       $_SESSION['admin'] = ($_SERVER['PHP_AUTH_USER'] === $this->web_config['baculum']['login']);
 
                        // Set api host for normal user
-                       if (!$_SESSION['admin'] && key_exists('users', $this->config) && array_key_exists($_SERVER['PHP_AUTH_USER'], $this->config['users'])) {
-                               $_SESSION['api_host'] = $this->config['users'][$_SERVER['PHP_AUTH_USER']];
+                       if (!$_SESSION['admin'] && key_exists('users', $this->web_config) && array_key_exists($_SERVER['PHP_AUTH_USER'], $this->web_config['users'])) {
+                               $_SESSION['api_host'] = $this->web_config['users'][$_SERVER['PHP_AUTH_USER']];
                        } elseif ($_SESSION['admin']) {
                                $_SESSION['api_host'] = 'Main';
                        }
index 522766ab5d56c58f5041951953c623c8edd8e8ad..4fbd8d2ee4f9abdd70ec318ac802bd66d0dffe23 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index 17f90d5f7e9273e2b5aa8fa8244ac4501580fed1..e00e5187dd73ad1fa71bd8872a3e976025b610b3 100644 (file)
@@ -2626,3 +2626,6 @@ msgstr "Refresh page"
 
 msgid "Tip: Use left-click to select table row. Use CTRL + left-click to multiple row selection. Use SHIFT + left-click to add a range of rows to selection."
 msgstr "Tip: Use left-click to select table row. Use CTRL + left-click to multiple row selection. Use SHIFT + left-click to add a range of rows to selection."
+
+msgid "Show time in job log:"
+msgstr "Show time in job log:"
index 9a1e3a6092d915493f8fdef899be79a589765b98..67dbea08305da1b4046d9b57210f2d4d59ee92c8 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index ad3680fee6f8c2d9a9e32dbe84660e9b71240c8f..7445d08744c0ccff4ef2a58b3833b4d4e573313f 100644 (file)
@@ -2712,3 +2712,6 @@ msgstr "Refresh page"
 
 msgid "Tip: Use left-click to select table row. Use CTRL + left-click to multiple row selection. Use SHIFT + left-click to add a range of rows to selection."
 msgstr "Tip: Use left-click to select table row. Use CTRL + left-click to multiple row selection. Use SHIFT + left-click to add a range of rows to selection."
+
+msgid "Show time in job log:"
+msgstr "Show time in job log:"
index 1f3568ba435295503181d44d7124a6bf057796e0..50d30a7a87beab9ad6ae00813753e411b0f2442e 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index e9e15f0b9e673fe659d2031ce8631699f8462557..7b8e91a9c8b69c394ad2ae20c38b9b0294910c66 100644 (file)
@@ -2634,3 +2634,6 @@ msgstr "Odśwież stronę"
 
 msgid "Tip: Use left-click to select table row. Use CTRL + left-click to multiple row selection. Use SHIFT + left-click to add a range of rows to selection."
 msgstr "Tip: Użyj lewego przycisku myszy, aby wybrać wiersz tabeli. Użyj CTRL + lewy przycisk myszy, aby zaznaczyć wiele wierszy. Użyj SHIFT + lewy przycisk myszy, aby dodać zakres wierszy do zaznaczenia."
+
+msgid "Show time in job log:"
+msgstr "Pokaż czas w dzienniku zadania:"
index 2ce2c06451a670c2add0df7d1c951ffab52dcca6..927ea42a31972ebc25ea915f570c918cfdf3970c 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index f4b675c40f5997f804931cbd755d7416e03d25f7..78cb1bf94d9ff52edec8fee50251d3dcc69f7743 100644 (file)
@@ -2634,3 +2634,6 @@ msgstr "Atualizar página"
 
 msgid "Tip: Use left-click to select table row. Use CTRL + left-click to multiple row selection. Use SHIFT + left-click to add a range of rows to selection."
 msgstr "Tip: Use left-click to select table row. Use CTRL + left-click to multiple row selection. Use SHIFT + left-click to add a range of rows to selection."
+
+msgid "Show time in job log:"
+msgstr "Show time in job log:"
index 7515f91c91ef9d8a69dc4f73ac0a327d9d9e4e53..e4fe3eca4b42b7252d2b0ae8dce22cc5e775023d 100644 (file)
                        /> <com:TLabel ForControl="BinaryBytes"><%[ Binary Bytes (1 mebi = 2<sup>20</sup>) ]%></com:TLabel></p>
                </div>
        </div>
+       <div class="w3-container w3-row w3-padding">
+               <div class="w3-third w3-col"><%[ Show time in job log: ]%></div>
+               <div class="w3-third w3-col">
+                       <com:TCheckBox
+                               ID="TimeInJobLog"
+                               CssClass="w3-check"
+                       />
+               </div>
+       </div>
        <div class="w3-center">
                <com:TActiveLinkButton
                        CssClass="w3-button w3-green"
index 57cb0d19184736e3551d42256d17f56863e3ff7d..c32934eb5dc44350704d4dad474e82feead7ba3d 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2020 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -35,11 +35,8 @@ class ApplicationSettings extends BaculumWebPage {
 
        protected $admin = true;
 
-       public $web_config;
-
        public function onInit($param) {
                parent::onInit($param);
-               $this->web_config = $this->getModule('web_config')->getConfig();
                $this->DecimalBytes->Checked = true;
                if(count($this->web_config) > 0) {
                        $this->Debug->Checked = ($this->web_config['baculum']['debug'] == 1);
@@ -48,6 +45,9 @@ class ApplicationSettings extends BaculumWebPage {
                                $this->DecimalBytes->Checked = ($this->web_config['baculum']['size_values_unit'] === 'decimal');
                                $this->BinaryBytes->Checked = ($this->web_config['baculum']['size_values_unit'] === 'binary');
                        }
+                       if (key_exists('time_in_job_log', $this->web_config['baculum'])) {
+                               $this->TimeInJobLog->Checked = ($this->web_config['baculum']['time_in_job_log'] == 1);
+                       }
                }
        }
 
@@ -58,6 +58,7 @@ class ApplicationSettings extends BaculumWebPage {
                        $max_jobs = intval($this->MaxJobs->Text);
                        $this->web_config['baculum']['max_jobs'] = $max_jobs;
                        $this->web_config['baculum']['size_values_unit'] = $this->BinaryBytes->Checked ? 'binary' : 'decimal';
+                       $this->web_config['baculum']['time_in_job_log'] = ($this->TimeInJobLog->Checked === true) ? 1 : 0;
                        $this->getModule('web_config')->setConfig($this->web_config);
                }
        }
index 4d0305441875a90999453c89b13e0aae6ba126ea..b9cadaad8a6998e4093a378b0d0e3a2c9f1975b4 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2020 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -283,7 +283,17 @@ class JobHistoryView extends BaculumWebPage {
         * @param $param TCallbackParameter parameter object
         */
        public function refreshJobLog($sender, $param) {
-               $log = $this->getModule('api')->get(array('joblog', $this->getJobId()));
+               $params = ['joblog', $this->getJobId()];
+
+               // add time to log if defiend in configuration
+               if (key_exists('time_in_job_log', $this->web_config['baculum'])) {
+                       $query_params = [
+                               'show_time' => $this->web_config['baculum']['time_in_job_log']
+                       ];
+                       $params[] = '?' . http_build_query($query_params);
+               }
+               $log = $this->getModule('api')->get($params);
+
                if (!is_array($log->output) || count($log->output) == 0) {
                        $msg = Prado::localize("Output for selected job is not available yet or you do not have enabled logging job logs to the catalog database.\n\nTo watch job log you need to add to the job Messages resource the following directive:\n\nCatalog = all, !debug, !skipped, !saved");
                        $joblog = array($msg);
index cdf7cd14768a4c19f462a46e0b14cfe22b4ded38..2b73b34877f1f017bae4f6b88a6bfa632a9b8106 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2020 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -36,13 +36,6 @@ class Users extends BaculumWebPage {
 
        protected $admin = true;
 
-       public $web_config;
-
-       public function onInit($param) {
-               parent::onInit($param);
-               $this->web_config = $this->getModule('web_config')->getConfig();
-       }
-
        public function setUsers() {
                $all_users = $this->getModule('basic_webuser')->getAllUsers();
                $users = array_keys($all_users);
index 5e364f9f4c1b887310fe49cef14172736a040761..5384f2f1ea44f9986f8f659b6c9c5cf3f913beda 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2020 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -20,8 +20,6 @@
  * Bacula(R) is a registered trademark of Kern Sibbald.
  */
 
-// @TODO: move this page to API part before any release.
 Prado::using('Application.Web.Class.BaculumWebPage'); 
 Prado::using('Application.Web.Class.HostConfig');
 Prado::using('Application.Web.Class.BasicWebUserConfig'); 
@@ -40,14 +38,11 @@ class WebConfigWizard extends BaculumWebPage
        protected $admin = false;
 
        public $first_run;
-       public $web_config;
        public $host_config;
 
        public function onInit($param) {
                parent::onInit($param);
                $this->Lang->SelectedValue = $this->getLanguage();
-               $config = $this->getModule('web_config');
-               $this->web_config = $config->getConfig();
                $this->host_config = $this->getModule('host_config')->getConfig();
                $this->first_run = (count($this->host_config) == 0 || !key_exists(HostConfig::MAIN_CATALOG_HOST, $this->host_config));
                Logging::$debug_enabled = Logging::$debug_enabled ?: $this->first_run;
@@ -129,10 +124,9 @@ class WebConfigWizard extends BaculumWebPage
                $host_config[$host] = $cfg_host;
                $ret = $this->getModule('host_config')->setConfig($host_config);
                if($ret === true) {
-                       $web_config = $this->getModule('web_config')->getConfig();
                        $cfg_web = array('baculum' => array(), 'users' => array());
-                       if (count($web_config) > 0) {
-                               $cfg_web = $web_config;
+                       if (count($this->web_config) > 0) {
+                               $cfg_web = $this->web_config;
                        }
                        $cfg_web['baculum']['login'] = $this->WebLogin->Text;
                        $cfg_web['baculum']['debug'] = 0;