-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJobController.php
45 lines (35 loc) · 1.29 KB
/
JobController.php
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
<?php
/* Icinga for Kubernetes Web | (c) 2023 Icinga GmbH | AGPLv3 */
namespace Icinga\Module\Kubernetes\Controllers;
use Icinga\Module\Kubernetes\Common\Auth;
use Icinga\Module\Kubernetes\Common\Database;
use Icinga\Module\Kubernetes\Model\Job;
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\JobDetail;
use Icinga\Module\Kubernetes\Web\JobList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;
class JobController extends Controller
{
public function indexAction(): void
{
$this->assertPermission(Auth::SHOW_JOBS);
$this->addTitleTab($this->translate('Job'));
$uuid = $this->params->getRequired('id');
$uuidBytes = Uuid::fromString($uuid)->getBytes();
$job = Auth::getInstance()
->withRestrictions(Auth::SHOW_JOBS, Job::on(Database::connection()))
->filter(Filter::equal('uuid', $uuidBytes))
->first();
if ($job === null) {
$this->httpNotFound($this->translate('Job not found'));
}
$this->addControl(
(new JobList([$job]))
->setActionList(false)
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
);
$this->addContent(new JobDetail($job));
}
}