summaryrefslogtreecommitdiffstats
path: root/library/Director/Dashboard/Dashlet/EndpointObjectDashlet.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Dashboard/Dashlet/EndpointObjectDashlet.php')
-rw-r--r--library/Director/Dashboard/Dashlet/EndpointObjectDashlet.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/library/Director/Dashboard/Dashlet/EndpointObjectDashlet.php b/library/Director/Dashboard/Dashlet/EndpointObjectDashlet.php
new file mode 100644
index 0000000..9dd9467
--- /dev/null
+++ b/library/Director/Dashboard/Dashlet/EndpointObjectDashlet.php
@@ -0,0 +1,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;
+ }
+}