mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-22 09:27:39 +02:00
Use Menu class instead of HomeMenu
This commit is contained in:
parent
100e852e26
commit
41f1ac4a90
@ -4,7 +4,7 @@
|
||||
namespace Icinga\Controllers;
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\HomeMenu;
|
||||
use Icinga\Web\Menu;
|
||||
|
||||
/**
|
||||
* Create complex layout parts
|
||||
@ -18,7 +18,7 @@ class LayoutController extends ActionController
|
||||
{
|
||||
$this->setAutorefreshInterval(15);
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->view->menuRenderer = (new HomeMenu())->getRenderer();
|
||||
$this->view->menuRenderer = (new Menu())->getRenderer();
|
||||
}
|
||||
|
||||
public function announcementsAction()
|
||||
|
@ -76,7 +76,11 @@ abstract class BaseDashboardForm extends CompatForm
|
||||
*/
|
||||
protected function createCancelButton()
|
||||
{
|
||||
return $this->createElement('submitButton', 'btn_cancel', ['class' => 'modal-cancel', 'label' => t('Cancel')]);
|
||||
return $this->createElement('submitButton', 'btn_cancel', [
|
||||
'class' => 'modal-cancel',
|
||||
'label' => t('Cancel'),
|
||||
'data-icinga-modal-cancel' => true
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +87,7 @@ $innerLayoutScript = $this->layout()->innerLayout . '.phtml';
|
||||
<section class="modal-window">
|
||||
<div class="modal-header">
|
||||
<h1></h1>
|
||||
<button type="button"><?= $this->icon('cancel') ?></button>
|
||||
<button type="button" data-icinga-modal-cancel><?= $this->icon('cancel') ?></button>
|
||||
</div>
|
||||
<div class="modal-area">
|
||||
<div id="modal-content" data-base-target="modal-content" tabindex data-no-icinga-ajax></div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Icinga\Web\HomeMenu;
|
||||
use Icinga\Web\Menu;
|
||||
|
||||
// Don't render a menu for unauthenticated users unless menu is auth aware
|
||||
if (! $this->auth()->isAuthenticated()) {
|
||||
@ -25,7 +25,7 @@ if (! $this->auth()->isAuthenticated()) {
|
||||
'layout/menu.phtml',
|
||||
'default',
|
||||
array(
|
||||
'menuRenderer' => (new HomeMenu())->getRenderer()->setUseStandardItemRenderer()
|
||||
'menuRenderer' => (new Menu())->getRenderer()->setUseStandardItemRenderer()
|
||||
)
|
||||
) ?>
|
||||
</div>
|
||||
|
@ -5,7 +5,8 @@ use Icinga\Web\Widget\SearchDashboard;
|
||||
$searchDashboard = new SearchDashboard();
|
||||
$searchDashboard->setUser($this->Auth()->getUser());
|
||||
|
||||
if ($searchDashboard->search('dummy')->getActiveHome()->getEntry('search')->hasEntries()): ?>
|
||||
$searchPane = $searchDashboard->search('dummy')->getActiveHome()->getEntry(SearchDashboard::SEARCH_PANE);
|
||||
if ($searchPane->hasEntries()): ?>
|
||||
<form action="<?= $this->href('search') ?>" method="get" role="search" class="search-control">
|
||||
<input type="text" name="q" id="search" class="search search-input" required
|
||||
placeholder="<?= $this->translate('Search') ?> …"
|
||||
|
@ -5,8 +5,12 @@ namespace Icinga\Web;
|
||||
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Authentication\Auth;
|
||||
use Icinga\Model\Home;
|
||||
use Icinga\Web\Dashboard\DashboardHome;
|
||||
use Icinga\Web\Navigation\DashboardHomeItem;
|
||||
use Icinga\Web\Navigation\Navigation;
|
||||
use Icinga\Web\Dashboard\Dashboard;
|
||||
use ipl\Stdlib\Filter;
|
||||
|
||||
/**
|
||||
* Main menu for Icinga Web 2
|
||||
@ -19,6 +23,8 @@ class Menu extends Navigation
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
$this->initHome();
|
||||
|
||||
$this->load('menu-item');
|
||||
}
|
||||
|
||||
@ -148,4 +154,44 @@ class Menu extends Navigation
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
public function initHome()
|
||||
{
|
||||
$user = Dashboard::getUser();
|
||||
$dashboardItem = $this->getItem('dashboard');
|
||||
|
||||
$homes = Home::on(Dashboard::getConn());
|
||||
$homes->filter(Filter::equal('username', $user->getUsername()));
|
||||
|
||||
foreach ($homes as $home) {
|
||||
$dashboardHome = new DashboardHomeItem($home->name, [
|
||||
'uuid' => $home->id,
|
||||
'label' => t($home->label),
|
||||
'priority' => $home->priority,
|
||||
'type' => $home->type,
|
||||
]);
|
||||
|
||||
$dashboardItem->addChild($dashboardHome);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load dashboard homes form the navigation menu
|
||||
*
|
||||
* @return DashboardHome[]
|
||||
*/
|
||||
public function loadHomes()
|
||||
{
|
||||
$homes = [];
|
||||
foreach ($this->getItem('dashboard')->getChildren() as $child) {
|
||||
if (! $child instanceof DashboardHomeItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$homes[$child->getName()] = DashboardHome::create($child);
|
||||
}
|
||||
|
||||
return $homes;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user