From f66ab8dae2f3d0418759f81a3a64dc9517a62449 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:31 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- library/Director/Web/Widget/JobDetails.php | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 library/Director/Web/Widget/JobDetails.php (limited to 'library/Director/Web/Widget/JobDetails.php') diff --git a/library/Director/Web/Widget/JobDetails.php b/library/Director/Web/Widget/JobDetails.php new file mode 100644 index 0000000..3a530a2 --- /dev/null +++ b/library/Director/Web/Widget/JobDetails.php @@ -0,0 +1,69 @@ +get('run_interval'); + if ($job->hasBeenDisabled()) { + $this->add(Hint::error(sprintf( + $this->translate( + 'This job would run every %ds. It has been disabled and will' + . ' therefore not be executed as scheduled' + ), + $runInterval + ))); + } else { + //$class = $job->job(); echo $class::getDescription() + $msg = $job->isPending() + ? sprintf( + $this->translate('This job runs every %ds and is currently pending'), + $runInterval + ) + : sprintf( + $this->translate('This job runs every %ds.'), + $runInterval + ); + $this->add(Html::tag('p', null, $msg)); + } + + $tsLastAttempt = $job->get('ts_last_attempt'); + if ($tsLastAttempt) { + $ts = \strtotime($tsLastAttempt); + $timeAgo = Html::tag('span', [ + 'class' => 'time-ago', + 'title' => DateFormatter::formatDateTime($ts) + ], DateFormatter::timeAgo($ts)); + if ($job->get('last_attempt_succeeded') === 'y') { + $this->add(Hint::ok(Html::sprintf( + $this->translate('The last attempt succeeded %s'), + $timeAgo + ))); + } else { + $this->add(Hint::error(Html::sprintf( + $this->translate('The last attempt failed %s: %s'), + $timeAgo, + $job->get('last_error_message') + ))); + } + } else { + $this->add(Hint::warning($this->translate('This job has not been executed yet'))); + } + } +} -- cgit v1.2.3