mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 18:59:05 +02:00
parent
885f76715a
commit
aaaa8aed0a
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Controllers;
|
|||||||
|
|
||||||
use Icinga\Module\Director\Dashboard\Dashboard;
|
use Icinga\Module\Director\Dashboard\Dashboard;
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
|
use Icinga\Module\Director\Web\Form\DbSelectorForm;
|
||||||
|
|
||||||
class DashboardController extends ActionController
|
class DashboardController extends ActionController
|
||||||
{
|
{
|
||||||
@ -11,6 +12,17 @@ class DashboardController extends ActionController
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function addDbSelection()
|
||||||
|
{
|
||||||
|
$form = new DbSelectorForm($this->Window(), $this->listAllowedDbResourceNames());
|
||||||
|
$this->content()->add($form);
|
||||||
|
$form->handleRequest($this->getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Icinga\Exception\ConfigurationError
|
||||||
|
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
||||||
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
if ($this->getRequest()->isGet()) {
|
if ($this->getRequest()->isGet()) {
|
||||||
@ -20,6 +32,9 @@ class DashboardController extends ActionController
|
|||||||
$mainDashboards = ['Objects', 'Alerts', 'Automation', 'Deployment', 'Data'];
|
$mainDashboards = ['Objects', 'Alerts', 'Automation', 'Deployment', 'Data'];
|
||||||
$this->setTitle($this->translate('Icinga Director - Main Dashboard'));
|
$this->setTitle($this->translate('Icinga Director - Main Dashboard'));
|
||||||
$names = $this->params->getValues('name', $mainDashboards);
|
$names = $this->params->getValues('name', $mainDashboards);
|
||||||
|
if (! $this->params->has('name')) {
|
||||||
|
$this->addDbSelection();
|
||||||
|
}
|
||||||
if (count($names) === 1) {
|
if (count($names) === 1) {
|
||||||
$name = $names[0];
|
$name = $names[0];
|
||||||
$dashboard = Dashboard::loadByName($name, $this->db());
|
$dashboard = Dashboard::loadByName($name, $this->db());
|
||||||
|
@ -24,6 +24,7 @@ before switching to a new version.
|
|||||||
* FEATURE: it's now possible to blacklist inherited or applied Services on
|
* FEATURE: it's now possible to blacklist inherited or applied Services on
|
||||||
single hosts (#907)
|
single hosts (#907)
|
||||||
* FEATURE: timestamped startup log rendering for upcoming Icinga v2.9.0 (#1478)
|
* FEATURE: timestamped startup log rendering for upcoming Icinga v2.9.0 (#1478)
|
||||||
|
* FEATURE: allow to switch between multiple Director databases (#1498)
|
||||||
|
|
||||||
### User Interface
|
### User Interface
|
||||||
* FEATURE: Admins have now access to JSON download links in many places
|
* FEATURE: Admins have now access to JSON download links in many places
|
||||||
|
47
library/Director/Web/Form/DbSelectorForm.php
Normal file
47
library/Director/Web/Form/DbSelectorForm.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Web\Form;
|
||||||
|
|
||||||
|
use dipl\Html\Form;
|
||||||
|
use Icinga\Web\Window;
|
||||||
|
|
||||||
|
class DbSelectorForm extends Form
|
||||||
|
{
|
||||||
|
protected $defaultAttributes = [
|
||||||
|
'class' => 'db-selector'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $allowedNames;
|
||||||
|
|
||||||
|
/** @var Window */
|
||||||
|
protected $window;
|
||||||
|
|
||||||
|
public function __construct(Window $window, $allowedNames)
|
||||||
|
{
|
||||||
|
$this->window = $window;
|
||||||
|
$this->allowedNames = $allowedNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assemble()
|
||||||
|
{
|
||||||
|
$this->addElement('db_resource', 'select', [
|
||||||
|
'options' => $this->allowedNames,
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
'value' => $this->getSession()->get('db_resource')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onSuccess()
|
||||||
|
{
|
||||||
|
$this->getSession()->set('db_resource', $this->getValue('db_resource'));
|
||||||
|
$this->redirectOnSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Icinga\Web\Session\SessionNamespace
|
||||||
|
*/
|
||||||
|
protected function getSession()
|
||||||
|
{
|
||||||
|
return $this->window->getSessionNamespace('director');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user