From: Marcin Haba Date: Tue, 13 Jul 2021 02:48:23 +0000 (+0200) Subject: baculum: Add to config API endpoint parameter to apply jobdefs in results X-Git-Tag: Release-11.0.6~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8383e2955d72178ae2cfa2ae108841a24f485ea;p=thirdparty%2Fbacula.git baculum: Add to config API endpoint parameter to apply jobdefs in results --- diff --git a/gui/baculum/protected/API/Class/BaculaSetting.php b/gui/baculum/protected/API/Class/BaculaSetting.php index 375dc5887..4e2d046e2 100644 --- a/gui/baculum/protected/API/Class/BaculaSetting.php +++ b/gui/baculum/protected/API/Class/BaculaSetting.php @@ -84,14 +84,14 @@ class BaculaSetting extends APIModule { return $types; } - public function getConfig($component_type = null, $resource_type = null, $resource_name = null) { + public function getConfig($component_type = null, $resource_type = null, $resource_name = null, $opts = []) { $this->checkConfigSupport($component_type); $config = array(); $json_tools = $this->Application->getModule('json_tools'); if (!is_null($component_type)) { // get resources config $params = array(); - if ($component_type == self::COMPONENT_DIR_TYPE) { + if ($component_type == self::COMPONENT_DIR_TYPE && (!key_exists('apply_jobdefs', $opts) || $opts['apply_jobdefs'] == false)) { $params['dont_apply_jobdefs'] = true; } if (!is_null($resource_type)) { @@ -188,6 +188,7 @@ class BaculaSetting extends APIModule { if (!is_null($resource_type) && !is_null($resource_name)) { // Update single resource in config + $config = $this->updateConfigResource($config_orig, $config_new, $resource_type, $resource_name); } elseif (count($config_orig) > 0 && !is_null($resource_type)) { // Update whole config @@ -200,7 +201,6 @@ class BaculaSetting extends APIModule { $config[$i] = $this->updateResource($config[$i], $config[$i]); } } - // Save config to file return $this->getModule('bacula_config')->setConfig($component_type, $config); } diff --git a/gui/baculum/protected/API/Pages/API/Config.php b/gui/baculum/protected/API/Pages/API/Config.php index e7cf9d7c6..c74a6e78e 100644 --- a/gui/baculum/protected/API/Pages/API/Config.php +++ b/gui/baculum/protected/API/Pages/API/Config.php @@ -31,11 +31,17 @@ Prado::using('Application.Common.Class.Errors'); */ class Config extends BaculumAPIServer { public function get() { + $misc = $this->getModule('misc'); $component_type = $this->Request->contains('component_type') ? $this->Request['component_type'] : null; $resource_type = $this->Request->contains('resource_type') ? $this->Request['resource_type'] : null; $resource_name = $this->Request->contains('resource_name') ? $this->Request['resource_name'] : null; + $apply_jobdefs = $this->Request->contains('apply_jobdefs') && $misc->isValidBoolean($this->Request['apply_jobdefs']) ? (bool)$this->Request['apply_jobdefs'] : null; + $opts = []; + if ($apply_jobdefs) { + $opts['apply_jobdefs'] = $apply_jobdefs; + } - $config = $this->getModule('bacula_setting')->getConfig($component_type, $resource_type, $resource_name); + $config = $this->getModule('bacula_setting')->getConfig($component_type, $resource_type, $resource_name, $opts); $this->output = $config['output']; $this->error = $config['exitcode']; }