summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Widget/ItemList/CommandTransportListItem.php
blob: 9873403b5f7abe4495e3f40d46beb113f584dcea (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
70
71
<?php

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

namespace Icinga\Module\Icingadb\Widget\ItemList;

use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Stdlib\Filter;
use ipl\Web\Common\BaseOrderedListItem;
use ipl\Web\Url;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\Link;

class CommandTransportListItem extends BaseOrderedListItem
{
    protected function init(): void
    {
        $this->list->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name));
    }

    protected function assembleHeader(BaseHtmlElement $header): void
    {
    }

    protected function assembleMain(BaseHtmlElement $main): void
    {
        $main->addHtml(new Link(
            new HtmlElement('strong', null, Text::create($this->item->name)),
            Url::fromPath('icingadb/command-transport/show', ['name' => $this->item->name])
        ));

        $main->addHtml(new Link(
            new Icon('trash', ['title' => sprintf(t('Remove command transport "%s"'), $this->item->name)]),
            Url::fromPath('icingadb/command-transport/remove', ['name' => $this->item->name]),
            [
                'class' => 'pull-right action-link',
                'data-icinga-modal' => true,
                'data-no-icinga-ajax' => true
            ]
        ));

        if ($this->getOrder() + 1 < $this->list->count()) {
            $main->addHtml((new Link(
                new Icon('arrow-down'),
                Url::fromPath('icingadb/command-transport/sort', [
                    'name'  => $this->item->name,
                    'pos'   => $this->getOrder() + 1
                ]),
                ['class' => 'pull-right action-link']
            ))->setBaseTarget('_self'));
        }

        if ($this->getOrder() > 0) {
            $main->addHtml((new Link(
                new Icon('arrow-up'),
                Url::fromPath('icingadb/command-transport/sort', [
                    'name'  => $this->item->name,
                    'pos'   => $this->getOrder() - 1
                ]),
                ['class' => 'pull-right action-link']
            ))->setBaseTarget('_self'));
        }
    }

    protected function createVisual(): ?BaseHtmlElement
    {
        return null;
    }
}