From: Marcin Haba
Date: Sat, 18 Apr 2020 19:07:25 +0000 (+0200)
Subject: baculum: Add option to show time in job log - idea proposed by Wanderlei Huttel
X-Git-Tag: Release-9.6.4~35
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94ac013f6e68b090ecec0688ebdc4d8ab94cbbca;p=thirdparty%2Fbacula.git
baculum: Add option to show time in job log - idea proposed by Wanderlei Huttel
---
diff --git a/gui/baculum/protected/Web/Class/BaculumWebPage.php b/gui/baculum/protected/Web/Class/BaculumWebPage.php
index 41e74aaad..75449e8ea 100644
--- a/gui/baculum/protected/Web/Class/BaculumWebPage.php
+++ b/gui/baculum/protected/Web/Class/BaculumWebPage.php
@@ -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';
}
diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo
index 522766ab5..4fbd8d2ee 100644
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po
index 17f90d5f7..e00e5187d 100644
--- a/gui/baculum/protected/Web/Lang/en/messages.po
+++ b/gui/baculum/protected/Web/Lang/en/messages.po
@@ -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:"
diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo
index 9a1e3a609..67dbea083 100644
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po
index ad3680fee..7445d0874 100644
--- a/gui/baculum/protected/Web/Lang/ja/messages.po
+++ b/gui/baculum/protected/Web/Lang/ja/messages.po
@@ -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:"
diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo
index 1f3568ba4..50d30a7a8 100644
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po
index e9e15f0b9..7b8e91a9c 100644
--- a/gui/baculum/protected/Web/Lang/pl/messages.po
+++ b/gui/baculum/protected/Web/Lang/pl/messages.po
@@ -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:"
diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo
index 2ce2c0645..927ea42a3 100644
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po
index f4b675c40..78cb1bf94 100644
--- a/gui/baculum/protected/Web/Lang/pt/messages.po
+++ b/gui/baculum/protected/Web/Lang/pt/messages.po
@@ -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:"
diff --git a/gui/baculum/protected/Web/Pages/ApplicationSettings.page b/gui/baculum/protected/Web/Pages/ApplicationSettings.page
index 7515f91c9..e4fe3eca4 100644
--- a/gui/baculum/protected/Web/Pages/ApplicationSettings.page
+++ b/gui/baculum/protected/Web/Pages/ApplicationSettings.page
@@ -57,6 +57,15 @@
/> <%[ Binary Bytes (1 mebi = 220) ]%>
+
+
<%[ Show time in job log: ]%>
+
+
+
+
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);
}
}
diff --git a/gui/baculum/protected/Web/Pages/JobHistoryView.php b/gui/baculum/protected/Web/Pages/JobHistoryView.php
index 4d0305441..b9cadaad8 100644
--- a/gui/baculum/protected/Web/Pages/JobHistoryView.php
+++ b/gui/baculum/protected/Web/Pages/JobHistoryView.php
@@ -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);
diff --git a/gui/baculum/protected/Web/Pages/Users.php b/gui/baculum/protected/Web/Pages/Users.php
index cdf7cd147..2b73b3487 100644
--- a/gui/baculum/protected/Web/Pages/Users.php
+++ b/gui/baculum/protected/Web/Pages/Users.php
@@ -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);
diff --git a/gui/baculum/protected/Web/Pages/WebConfigWizard.php b/gui/baculum/protected/Web/Pages/WebConfigWizard.php
index 5e364f9f4..5384f2f1e 100644
--- a/gui/baculum/protected/Web/Pages/WebConfigWizard.php
+++ b/gui/baculum/protected/Web/Pages/WebConfigWizard.php
@@ -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;