From: hickert Date: Fri, 22 Oct 2010 15:05:04 +0000 (+0000) Subject: Updated config management X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1045436387fa212d2db17b4f2c3d0eadc95a3f5e;p=gosa.git Updated config management -Dynamically load configItems git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20127 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl b/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl index b32482581..e4c7373b2 100644 --- a/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl +++ b/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl @@ -6,8 +6,8 @@ - - + + diff --git a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc index dcb5d598a..2f35075ec 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc @@ -68,6 +68,11 @@ class ConfigManagementDataModel } + function itemExistsByPath($path) + { + return(isset($this->data['linear'][$path])); + } + function getItemByPath($path) { if(isset($this->data['linear'][$path])){ @@ -76,6 +81,15 @@ class ConfigManagementDataModel return(NULL); } + function setItemStatus($path, $status) + { + if(!$this->itemExistsByPath($path)){ + trigger_error("Invalid item path '{$path}'!"); + }else{ + $this->data['linear'][$path]['status'] = $status; + } + } + function getItemsByType($type) { $res = array(); diff --git a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc index bad03f55b..427f02276 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc @@ -5,8 +5,8 @@ class ConfigManagementListing extends management private $base = ""; - private $distributionSelector = NULL; - private $releaseSelector = NULL; + private $containerSelector = NULL; + private $itemSelector = NULL; function __construct($config, $ui) @@ -15,47 +15,47 @@ class ConfigManagementListing extends management $this->storagePoints = array(""); $this->rebuildListing(); - $this->distributionSelector = new ItemSelector(array(),'/root','/root'); - $this->releaseSelector = new ItemSelector(array(),'/root','/root'); + $this->containerSelector = new ItemSelector(array(),'/root','/root'); + $this->itemSelector = new ItemSelector(array(),'/root','/root'); } function save_object() { - $this->distributionSelector->update(); - $this->releaseSelector->update(); + $this->containerSelector->update(); + $this->itemSelector->update(); } - function getSelectedDistribution() + function getSelectedContainer() { - return($this->distributionSelector->getBase()); + return($this->containerSelector->getBase()); } - function setDistribution($dist) + function setContainer($dist) { - return($this->distributionSelector->setBase($dist)); + return($this->containerSelector->setBase($dist)); } - function setRelease($rel) + function setItem($rel) { - return($this->releaseSelector->setBase($rel)); + return($this->itemSelector->setBase($rel)); } - function getSelectedRelease() + function getSelectedItem() { - return($this->releaseSelector->getBase()); + return($this->itemSelector->getBase()); } - function setDistributions($distributions) + function setContainers($containers) { - $this->distributionSelector->setBases($distributions); - $this->distributionSelector->update(TRUE); + $this->containerSelector->setBases($containers); + $this->containerSelector->update(TRUE); } - function setReleases($releases) + function setItems($items) { - $this->releaseSelector->setBases($releases); - $this->releaseSelector->update(TRUE); + $this->itemSelector->setBases($items); + $this->itemSelector->update(TRUE); } function renderList() @@ -67,8 +67,8 @@ class ConfigManagementListing extends management $headpage->update(); $smarty = get_smarty(); - $smarty->assign("DISTRIBUTION", $this->distributionSelector->render()); - $smarty->assign("RELEASE", $this->releaseSelector->render()); + $smarty->assign("CONTAINER", $this->containerSelector->render()); + $smarty->assign("ITEM", $this->itemSelector->render()); $display = $headpage->render(); return($this->getHeader().$display); diff --git a/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc index 52b129e1b..8b7cf00d4 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc @@ -6,8 +6,8 @@ class newConfigManagement extends plugin var $plHeadline = "Config management"; var $plDescription = "Config management"; - var $selectedDistribution; - var $selectedRelease; + var $selectedContainer; + var $selectedItem; var $dataModel = NULL; var $listing = NULL; @@ -41,39 +41,17 @@ class newConfigManagement extends plugin return(NULL); } foreach($res as $dist){ - $this->dataModel->addItem('Distribution','/root', $dist); - - // Load the releases for the current distribution - $releases = $rpc->getReleases($dist); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), sprintf(_("Failed to load releases, error was '%s'!"), $rpc->get_error()),ERROR_DIALOG); - return(NULL); - } - foreach($releases as $release){ - $this->dataModel->addItem('Release',"/root/{$dist}", $release); - - // Load packages - $packages = $rpc->getPackages($release); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), sprintf(_("Failed to load packages, error was '%s'!"), $rpc->get_error()),ERROR_DIALOG); - return(NULL); - } - foreach($packages as $package){ - $this->dataModel->addItem('Package',"/root/{$dist}/{$release}", $package['name'], $package); - } - - // Load items - $items = $rpc->listConfigItems($release); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), sprintf(_("Failed to load items, error was '%s'!"), $rpc->get_error()),ERROR_DIALOG); - return(NULL); - } - foreach($items as $package){ - $this->dataModel->addItem('Item',"/root/{$dist}/{$release}", $package['name'], $package); + $this->dataModel->addItem('Distribution','/root', $dist['name'], $dist); + foreach($dist['releases'] as $release){ + $distPath = "/root/{$dist['name']}"; + $this->dataModel->addItem('Release',$distPath, $release['name'], $release); + + foreach($dist['components'] as $component){ + $comPath = "{$distPath}/{$release['name']}"; + $this->dataModel->addItem('Component',$comPath, $component['name'], $component); } } } - } @@ -88,27 +66,65 @@ class newConfigManagement extends plugin $this->listing->save_object(); // Get the selected distribution and release from the listing widget. - $this->selectedDistribution = $this->listing->getSelectedDistribution(); - $this->selectedRelease = $this->listing->getSelectedRelease(); - + $this->selectedContainer = $this->listing->getSelectedContainer(); + $this->selectedItem = $this->listing->getSelectedItem(); + // Get a list of all available distributions and releases. $distList = $this->getDistList(); - $releaseList = $this->getReleaseList(); + $releaseList = $this->getItemList(); // Ensure that we've valid values selected. - if(!isset($releaseList[$this->selectedRelease])){ + if(!isset($releaseList[$this->selectedItem])){ if(count($releaseList)){ - $this->selectedRelease = key($releaseList); + $this->selectedItem = key($releaseList); }else{ - $this->selectedRelease = ""; + $this->selectedItem = ""; } } + // Update list of items within the selected container. + $this->updateItemList($this->selectedContainer); + // Transfer checked values back to the listing class. - $this->listing->setDistribution($this->selectedDistribution); - $this->listing->setRelease($this->selectedRelease); - $this->listing->setDistributions($this->getDistList()); - $this->listing->setReleases($this->getReleaseList()); + $this->listing->setContainer($this->selectedContainer); + $this->listing->setItem($this->selectedItem); + $this->listing->setContainers($this->getDistList()); + $this->listing->setItems($this->getItemList()); + } + + + function updateItemList($path) + { + // Fist get Item and check if it is an release + if($this->dataModel->itemExistsByPath($path)){ + $data = $this->dataModel->getItemByPath($path); + + // Only releases can contain config-items. + if($data['type'] == 'Release' && $data['status'] != "fetched"){ + + $rpc = $this->config->getRpcHandle(); + $res = $rpc->listConfigItems($data['name']); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), + sprintf(_("Failed to load distributions, error was '%s'!"), + $rpc->get_error()),ERROR_DIALOG); + }else{ + $this->dataModel->setItemStatus($path, 'käse'); + foreach($res as $itemPath => $type){ + + // Make names dataModel conform + $itemPath = $path.preg_replace("/^\//","/root", $itemPath); + $name = preg_replace("/^.*\//","",$itemPath); + + $itemPath = preg_replace("/\/[^\/]*$/","", $itemPath); + + print_a(array($type, $itemPath, $name)); + + $this->dataModel->addItem($type, $itemPath, $name); + } + } + } + } } @@ -120,7 +136,7 @@ class newConfigManagement extends plugin // Get the selected release and store it in a session variable // to allow the configFilter to access it and display the // packages and items. - $item = $this->dataModel->getItemByPath($this->selectedRelease); + $item = $this->dataModel->getItemByPath($this->selectedItem); session::set('CONFIG_ITEM', $item); return($this->listing->renderList()); @@ -131,12 +147,12 @@ class newConfigManagement extends plugin * This list will then be used to generate the entries of the * ItemSelectors in the listing class. */ - function getReleaseList() + function getItemList() { $data = $this->dataModel->getItemByPath('/root'); return($this->__recurseItem($data)); $res = array(); - $dist = $this->selectedDistribution; + $dist = $this->selectedContainer; $list = $this->dataModel->getItemsByType('Release'); foreach($list as $base => $entry){ if($entry['parentPath'] != $dist) continue; @@ -152,7 +168,6 @@ class newConfigManagement extends plugin */ function getDistList() { - $data = $this->dataModel->getItemByPath('/root'); return($this->__recurseItem($data)); @@ -169,7 +184,7 @@ class newConfigManagement extends plugin function __recurseItem($item) { $res = array(); - $res[$item['path']] = $item['name']; + $res[$item['path']] = $item['type']; if(count($item['children'])){ foreach($item['children'] as $child){ $res = array_merge($res, $this->__recurseItem($child));
{$RELOAD}{t}Distribution{/t} {$DISTRIBUTION}{t}Release{/t} {$RELEASE}{t}Container{/t} {$CONTAINER}{t}Item{/t} {$ITEM} {$ACTIONS} {$FILTER}