icingaweb2-module-director/application/controllers/IndexController.php

58 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2015-10-20 22:34:04 +02:00
namespace Icinga\Module\Director\Controllers;
2016-03-13 23:48:22 +01:00
use Exception;
use Icinga\Module\Director\Db\Migrations;
class IndexController extends DashboardController
{
public function indexAction()
{
$this->view->dashboards = array();
2016-04-22 11:19:54 +02:00
$this->setViewScript('dashboard/index');
if ($this->Config()->get('db', 'resource')) {
$migrations = new Migrations($this->db());
if ($migrations->hasSchema()) {
if (!$this->hasDeploymentEndpoint()) {
$this->showKickstartForm();
}
} else {
$this->showKickstartForm();
return;
}
if ($migrations->hasPendingMigrations()) {
$this->view->form = $this
->loadForm('applyMigrations')
->setMigrations($migrations)
->handleRequest();
}
parent::indexAction();
2016-04-22 11:19:54 +02:00
} else {
$this->showKickstartForm();
2016-04-22 11:19:54 +02:00
}
2016-04-22 14:31:41 +02:00
}
protected function showKickstartForm()
2016-04-22 15:51:38 +02:00
{
$this->singleTab($this->translate('Kickstart'));
$this->view->form = $this->loadForm('kickstart')->handleRequest();
2016-04-22 11:19:54 +02:00
}
protected function hasDeploymentEndpoint()
{
try {
$this->view->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
} catch (Exception $e) {
return false;
2015-12-18 10:51:38 +01:00
}
return $this->view->hasDeploymentEndpoint;
}
}