diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 7a9647c2..beff0ef7 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -22,6 +22,7 @@ class IndexController extends ActionController return; } + $this->view->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint(); $this->view->stats = $this->db()->getObjectSummary(); $this->view->undeployedActivities = $this->db()->countActivitiesSinceLastDeployedConfig(); if ((int) $this->view->stats['apiuser']->cnt_total === 0) { diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml index 814269a5..a9295dcb 100644 --- a/application/views/scripts/index/index.phtml +++ b/application/views/scripts/index/index.phtml @@ -99,7 +99,7 @@ $all = array( $this->translate('Deploy configuration to your Icinga nodes') => array( array('wrench', $this->translate('Deployment'), 'director/config/deployments', $this->translate('Manage deployments, access audit log and history') . pendingDeployments($this), $this->undeployedActivities ? 'warning' : 'ok'), array('lock-open-alt', $this->translate('Api users'), 'director/apiusers', statSummary($this, 'apiuser')), - array('cloud', $this->translate('Endpoints'), 'director/endpoints', statSummary($this, 'endpoint')), + array('cloud', $this->translate('Endpoints'), 'director/endpoints', statSummary($this, 'endpoint') . ( $this->hasDeploymentEndpoint ? '' : '. ' . $this->translate('None could be used for deployments right now')), $this->hasDeploymentEndpoint ? '' : 'critical'), array('globe', $this->translate('Zones'), 'director/zones', statSummary($this, 'zone')), ), $this->translate('Do more with your data') => array( diff --git a/library/Director/Db.php b/library/Director/Db.php index 53ba59fd..d1cdbe93 100644 --- a/library/Director/Db.php +++ b/library/Director/Db.php @@ -55,6 +55,25 @@ class Db extends DbConnection return $this->getSetting('default_global_zone', 'director-global'); } + public function hasDeploymentEndpoint() + { + $db = $this->db(); + $query = $db->select()->from( + array('z' => 'icinga_zone'), + array('cnt' => 'COUNT(*)') + )->join( + array('e' => 'icinga_endpoint'), + 'e.zone_id = z.id', + array() + )->join( + array('au' => 'icinga_apiuser'), + 'e.apiuser_id = au.id', + array() + )->where('z.object_name = ?', $this->getMasterZoneName()); + + return $db->fetchOne($query) > 0; + } + public function getDeploymentEndpointName() { $db = $this->db();