From 2f21cf48d2861d83621ca66bb49e98e6deb56ccf Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 4 Apr 2011 13:50:16 +0000 Subject: [PATCH] Updated Config Management git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20648 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../class_ConfigManagementListing.inc | 22 ++++- .../class_newConfigManagement.inc | 95 +++++++++++++------ .../goto/Config/TemplateEngine.tpl | 11 +++ .../goto/Config/puppet.tpl | 39 ++++++++ 4 files changed, 136 insertions(+), 31 deletions(-) create mode 100644 gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/TemplateEngine.tpl create mode 100644 gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/puppet.tpl diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc index 8c3ea548a..762353f43 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc @@ -63,6 +63,20 @@ class ConfigManagementListing extends management $this->objectTypeStr = $str; } + + // Inject user actions + function detectPostActions() + { + $action = management::detectPostActions(); + if(isset($_POST['saveItemEdit'])) $action['action'] = "saveItemChanges"; + if(isset($_POST['saveItemAdd'])) $action['action'] = "saveItemAdd"; + if(isset($_POST['cancelItemEdit'])) $action['action'] = "cancelItemEdit"; + if(isset($_POST['cancelItemAdd'])) $action['action'] = "cancelItemAdd"; + return($action); + } + + + function execute() { @@ -171,6 +185,9 @@ class ConfigManagementListing extends management $this->registerAction("saveFilter","saveFilter"); $this->registerAction("cancelFilter","cancelFilter"); + $this->registerAction("cancelItemEdit", "closeDialogs"); + $this->registerAction("cancelItemAdd", "closeDialogs"); + $this->registerAction("saveItemAdd", "saveItemAdd"); } function removeEntryRequested($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") @@ -185,7 +202,10 @@ class ConfigManagementListing extends management function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { - $this->parent->editEntry($target); + $this->dialogObject = $this->parent->TemplateEngine; + $this->skipFooter = TRUE; + $this->dialog = TRUE; + } } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc index 5b2a60f2e..f3d169819 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc @@ -21,6 +21,11 @@ class newConfigManagement extends plugin $this->config = &$config; $this->listing = new ConfigManagementListing($this->config, get_userinfo(), $this); + // Load the template engine and tell her what template + // to use for the HTML it produces. + $this->TemplateEngine = new TemplateEngine($config); + $this->TemplateEngine->setTemplate('puppet.tpl'); + // Request an update of the data model $this->loadInstallationMethods(); $this->updateDataModel(); @@ -28,6 +33,45 @@ class newConfigManagement extends plugin } + /*! \brief Sets the installation method to the given method. + * Updates the template engine and adds the initial root + * object for the selected method. + * @param The method to use. + * @return TRUE on success else FALSE. + */ + function setInstallMethod($str) + { + if(!isset($this->installationMethods[$str])){ + $this->itemConfig = array(); + $this->invalidInstallMethod =TRUE; + $this->errorMessage = sprintf(_("Invalid installation method %s selected!"), bold($str)); + msg_dialog::display(_("Setup"), $this->errorMessage, ERROR_DIALOG); + return(FALSE); + }else{ + + $this->itemConfig = $this->installationMethods[$str]['items']; + $this->invalidInstallMethod =FALSE; + $this->TemplateEngine->load($this->itemConfig); + + // Detect root item, its name is / + $root = NULL; + foreach($this->itemConfig as $key => $item){ + if($item['name'] == '/') { + $root = $key; + break; + } + } + if(!$root){ + $this->errorMessage = sprintf(_("Installation method %s is invalid: no root object found!"), bold($str)); + msg_dialog::display(_("Setup"), $this->errorMessage , ERROR_DIALOG); + $this->initFailed = TRUE; + $this->itemConfig = array(); + return(FALSE); + } + } + } + + /*! \brief Updates all distributions, releases, packages and items in the dataModel * Load information from the backend. */ @@ -160,6 +204,9 @@ class newConfigManagement extends plugin // Transfer checked values back to the listing class. $this->listing->setContainers($this->getContainerList()); $this->listing->setContainer($cont); + + $this->setInstallMethod('puppet'); + } @@ -303,36 +350,9 @@ class newConfigManagement extends plugin */ function editEntry($ids) { - foreach($ids as $id){ - echo "
Edit {$id}"; - } - } - - - /*! \brief Acts on remove requests. - * (This action is received from the ConfigManagementListing class.) - * @param Array The items ids. (May contain multiple ids) - * @return - */ - function removeEntry($ids) - { - foreach($ids as $id){ - echo "
Remove {$id}"; - } - } - - - /*! \brief Acts on open requests. - * (This action is received from the ConfigManagementListing class.) - * @param Array The items ids. (May contain multiple ids) - * @return - */ - function openEntry($ids) - { - $id = $ids[0]; - $item = $this->dataModel->getItemById($id); - $this->setCurrentContainer($item['path']); - return; + // Update the template engine to use another type of item and + // some other values. + $this->TemplateEngine->setValues('PuppetTemplate',array('data' => array())); } @@ -356,6 +376,21 @@ class newConfigManagement extends plugin } + /*! \brief Acts on open requests. + * (This action is received from the ConfigManagementListing class.) + * @param Array The items ids. (May contain multiple ids) + * @return + */ + function openEntry($ids) + { + $id = $ids[0]; + $item = $this->dataModel->getItemById($id); + $this->setCurrentContainer($item['path']); + return; + } + + + /*! \brief * @param * @return diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/TemplateEngine.tpl b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/TemplateEngine.tpl new file mode 100644 index 000000000..e60c5ae1c --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/TemplateEngine.tpl @@ -0,0 +1,11 @@ +

Bla

+ +{$template} + +
+ +
+ + +
+ diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/puppet.tpl b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/puppet.tpl new file mode 100644 index 000000000..8b8d95b56 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/puppet.tpl @@ -0,0 +1,39 @@ +{if $type == 'PuppetModule'} + + + + + +
+ + + + + + + + + + + + + +
{$nameName}{$name}
{$descriptionName}{$description}
{$versionName}{$version}
+
+ {$dependencyName}:
+ {$dependency} +
+{/if} +{if $type == 'PuppetTemplate'} + + + + + + + + + +
{$nameName}{$name}
{$dataName}{$data}
+ +{/if} -- 2.30.2