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

View File

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