diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 000000000..dfa4cd630
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1,7 @@
+## Approach
+- Read existing files before writing. Don't re-read unless changed.
+- Thorough in reasoning, concise in output.
+- Skip files over 100KB unless required.
+- No sycophantic openers or closing fluff.
+- No emojis or em-dashes.
+- Do not guess APIs, versions, flags, commit SHAs, or package names. Verify by reading code or docs before asserting.
\ No newline at end of file
diff --git a/www/controllers/Layout/Chart/vars/repo-storage-chart.vars.inc.php b/www/controllers/Layout/Chart/vars/repo-storage-chart.vars.inc.php
deleted file mode 100644
index 8d08c2b30..000000000
--- a/www/controllers/Layout/Chart/vars/repo-storage-chart.vars.inc.php
+++ /dev/null
@@ -1,44 +0,0 @@
- 0 && $diskUsedSpacePercent <= 30) {
- $datasets[0]['colors'][] = '#15bf7f';
- $datasets[0]['colors'][] = 'rgba(21, 191, 127, 0.40)';
-}
-if ($diskUsedSpacePercent > 30 && $diskUsedSpacePercent <= 50) {
- $datasets[0]['colors'][] = '#ffb536';
- $datasets[0]['colors'][] = 'rgba(255, 181, 54, 0.40)';
-}
-if ($diskUsedSpacePercent > 50 && $diskUsedSpacePercent <= 70) {
- $datasets[0]['colors'][] = '#ff7c49';
- $datasets[0]['colors'][] = 'rgba(255, 124, 73, 0.40)';
-}
-if ($diskUsedSpacePercent > 70 && $diskUsedSpacePercent <= 100) {
- $datasets[0]['colors'][] = '#F32F63';
- $datasets[0]['colors'][] = 'rgba(243, 47, 99, 0.40)';
-}
-
-$options['innerRadius'] = '65%';
-$options['outerRadius'] = '99%';
-$options['toolbox']['show'] = false;
-$options['legend']['show'] = false;
-$options['tooltip']['show'] = false;
-$options['emphasis']['disabled'] = true;
-
-unset($diskTotalSpace, $diskFreeSpace, $diskUsedSpace);
diff --git a/www/controllers/Layout/Container/vars/hosts/overview.vars.inc.php b/www/controllers/Layout/Container/vars/hosts/overview.vars.inc.php
index 6780808f8..c7f5fa5a4 100644
--- a/www/controllers/Layout/Container/vars/hosts/overview.vars.inc.php
+++ b/www/controllers/Layout/Container/vars/hosts/overview.vars.inc.php
@@ -1,27 +1,61 @@
get();
-/**
- * Getting total hosts
- */
-$totalHosts = count($hostListingController->get());
+// Getting total hosts
+$totalHosts = count($hosts);
-/**
- * Getting a list of all hosts kernel
- */
+// Getting a list of all host kernels and sort them by count desc
$kernels = $hostListingController->getKernel();
array_multisort(array_column($kernels, 'Count'), SORT_DESC, $kernels);
-/**
- * Getting a list of all hosts profiles
- */
+// Getting a list of all host profiles and sort them by count desc
$profiles = $hostListingController->getProfile();
array_multisort(array_column($profiles, 'Count'), SORT_DESC, $profiles);
-/**
- * Getting a list of all hosts requiring a reboot
- */
+// Getting a list of all hosts requiring a reboot
$rebootRequiredList = $hostListingController->getRebootRequired();
$rebootRequiredCount = count($rebootRequiredList);
-unset($hostListingController);
+// Getting general hosts threshold settings
+$hostsSettings = $hostController->getSettings();
+
+// Threshold of the maximum number of available update above which the host is considered as 'not up to date' (but not critical)
+$packagesCountConsideredOutdated = $hostsSettings['pkgs_count_considered_outdated'];
+
+// Loop through the list of hosts to determine the number of hosts up to date and not up to date
+foreach ($hosts as $host) {
+ // Open the dedicated database of the host from its ID to be able to retrieve additional information
+ $hostPackageController = new Package($host['Id']);
+
+ // Retrieve the total number of available packages
+ $packagesAvailableTotal = count($hostPackageController->getAvailable());
+
+ // Retrieve the total number of installed packages
+ $packagesInstalledTotal = count($hostPackageController->getInstalled());
+
+ /**
+ * If the total number of available packages retrieved previously is > $packagesCountConsideredOutdated (threshold defined by the user) then we increment $totalOutdated (counts the number of hosts that are not up to date in the chartjs)
+ * Else it's $totalUptodate that we increment.
+ */
+ if ($packagesAvailableTotal >= $packagesCountConsideredOutdated) {
+ $totalOutdated++;
+ } else {
+ $totalUptodate++;
+ }
+}
+
+// Calculation of the compliance percent (number of hosts up to date / total number of hosts * 100)
+if ($totalHosts > 0) {
+ $compliancePercent = round(($totalUptodate / $totalHosts) * 100);
+}
+
+unset($hostController, $hostListingController, $hostPackageController, $hosts, $hostsSettings, $packagesCountConsideredOutdated, $packagesAvailableTotal, $packagesInstalledTotal);
diff --git a/www/controllers/Layout/Container/vars/repos/list.vars.inc.php b/www/controllers/Layout/Container/vars/repos/list.vars.inc.php
index 6c618f2ce..0f06ac089 100644
--- a/www/controllers/Layout/Container/vars/repos/list.vars.inc.php
+++ b/www/controllers/Layout/Container/vars/repos/list.vars.inc.php
@@ -1,4 +1,6 @@
$group['Name'],
+ 'repos' => [],
+ 'count' => 0,
+ 'show' => $show
+ ];
+ }
+
+ foreach ($myrepoListing->listByGroup($group['Name']) as $repo) {
+ // Add the whole repo to the repos array
+ $repos[] = $repo;
+
+ // Add the repoId to the group if not already in the group repos (to avoid duplicate repos in the same group)
+ if (!in_array($repo['repoId'], $groups[$group['Id']]['repos'])) {
+ $groups[$group['Id']]['repos'][] = $repo['repoId'];
+ }
+
+ // Add 1 to the group count only if the repoId is different from the previous one
+ if ($previousId != $repo['repoId']) {
+ $groups[$group['Id']]['count']++;
+ }
+
+ // TODO: If the repository is in the user permissions, then the group become showable for the user
+
+ $previousId = $repo['repoId'];
+ }
+
+
+
+}
+
unset($groupController, $repoController, $taskController, $diskTotalSpace, $diskFreeSpace, $diskUsedSpace, $data);
diff --git a/www/controllers/Layout/Container/vars/tasks/tasks.vars.inc.php b/www/controllers/Layout/Container/vars/tasks/tasks.vars.inc.php
new file mode 100644
index 000000000..9c6f3507f
--- /dev/null
+++ b/www/controllers/Layout/Container/vars/tasks/tasks.vars.inc.php
@@ -0,0 +1,13 @@
+get());
+
+// Get running tasks
+$runningCount = count($taskListingController->getRunning());
+
+// Get scheduled tasks
+$scheduledCount = count($taskListingController->getScheduled());
+
+unset($taskListingController);
diff --git a/www/controllers/Layout/Panel/vars/repos/edit.vars.inc.php b/www/controllers/Layout/Panel/vars/repos/edit.vars.inc.php
index a429abbd0..b09ef5662 100644
--- a/www/controllers/Layout/Panel/vars/repos/edit.vars.inc.php
+++ b/www/controllers/Layout/Panel/vars/repos/edit.vars.inc.php
@@ -14,7 +14,7 @@
* Check that action and repos params have been sent
*/
if (empty($item['repos'])) {
- throw new Exception('Task repositories required');
+ throw new Exception('Repositories required');
}
$slidePanelTitle = 'EDIT REPOSITORY & SNAPSHOT PROPERTIES';
diff --git a/www/controllers/Layout/Panel/vars/repos/install.vars.inc.php b/www/controllers/Layout/Panel/vars/repos/install.vars.inc.php
index 767fb96f4..0f7f94515 100644
--- a/www/controllers/Layout/Panel/vars/repos/install.vars.inc.php
+++ b/www/controllers/Layout/Panel/vars/repos/install.vars.inc.php
@@ -1,33 +1,28 @@
existsId($repo['repo-id'])) {
throw new Exception('Repository Id #' . $repo['repo-id'] . ' does not exist');
}
@@ -45,14 +38,10 @@
throw new Exception('Snapshot Id #' . $repo['snap-id'] . ' does not exist');
}
- /**
- * Retrieve all repo data from the Ids
- */
+ // Retrieve all repo data from the Ids
$repoController->getAllById($repo['repo-id'], $repo['snap-id']);
- /**
- * Retrieve the package type of the repo
- */
+ // Retrieve the package type of the repo
$packageType = $repoController->getPackageType();
$packagesTypes[] = $packageType; ?>
@@ -67,20 +56,23 @@
echo '
-
- = strtoupper($packageType) ?>
+
+ = strtoupper($packageType) ?>
-
+
+ Alternative syntax (deb822):
+
-
+
get('rename', json_decode($item['repos'], true));
+} catch (JsonException $e) {
+ throw new Exception('Error while retrieving the form content: ' . $e->getMessage());
+}
diff --git a/www/controllers/Layout/Tab/Run.php b/www/controllers/Layout/Tab/Run.php
index 94ea57c5d..b96d1f47d 100644
--- a/www/controllers/Layout/Tab/Run.php
+++ b/www/controllers/Layout/Tab/Run.php
@@ -2,20 +2,27 @@
namespace Controllers\Layout\Tab;
-use Controllers\User\Permission\Task as TaskPermission;
-use Controllers\Layout\Container\Render;
-
class Run
{
public static function render()
{
- // If user is not allowed to see tasks, redirect to home page
- if (!TaskPermission::allowed()) {
- header('Location: /');
+ /**
+ * /run now redirects to "/tasks", which is the main page for task management
+ * If it is followed by an ID (ex: /run/123), then redirects to /task/123
+ */
+ $currentPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
+
+ // If the path is exactly "/run", redirect to "/tasks"
+ if ($currentPath === '/run') {
+ header('Location: /tasks');
exit;
}
- Render::render('tasks/log');
- Render::render('tasks/list');
+ // If the path starts with "/run/" followed by an ID, redirect to "/task/{ID}"
+ if (preg_match('#^/run/(\d+)$#', $currentPath, $matches)) {
+ $taskId = $matches[1];
+ header('Location: /task/' . $taskId);
+ exit;
+ }
}
}
diff --git a/www/controllers/Layout/Tab/Task.php b/www/controllers/Layout/Tab/Task.php
new file mode 100644
index 000000000..a16e499cd
--- /dev/null
+++ b/www/controllers/Layout/Tab/Task.php
@@ -0,0 +1,20 @@
+ 1) {
- $output .= '';
+ $output .= '';
}
// First page button (n°1)
@@ -92,7 +92,7 @@ public static function paginationBtn($currentPage, $totalPages)
// Next button
if ($currentPage < $totalPages) {
- $output .= '';
+ $output .= '';
}
echo $output;
diff --git a/www/controllers/Repo/Deb.php b/www/controllers/Repo/Deb.php
index f16885657..5534e98ab 100644
--- a/www/controllers/Repo/Deb.php
+++ b/www/controllers/Repo/Deb.php
@@ -20,14 +20,6 @@ public function getIdByNameDistComponent(string $name, string $distribution, str
return $this->model->getIdByNameDistComponent($name, $distribution, $component);
}
- /**
- * Return repository environment description
- */
- public function getDescriptionByName(string $name, string $dist, string $component, string $env) : string|null
- {
- return $this->model->getDescriptionByName($name, $dist, $component, $env);
- }
-
/**
* Return environment Id from repo name
*/
diff --git a/www/controllers/Repo/Environment.php b/www/controllers/Repo/Environment.php
index f99a3f937..db6f0077c 100644
--- a/www/controllers/Repo/Environment.php
+++ b/www/controllers/Repo/Environment.php
@@ -38,19 +38,6 @@ public function remove(int $id) : void
$this->model->remove($id);
}
- /**
- * Update environment description
- */
- public function updateDescription(int $id, string $description) : void
- {
- // Description should not contain single quotes or backslashes
- if (str_contains($description, "'") || str_contains($description, "\\") || str_contains($description, '') || str_contains($description, '?>')) {
- throw new Exception('Description contains invalid characters');
- }
-
- $this->model->updateDescription($id, Validate::string($description));
- }
-
/**
* Return true if the repository environment Id exists
*/
diff --git a/www/controllers/Repo/Package/Sync.php b/www/controllers/Repo/Package/Sync.php
index bad8438bf..e3b8bb086 100644
--- a/www/controllers/Repo/Package/Sync.php
+++ b/www/controllers/Repo/Package/Sync.php
@@ -58,12 +58,12 @@ private function syncPackage()
if ($this->repoSnapshotController->getDateById($this->repoController->getSnapId()) != $this->repoController->getDate()) {
if ($this->repoController->getPackageType() == 'rpm') {
if ($this->rpmRepoController->existsSnapDate($this->repoController->getName(), $this->repoController->getReleasever(), $this->repoController->getDate())) {
- throw new Exception('A snapshot already exists on the ' . Label::black($this->repoController->getDateFormatted()));
+ throw new Exception('A snapshot already exists on the ' . Label::white($this->repoController->getDateFormatted()));
}
}
if ($this->repoController->getPackageType() == 'deb') {
if ($this->debRepoController->existsSnapDate($this->repoController->getName(), $this->repoController->getDist(), $this->repoController->getSection(), $this->repoController->getDate())) {
- throw new Exception('A snapshot already exists on the ' . Label::black($this->repoController->getDateFormatted()));
+ throw new Exception('A snapshot already exists on the ' . Label::white($this->repoController->getDateFormatted()));
}
}
}
diff --git a/www/controllers/Repo/Repo.php b/www/controllers/Repo/Repo.php
index eb34138d1..3856a1d39 100644
--- a/www/controllers/Repo/Repo.php
+++ b/www/controllers/Repo/Repo.php
@@ -533,4 +533,17 @@ public function updateSource(int $repoId, string $source): void
{
$this->model->updateSource($repoId, $source);
}
+
+ /**
+ * Update description
+ */
+ public function updateDescription(int $id, string $description) : void
+ {
+ // Description should not contain single quotes or backslashes
+ if (str_contains($description, "'") || str_contains($description, "\\") || str_contains($description, '') || str_contains($description, '?>')) {
+ throw new Exception('Description contains invalid characters');
+ }
+
+ $this->model->updateDescription($id, Validate::string($description));
+ }
}
diff --git a/www/controllers/Repo/Rpm.php b/www/controllers/Repo/Rpm.php
index 264c8ad41..f15c34232 100644
--- a/www/controllers/Repo/Rpm.php
+++ b/www/controllers/Repo/Rpm.php
@@ -20,14 +20,6 @@ public function getIdByNameReleasever(string $name, string $releaseVersion) : in
return $this->model->getIdByNameReleasever($name, $releaseVersion);
}
- /**
- * Return repository environment description
- */
- public function getDescriptionByName(string $name, string $releaseVersion, string $env) : string|null
- {
- return $this->model->getDescriptionByName($name, $releaseVersion, $env);
- }
-
/**
* Return environment Id from repo name
*/
diff --git a/www/controllers/Repo/Task/Create.php b/www/controllers/Repo/Task/Create.php
index cd9f25a87..de1bbef55 100644
--- a/www/controllers/Repo/Task/Create.php
+++ b/www/controllers/Repo/Task/Create.php
@@ -38,6 +38,9 @@ public function __construct(string $taskId)
// Set repo type for the task to be executed
$this->type = $this->params['repo-type'];
+ // Set
+ // $this->repoController->setAdvancedParams($this->params['advanced-params']);
+
// Execute the task
try {
$this->execute();
diff --git a/www/controllers/Repo/Task/Env.php b/www/controllers/Repo/Task/Env.php
index 4d9634645..8f507e6a1 100644
--- a/www/controllers/Repo/Task/Env.php
+++ b/www/controllers/Repo/Task/Env.php
@@ -67,27 +67,6 @@ public function execute()
}
}
- /**
- * If the user did not specify any description then we get the one currently in place on the environment of the same name (if the environment exists and if it has a description)
- */
- if (empty($this->repoController->getDescription())) {
- if ($this->repoController->getPackageType() == 'rpm') {
- $actualDescription = $this->rpmRepoController->getDescriptionByName($this->repoController->getName(), $this->repoController->getReleasever(), $env);
- }
- if ($this->repoController->getPackageType() == 'deb') {
- $actualDescription = $this->debRepoController->getDescriptionByName($this->repoController->getName(), $this->repoController->getDist(), $this->repoController->getSection(), $env);
- }
-
- /**
- * If the description is empty then the description will remain empty
- */
- if (!empty($actualDescription)) {
- $this->repoController->setDescription(htmlspecialchars_decode($actualDescription));
- } else {
- $this->repoController->setDescription('');
- }
- }
-
$this->taskLogSubStepController->completed();
$this->taskLogSubStepController->new('create-symlink-' . $env, 'CREATING SYMLINK');
diff --git a/www/controllers/Repo/Task/Finalize.php b/www/controllers/Repo/Task/Finalize.php
index aad2e24f8..a21c648b3 100644
--- a/www/controllers/Repo/Task/Finalize.php
+++ b/www/controllers/Repo/Task/Finalize.php
@@ -122,23 +122,6 @@ protected function finalize()
$this->taskLogSubStepController->new('adding-env', 'ADDING ENVIRONMENT');
foreach ($this->repoController->getEnv() as $env) {
- // If the user has not specified any description, then we retrieve the one currently in place on the environment of the same name (if the environment exists and if it has a description)
- if (empty($this->repoController->getDescription())) {
- if ($this->repoController->getPackageType() == 'rpm') {
- $actualDescription = $this->rpmRepoController->getDescriptionByName($this->repoController->getName(), $this->repoController->getReleasever(), $env);
- }
- if ($this->repoController->getPackageType() == 'deb') {
- $actualDescription = $this->debRepoController->getDescriptionByName($this->repoController->getName(), $this->repoController->getDist(), $this->repoController->getSection(), $env);
- }
-
- // If the retrieved description is empty then the description will remain empty
- if (!empty($actualDescription)) {
- $this->repoController->setDescription(htmlspecialchars_decode($actualDescription));
- } else {
- $this->repoController->setDescription('');
- }
- }
-
// Retrieve the Id of the environment currently in place (if there is one)
if ($this->repoController->getPackageType() == 'rpm') {
$actualEnvIds = $this->rpmRepoController->getEnvIdFromRepoName($this->repoController->getName(), $this->repoController->getReleasever(), $env);
diff --git a/www/controllers/Repo/Task/Rebuild.php b/www/controllers/Repo/Task/Rebuild.php
index c74aa37bf..1303d956c 100644
--- a/www/controllers/Repo/Task/Rebuild.php
+++ b/www/controllers/Repo/Task/Rebuild.php
@@ -36,6 +36,12 @@ public function __construct(string $taskId)
*/
public function execute()
{
+ // TODO debug
+ // while (true) {
+ // sleep(5);
+ // }
+
+
/**
* Set snapshot metadata rebuild state in database
*/
diff --git a/www/controllers/Task/Form/Form.php b/www/controllers/Task/Form/Form.php
index fab2243f5..58b7b82f8 100644
--- a/www/controllers/Task/Form/Form.php
+++ b/www/controllers/Task/Form/Form.php
@@ -3,6 +3,7 @@
namespace Controllers\Task\Form;
use Exception;
+use Controllers\User\User;
use Controllers\Repo\Repo;
use Controllers\Utils\Validate;
use Controllers\Repo\Environment;
@@ -18,7 +19,7 @@ class Form
*/
public function get(string $action, array $repos) : string
{
- $userController = new \Controllers\User\User();
+ $userController = new User();
$usersEmail = $userController->getEmails();
$content = '