IndexController: slight fixes, work with new tabs

This commit is contained in:
Thomas Gelf 2017-06-14 18:35:37 +02:00
parent 4590fa1d73
commit 02c015d163
1 changed files with 16 additions and 12 deletions

View File

@ -7,18 +7,16 @@ use Icinga\Module\Director\Db\Migrations;
class IndexController extends DashboardController
{
protected $hasDeploymentEndpoint;
public function indexAction()
{
$this->view->dashboards = array();
$this->setViewScript('dashboard/index');
if ($this->Config()->get('db', 'resource')) {
$migrations = new Migrations($this->db());
if ($migrations->hasSchema()) {
if (!$this->hasDeploymentEndpoint()) {
$this->showKickstartForm();
$this->showKickstartForm(false);
}
} else {
$this->showKickstartForm();
@ -26,10 +24,11 @@ class IndexController extends DashboardController
}
if ($migrations->hasPendingMigrations()) {
$this->view->form = $this
$this->content()->prepend($this
->loadForm('applyMigrations')
->setMigrations($migrations)
->handleRequest();
->handleRequest()
);
}
parent::indexAction();
@ -38,20 +37,25 @@ class IndexController extends DashboardController
}
}
protected function showKickstartForm()
protected function showKickstartForm($showTab = true)
{
$this->singleTab($this->translate('Kickstart'));
$this->view->form = $this->loadForm('kickstart')->handleRequest();
if ($showTab) {
$this->addSingleTab($this->translate('Kickstart'));
}
$this->content()->prepend(
$this->loadForm('kickstart')->handleRequest()
);
}
protected function hasDeploymentEndpoint()
{
try {
$this->view->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
$this->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
} catch (Exception $e) {
return false;
}
return $this->view->hasDeploymentEndpoint;
return $this->hasDeploymentEndpoint;
}
}