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

🚜 fix(fai) Use an objectType for packages

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

issue #6007
parent 25e429c7
......@@ -88,6 +88,6 @@ class argonautQueueFilter extends managementFilter
$entries[$dn]->aclBase = $acl_base;
}
return [$entries, ['argonautTask' => count($entries)]];
return [$entries, ['ARGONAUTTASK' => count($entries)]];
}
}
......@@ -21,9 +21,23 @@
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 */
public static $columns = [
//~ ['ObjectTypeColumn', []],
['ObjectTypeColumn', []],
['LinkColumn', ['attributes' => 'PACKAGE', 'label' => 'Package']],
['LinkColumn', ['attributes' => 'VERSION', 'label' => 'Version']],
];
......@@ -58,12 +72,12 @@ class packageSelectManagement extends selectManagement
$this->filter = new packageSelectManagementFilter($this, TRUE, $filterElementDefinitions);
}
public function getCustomReleases(): array
public function getCustomReleases (): array
{
return serviceRepository::getCustomReleases($this->parentPlugin->FAIdebianRelease);
}
public function getRelease(): string
public function getRelease (): string
{
return $this->parentPlugin->FAIdebianRelease;
}
......
......@@ -25,47 +25,54 @@ class packageSelectManagementFilter extends managementFilter
{
$filterElementDefinitions[] = ['PackageSelectCustomFilterElement', []];
parent::__construct ($parent, $fixedScope, $filterElementDefinitions);
parent::__construct($parent, $fixedScope, $filterElementDefinitions);
}
function query (array $attrs, string $base): array
{
//~ static function query ($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = '')
$customs = [];
$this->filterElements[0]->getFilters('faiRepositoryPackage', $customs);
$entries = [];
$row = 0;
$q = new supportDaemon();
$filter = [$this->search];
$attrs = ['distribution', 'package', 'version', 'section', 'timestamp'];
$release = $this->parent->getRelease();
$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);
$objectTypeCount = [];
$entries = [];
$row = 0;
$q = new supportDaemon();
$filter = [$this->search];
$attrs = ['distribution', 'package', 'version', 'section', 'timestamp'];
$release = $this->parent->getRelease();
foreach ($this->parent->objectTypes as $type) {
if (!$this->types['filter_type_'.$type]['show']) {
continue;
}
foreach ($ret as $attr) {
if (in_array($attr['PACKAGE'], $this->parent->blackList['PACKAGE'])) {
continue;
$customs = [];
$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 = [];
foreach ($attr as $key => $value) {
$item[$key] = [$value];
$objectTypeCount[$type] = count($ret);
foreach ($ret as $attr) {
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

    • 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. Merge this if statement with the enclosing one. 📘
Markdown is supported
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