2015-06-29 16:01:10 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
2015-06-30 11:27:32 +02:00
|
|
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
2015-06-29 16:01:10 +02:00
|
|
|
|
2015-12-18 09:01:25 +01:00
|
|
|
class IndexController extends ActionController
|
2015-06-29 16:01:10 +02:00
|
|
|
{
|
2015-12-16 11:45:00 +01:00
|
|
|
protected $globalTypes = array(
|
2015-12-18 09:01:25 +01:00
|
|
|
'ApiUser',
|
2015-12-16 11:45:00 +01:00
|
|
|
'Zone',
|
2015-12-18 09:01:25 +01:00
|
|
|
'Endpoint',
|
|
|
|
'TimePeriod',
|
2015-12-16 11:45:00 +01:00
|
|
|
);
|
|
|
|
|
2015-06-29 16:01:10 +02:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2015-12-16 11:45:00 +01:00
|
|
|
$this->getTabs()->add('overview', array(
|
2015-06-29 16:01:10 +02:00
|
|
|
'url' => $this->getRequest()->getUrl(),
|
2015-12-16 11:45:00 +01:00
|
|
|
'label' => $this->translate('Overview')
|
|
|
|
))->activate('overview');
|
|
|
|
|
2015-12-23 10:56:17 +01:00
|
|
|
if (! $this->Config()->get('db', 'resource')) {
|
2015-06-29 16:01:10 +02:00
|
|
|
$this->view->errorMessage = sprintf(
|
|
|
|
$this->translate('No database resource has been configured yet. Please %s to complete your config'),
|
|
|
|
$this->view->qlink($this->translate('click here'), 'director/settings')
|
|
|
|
);
|
2015-12-23 10:56:17 +01:00
|
|
|
return;
|
2015-06-29 16:01:10 +02:00
|
|
|
}
|
2015-12-18 10:51:38 +01:00
|
|
|
|
2015-12-23 10:56:17 +01:00
|
|
|
$this->addGlobalTypeTabs();
|
2015-12-18 10:51:38 +01:00
|
|
|
$this->view->stats = $this->db()->getObjectSummary();
|
|
|
|
if ((int) $this->view->stats['apiuser']->cnt_total === 0) {
|
|
|
|
$this->view->form = $this->loadForm('kickstart')->setDb($this->db)->handleRequest();
|
|
|
|
}
|
2015-06-29 16:01:10 +02:00
|
|
|
}
|
2015-12-16 11:45:00 +01:00
|
|
|
|
|
|
|
protected function addGlobalTypeTabs()
|
|
|
|
{
|
|
|
|
$tabs = $this->getTabs();
|
|
|
|
|
|
|
|
foreach ($this->globalTypes as $tabType) {
|
|
|
|
$ltabType = strtolower($tabType);
|
|
|
|
$tabs->add($ltabType, array(
|
|
|
|
'label' => $this->translate(ucfirst($ltabType) . 's'),
|
|
|
|
'url' => sprintf('director/%ss', $ltabType)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
2015-06-29 16:01:10 +02:00
|
|
|
}
|