summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Widget/ItemList/DowntimeList.php
blob: 591ad98448d486ec2260fd6c455487399333ba14 (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
<?php

/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Icingadb\Widget\ItemList;

use Icinga\Module\Icingadb\Common\CaptionDisabled;
use Icinga\Module\Icingadb\Common\DetailActions;
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Common\NoSubjectLink;
use Icinga\Module\Icingadb\Common\ObjectLinkDisabled;
use Icinga\Module\Icingadb\Common\TicketLinks;
use Icinga\Module\Icingadb\Common\ViewMode;
use ipl\Web\Common\BaseItemList;
use ipl\Web\Url;

class DowntimeList extends BaseItemList
{
    use CaptionDisabled;
    use NoSubjectLink;
    use ObjectLinkDisabled;
    use ViewMode;
    use TicketLinks;
    use DetailActions;

    protected $defaultAttributes = ['class' => 'downtime-list'];

    protected function getItemClass(): string
    {
        $viewMode = $this->getViewMode();

        $this->addAttributes(['class' => $viewMode]);

        if ($viewMode === 'minimal') {
            return DowntimeListItemMinimal::class;
        } elseif ($viewMode === 'detailed') {
            $this->removeAttribute('class', 'default-layout');
        }

        return DowntimeListItem::class;
    }

    protected function init(): void
    {
        $this->initializeDetailActions();
        $this->setMultiselectUrl(Links::downtimesDetails());
        $this->setDetailUrl(Url::fromPath('icingadb/downtime'));
    }
}