Welcome: new controller showing initial help...

...especially in case your config is still missing.
This commit is contained in:
Thomas Gelf 2015-06-29 16:01:10 +02:00
parent 18b201d824
commit 816f8b8a72
4 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,20 @@
<?php
use Icinga\Module\Director\ActionController;
class Director_WelcomeController extends ActionController
{
public function indexAction()
{
$this->getTabs()->add('welcome', array(
'url' => $this->getRequest()->getUrl(),
'label' => $this->translate('Welcome')
))->activate('welcome');
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')
);
}
}
}

View File

@ -0,0 +1,11 @@
<div class="controls">
<?= $this->tabs ?>
</div>
<div class="content">
<h1><?= $this->translate('Welcome to the Icinga Director') ?></h1>
<?php if ($this->errorMessage): ?>
<p class="error"><?= $this->errorMessage ?></p>
<?php endif ?>
Nothing to see here yet. We will point you to the most common tasks later on.
</div>

View File

@ -105,7 +105,12 @@ abstract class ActionController extends Controller
protected function db()
{
if ($this->db === null) {
$this->db = Db::fromResourceName($this->Config()->get('db', 'resource'));
$resourceName = $this->Config()->get('db', 'resource');
if ($resourceName) {
$this->db = Db::fromResourceName($resourceName);
} else {
$this->redirectNow('director/welcome');
}
}
return $this->db;

View File

@ -56,3 +56,15 @@ table.log-properties {
color: white;
}
}
p.error {
color: white;
padding: 1em 2em;
background-color: @colorCriticalHandled;
border: 3px solid @colorCritical;
a {
color: inherit;
font-weight: bold;
}
}