Code

Updated config management listing
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Apr 2011 09:21:04 +0000 (09:21 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Apr 2011 09:21:04 +0000 (09:21 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20652 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc

index 5ab5259728220275e6981783f649a6d5b4df3418..062d4681879094968d2d41a611cc6232e9cba6cd 100644 (file)
@@ -98,6 +98,15 @@ class ConfigManagementDataModel
         }
     }
 
+    function setItemValues($path, $values)
+    {
+        if(!$this->itemExistsByPath($path)){
+            trigger_error("Invalid item path '{$path}'!");
+        }else{
+            $this->data['linear'][$path]['values'] = $values;
+        }
+    }
+
     function getItemsByType($types)
     {
         $res = array();
index f6acaf539ae2cc966b1bedc89f8bedea439e9f86..ef0705cba199d441349004b550803edfecf5060f 100644 (file)
@@ -206,8 +206,8 @@ class ConfigManagementListing extends management
     function setDialogObject($o)
     {
         $this->dialogObject = &$o;
-        $this->listing->skipFooter = TRUE;
-        $this->listing->dialog = TRUE;
+        $this->skipFooter = TRUE;
+        $this->dialog = TRUE;
 
     }
 } 
index 1b6bba4b89f4a0e1b9e547c9bc8b0b7b910696ed..2633eda4004eec32ca3188d126358120b76e99ab 100644 (file)
@@ -25,9 +25,9 @@ class newConfigManagement extends plugin
         // 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->cfgTypeMap = array();
         $this->loadInstallationMethods();
         $this->updateDataModel();
         $this->listing->setListingTypes($this->getListingTypes());
@@ -49,7 +49,8 @@ class newConfigManagement extends plugin
             msg_dialog::display(_("Setup"), $this->errorMessage, ERROR_DIALOG);
             return(FALSE);
         }else{
-
+    
+            $this->TemplateEngine->setTemplate($str.".tpl");
             $this->itemConfig = $this->installationMethods[$str]['items'];
             $this->invalidInstallMethod =FALSE;
             $this->TemplateEngine->load($this->itemConfig);
@@ -89,7 +90,6 @@ class newConfigManagement extends plugin
             msg_dialog::display(_("Error"), sprintf(_("Failed to load distributions: %s"), $rpc->get_error()),ERROR_DIALOG);
             return(NULL);
         }else{
-            $this->cfgTypeMap = array();
             foreach($res as $dist){
                 $this->dataModel->addItem('Distribution','/root', $dist['name'], $dist);
                 $this->cfgTypeMap['/root/'.$dist['name']] = $dist['installation_method'];
@@ -304,6 +304,12 @@ class newConfigManagement extends plugin
             msg_dialog::display(_("Setup"), $this->errorMessage , ERROR_DIALOG);
             $this->initFailed = TRUE;
             return;
+        }else{
+            foreach($this->installationMethods as $method => $items){
+                foreach($items['items'] as $itemName => $item){
+                    $this->cfgTypeMap[$itemName] = $method;
+                }
+            }
         }
     }
 
@@ -396,20 +402,21 @@ class newConfigManagement extends plugin
         // Update the template engine to use another type of item and
         //  some other values.
         $item = $this->dataModel->getItemById($ids[0]);
+        $release = preg_replace("/^.*\//","",$item['values']['__release']);
+        $path = $item['values']['__path'];
+
+        // Load item values on demand
         if($item['status'] == '-'){
-            $release = preg_replace("/^.*\//","",$item['values']['__release']);
-            $path = $item['values']['__path'];
-            //$rpc = $this->config->getRpcHandle();
-            //$res = $rpc->getConfigItem();
-            $item['values']['distribution'] = 'debian';
-            $item['values']['dependency'] = array('debian');
-            $item['values']['version'] = '10.0.0';
-            $item['values']['name'] = $item['name'];
-            $item['values']['description'] = 'bla';
+            $rpc = $this->config->getRpcHandle();
+            $item['values']['itemValues'] = $rpc->getConfigItem($release, $path);
+            $this->dataModel->setItemStatus($item['path'], 'fetched');
+            $this->dataModel->setItemValues($item['path'], $item['values']);
         }
 
-        $this->TemplateEngine->setValues($item['type'],$item['values']);
+        $method = $this->cfgTypeMap[$item['type']];
+        $this->setInstallMethod($method);
+        echo $method;
+        $this->TemplateEngine->setValues($item['type'],$item['values']['itemValues']);
         $this->listing->setDialogObject($this->TemplateEngine);
     }