Verified Commit 20af914e authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:tractor: fix(fai) Use an objectType for packages

This will avoid problems and bring a bit more consistency to the UI

issue #6007
Showing with 57 additions and 36 deletions
+57 -36
...@@ -88,6 +88,6 @@ class argonautQueueFilter extends managementFilter ...@@ -88,6 +88,6 @@ class argonautQueueFilter extends managementFilter
$entries[$dn]->aclBase = $acl_base; $entries[$dn]->aclBase = $acl_base;
} }
return [$entries, ['argonautTask' => count($entries)]]; return [$entries, ['ARGONAUTTASK' => count($entries)]];
} }
} }
...@@ -21,9 +21,23 @@ ...@@ -21,9 +21,23 @@
class packageSelectManagement extends selectManagement class packageSelectManagement extends selectManagement
{ {
/* Create faiRepositoryPackage object type */
static function plInfo (): array
{
return [
'plShortName' => 'Package selection',
'plDescription' => 'Package selection for FAI package class',
'plObjectType' => ['faiRepositoryPackage' => [
'name' => _('Package'),
'aclCategory' => 'fai',
'icon' => 'geticon.php?context=applications&icon=fai-packages&size=16',
]],
];
}
/* Default columns */ /* Default columns */
public static $columns = [ public static $columns = [
//~ ['ObjectTypeColumn', []], ['ObjectTypeColumn', []],
['LinkColumn', ['attributes' => 'PACKAGE', 'label' => 'Package']], ['LinkColumn', ['attributes' => 'PACKAGE', 'label' => 'Package']],
['LinkColumn', ['attributes' => 'VERSION', 'label' => 'Version']], ['LinkColumn', ['attributes' => 'VERSION', 'label' => 'Version']],
]; ];
...@@ -58,12 +72,12 @@ class packageSelectManagement extends selectManagement ...@@ -58,12 +72,12 @@ class packageSelectManagement extends selectManagement
$this->filter = new packageSelectManagementFilter($this, TRUE, $filterElementDefinitions); $this->filter = new packageSelectManagementFilter($this, TRUE, $filterElementDefinitions);
} }
public function getCustomReleases(): array public function getCustomReleases (): array
{ {
return serviceRepository::getCustomReleases($this->parentPlugin->FAIdebianRelease); return serviceRepository::getCustomReleases($this->parentPlugin->FAIdebianRelease);
} }
public function getRelease(): string public function getRelease (): string
{ {
return $this->parentPlugin->FAIdebianRelease; return $this->parentPlugin->FAIdebianRelease;
} }
......
...@@ -25,47 +25,54 @@ class packageSelectManagementFilter extends managementFilter ...@@ -25,47 +25,54 @@ class packageSelectManagementFilter extends managementFilter
{ {
$filterElementDefinitions[] = ['PackageSelectCustomFilterElement', []]; $filterElementDefinitions[] = ['PackageSelectCustomFilterElement', []];
parent::__construct ($parent, $fixedScope, $filterElementDefinitions); parent::__construct($parent, $fixedScope, $filterElementDefinitions);
} }
function query (array $attrs, string $base): array function query (array $attrs, string $base): array
{ {
//~ static function query ($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = '') $objectTypeCount = [];
$customs = []; $entries = [];
$this->filterElements[0]->getFilters('faiRepositoryPackage', $customs); $row = 0;
$q = new supportDaemon();
$entries = []; $filter = [$this->search];
$row = 0; $attrs = ['distribution', 'package', 'version', 'section', 'timestamp'];
$q = new supportDaemon(); $release = $this->parent->getRelease();
$filter = [$this->search]; foreach ($this->parent->objectTypes as $type) {
$attrs = ['distribution', 'package', 'version', 'section', 'timestamp']; if (!$this->types['filter_type_'.$type]['show']) {
$release = $this->parent->getRelease(); continue;
$ret = $q->FAI_get_packages($release, $attrs, $filter, 0, 200);
if ($q->is_error()) {
msg_dialog::display(_('Infrastructure service'), msgPool::siError($q->get_error()), ERROR_DIALOG);
} else {
for ($i = 0;(count($ret) < 200) && ($i < count($customs));$i++) {
$ret2 = $q->FAI_get_packages($customs[$i], $attrs, $filter, 0, 200 - count($ret));
if ($q->is_error()) {
msg_dialog::display(_('Infrastructure service'), msgPool::siError($q->get_error()), ERROR_DIALOG);
return [];
}
$ret = array_merge($ret, $ret2);
} }
foreach ($ret as $attr) {
if (in_array($attr['PACKAGE'], $this->parent->blackList['PACKAGE'])) { $customs = [];
continue; $this->filterElements[0]->getFilters($type, $customs);
$ret = $q->FAI_get_packages($release, $attrs, $filter, 0, 200);
if ($q->is_error()) {
msg_dialog::display(_('Infrastructure service'), msgPool::siError($q->get_error()), ERROR_DIALOG);
} else {
for ($i = 0;(count($ret) < 200) && ($i < count($customs));$i++) {
$ret2 = $q->FAI_get_packages($customs[$i], $attrs, $filter, 0, 200 - count($ret));
if ($q->is_error()) {
msg_dialog::display(_('Infrastructure service'), msgPool::siError($q->get_error()), ERROR_DIALOG);
return [];
}
$ret = array_merge($ret, $ret2);
} }
$item = []; $objectTypeCount[$type] = count($ret);
foreach ($attr as $key => $value) { foreach ($ret as $attr) {
$item[$key] = [$value]; if (in_array($attr['PACKAGE'], $this->parent->blackList['PACKAGE'])) {
continue;
}
$item = [];
foreach ($attr as $key => $value) {
$item[$key] = [$value];
}
$dn = 'dn='.$attr['PACKAGE'].','.$attr['DISTRIBUTION'].','.$base;
$entries[$dn] = new ListingEntry($this->parent->listing, $type, $dn, $item, $row++);
$entries[$dn]->aclBase = $base;
} }
$dn = 'dn='.$attr['PACKAGE'].','.$attr['DISTRIBUTION'].','.$base;
$entries[$dn] = new ListingEntry($this->parent->listing, 'faiRepositoryPackage', $dn, $item, $row++);
$entries[$dn]->aclBase = $base;
} }
} }
return [$entries, ['faiRepositoryPackage' => count($entries)]]; return [$entries, $objectTypeCount];
} }
} }
  • SonarQube analysis reported 1 issue

    • :warning: 1 major

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. :warning: Merge this if statement with the enclosing one. :blue_book:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment