DashboardsController: Add index action

This commit is contained in:
Johannes Meyer 2015-09-29 13:45:12 +02:00
parent 0d0480afea
commit 2be8835f06
2 changed files with 53 additions and 0 deletions

View File

@ -4,10 +4,34 @@
namespace Icinga\Controllers;
use Icinga\Web\Controller;
use Icinga\Web\Widget\Dashboard;
/**
* Dashboards
*/
class DashboardsController extends Controller
{
/**
* Display the dashboard with the pane set in the "pane" request parameter
*
* If no pane is given or the given one doesn't exist, the default pane is displayed
*/
public function indexAction()
{
$dashboard = new Dashboard();
$dashboard->setUser($this->Auth()->getUser());
$dashboard->load();
$this->view->title = 'Dashboard';
$this->view->tabs = $dashboard->getTabs();
if ($dashboard->hasPanes()) {
if (($pane = $this->params->get('pane')) !== null) {
$dashboard->activate($pane);
}
$this->view->dashboard = $dashboard;
$this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard';
}
}
}

View File

@ -0,0 +1,29 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $tabs; ?>
</div>
<?php endif ?>
<?php if ($dashboard): ?>
<div class="dashboard content">
<?= $dashboard; ?>
</div>
<?php else: ?>
<div class="content">
<h1><?= $this->escape($this->translate('Welcome to Icinga Web 2!')); ?></h1>
<p>
<?php if (! $this->hasPermission('config/modules')): ?>
<?= $this->escape($this->translate(
'Currently there is no dashboard available. Please contact the administrator.'
)); ?>
<?php else: ?>
<?= sprintf(
$this->escape($this->translate(
'Currently there is no dashboard available. This might change once you enabled some of the available %smodules%s.'
)),
substr($this->qlink(null, 'config/modules'), 0, -4),
'</a>'
); ?>
<?php endif ?>
</p>
</div>
<?php endif ?>