summaryrefslogtreecommitdiffstats
path: root/application/controllers/ServicesController.php
blob: 0914aa2e335dcb907670d0d5ce366887d8de22af (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
<?php

// Icinga Web 2 Cube Module | (c) 2019 Icinga GmbH | GPLv2

namespace Icinga\Module\Cube\Controllers;

use Icinga\Module\Cube\IcingaDb\IcingaDbCube;
use Icinga\Module\Cube\IcingaDb\IcingaDbServiceStatusCube;
use Icinga\Module\Cube\Web\Controller;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions;

class ServicesController extends Controller
{
    public function indexAction(): void
    {
        $this->createTabs()->activate('cube/services');

        $this->renderCube();
    }

    protected function getCube(): IcingaDbCube
    {
        return new IcingaDbServiceStatusCube();
    }

    public function completeAction(): void
    {
        $suggestions = new ObjectSuggestions();
        $suggestions->setModel(Service::class);
        $suggestions->forRequest($this->getServerRequest());
        $this->getDocument()->add($suggestions);
    }

    public function searchEditorAction(): void
    {
        $editor = $this->createSearchEditor(
            Service::on($this->getDb()),
            $this->preserveParams
        );

        $this->getDocument()->add($editor);
        $this->setTitle($this->translate('Adjust Filter'));
    }
}