]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add to config API endpoint parameter to apply jobdefs in results
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 13 Jul 2021 02:48:23 +0000 (04:48 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Tue, 13 Jul 2021 02:48:23 +0000 (04:48 +0200)
gui/baculum/protected/API/Class/BaculaSetting.php
gui/baculum/protected/API/Pages/API/Config.php

index 375dc58874cf0c43901675396289305985e241ef..4e2d046e2ff905c73f85f69072c60b2947f4be52 100644 (file)
@@ -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);
        }
index e7cf9d7c6ba958a1d8d53471093976e6ea0e414c..c74a6e78ec1592a922206485212ea8085451b276 100644 (file)
@@ -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'];
        }