summaryrefslogtreecommitdiffstats
path: root/library/Director/Dashboard/Dashlet/EndpointObjectDashlet.php
blob: 9dd94674f2a5e808c84347b4905f71380c53d7f4 (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
<?php

namespace Icinga\Module\Director\Dashboard\Dashlet;

use Exception;

class EndpointObjectDashlet extends Dashlet
{
    protected $icon = 'cloud';

    protected $requiredStats = array('endpoint');

    protected $hasDeploymentEndpoint;

    public function getTitle()
    {
        return $this->translate('Endpoints');
    }

    public function getUrl()
    {
        return 'director/endpoints';
    }

    public function listRequiredPermissions()
    {
        return array('director/admin');
    }

    protected function hasDeploymentEndpoint()
    {
        if ($this->hasDeploymentEndpoint === null) {
            try {
                $this->hasDeploymentEndpoint = $this->db->hasDeploymentEndpoint();
            } catch (Exception $e) {
                return false;
            }
        }

        return $this->hasDeploymentEndpoint;
    }

    public function listCssClasses()
    {
        if (! $this->hasDeploymentEndpoint()) {
            return 'state-critical';
        }

        return null;
    }

    public function getSummary()
    {
        $msg = parent::getSummary();
        if (! $this->hasDeploymentEndpoint()) {
            $msg .= '. ' . $this->translate(
                'None could be used for deployments right now'
            );
        }

        return $msg;
    }
}