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

58 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2015-10-20 16:34:04 -04:00
namespace Icinga\Module\Director\Controllers;
2016-03-13 18:48:22 -04:00
use Exception;
use Icinga\Module\Director\Db\Migrations;
class IndexController extends DashboardController
{
public function indexAction()
{
$this->view->dashboards = array();
2016-04-22 05:19:54 -04: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 05:19:54 -04:00
} else {
$this->showKickstartForm();
2016-04-22 05:19:54 -04:00
}
2016-04-22 08:31:41 -04:00
}
protected function showKickstartForm()
2016-04-22 09:51:38 -04:00
{
$this->singleTab($this->translate('Kickstart'));
$this->view->form = $this->loadForm('kickstart')->handleRequest();
2016-04-22 05:19:54 -04:00
}
protected function hasDeploymentEndpoint()
{
try {
$this->view->hasDeploymentEndpoint = $this->db()->hasDeploymentEndpoint();
} catch (Exception $e) {
return false;
2015-12-18 04:51:38 -05:00
}
return $this->view->hasDeploymentEndpoint;
}
}