mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 16:54:06 +02:00
index: less logic, delegate work to wizard
This commit is contained in:
parent
e35aa18230
commit
1587051b17
@ -13,30 +13,39 @@ class IndexController extends ActionController
|
|||||||
$this->setAutorefreshInterval(10);
|
$this->setAutorefreshInterval(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getTabs()->add('overview', array(
|
if (! $this->Config()->get('db', 'resource')
|
||||||
'url' => $this->getRequest()->getUrl(),
|
|| !$this->fetchStats()
|
||||||
'label' => $this->translate('Overview')
|
|| !$this->hasDeploymentEndpoint()
|
||||||
))->activate('overview');
|
|
||||||
|
|
||||||
if (! $this->Config()->get('db', 'resource')) {
|
|
||||||
$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')
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $this->fetchStats()
|
|
||||||
|| (int) $this->view->stats['apiuser']->cnt_total === 0
|
|
||||||
) {
|
) {
|
||||||
$this->view->form = $this->loadForm('kickstart')->setDb($this->db)->handleRequest();
|
$this->getTabs()->add('overview', array(
|
||||||
|
'url' => $this->getRequest()->getUrl(),
|
||||||
|
'label' => $this->translate('Configuration')
|
||||||
|
))->activate('overview');
|
||||||
|
$this->view->title = $this->translate('Configuration');
|
||||||
|
$this->view->form = $this->loadForm('kickstart')->handleRequest();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->getTabs()->add('overview', array(
|
||||||
|
'url' => $this->getRequest()->getUrl(),
|
||||||
|
'label' => $this->translate('Overview')
|
||||||
|
))->activate('overview');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hasDeploymentEndpoint()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->view->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->view->hasDeploymentEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
protected function fetchStats()
|
protected function fetchStats()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->view->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
|
|
||||||
$this->view->stats = $this->db()->getObjectSummary();
|
$this->view->stats = $this->db()->getObjectSummary();
|
||||||
$this->view->undeployedActivities = $this->db()->countActivitiesSinceLastDeployedConfig();
|
$this->view->undeployedActivities = $this->db()->countActivitiesSinceLastDeployedConfig();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -80,7 +80,7 @@ function pendingDeployments($self) {
|
|||||||
$self->undeployedActivities
|
$self->undeployedActivities
|
||||||
) . '</span>';
|
) . '</span>';
|
||||||
}
|
}
|
||||||
if ($this->stats && (int) $this->stats['apiuser']->cnt_total === 0) {
|
if (!$this->hasDeploymentEndpoint) {
|
||||||
echo $this->form;
|
echo $this->form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user