Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Dec 30, 2024
1 parent a9449b3 commit f12f10e
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 71 deletions.
18 changes: 17 additions & 1 deletion www/controllers/Task/Log/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions www/controllers/Task/Repo/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -361,15 +361,15 @@ 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
*/
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();
}

/**
Expand All @@ -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();
}
}
8 changes: 4 additions & 4 deletions www/controllers/Task/Repo/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function execute()
throw new Exception('Cannot delete snapshot of the <span class="label-black">' . $this->repo->getDateFormatted() . '</span>');
}

$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();

/**
* Set snapshot status to 'deleted' in database
Expand Down Expand Up @@ -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());

Expand All @@ -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();
}
}
10 changes: 5 additions & 5 deletions www/controllers/Task/Repo/Duplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -269,7 +269,7 @@ public function execute()
*/
$this->repo->addRepoIdToGroup($targetRepoId, $this->repo->getGroup());

$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();
}

/**
Expand All @@ -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();
}
}
14 changes: 7 additions & 7 deletions www/controllers/Task/Repo/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -206,7 +206,7 @@ public function execute()
/**
* Close current step
*/
$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();
}
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -286,7 +286,7 @@ public function execute()
/**
* Close current step
*/
$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();
}
}

Expand All @@ -310,7 +310,7 @@ public function execute()
/**
* Close current step
*/
$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();

/**
* Cleaning of unused snapshots
Expand Down Expand Up @@ -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();
}
}
4 changes: 2 additions & 2 deletions www/controllers/Task/Repo/Finalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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é.
Expand All @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion www/controllers/Task/Repo/Metadata/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ private function createMetadata()
}
}

$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();
}
}
2 changes: 1 addition & 1 deletion www/controllers/Task/Repo/Package/Sign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion www/controllers/Task/Repo/Package/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,6 @@ private function syncPackage()
throw new Exception($e->getMessage());
}

$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();
}
}
4 changes: 2 additions & 2 deletions www/controllers/Task/Repo/Rebuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
10 changes: 5 additions & 5 deletions www/controllers/Task/Repo/RemoveEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -111,15 +111,15 @@ public function execute()
if (!empty($snapshotsRemoved)) {
$this->loggingStepController->completed($snapshotsRemoved);
} else {
$this->loggingStepController->completed('Done');
$this->loggingStepController->completed();
}

/**
* Set task status to done
*/
$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());

Expand All @@ -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();
}
}
4 changes: 2 additions & 2 deletions www/controllers/Task/Repo/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
1 change: 0 additions & 1 deletion www/models/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions www/public/resources/js/events/task/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

/**
Expand Down
23 changes: 13 additions & 10 deletions www/views/includes/containers/tasks/log.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
<?php
endif;

if (!empty($_COOKIE['autoscroll']) and $_COOKIE['autoscroll'] == 'true') : ?>
<div id="autoscroll-btn" class="round-btn-green pointer margin-bottom-15" title="Disable auto scroll">
<img src="/assets/icons/pause.svg" />
</div>
<?php
else : ?>
<div id="autoscroll-btn" class="round-btn-green pointer margin-bottom-15" title="Enable auto scroll">
<img src="/assets/icons/play.svg" />
</div>
<?php
// Print the auto scroll button only if the task is running
if ($taskInfo['Status'] == 'running') :
if (!empty($_COOKIE['autoscroll']) and $_COOKIE['autoscroll'] == 'true') : ?>
<div id="autoscroll-btn" class="round-btn-green pointer margin-bottom-15" title="Disable auto scroll">
<img src="/assets/icons/pause.svg" />
</div>
<?php
else : ?>
<div id="autoscroll-btn" class="round-btn-green pointer margin-bottom-15" title="Enable auto scroll">
<img src="/assets/icons/play.svg" />
</div>
<?php
endif;
endif ?>
</div>
</div>
Expand Down
Loading

0 comments on commit f12f10e

Please sign in to comment.