blob: 3a530a25b38abd6819b672ac761d83782fb15921 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?php
namespace Icinga\Module\Director\Web\Widget;
use gipfl\Web\Widget\Hint;
use Icinga\Date\DateFormatter;
use ipl\Html\HtmlDocument;
use Icinga\Module\Director\Objects\DirectorJob;
use ipl\Html\Html;
use gipfl\Translation\TranslationHelper;
class JobDetails extends HtmlDocument
{
use TranslationHelper;
/**
* JobDetails constructor.
* @param DirectorJob $job
* @throws \Icinga\Exception\NotFoundError
*/
public function __construct(DirectorJob $job)
{
$runInterval = $job->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')));
}
}
}
|