From f12f10e3ea4c16fe2b0ade1fa4c60a484baab49f Mon Sep 17 00:00:00 2001 From: Ludovic <54670129+lbr38@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:51:12 +0100 Subject: [PATCH] patch --- www/controllers/Task/Log/Step.php | 18 ++++++++- www/controllers/Task/Repo/Create.php | 12 +++--- www/controllers/Task/Repo/Delete.php | 8 ++-- www/controllers/Task/Repo/Duplicate.php | 10 ++--- www/controllers/Task/Repo/Env.php | 14 +++---- www/controllers/Task/Repo/Finalize.php | 4 +- www/controllers/Task/Repo/Metadata/Create.php | 2 +- www/controllers/Task/Repo/Package/Sign.php | 2 +- www/controllers/Task/Repo/Package/Sync.php | 2 +- www/controllers/Task/Repo/Rebuild.php | 4 +- www/controllers/Task/Repo/RemoveEnv.php | 10 ++--- www/controllers/Task/Repo/Update.php | 4 +- www/models/Connection.php | 1 - .../resources/js/events/task/actions.js | 7 +++- .../includes/containers/tasks/log.inc.php | 23 +++++++----- .../containers/tasks/log/step.inc.php | 37 +++++++++++++------ www/views/templates/tasks/duplicate.inc.php | 29 ++++++++++----- www/views/templates/tasks/env.inc.php | 2 +- 18 files changed, 118 insertions(+), 71 deletions(-) diff --git a/www/controllers/Task/Log/Step.php b/www/controllers/Task/Log/Step.php index 9437e745..415e80d1 100644 --- a/www/controllers/Task/Log/Step.php +++ b/www/controllers/Task/Log/Step.php @@ -23,10 +23,26 @@ public function new(string $identifier, string $title) : void $this->model->new($this->taskId, $identifier, $title); } + /** + * Set the latest step with no status (none) + */ + public function none(string $message = '') : void + { + /** + * Get latest step Id from database + */ + $stepId = $this->getLatestStepId($this->taskId); + + /** + * Mark step as completed in database + */ + $this->model->status($stepId, 'none', $message); + } + /** * Set the latest step as completed */ - public function completed(string|null $message = null) : void + public function completed(string $message = '') : void { /** * Get latest step Id from database diff --git a/www/controllers/Task/Repo/Create.php b/www/controllers/Task/Repo/Create.php index 6a228224..00cae965 100644 --- a/www/controllers/Task/Repo/Create.php +++ b/www/controllers/Task/Repo/Create.php @@ -182,13 +182,13 @@ private function mirror() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } @@ -361,7 +361,7 @@ private function local() \Controllers\Filesystem\File::recursiveChown(REPOS_DIR . '/' . $this->repo->getName(), WWW_USER, 'repomanager'); } - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * Add repo to group if a group has been specified @@ -369,7 +369,7 @@ private function local() if (!empty($this->repo->getGroup())) { $this->loggingStepController->new('add-to-group', 'ADDING REPOSITORY TO GROUP'); $this->repo->addRepoIdToGroup($this->repo->getRepoId(), $this->repo->getGroup()); - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } /** @@ -395,13 +395,13 @@ private function local() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } } diff --git a/www/controllers/Task/Repo/Delete.php b/www/controllers/Task/Repo/Delete.php index 109f5575..8a6e035b 100644 --- a/www/controllers/Task/Repo/Delete.php +++ b/www/controllers/Task/Repo/Delete.php @@ -100,7 +100,7 @@ public function execute() throw new Exception('Cannot delete snapshot of the ' . $this->repo->getDateFormatted() . ''); } - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * Set snapshot status to 'deleted' in database @@ -154,7 +154,7 @@ public function execute() */ $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); - } catch (\Exception $e) { + } catch (Exception $e) { // Set step error message $this->loggingStepController->error($e->getMessage()); @@ -167,13 +167,13 @@ public function execute() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } } diff --git a/www/controllers/Task/Repo/Duplicate.php b/www/controllers/Task/Repo/Duplicate.php index 99ed431d..98be296b 100644 --- a/www/controllers/Task/Repo/Duplicate.php +++ b/www/controllers/Task/Repo/Duplicate.php @@ -152,7 +152,7 @@ public function execute() throw new Exception('Could not copy data from the source repo to the new repo'); } - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * On a deb repo, the duplicated repo metadata must be rebuilded @@ -256,7 +256,7 @@ public function execute() \Controllers\Filesystem\File::recursiveChown(REPOS_DIR . '/' . $this->repo->getName() . '/' . $this->repo->getDist() . '/' . $this->repo->getDateFormatted() . '_' . $this->repo->getSection(), WWW_USER, 'repomanager'); } - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * Add the new repo to a group if a group has been specified @@ -269,7 +269,7 @@ public function execute() */ $this->repo->addRepoIdToGroup($targetRepoId, $this->repo->getGroup()); - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } /** @@ -295,13 +295,13 @@ public function execute() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } } diff --git a/www/controllers/Task/Repo/Env.php b/www/controllers/Task/Repo/Env.php index 09884c36..ac6a1031 100644 --- a/www/controllers/Task/Repo/Env.php +++ b/www/controllers/Task/Repo/Env.php @@ -162,7 +162,7 @@ public function execute() /** * Close current step */ - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * Case 2: There is already an environment of the same name pointing to a snapshot. @@ -206,7 +206,7 @@ public function execute() /** * Close current step */ - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } } @@ -242,7 +242,7 @@ public function execute() /** * Close current step */ - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * Case 2: There is already an environment of the same name pointing to a snapshot. @@ -286,7 +286,7 @@ public function execute() /** * Close current step */ - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } } @@ -310,7 +310,7 @@ public function execute() /** * Close current step */ - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * Cleaning of unused snapshots @@ -345,13 +345,13 @@ public function execute() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } } diff --git a/www/controllers/Task/Repo/Finalize.php b/www/controllers/Task/Repo/Finalize.php index a4ca386c..f3ea75ff 100644 --- a/www/controllers/Task/Repo/Finalize.php +++ b/www/controllers/Task/Repo/Finalize.php @@ -211,7 +211,7 @@ protected function finalize() \Controllers\Filesystem\File::recursiveChown(REPOS_DIR . '/' . $this->repo->getName(), WWW_USER, 'repomanager'); } - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); /** * Ajout du repo à un groupe si un groupe a été renseigné. @@ -220,7 +220,7 @@ protected function finalize() if ($this->task->getAction() == 'create' and !empty($this->repo->getGroup())) { $this->loggingStepController->new('adding-to-group', 'ADDING REPOSITORY TO GROUP'); $this->repo->addRepoIdToGroup($this->repo->getRepoId(), $this->repo->getGroup()); - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } /** diff --git a/www/controllers/Task/Repo/Metadata/Create.php b/www/controllers/Task/Repo/Metadata/Create.php index 2bb21d84..239d95fc 100644 --- a/www/controllers/Task/Repo/Metadata/Create.php +++ b/www/controllers/Task/Repo/Metadata/Create.php @@ -117,6 +117,6 @@ private function createMetadata() } } - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } } diff --git a/www/controllers/Task/Repo/Package/Sign.php b/www/controllers/Task/Repo/Package/Sign.php index 47e5b93e..a73f16d0 100644 --- a/www/controllers/Task/Repo/Package/Sign.php +++ b/www/controllers/Task/Repo/Package/Sign.php @@ -186,6 +186,6 @@ private function signPackage() // Set the main substep as completed $this->loggingSubStepController->completed('', 'sign-packages'); - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } } diff --git a/www/controllers/Task/Repo/Package/Sync.php b/www/controllers/Task/Repo/Package/Sync.php index ff72005d..0a05543e 100644 --- a/www/controllers/Task/Repo/Package/Sync.php +++ b/www/controllers/Task/Repo/Package/Sync.php @@ -321,6 +321,6 @@ private function syncPackage() throw new Exception($e->getMessage()); } - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } } diff --git a/www/controllers/Task/Repo/Rebuild.php b/www/controllers/Task/Repo/Rebuild.php index 178d431d..3edfcefc 100644 --- a/www/controllers/Task/Repo/Rebuild.php +++ b/www/controllers/Task/Repo/Rebuild.php @@ -131,13 +131,13 @@ public function execute() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } } diff --git a/www/controllers/Task/Repo/RemoveEnv.php b/www/controllers/Task/Repo/RemoveEnv.php index 3c1aa19c..c544ba4d 100644 --- a/www/controllers/Task/Repo/RemoveEnv.php +++ b/www/controllers/Task/Repo/RemoveEnv.php @@ -94,7 +94,7 @@ public function execute() */ $this->repo->removeEnv($this->repo->getEnvId()); - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); $this->loggingStepController->new('cleaning', 'CLEANING'); @@ -111,7 +111,7 @@ public function execute() if (!empty($snapshotsRemoved)) { $this->loggingStepController->completed($snapshotsRemoved); } else { - $this->loggingStepController->completed('Done'); + $this->loggingStepController->completed(); } /** @@ -119,7 +119,7 @@ public function execute() */ $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); - } catch (\Exception $e) { + } catch (Exception $e) { // Set step error message $this->loggingStepController->error($e->getMessage()); @@ -132,13 +132,13 @@ public function execute() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } } diff --git a/www/controllers/Task/Repo/Update.php b/www/controllers/Task/Repo/Update.php index c0864abe..def244ed 100644 --- a/www/controllers/Task/Repo/Update.php +++ b/www/controllers/Task/Repo/Update.php @@ -164,13 +164,13 @@ public function execute() /** * Get total duration */ - $duration = $this->task->getDuration(); + $duration = \Controllers\Common::convertMicrotime($this->task->getDuration()); /** * End task */ $this->loggingStepController->new('duration', 'DURATION'); - $this->loggingStepController->completed('Total duration: ' . $duration); + $this->loggingStepController->none('Total duration: ' . $duration); $this->task->end(); } } diff --git a/www/models/Connection.php b/www/models/Connection.php index 1af508ae..d84188cc 100644 --- a/www/models/Connection.php +++ b/www/models/Connection.php @@ -990,7 +990,6 @@ private function generateTaskLogTables() End VARCHAR(255), Duration VARCHAR(255), Message VARCHAR(255), - Error_message VARCHAR(255), Task_id INTEGER)"); // substeps table diff --git a/www/public/resources/js/events/task/actions.js b/www/public/resources/js/events/task/actions.js index 61931d8b..1d86012a 100644 --- a/www/public/resources/js/events/task/actions.js +++ b/www/public/resources/js/events/task/actions.js @@ -30,8 +30,11 @@ $(document).on('click','.show-step-content-btn',function () { $(document).on('click','.show-task-btn',function () { var taskId = $(this).attr('task-id'); - // Go to task page - window.location.href = '/run/' + taskId; + // Change URL without reloading the page + history.pushState(null, null, '/run/' + taskId); + + // Reload task container + reloadContainer('tasks/log'); }); /** diff --git a/www/views/includes/containers/tasks/log.inc.php b/www/views/includes/containers/tasks/log.inc.php index 8d864df3..8f9973b4 100644 --- a/www/views/includes/containers/tasks/log.inc.php +++ b/www/views/includes/containers/tasks/log.inc.php @@ -17,16 +17,19 @@ -
- -
- -
- -
- +
+ +
+ +
+ +
+ diff --git a/www/views/includes/containers/tasks/log/step.inc.php b/www/views/includes/containers/tasks/log/step.inc.php index 8bc8a001..e670e29d 100644 --- a/www/views/includes/containers/tasks/log/step.inc.php +++ b/www/views/includes/containers/tasks/log/step.inc.php @@ -11,6 +11,7 @@ if ($step['status'] == 'error' or $step['status'] == 'stopped') { $titleClass = 'bkg-red'; } + // If the step is completed, the title will be green if ($step['status'] == 'completed') { $titleClass = 'bkg-green'; @@ -26,26 +27,40 @@

Running

'; + $icon = 'loading.svg'; + $message = 'Running'; } if ($step['status'] == 'completed') { - echo '

Completed

'; + $icon = 'check.svg'; + $message = 'Completed'; } if ($step['status'] == 'stopped') { - echo '

Task stopped by the user

'; + $icon = 'warning-red.svg'; + $message = 'Task stopped by the user'; } if ($step['status'] == 'error') { - echo ''; - - if (!empty($step['error-message'])) { - echo '

' . $step['error-message'] . '

'; - } else { - echo '

Error

'; - } - } ?> + $icon = 'error.svg'; + $message = 'Error'; + } + + // If the step has no status, hide the icon, this is mostly used for the DURATION step + if ($step['status'] == 'none') { + $icon = null; + } + + // If a custom message is set, use it + if (!empty($step['message'])) { + $message = $step['message']; + } + + if ($icon != null) { + echo ''; + } + + echo '

' . $message . '

'; ?>
diff --git a/www/views/templates/tasks/duplicate.inc.php b/www/views/templates/tasks/duplicate.inc.php index 37a6a1a9..e2d9b30d 100644 --- a/www/views/templates/tasks/duplicate.inc.php +++ b/www/views/templates/tasks/duplicate.inc.php @@ -16,11 +16,11 @@

sourceRepo->getPackageType() == 'rpm') { - echo $this->sourceRepo->getName(); + if ($repoController->getPackageType() == 'rpm') { + echo $repoController->getName(); } - if ($this->sourceRepo->getPackageType() == 'deb') { - echo $this->sourceRepo->getName() . ' ❯ ' . $this->sourceRepo->getDist() . ' ❯ ' . $this->sourceRepo->getSection(); + if ($repoController->getPackageType() == 'deb') { + echo $repoController->getName() . ' ❯ ' . $repoController->getDist() . ' ❯ ' . $repoController->getSection(); } ?>

@@ -29,7 +29,7 @@
SNAPSHOT

- sourceRepo->getDateFormatted() ?> + getDateFormatted() ?>

@@ -40,15 +40,26 @@

sourceRepo->getPackageType() == 'rpm') { - echo $repoController->getName(); + if ($repoController->getPackageType() == 'rpm') { + echo $rawParams['name']; } - if ($this->sourceRepo->getPackageType() == 'deb') { - echo $repoController->getName() . ' ❯ ' . $this->sourceRepo->getDist() . ' ❯ ' . $this->sourceRepo->getSection(); + if ($repoController->getPackageType() == 'deb') { + echo $rawParams['name'] . ' ❯ ' . $repoController->getDist() . ' ❯ ' . $repoController->getSection(); } ?>

+ + +
+
POINT AN ENVIRONMENT
+

+ +

+
+
diff --git a/www/views/templates/tasks/env.inc.php b/www/views/templates/tasks/env.inc.php index 93577707..b7b9e082 100644 --- a/www/views/templates/tasks/env.inc.php +++ b/www/views/templates/tasks/env.inc.php @@ -38,7 +38,7 @@
ENVIRONMENT

- getEnv()) ?> +