From cf5480aedcdcaa5f090aa973b1940b75dc22901f Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Thu, 13 Apr 2023 14:14:17 +0200 Subject: [PATCH 1/3] webui: make restore merge options configurable If you select a client in the webui restore module the default is that according jobs and filesets get merged for the file tree presentation. In larger environments you probably do not want this default behaviour. Therefore, this commit introduces two new configuration.ini settings to switch the default merge option behaviour in webui restore. The newly introduced configuration.ini parameters are "merge_jobs" and "merge_filesets" in the restore section. Co-authored-by: Joerg Steffens --- webui/config/autoload/global.php.in | 8 +++++++ webui/install/configuration.ini.in | 8 +++++++ .../src/Auth/Controller/AuthController.php | 2 ++ .../Restore/Controller/RestoreController.php | 21 ++++++++----------- .../Restore/src/Restore/Form/RestoreForm.php | 20 +++++++++--------- .../src/Restore/Model/RestoreModel.php | 12 +++++------ .../Restore/view/restore/restore/index.phtml | 19 +++-------------- .../view/restore/restore/versions.phtml | 17 +++------------ webui/public/js/bootstrap-table-formatter.js | 2 +- 9 files changed, 50 insertions(+), 59 deletions(-) diff --git a/webui/config/autoload/global.php.in b/webui/config/autoload/global.php.in index f114fe07d88..1a79571ff74 100644 --- a/webui/config/autoload/global.php.in +++ b/webui/config/autoload/global.php.in @@ -85,6 +85,8 @@ function read_configuration_ini($configuration_ini) ), 'restore' => array( 'filetree_refresh_timeout' => 120000, + 'merge_jobs' => true, + 'merge_filesets' => true ), 'theme' => array( 'name' => "sunflower" @@ -120,6 +122,12 @@ function read_configuration_ini($configuration_ini) if (isset($configuration['restore']['filetree_refresh_timeout'])) { $result['restore']['filetree_refresh_timeout'] = $configuration['restore']['filetree_refresh_timeout']; } + if (isset($configuration['restore']['merge_jobs'])) { + $result['restore']['merge_jobs'] = $configuration['restore']['merge_jobs']; + } + if (isset($configuration['restore']['merge_filesets'])) { + $result['restore']['merge_filesets'] = $configuration['restore']['merge_filesets']; + } if (isset($configuration['theme']['name'])) { $result['theme']['name'] = $configuration['theme']['name']; } diff --git a/webui/install/configuration.ini.in b/webui/install/configuration.ini.in index 85d319bce3f..d9f28209120 100644 --- a/webui/install/configuration.ini.in +++ b/webui/install/configuration.ini.in @@ -51,6 +51,14 @@ ; Default: ;filetree_refresh_timeout=120000 +; Merge jobs on client selection +; Default: +;merge_jobs=true + +; Merge filesets on client selection +; Default: +;merge_filesets=true + ;------------------------------------------------------------------------------ ; THEME SETTINGS ;------------------------------------------------------------------------------ diff --git a/webui/module/Auth/src/Auth/Controller/AuthController.php b/webui/module/Auth/src/Auth/Controller/AuthController.php index a96d7c26919..03564f3b846 100644 --- a/webui/module/Auth/src/Auth/Controller/AuthController.php +++ b/webui/module/Auth/src/Auth/Controller/AuthController.php @@ -125,6 +125,8 @@ public function loginAction() $session->offsetSet('dt_statesave', ($configuration['configuration']['tables']['save_previous_state']) ? 'true' : 'false'); $session->offsetSet('dashboard_autorefresh_interval', $configuration['configuration']['dashboard']['autorefresh_interval']); $session->offsetSet('filetree_refresh_timeout', $configuration['configuration']['restore']['filetree_refresh_timeout']); + $session->offsetSet('merge_jobs', $configuration['configuration']['restore']['merge_jobs']); + $session->offsetSet('merge_filesets', $configuration['configuration']['restore']['merge_filesets']); $session->offsetSet('configuration_resource_graph', $configuration['configuration']['experimental']['configuration_resource_graph']); if (isset($configuration['configuration']['autochanger']['labelpooltype'])) { diff --git a/webui/module/Restore/src/Restore/Controller/RestoreController.php b/webui/module/Restore/src/Restore/Controller/RestoreController.php index 1d642b6f842..ff961738e95 100644 --- a/webui/module/Restore/src/Restore/Controller/RestoreController.php +++ b/webui/module/Restore/src/Restore/Controller/RestoreController.php @@ -398,14 +398,10 @@ private function handleJobId() private function handleJobMerge() { - if (isset($this->restore_params['mergejobs']) && $this->restore_params['mergejobs'] == 1) { - $this->restore_params['jobids'] = $this->restore_params['jobid']; - } else { - try { - $this->restore_params['jobids'] = $this->getRestoreModel()->getJobIds($this->bsock, $this->restore_params['jobid'], $this->restore_params['mergefilesets']); - } catch (Exception $e) { - echo $e->getMessage(); - } + try { + $this->restore_params['jobids'] = $this->getRestoreModel()->getJobIds($this->bsock, $this->restore_params['jobid'], $this->restore_params['mergefilesets']); + } catch (Exception $e) { + echo $e->getMessage(); } } @@ -692,16 +688,16 @@ private function setRestoreParams() $this->restore_params['jobids'] = null; } - if ($this->params()->fromQuery('mergefilesets')) { + if ($this->params()->fromQuery('mergefilesets') !== null) { $this->restore_params['mergefilesets'] = $this->params()->fromQuery('mergefilesets'); } else { - $this->restore_params['mergefilesets'] = 0; + $this->restore_params['mergefilesets'] = $_SESSION['bareos']['merge_filesets'] ? 1 : 0; } - if ($this->params()->fromQuery('mergejobs')) { + if ($this->params()->fromQuery('mergejobs') !== null) { $this->restore_params['mergejobs'] = $this->params()->fromQuery('mergejobs'); } else { - $this->restore_params['mergejobs'] = 0; + $this->restore_params['mergejobs'] = $_SESSION['bareos']['merge_jobs'] ? 1 : 0; } if ($this->params()->fromQuery('replace')) { @@ -721,6 +717,7 @@ private function setRestoreParams() } else { $this->restore_params['versions'] = null; } + } /** diff --git a/webui/module/Restore/src/Restore/Form/RestoreForm.php b/webui/module/Restore/src/Restore/Form/RestoreForm.php index a42834b2023..529fc2da9b4 100644 --- a/webui/module/Restore/src/Restore/Form/RestoreForm.php +++ b/webui/module/Restore/src/Restore/Form/RestoreForm.php @@ -261,8 +261,8 @@ public function __construct($restore_params = null, $clients = null, $filesets = 'options' => array( 'label' => _('Merge all client filesets'), 'value_options' => array( - '0' => _('Yes'), - '1' => _('No') + '1' => _('Yes'), + '0' => _('No') ) ), 'attributes' => array( @@ -280,14 +280,14 @@ public function __construct($restore_params = null, $clients = null, $filesets = 'options' => array( 'label' => _('Merge all client filesets'), 'value_options' => array( - '0' => _('Yes'), - '1' => _('No') + '1' => _('Yes'), + '0' => _('No') ) ), 'attributes' => array( 'class' => 'form-control selectpicker show-tick', 'id' => 'mergefilesets', - 'value' => '0', + 'value' => $_SESSION['bareos']['merge_filesets'] ? 1 : 0, 'disabled' => true ) ) @@ -303,8 +303,8 @@ public function __construct($restore_params = null, $clients = null, $filesets = 'options' => array( 'label' => _('Merge all related jobs to last full backup of selected backup job'), 'value_options' => array( - '0' => _('Yes'), - '1' => _('No') + '1' => _('Yes'), + '0' => _('No') ) ), 'attributes' => array( @@ -322,14 +322,14 @@ public function __construct($restore_params = null, $clients = null, $filesets = 'options' => array( 'label' => _('Merge jobs'), 'value_options' => array( - '0' => _('Yes'), - '1' => _('No') + '1' => _('Yes'), + '0' => _('No') ) ), 'attributes' => array( 'class' => 'form-control selectpicker show-tick', 'id' => 'mergejobs', - 'value' => '0', + 'value' => $_SESSION['bareos']['merge_jobs'] ? 1 : 0, 'disabled' => true ) ) diff --git a/webui/module/Restore/src/Restore/Model/RestoreModel.php b/webui/module/Restore/src/Restore/Model/RestoreModel.php index 436688357cd..eb927ba2fe1 100644 --- a/webui/module/Restore/src/Restore/Model/RestoreModel.php +++ b/webui/module/Restore/src/Restore/Model/RestoreModel.php @@ -195,21 +195,21 @@ public function getRestoreJobResources(&$bsock = null, $restorejobs = null) * * @return array */ - public function getJobIds(&$bsock = null, $jobid = null, $mergefilesets = 0, $mergejobs = 0) + public function getJobIds(&$bsock = null, $jobid = null, $mergefilesets = 1, $mergejobs = 1) { - if (isset($bsock)) { - if ($mergefilesets == 1 && $mergejobs == 1) { + if (isset($bsock) && isset($jobid)) { + if ($mergejobs == 0) { return $jobid; } - if ($mergefilesets == 0) { + if ($mergefilesets == 1) { $cmd = '.bvfs_get_jobids jobid=' . $jobid . ' all'; } else { - $cmd = '.bvfs_get_jobids jobid=' . $jobid . ''; + $cmd = '.bvfs_get_jobids jobid=' . $jobid; } $result = $bsock->send_command($cmd, 2); $jobids = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY); $result = ""; - if (!empty($jobids['result'])) { + if (isset($jobids['result']['jobids'])) { $i = count($jobids['result']['jobids']); foreach ($jobids['result']['jobids'] as $jobid) { $result .= $jobid['id']; diff --git a/webui/module/Restore/view/restore/restore/index.phtml b/webui/module/Restore/view/restore/restore/index.phtml index c8423349401..8e38fd80043 100644 --- a/webui/module/Restore/view/restore/restore/index.phtml +++ b/webui/module/Restore/view/restore/restore/index.phtml @@ -337,21 +337,8 @@ $this->headTitle($title); p['where'] = 'restore_params['where']; ?>'; p['pluginoptions'] = 'restore_params['pluginoptions']; ?>'; p['fileset'] = 'restore_params['fileset']; ?>'; - - if(k === 'mergejobs' && v === '1') { - p['mergefilesets'] = '1'; - } - else { - p['mergefilesets'] = 'restore_params['mergefilesets']; ?>'; - } - - if(k === 'mergefilesets' && v === '0') { - p['mergejobs'] = '0'; - } - else { - p['mergejobs'] = 'restore_params['mergejobs']; ?>'; - } - + p['mergefilesets'] = 'restore_params['mergefilesets']; ?>'; + p['mergejobs'] = 'restore_params['mergejobs']; ?>'; p['limit'] = 'restore_params['limit']; ?>'; p[k] = v; @@ -411,7 +398,7 @@ $this->headTitle($title); 'data' : function (node) { return { 'id' : node.id }; }, - timeout: , + 'timeout': , }, }, 'state' : { diff --git a/webui/module/Restore/view/restore/restore/versions.phtml b/webui/module/Restore/view/restore/restore/versions.phtml index dc8494028ad..8288d8dcd2d 100644 --- a/webui/module/Restore/view/restore/restore/versions.phtml +++ b/webui/module/Restore/view/restore/restore/versions.phtml @@ -487,19 +487,8 @@ function updateRestoreParams(k, v) { p['where'] = 'restore_params['where']; ?>'; p['pluginoptions'] = 'restore_params['pluginoptions']; ?>'; p['fileset'] = 'restore_params['fileset']; ?>'; - - if (k === 'mergejobs' && v === '1') { - p['mergefilesets'] = '1'; - } else { - p['mergefilesets'] = 'restore_params['mergefilesets']; ?>'; - } - - if (k === 'mergefilesets' && v === '0') { - p['mergejobs'] = '0'; - } else { - p['mergejobs'] = 'restore_params['mergejobs']; ?>'; - } - + p['mergefilesets'] = 'restore_params['mergefilesets']; ?>'; + p['mergejobs'] = 'restore_params['mergejobs']; ?>'; p['limit'] = 'restore_params['limit']; ?>'; p[k] = v; @@ -557,7 +546,7 @@ function showFileTree() { 'state': {'checkbox_disabled': true} }; }, - timeout: , + 'timeout': , }, }, 'state' : { diff --git a/webui/public/js/bootstrap-table-formatter.js b/webui/public/js/bootstrap-table-formatter.js index 297e37a1f75..67650f82851 100644 --- a/webui/public/js/bootstrap-table-formatter.js +++ b/webui/public/js/bootstrap-table-formatter.js @@ -512,7 +512,7 @@ function scheduleActionButtonsFormatter(value, row, index, basePath) { function jobActionButtonsFormatter(value, row, index, basePath) { let jobDetailsButton = ''; let jobRerunButton = ''; - let jobRestoreButton = ''; + let jobRestoreButton = ''; let jobCancelButton = ''; switch(row.jobstatus) { From ccf136aa245bce5e7e9de43f4bc91eee224a9bd6 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Thu, 13 Apr 2023 14:33:01 +0200 Subject: [PATCH 2/3] docs: update BareosWebui.rst --- .../source/IntroductionAndTutorial/BareosWebui.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/manuals/source/IntroductionAndTutorial/BareosWebui.rst b/docs/manuals/source/IntroductionAndTutorial/BareosWebui.rst index abdae728860..d87509f68d5 100644 --- a/docs/manuals/source/IntroductionAndTutorial/BareosWebui.rst +++ b/docs/manuals/source/IntroductionAndTutorial/BareosWebui.rst @@ -519,6 +519,14 @@ Some parameters of the |webui| can be configured in :file:`/etc/bareos-webui/con ; Default: ;filetree_refresh_timeout=120000 + ; Merge jobs on client selection + ; Default: + ;merge_jobs=true + + ; Merge filesets on client selection + ; Default: + ;merge_filesets=true + ;------------------------------------------------------------------------------ ; THEME SETTINGS ;------------------------------------------------------------------------------ From 445acaa771991420946bbba79bb37ff4cb101f3a Mon Sep 17 00:00:00 2001 From: Joerg Steffens Date: Tue, 25 Apr 2023 12:52:03 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 379ae7240b1..c7a08345668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https: - daemons: remove deprecated `Pid Directory` config option, and update `Maximum Concurrent Jobs` default value to 1 [PR #1426] - build: switch to FreeBSD 12.4 [PR #1440] - webui: create internal api module [PR #1447] +- webui: make restore merge options configurable [PR #1445] ### Removed - remove no longer used pkglists [PR #1335] @@ -143,5 +144,6 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https: [PR #1429]: https://github.com/bareos/bareos/pull/1429 [PR #1439]: https://github.com/bareos/bareos/pull/1439 [PR #1440]: https://github.com/bareos/bareos/pull/1440 +[PR #1445]: https://github.com/bareos/bareos/pull/1445 [PR #1447]: https://github.com/bareos/bareos/pull/1447 [unreleased]: https://github.com/bareos/bareos/tree/master