mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
commit
85a4c67705
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
# namespace Icinga\Application\Controllers;
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
|
||||||
use Icinga\Application\Version;
|
use Icinga\Application\Version;
|
||||||
|
use Icinga\Web\Controller\ActionController;
|
||||||
|
|
||||||
class AboutController extends ActionController
|
class AboutController extends ActionController
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
# namespace Icinga\Application\Controllers;
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Forms\Authentication\LoginForm;
|
use Icinga\Forms\Authentication\LoginForm;
|
||||||
use Icinga\Web\Controller;
|
use Icinga\Web\Controller;
|
||||||
use Icinga\Web\Cookie;
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,8 +38,11 @@ class AuthenticationController extends Controller
|
|||||||
}
|
}
|
||||||
if (! $requiresSetup) {
|
if (! $requiresSetup) {
|
||||||
if (! $this->getRequest()->hasCookieSupport()) {
|
if (! $this->getRequest()->hasCookieSupport()) {
|
||||||
echo $this->translate("Cookies must be enabled to run this application.\n");
|
$this
|
||||||
$this->getResponse()->setHttpResponseCode(403)->sendHeaders();
|
->getResponse()
|
||||||
|
->setBody("Cookies must be enabled to run this application.\n")
|
||||||
|
->setHttpResponseCode(403)
|
||||||
|
->sendResponse();
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$form->handleRequest();
|
$form->handleRequest();
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Application\Modules\Module;
|
use Icinga\Application\Modules\Module;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\Config\UserBackendConfigForm;
|
|
||||||
use Icinga\Forms\Config\UserBackendReorderForm;
|
|
||||||
use Icinga\Forms\Config\GeneralConfigForm;
|
use Icinga\Forms\Config\GeneralConfigForm;
|
||||||
use Icinga\Forms\Config\ResourceConfigForm;
|
use Icinga\Forms\Config\ResourceConfigForm;
|
||||||
|
use Icinga\Forms\Config\UserBackendConfigForm;
|
||||||
|
use Icinga\Forms\Config\UserBackendReorderForm;
|
||||||
use Icinga\Forms\ConfirmRemovalForm;
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Security\SecurityException;
|
use Icinga\Security\SecurityException;
|
||||||
use Icinga\Web\Controller;
|
use Icinga\Web\Controller;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Url;
|
|
||||||
use Icinga\Web\Widget;
|
use Icinga\Web\Widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Zend_Controller_Action_Exception;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Forms\ConfirmRemovalForm;
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Forms\Dashboard\DashletForm;
|
use Icinga\Forms\Dashboard\DashletForm;
|
||||||
|
use Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Controller\ActionController;
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Dashboard;
|
use Icinga\Web\Widget\Dashboard;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardSettings;
|
use Icinga\Web\Widget\Tabextension\DashboardSettings;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Zend_Controller_Plugin_ErrorHandler;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Exception\Http\HttpMethodNotAllowedException;
|
use Icinga\Exception\Http\HttpMethodNotAllowedException;
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
|
||||||
use Icinga\Filter\Filter;
|
|
||||||
use Icinga\Application\Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Application wide interface for filtering
|
|
||||||
*/
|
|
||||||
class FilterController extends ActionController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The current filter registry
|
|
||||||
*
|
|
||||||
* @var Filter
|
|
||||||
*/
|
|
||||||
private $registry;
|
|
||||||
|
|
||||||
private $moduleRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entry point for filtering, uses the filter_domain and filter_module request parameter
|
|
||||||
* to determine which filter registry should be used
|
|
||||||
*/
|
|
||||||
public function indexAction()
|
|
||||||
{
|
|
||||||
$this->registry = new Filter();
|
|
||||||
$query = $this->getRequest()->getParam('query', '');
|
|
||||||
$target = $this->getRequest()->getParam('filter_domain', '');
|
|
||||||
|
|
||||||
if ($this->getRequest()->getHeader('accept') == 'application/json') {
|
|
||||||
$this->getResponse()->setHeader('Content-Type', 'application/json');
|
|
||||||
$this->setupQueries(
|
|
||||||
$target,
|
|
||||||
$this->getParam('filter_module', '')
|
|
||||||
);
|
|
||||||
$this->_helper->json($this->parse($query, $target));
|
|
||||||
} else {
|
|
||||||
$this->setupQueries(
|
|
||||||
$target,
|
|
||||||
$this->getParam('filter_module')
|
|
||||||
);
|
|
||||||
$urlTarget = $this->parse($query, $target);
|
|
||||||
$this->redirect($urlTarget['urlParam']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the query handler for the given domain and module
|
|
||||||
*
|
|
||||||
* @param string $domain The domain to use
|
|
||||||
* @param string $module The module to use
|
|
||||||
*/
|
|
||||||
private function setupQueries($domain, $module = 'default')
|
|
||||||
{
|
|
||||||
$class = '\\Icinga\\Module\\' . ucfirst($module) . '\\Filter\\Registry';
|
|
||||||
$factory = strtolower($domain) . 'Filter';
|
|
||||||
$this->moduleRegistry = $class;
|
|
||||||
$this->registry->addDomain($class::$factory());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the given query text and returns the json as expected by the semantic search box
|
|
||||||
*
|
|
||||||
* @param String $text The query to parse
|
|
||||||
* @return array The result structure to be returned in json format
|
|
||||||
*/
|
|
||||||
private function parse($text, $target)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
|
|
||||||
$queryTree = $this->registry->createQueryTreeForFilter($text);
|
|
||||||
$registry = $this->moduleRegistry;
|
|
||||||
return array(
|
|
||||||
'state' => 'success',
|
|
||||||
'proposals' => $this->registry->getProposalsForQuery($text),
|
|
||||||
'urlParam' => $registry::getUrlForTarget($target, $queryTree),
|
|
||||||
'valid' => count($this->registry->getIgnoredQueryParts()) === 0
|
|
||||||
);
|
|
||||||
} catch (\Exception $exc) {
|
|
||||||
Logger::error($exc);
|
|
||||||
$this->getResponse()->setHttpResponseCode(500);
|
|
||||||
return array(
|
|
||||||
'state' => 'error',
|
|
||||||
'message' => 'Search service is currently not available'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Data\DataArray\ArrayDatasource;
|
use Icinga\Data\DataArray\ArrayDatasource;
|
||||||
use Icinga\Data\Reducible;
|
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Reducible;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\Config\UserGroup\AddMemberForm;
|
use Icinga\Forms\Config\UserGroup\AddMemberForm;
|
||||||
use Icinga\Forms\Config\UserGroup\UserGroupForm;
|
use Icinga\Forms\Config\UserGroup\UserGroupForm;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
# namespace Icinga\Application\Controllers;
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Application\Benchmark;
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,6 +17,7 @@ class IndexController extends ActionController
|
|||||||
public function preDispatch()
|
public function preDispatch()
|
||||||
{
|
{
|
||||||
if ($this->getRequest()->getActionName() !== 'welcome') {
|
if ($this->getRequest()->getActionName() !== 'welcome') {
|
||||||
|
// @TODO(el): Avoid landing page redirects: https://dev.icinga.org/issues/9656
|
||||||
$this->redirectNow(Url::fromRequest()->setPath('dashboard'));
|
$this->redirectNow(Url::fromRequest()->setPath('dashboard'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Web\MenuRenderer;
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
use Icinga\Web\Menu;
|
use Icinga\Web\Menu;
|
||||||
|
use Icinga\Web\MenuRenderer;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
@ -11,8 +13,6 @@ use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|||||||
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ListController
|
|
||||||
*
|
|
||||||
* Application wide controller for various listing actions
|
* Application wide controller for various listing actions
|
||||||
*/
|
*/
|
||||||
class ListController extends Controller
|
class ListController extends Controller
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Application\Config;
|
||||||
|
use Icinga\Data\ConfigObject;
|
||||||
|
use Icinga\Forms\PreferenceForm;
|
||||||
|
use Icinga\User\Preferences\PreferencesStore;
|
||||||
use Icinga\Web\Controller\BasePreferenceController;
|
use Icinga\Web\Controller\BasePreferenceController;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tab;
|
use Icinga\Web\Widget\Tab;
|
||||||
use Icinga\Application\Config;
|
|
||||||
use Icinga\Forms\PreferenceForm;
|
|
||||||
use Icinga\Data\ConfigObject;
|
|
||||||
use Icinga\User\Preferences\PreferencesStore;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application wide preference controller for user preferences
|
* Application wide preference controller for user preferences
|
||||||
|
*
|
||||||
|
* @TODO(el): Rename to PreferencesController: https://dev.icinga.org/issues/10014
|
||||||
*/
|
*/
|
||||||
class PreferenceController extends BasePreferenceController
|
class PreferenceController extends BasePreferenceController
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
|
use Icinga\Exception\AlreadyExistsException;
|
||||||
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\ConfirmRemovalForm;
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Forms\Security\RoleForm;
|
use Icinga\Forms\Security\RoleForm;
|
||||||
use Icinga\Web\Controller\AuthBackendController;
|
use Icinga\Web\Controller\AuthBackendController;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage user permissions and restrictions based on roles
|
||||||
|
*
|
||||||
|
* @TODO(el): Rename to RolesController: https://dev.icinga.org/issues/10015
|
||||||
|
*/
|
||||||
class RoleController extends AuthBackendController
|
class RoleController extends AuthBackendController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -31,7 +40,7 @@ class RoleController extends AuthBackendController
|
|||||||
$values = $role->getValues();
|
$values = $role->getValues();
|
||||||
try {
|
try {
|
||||||
$role->add($name, $values);
|
$role->add($name, $values);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (AlreadyExistsException $e) {
|
||||||
$role->addError($e->getMessage());
|
$role->addError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -54,19 +63,11 @@ class RoleController extends AuthBackendController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a role
|
* Update a role
|
||||||
*
|
|
||||||
* @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist
|
|
||||||
*/
|
*/
|
||||||
public function editAction()
|
public function editAction()
|
||||||
{
|
{
|
||||||
$this->assertPermission('config/authentication/roles/edit');
|
$this->assertPermission('config/authentication/roles/edit');
|
||||||
$name = $this->_request->getParam('role');
|
$name = $this->params->getRequired('role');
|
||||||
if (empty($name)) {
|
|
||||||
throw new Zend_Controller_Action_Exception(
|
|
||||||
sprintf($this->translate('Required parameter \'%s\' missing'), 'role'),
|
|
||||||
400
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$role = new RoleForm();
|
$role = new RoleForm();
|
||||||
$role->setTitle(sprintf($this->translate('Update Role %s'), $name));
|
$role->setTitle(sprintf($this->translate('Update Role %s'), $name));
|
||||||
$role->setSubmitLabel($this->translate('Update Role'));
|
$role->setSubmitLabel($this->translate('Update Role'));
|
||||||
@ -74,11 +75,8 @@ class RoleController extends AuthBackendController
|
|||||||
$role
|
$role
|
||||||
->setIniConfig(Config::app('roles', true))
|
->setIniConfig(Config::app('roles', true))
|
||||||
->load($name);
|
->load($name);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (NotFoundError $e) {
|
||||||
throw new Zend_Controller_Action_Exception(
|
$this->httpNotFound($e->getMessage());
|
||||||
$e->getMessage(),
|
|
||||||
400
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$role
|
$role
|
||||||
->setOnSuccess(function (RoleForm $role) use ($name) {
|
->setOnSuccess(function (RoleForm $role) use ($name) {
|
||||||
@ -87,7 +85,7 @@ class RoleController extends AuthBackendController
|
|||||||
$values = $role->getValues();
|
$values = $role->getValues();
|
||||||
try {
|
try {
|
||||||
$role->update($name, $values, $oldName);
|
$role->update($name, $values, $oldName);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (NotFoundError $e) {
|
||||||
$role->addError($e->getMessage());
|
$role->addError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -105,35 +103,24 @@ class RoleController extends AuthBackendController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a role
|
* Remove a role
|
||||||
*
|
|
||||||
* @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist
|
|
||||||
*/
|
*/
|
||||||
public function removeAction()
|
public function removeAction()
|
||||||
{
|
{
|
||||||
$this->assertPermission('config/authentication/roles/remove');
|
$this->assertPermission('config/authentication/roles/remove');
|
||||||
$name = $this->_request->getParam('role');
|
$name = $this->params->getRequired('role');
|
||||||
if (empty($name)) {
|
|
||||||
throw new Zend_Controller_Action_Exception(
|
|
||||||
sprintf($this->translate('Required parameter \'%s\' missing'), 'role'),
|
|
||||||
400
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$role = new RoleForm();
|
$role = new RoleForm();
|
||||||
try {
|
try {
|
||||||
$role
|
$role
|
||||||
->setIniConfig(Config::app('roles', true))
|
->setIniConfig(Config::app('roles', true))
|
||||||
->load($name);
|
->load($name);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (NotFoundError $e) {
|
||||||
throw new Zend_Controller_Action_Exception(
|
$this->httpNotFound($e->getMessage());
|
||||||
$e->getMessage(),
|
|
||||||
400
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$confirmation = new ConfirmRemovalForm(array(
|
$confirmation = new ConfirmRemovalForm(array(
|
||||||
'onSuccess' => function (ConfirmRemovalForm $confirmation) use ($name, $role) {
|
'onSuccess' => function (ConfirmRemovalForm $confirmation) use ($name, $role) {
|
||||||
try {
|
try {
|
||||||
$role->remove($name);
|
$role->remove($name);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (NotFoundError $e) {
|
||||||
Notification::error($e->getMessage());
|
Notification::error($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -162,15 +149,15 @@ class RoleController extends AuthBackendController
|
|||||||
$tabs->add(
|
$tabs->add(
|
||||||
'role/list',
|
'role/list',
|
||||||
array(
|
array(
|
||||||
'title' => $this->translate(
|
'baseTarget' => '_main',
|
||||||
|
'label' => $this->translate('Roles'),
|
||||||
|
'title' => $this->translate(
|
||||||
'Configure roles to permit or restrict users and groups accessing Icinga Web 2'
|
'Configure roles to permit or restrict users and groups accessing Icinga Web 2'
|
||||||
),
|
),
|
||||||
'label' => $this->translate('Roles'),
|
'url' => 'role/list'
|
||||||
'url' => 'role/list',
|
|
||||||
'baseTarget' => '_main'
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $tabs;
|
return $tabs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Web\Widget;
|
use Icinga\Web\Widget;
|
||||||
use Icinga\Web\Widget\SearchDashboard;
|
use Icinga\Web\Widget\SearchDashboard;
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Web\Controller;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Web\FileCache;
|
use Icinga\Web\FileCache;
|
||||||
use Zend_Controller_Action_Exception as ActionException;
|
use Icinga\Web\LessCompiler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delivery static content to clients
|
* Delivery static content to clients
|
||||||
*/
|
*/
|
||||||
class StaticController extends ActionController
|
class StaticController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Static routes don't require authentication
|
* Static routes don't require authentication
|
||||||
@ -57,17 +59,15 @@ class StaticController extends ActionController
|
|||||||
*/
|
*/
|
||||||
public function imgAction()
|
public function imgAction()
|
||||||
{
|
{
|
||||||
|
// TODO(el): I think this action only retrieves images from modules
|
||||||
$module = $this->_getParam('module_name');
|
$module = $this->_getParam('module_name');
|
||||||
$file = $this->_getParam('file');
|
$file = $this->_getParam('file');
|
||||||
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
||||||
|
|
||||||
$filePath = realpath($basedir . '/public/img/' . $file);
|
$filePath = realpath($basedir . '/public/img/' . $file);
|
||||||
|
|
||||||
if (! $filePath || strpos($filePath, $basedir) !== 0) {
|
if ($filePath === false) {
|
||||||
throw new ActionException(sprintf(
|
$this->httpNotFound('%s does not exist', $filePath);
|
||||||
'%s does not exist',
|
|
||||||
$filePath
|
|
||||||
), 404);
|
|
||||||
}
|
}
|
||||||
if (preg_match('/\.([a-z]+)$/i', $file, $m)) {
|
if (preg_match('/\.([a-z]+)$/i', $file, $m)) {
|
||||||
$extension = $m[1];
|
$extension = $m[1];
|
||||||
@ -80,10 +80,7 @@ class StaticController extends ActionController
|
|||||||
header(sprintf('ETag: "%x-%x-%x"', $s['ino'], $s['size'], (float) str_pad($s['mtime'], 16, '0')));
|
header(sprintf('ETag: "%x-%x-%x"', $s['ino'], $s['size'], (float) str_pad($s['mtime'], 16, '0')));
|
||||||
header('Cache-Control: public, max-age=3600');
|
header('Cache-Control: public, max-age=3600');
|
||||||
header('Pragma: cache');
|
header('Pragma: cache');
|
||||||
header('Last-Modified: ' . gmdate(
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $s['mtime']) . ' GMT');
|
||||||
'D, d M Y H:i:s',
|
|
||||||
$s['mtime']
|
|
||||||
) . ' GMT');
|
|
||||||
|
|
||||||
readfile($filePath);
|
readfile($filePath);
|
||||||
}
|
}
|
||||||
@ -100,7 +97,7 @@ class StaticController extends ActionController
|
|||||||
$basedir = Icinga::app()->getApplicationDir('../public/js/icinga/components/');
|
$basedir = Icinga::app()->getApplicationDir('../public/js/icinga/components/');
|
||||||
$filePath = $basedir . $file;
|
$filePath = $basedir . $file;
|
||||||
} else {
|
} else {
|
||||||
if (!Icinga::app()->getModuleManager()->hasEnabled($module)) {
|
if (! Icinga::app()->getModuleManager()->hasEnabled($module)) {
|
||||||
Logger::error(
|
Logger::error(
|
||||||
'Non-existing frontend component "' . $module . '/' . $file
|
'Non-existing frontend component "' . $module . '/' . $file
|
||||||
. '" was requested. The module "' . $module . '" does not exist or is not active.'
|
. '" was requested. The module "' . $module . '" does not exist or is not active.'
|
||||||
@ -112,7 +109,7 @@ class StaticController extends ActionController
|
|||||||
$filePath = $basedir . '/public/js/' . $file;
|
$filePath = $basedir . '/public/js/' . $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($filePath)) {
|
if (! file_exists($filePath)) {
|
||||||
Logger::error(
|
Logger::error(
|
||||||
'Non-existing frontend component "' . $module . '/' . $file
|
'Non-existing frontend component "' . $module . '/' . $file
|
||||||
. '" was requested, which would resolve to the the path: ' . $filePath
|
. '" was requested, which would resolve to the the path: ' . $filePath
|
||||||
@ -122,41 +119,41 @@ class StaticController extends ActionController
|
|||||||
}
|
}
|
||||||
$response = $this->getResponse();
|
$response = $this->getResponse();
|
||||||
$response->setHeader('Content-Type', 'text/javascript');
|
$response->setHeader('Content-Type', 'text/javascript');
|
||||||
$this->setCacheHeader(3600);
|
$this->setCacheHeader();
|
||||||
|
|
||||||
$response->setHeader(
|
$response->setHeader(
|
||||||
'Last-Modified',
|
'Last-Modified',
|
||||||
gmdate(
|
gmdate('D, d M Y H:i:s', filemtime($filePath)) . ' GMT'
|
||||||
'D, d M Y H:i:s',
|
|
||||||
filemtime($filePath)
|
|
||||||
) . ' GMT'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
readfile($filePath);
|
readfile($filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set cache header for this response
|
* Set cache header for the response
|
||||||
*
|
*
|
||||||
* @param integer $maxAge The maximum age to set
|
* @param int $maxAge The maximum age to set
|
||||||
*/
|
*/
|
||||||
private function setCacheHeader($maxAge)
|
private function setCacheHeader($maxAge = 3600)
|
||||||
{
|
{
|
||||||
$this->_response->setHeader('Cache-Control', 'max-age=3600', true);
|
$maxAge = (int) $maxAge;
|
||||||
$this->_response->setHeader('Pragma', 'cache', true);
|
$this
|
||||||
$this->_response->setHeader(
|
->getResponse()
|
||||||
'Expires',
|
->setHeader('Cache-Control', sprintf('max-age=%d', $maxAge), true)
|
||||||
gmdate(
|
->setHeader('Pragma', 'cache', true)
|
||||||
'D, d M Y H:i:s',
|
->setHeader(
|
||||||
time()+3600
|
'Expires',
|
||||||
) . ' GMT',
|
gmdate('D, d M Y H:i:s', time() + $maxAge) . ' GMT',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send application's and modules' CSS
|
||||||
|
*/
|
||||||
public function stylesheetAction()
|
public function stylesheetAction()
|
||||||
{
|
{
|
||||||
$lessCompiler = new \Icinga\Web\LessCompiler();
|
$lessCompiler = new LessCompiler();
|
||||||
$moduleManager = Icinga::app()->getModuleManager();
|
$moduleManager = Icinga::app()->getModuleManager();
|
||||||
|
|
||||||
$publicDir = realpath(dirname($_SERVER['SCRIPT_FILENAME']));
|
$publicDir = realpath(dirname($_SERVER['SCRIPT_FILENAME']));
|
||||||
@ -172,7 +169,7 @@ class StaticController extends ActionController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_response->setHeader('Content-Type', 'text/css');
|
$this->getResponse()->setHeader('Content-Type', 'text/css');
|
||||||
$this->setCacheHeader(3600);
|
$this->setCacheHeader(3600);
|
||||||
|
|
||||||
$lessCompiler->printStack();
|
$lessCompiler->printStack();
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
|
use Icinga\Data\DataArray\ArrayDatasource;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\Config\User\CreateMembershipForm;
|
use Icinga\Forms\Config\User\CreateMembershipForm;
|
||||||
use Icinga\Forms\Config\User\UserForm;
|
use Icinga\Forms\Config\User\UserForm;
|
||||||
use Icinga\Data\DataArray\ArrayDatasource;
|
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
use Icinga\Web\Controller\AuthBackendController;
|
use Icinga\Web\Controller\AuthBackendController;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\ConfirmRemovalForm;
|
|
||||||
use Icinga\Forms\Config\UserGroup\UserGroupBackendForm;
|
use Icinga\Forms\Config\UserGroup\UserGroupBackendForm;
|
||||||
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Web\Controller;
|
use Icinga\Web\Controller;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller to configure user group backends
|
* Controller to configure user group backends
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
namespace Icinga\Forms\Security;
|
namespace Icinga\Forms\Security;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Zend_Form_Element;
|
use Zend_Form_Element;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
|
use Icinga\Exception\AlreadyExistsException;
|
||||||
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\ConfigForm;
|
use Icinga\Forms\ConfigForm;
|
||||||
use Icinga\Util\String;
|
use Icinga\Util\String;
|
||||||
|
|
||||||
@ -168,6 +169,7 @@ class RoleForm extends ConfigForm
|
|||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws LogicException If the config is not set
|
* @throws LogicException If the config is not set
|
||||||
|
* @throws NotFoundError If the given role does not exist
|
||||||
* @see ConfigForm::setConfig() For setting the config.
|
* @see ConfigForm::setConfig() For setting the config.
|
||||||
*/
|
*/
|
||||||
public function load($name)
|
public function load($name)
|
||||||
@ -176,10 +178,10 @@ class RoleForm extends ConfigForm
|
|||||||
throw new LogicException(sprintf('Can\'t load role \'%s\'. Config is not set', $name));
|
throw new LogicException(sprintf('Can\'t load role \'%s\'. Config is not set', $name));
|
||||||
}
|
}
|
||||||
if (! $this->config->hasSection($name)) {
|
if (! $this->config->hasSection($name)) {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new NotFoundError(
|
||||||
$this->translate('Can\'t load role \'%s\'. Role does not exist'),
|
$this->translate('Can\'t load role \'%s\'. Role does not exist'),
|
||||||
$name
|
$name
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
$role = $this->config->getSection($name)->toArray();
|
$role = $this->config->getSection($name)->toArray();
|
||||||
$role['permissions'] = ! empty($role['permissions'])
|
$role['permissions'] = ! empty($role['permissions'])
|
||||||
@ -202,14 +204,14 @@ class RoleForm extends ConfigForm
|
|||||||
/**
|
/**
|
||||||
* Add a role
|
* Add a role
|
||||||
*
|
*
|
||||||
* @param string $name The name of the role
|
* @param string $name The name of the role
|
||||||
* @param array $values
|
* @param array $values
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws LogicException If the config is not set
|
* @throws LogicException If the config is not set
|
||||||
* @throws InvalidArgumentException If the role to add already exists
|
* @throws AlreadyExistsException If the role to add already exists
|
||||||
* @see ConfigForm::setConfig() For setting the config.
|
* @see ConfigForm::setConfig() For setting the config.
|
||||||
*/
|
*/
|
||||||
public function add($name, array $values)
|
public function add($name, array $values)
|
||||||
{
|
{
|
||||||
@ -217,10 +219,10 @@ class RoleForm extends ConfigForm
|
|||||||
throw new LogicException(sprintf('Can\'t add role \'%s\'. Config is not set', $name));
|
throw new LogicException(sprintf('Can\'t add role \'%s\'. Config is not set', $name));
|
||||||
}
|
}
|
||||||
if ($this->config->hasSection($name)) {
|
if ($this->config->hasSection($name)) {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new AlreadyExistsException(
|
||||||
$this->translate('Can\'t add role \'%s\'. Role already exists'),
|
$this->translate('Can\'t add role \'%s\'. Role already exists'),
|
||||||
$name
|
$name
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
$this->config->setSection($name, $values);
|
$this->config->setSection($name, $values);
|
||||||
return $this;
|
return $this;
|
||||||
@ -229,13 +231,13 @@ class RoleForm extends ConfigForm
|
|||||||
/**
|
/**
|
||||||
* Remove a role
|
* Remove a role
|
||||||
*
|
*
|
||||||
* @param string $name The name of the role
|
* @param string $name The name of the role
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws LogicException If the config is not set
|
* @throws LogicException If the config is not set
|
||||||
* @throws InvalidArgumentException If the role does not exist
|
* @throws NotFoundError If the role does not exist
|
||||||
* @see ConfigForm::setConfig() For setting the config.
|
* @see ConfigForm::setConfig() For setting the config.
|
||||||
*/
|
*/
|
||||||
public function remove($name)
|
public function remove($name)
|
||||||
{
|
{
|
||||||
@ -243,10 +245,10 @@ class RoleForm extends ConfigForm
|
|||||||
throw new LogicException(sprintf('Can\'t remove role \'%s\'. Config is not set', $name));
|
throw new LogicException(sprintf('Can\'t remove role \'%s\'. Config is not set', $name));
|
||||||
}
|
}
|
||||||
if (! $this->config->hasSection($name)) {
|
if (! $this->config->hasSection($name)) {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new NotFoundError(
|
||||||
$this->translate('Can\'t remove role \'%s\'. Role does not exist'),
|
$this->translate('Can\'t remove role \'%s\'. Role does not exist'),
|
||||||
$name
|
$name
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
$this->config->removeSection($name);
|
$this->config->removeSection($name);
|
||||||
return $this;
|
return $this;
|
||||||
@ -255,15 +257,15 @@ class RoleForm extends ConfigForm
|
|||||||
/**
|
/**
|
||||||
* Update a role
|
* Update a role
|
||||||
*
|
*
|
||||||
* @param string $name The possibly new name of the role
|
* @param string $name The possibly new name of the role
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* @param string $oldName The name of the role to update
|
* @param string $oldName The name of the role to update
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws LogicException If the config is not set
|
* @throws LogicException If the config is not set
|
||||||
* @throws InvalidArgumentException If the role to update does not exist
|
* @throws NotFoundError If the role to update does not exist
|
||||||
* @see ConfigForm::setConfig() For setting the config.
|
* @see ConfigForm::setConfig() For setting the config.
|
||||||
*/
|
*/
|
||||||
public function update($name, array $values, $oldName)
|
public function update($name, array $values, $oldName)
|
||||||
{
|
{
|
||||||
@ -276,10 +278,10 @@ class RoleForm extends ConfigForm
|
|||||||
$this->add($name, $values);
|
$this->add($name, $values);
|
||||||
} else {
|
} else {
|
||||||
if (! $this->config->hasSection($name)) {
|
if (! $this->config->hasSection($name)) {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new NotFoundError(
|
||||||
$this->translate('Can\'t update role \'%s\'. Role does not exist'),
|
$this->translate('Can\'t update role \'%s\'. Role does not exist'),
|
||||||
$name
|
$name
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
$this->config->setSection($name, $values);
|
$this->config->setSection($name, $values);
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,9 @@ abstract class ApplicationBootstrap
|
|||||||
protected $configDir;
|
protected $configDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icinga auto loader
|
* Icinga class loader
|
||||||
*
|
*
|
||||||
* @var Loader
|
* @var ClassLoader
|
||||||
*/
|
*/
|
||||||
private $loader;
|
private $loader;
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ abstract class ApplicationBootstrap
|
|||||||
/**
|
/**
|
||||||
* Getter for class loader
|
* Getter for class loader
|
||||||
*
|
*
|
||||||
* @return Loader
|
* @return ClassLoader
|
||||||
*/
|
*/
|
||||||
public function getLoader()
|
public function getLoader()
|
||||||
{
|
{
|
||||||
@ -339,15 +339,15 @@ abstract class ApplicationBootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup Icinga auto loader
|
* Setup Icinga class loader
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setupAutoloader()
|
public function setupAutoloader()
|
||||||
{
|
{
|
||||||
require $this->libDir . '/Icinga/Application/Loader.php';
|
require $this->libDir . '/Icinga/Application/ClassLoader.php';
|
||||||
|
|
||||||
$this->loader = new Loader();
|
$this->loader = new ClassLoader();
|
||||||
$this->loader->registerNamespace('Icinga', $this->libDir. '/Icinga');
|
$this->loader->registerNamespace('Icinga', $this->libDir. '/Icinga');
|
||||||
$this->loader->register();
|
$this->loader->register();
|
||||||
|
|
||||||
|
113
library/Icinga/Application/ClassLoader.php
Normal file
113
library/Icinga/Application/ClassLoader.php
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PSR-4 class loader
|
||||||
|
*/
|
||||||
|
class ClassLoader
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Namespace separator
|
||||||
|
*/
|
||||||
|
const NAMESPACE_SEPARATOR = '\\';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespaces
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $namespaces = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a base directory for a namespace prefix
|
||||||
|
*
|
||||||
|
* @param string $namespace
|
||||||
|
* @param string $directory
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function registerNamespace($namespace, $directory)
|
||||||
|
{
|
||||||
|
$this->namespaces[$namespace] = $directory;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether a namespace exists
|
||||||
|
*
|
||||||
|
* @param string $namespace
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasNamespace($namespace)
|
||||||
|
{
|
||||||
|
return array_key_exists($namespace, $this->namespaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the source file of the given class or interface
|
||||||
|
*
|
||||||
|
* @param string $class Name of the class or interface
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getSourceFile($class)
|
||||||
|
{
|
||||||
|
foreach ($this->namespaces as $namespace => $dir) {
|
||||||
|
if ($class === strstr($class, $namespace)) {
|
||||||
|
$classPath = str_replace(
|
||||||
|
self::NAMESPACE_SEPARATOR,
|
||||||
|
DIRECTORY_SEPARATOR,
|
||||||
|
substr($class, strlen($namespace))
|
||||||
|
) . '.php';
|
||||||
|
if (file_exists($file = $dir . $classPath)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the given class or interface
|
||||||
|
*
|
||||||
|
* @param string $class Name of the class or interface
|
||||||
|
*
|
||||||
|
* @return bool Whether the class or interface has been loaded
|
||||||
|
*/
|
||||||
|
public function loadClass($class)
|
||||||
|
{
|
||||||
|
if ($file = $this->getSourceFile($class)) {
|
||||||
|
require $file;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register {@link loadClass()} as an autoloader
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
spl_autoload_register(array($this, 'loadClass'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister {@link loadClass()} as an autoloader
|
||||||
|
*/
|
||||||
|
public function unregister()
|
||||||
|
{
|
||||||
|
spl_autoload_unregister(array($this, 'loadClass'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister this as an autoloader
|
||||||
|
*/
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
$this->unregister();
|
||||||
|
}
|
||||||
|
}
|
@ -1,138 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
|
||||||
|
|
||||||
namespace Icinga\Application;
|
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
|
||||||
|
|
||||||
class Loader
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Namespace separator
|
|
||||||
*/
|
|
||||||
const NAMESPACE_SEPARATOR = '\\';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of namespaces
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $namespaces = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detach spl autoload method from stack
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
$this->unRegister();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register new namespace for directory
|
|
||||||
*
|
|
||||||
* @param string $namespace
|
|
||||||
* @param string $directory
|
|
||||||
*
|
|
||||||
* @throws ProgrammingError
|
|
||||||
*/
|
|
||||||
public function registerNamespace($namespace, $directory)
|
|
||||||
{
|
|
||||||
if (!is_dir($directory)) {
|
|
||||||
throw new ProgrammingError(
|
|
||||||
'Directory "%s" for namespace "%s" does not exist',
|
|
||||||
$directory,
|
|
||||||
$namespace
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->namespaces[$namespace] = $directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if a namespace exists
|
|
||||||
*
|
|
||||||
* @param string $namespace
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function hasNamespace($namespace)
|
|
||||||
{
|
|
||||||
return array_key_exists($namespace, $this->namespaces);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class loader
|
|
||||||
*
|
|
||||||
* Ignores all but classes in registered namespaces.
|
|
||||||
*
|
|
||||||
* @param string $class
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function loadClass($class)
|
|
||||||
{
|
|
||||||
$namespace = $this->getNamespaceForClass($class);
|
|
||||||
|
|
||||||
if ($namespace) {
|
|
||||||
$file = $this->namespaces[$namespace] . preg_replace('/^' . preg_quote($namespace) . '/', '', $class);
|
|
||||||
$file = str_replace(self::NAMESPACE_SEPARATOR, '/', $file) . '.php';
|
|
||||||
|
|
||||||
if (@file_exists($file)) {
|
|
||||||
require_once $file;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if we have a registered namespaces for this class
|
|
||||||
*
|
|
||||||
* Return is the longest match in the array found
|
|
||||||
*
|
|
||||||
* @param string $className
|
|
||||||
*
|
|
||||||
* @return bool|string
|
|
||||||
*/
|
|
||||||
private function getNamespaceForClass($className)
|
|
||||||
{
|
|
||||||
$testNamespace = '';
|
|
||||||
$testLength = 0;
|
|
||||||
|
|
||||||
foreach (array_keys($this->namespaces) as $namespace) {
|
|
||||||
$stub = preg_replace(
|
|
||||||
'/^' . preg_quote($namespace) . '(' . preg_quote(self::NAMESPACE_SEPARATOR) . '|$)/', '', $className
|
|
||||||
);
|
|
||||||
$length = strlen($className) - strlen($stub);
|
|
||||||
if ($length > $testLength) {
|
|
||||||
$testLength = $length;
|
|
||||||
$testNamespace = $namespace;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($testLength > 0) {
|
|
||||||
return $testNamespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effectively registers the autoloader the PHP/SPL way
|
|
||||||
*/
|
|
||||||
public function register()
|
|
||||||
{
|
|
||||||
// Think about to add class pathes to php include path
|
|
||||||
// this could be faster (tg)
|
|
||||||
spl_autoload_register(array(&$this, 'loadClass'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detach autoloader from spl registration
|
|
||||||
*/
|
|
||||||
public function unRegister()
|
|
||||||
{
|
|
||||||
spl_autoload_unregister(array(&$this, 'loadClass'));
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,6 +17,7 @@ use Icinga\Exception\ProgrammingError;
|
|||||||
use Icinga\Module\Setup\SetupWizard;
|
use Icinga\Module\Setup\SetupWizard;
|
||||||
use Icinga\Util\File;
|
use Icinga\Util\File;
|
||||||
use Icinga\Util\Translator;
|
use Icinga\Util\Translator;
|
||||||
|
use Icinga\Web\Controller\Dispatcher;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
use Icinga\Web\Menu;
|
use Icinga\Web\Menu;
|
||||||
use Icinga\Web\Widget;
|
use Icinga\Web\Widget;
|
||||||
@ -935,7 +936,7 @@ class Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register module namespaces on the autoloader
|
* Register module namespaces on our class loader
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
@ -945,16 +946,17 @@ class Module
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$loader = $this->app->getLoader();
|
||||||
$moduleName = ucfirst($this->getName());
|
$moduleName = ucfirst($this->getName());
|
||||||
|
|
||||||
$moduleLibraryDir = $this->getLibDir(). '/'. $moduleName;
|
$moduleLibraryDir = $this->getLibDir(). '/'. $moduleName;
|
||||||
if (is_dir($moduleLibraryDir)) {
|
if (is_dir($moduleLibraryDir)) {
|
||||||
$this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir);
|
$loader->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$moduleFormDir = $this->getFormDir();
|
$moduleFormDir = $this->getFormDir();
|
||||||
if (is_dir($moduleFormDir)) {
|
if (is_dir($moduleFormDir)) {
|
||||||
$this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir);
|
$loader->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registeredAutoloader = true;
|
$this->registeredAutoloader = true;
|
||||||
@ -1016,19 +1018,23 @@ class Module
|
|||||||
*/
|
*/
|
||||||
protected function registerWebIntegration()
|
protected function registerWebIntegration()
|
||||||
{
|
{
|
||||||
if (!$this->app->isWeb()) {
|
if (! $this->app->isWeb()) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
$moduleControllerDir = $this->getControllerDir();
|
||||||
if (file_exists($this->controllerdir) && is_dir($this->controllerdir)) {
|
if (is_dir($moduleControllerDir)) {
|
||||||
$this->app->getfrontController()->addControllerDirectory(
|
$this->app->getfrontController()->addControllerDirectory(
|
||||||
$this->controllerdir,
|
$moduleControllerDir,
|
||||||
$this->name
|
$this->getName()
|
||||||
|
);
|
||||||
|
$this->app->getLoader()->registerNamespace(
|
||||||
|
'Icinga\\Module\\' . ucfirst($this->getName()) . '\\' . Dispatcher::CONTROLLER_NAMESPACE,
|
||||||
|
$moduleControllerDir
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
$this
|
||||||
$this->registerLocales()
|
->registerLocales()
|
||||||
->registerRoutes();
|
->registerRoutes();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1049,8 +1055,9 @@ class Module
|
|||||||
new Zend_Controller_Router_Route(
|
new Zend_Controller_Router_Route(
|
||||||
'js/' . $this->name . '/:file',
|
'js/' . $this->name . '/:file',
|
||||||
array(
|
array(
|
||||||
|
'action' => 'javascript',
|
||||||
'controller' => 'static',
|
'controller' => 'static',
|
||||||
'action' =>'javascript',
|
'module' => 'default',
|
||||||
'module_name' => $this->name
|
'module_name' => $this->name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -1060,8 +1067,9 @@ class Module
|
|||||||
new Zend_Controller_Router_Route_Regex(
|
new Zend_Controller_Router_Route_Regex(
|
||||||
'img/' . $this->name . '/(.+)',
|
'img/' . $this->name . '/(.+)',
|
||||||
array(
|
array(
|
||||||
'controller' => 'static',
|
|
||||||
'action' => 'img',
|
'action' => 'img',
|
||||||
|
'controller' => 'static',
|
||||||
|
'module' => 'default',
|
||||||
'module_name' => $this->name
|
'module_name' => $this->name
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
@ -3,12 +3,15 @@
|
|||||||
|
|
||||||
namespace Icinga\Application;
|
namespace Icinga\Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the version of Icinga Web 2
|
||||||
|
*/
|
||||||
class Version
|
class Version
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the version of this instance of Icinga Web 2
|
* Get the version of this instance of Icinga Web 2
|
||||||
*
|
*
|
||||||
* @return array|bool array on success, false otherwise
|
* @return array|false array on success, false otherwise
|
||||||
*/
|
*/
|
||||||
public static function get()
|
public static function get()
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ use Icinga\Authentication\Auth;
|
|||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
use Icinga\Util\TimezoneDetect;
|
use Icinga\Util\TimezoneDetect;
|
||||||
use Icinga\Util\Translator;
|
use Icinga\Util\Translator;
|
||||||
|
use Icinga\Web\Controller\Dispatcher;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Session;
|
use Icinga\Web\Session;
|
||||||
use Icinga\Web\Session\Session as BaseSession;
|
use Icinga\Web\Session\Session as BaseSession;
|
||||||
@ -88,7 +89,7 @@ class Web extends EmbeddedWeb
|
|||||||
->setupLogger()
|
->setupLogger()
|
||||||
->setupInternationalization()
|
->setupInternationalization()
|
||||||
->setupZendMvc()
|
->setupZendMvc()
|
||||||
->setupFormNamespace()
|
->setupNamespaces()
|
||||||
->setupModuleManager()
|
->setupModuleManager()
|
||||||
->setupUserBackendFactory()
|
->setupUserBackendFactory()
|
||||||
->loadSetupModuleIfNecessary()
|
->loadSetupModuleIfNecessary()
|
||||||
@ -210,6 +211,7 @@ class Web extends EmbeddedWeb
|
|||||||
private function setupFrontController()
|
private function setupFrontController()
|
||||||
{
|
{
|
||||||
$this->frontController = Zend_Controller_Front::getInstance();
|
$this->frontController = Zend_Controller_Front::getInstance();
|
||||||
|
$this->frontController->setDispatcher(new Dispatcher());
|
||||||
$this->frontController->setRequest($this->getRequest());
|
$this->frontController->setRequest($this->getRequest());
|
||||||
$this->frontController->setControllerDirectory($this->getApplicationDir('/controllers'));
|
$this->frontController->setControllerDirectory($this->getApplicationDir('/controllers'));
|
||||||
|
|
||||||
@ -306,16 +308,22 @@ class Web extends EmbeddedWeb
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup an autoloader namespace for Icinga\Forms
|
* Setup class loader namespaces for Icinga\Controllers and Icinga\Forms
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
private function setupFormNamespace()
|
private function setupNamespaces()
|
||||||
{
|
{
|
||||||
$this->getLoader()->registerNamespace(
|
$this
|
||||||
'Icinga\\Forms',
|
->getLoader()
|
||||||
$this->getApplicationDir('forms')
|
->registerNamespace(
|
||||||
);
|
'Icinga\\' . Dispatcher::CONTROLLER_NAMESPACE,
|
||||||
|
$this->getApplicationDir('controllers')
|
||||||
|
)
|
||||||
|
->registerNamespace(
|
||||||
|
'Icinga\\Forms',
|
||||||
|
$this->getApplicationDir('forms')
|
||||||
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
|
|
||||||
namespace Icinga\Application;
|
namespace Icinga\Application;
|
||||||
|
|
||||||
use Icinga\Application\EmbeddedWeb;
|
|
||||||
use Icinga\Application\Web;
|
|
||||||
use Icinga\Web\StyleSheet;
|
|
||||||
use Icinga\Web\JavaScript;
|
|
||||||
use Icinga\Chart\Inline\PieChart;
|
use Icinga\Chart\Inline\PieChart;
|
||||||
|
use Icinga\Web\JavaScript;
|
||||||
|
use Icinga\Web\StyleSheet;
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT);
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
|
||||||
|
11
library/Icinga/Exception/AlreadyExistsException.php
Normal file
11
library/Icinga/Exception/AlreadyExistsException.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown if something to add already exists
|
||||||
|
*/
|
||||||
|
class AlreadyExistsException extends IcingaException
|
||||||
|
{
|
||||||
|
}
|
92
library/Icinga/Web/Controller/Dispatcher.php
Normal file
92
library/Icinga/Web/Controller/Dispatcher.php
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Zend_Controller_Action;
|
||||||
|
use Zend_Controller_Action_Interface;
|
||||||
|
use Zend_Controller_Dispatcher_Exception;
|
||||||
|
use Zend_Controller_Dispatcher_Standard;
|
||||||
|
use Zend_Controller_Request_Abstract;
|
||||||
|
use Zend_Controller_Response_Abstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatcher supporting Zend-style and namespaced controllers
|
||||||
|
*
|
||||||
|
* Does not support a namespaced default controller in combination w/ the Zend parameter useDefaultControllerAlways.
|
||||||
|
*/
|
||||||
|
class Dispatcher extends Zend_Controller_Dispatcher_Standard
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Controller namespace
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const CONTROLLER_NAMESPACE = 'Controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch request to a controller and action
|
||||||
|
*
|
||||||
|
* @param Zend_Controller_Request_Abstract $request
|
||||||
|
* @param Zend_Controller_Response_Abstract $response
|
||||||
|
*
|
||||||
|
* @throws Zend_Controller_Dispatcher_Exception If the controller is not an instance of
|
||||||
|
* Zend_Controller_Action_Interface
|
||||||
|
* @throws Exception If dispatching the request fails
|
||||||
|
*/
|
||||||
|
public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)
|
||||||
|
{
|
||||||
|
$this->setResponse($response);
|
||||||
|
$controllerName = $request->getControllerName();
|
||||||
|
if (! $controllerName) {
|
||||||
|
parent::dispatch($request, $response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$controllerName = ucfirst($controllerName) . 'Controller';
|
||||||
|
$moduleName = $request->getModuleName();
|
||||||
|
if ($moduleName === null || $moduleName === $this->_defaultModule) {
|
||||||
|
$controllerClass = 'Icinga\\' . self::CONTROLLER_NAMESPACE . '\\' . $controllerName;
|
||||||
|
} else {
|
||||||
|
$controllerClass = 'Icinga\\Module\\' . ucfirst($moduleName) . '\\' . self::CONTROLLER_NAMESPACE . '\\'
|
||||||
|
. $controllerName;
|
||||||
|
}
|
||||||
|
if (! class_exists($controllerClass)) {
|
||||||
|
parent::dispatch($request, $response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$controller = new $controllerClass($request, $response, $this->getParams());
|
||||||
|
if (! $controller instanceof Zend_Controller_Action
|
||||||
|
&& ! $controller instanceof Zend_Controller_Action_Interface
|
||||||
|
) {
|
||||||
|
throw new Zend_Controller_Dispatcher_Exception(
|
||||||
|
'Controller "' . $controllerClass . '" is not an instance of Zend_Controller_Action_Interface'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$action = $this->getActionMethod($request);
|
||||||
|
$request->setDispatched(true);
|
||||||
|
// Buffer output by default
|
||||||
|
$disableOb = $this->getParam('disableOutputBuffering');
|
||||||
|
$obLevel = ob_get_level();
|
||||||
|
if (empty($disableOb)) {
|
||||||
|
ob_start();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$controller->dispatch($action);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Clean output buffer on error
|
||||||
|
$curObLevel = ob_get_level();
|
||||||
|
if ($curObLevel > $obLevel) {
|
||||||
|
do {
|
||||||
|
ob_get_clean();
|
||||||
|
$curObLevel = ob_get_level();
|
||||||
|
} while ($curObLevel > $obLevel);
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
if (empty($disableOb)) {
|
||||||
|
$content = ob_get_clean();
|
||||||
|
$response->appendBody($content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1012,6 +1012,8 @@ class Form extends Zend_Form
|
|||||||
* Populate the elements with the given values
|
* Populate the elements with the given values
|
||||||
*
|
*
|
||||||
* @param array $defaults The values to populate the elements with
|
* @param array $defaults The values to populate the elements with
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function populate(array $defaults)
|
public function populate(array $defaults)
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Doc\Controllers;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Module\Doc\DocController;
|
use Icinga\Module\Doc\DocController;
|
||||||
|
|
||||||
class Doc_IcingawebController extends DocController
|
class IcingawebController extends DocController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the path to Icinga Web 2's documentation
|
* Get the path to Icinga Web 2's documentation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws Zend_Controller_Action_Exception If Icinga Web 2's documentation is not available
|
* @throws \Icinga\Exception\Http\HttpNotFoundException If Icinga Web 2's documentation is not available
|
||||||
*/
|
*/
|
||||||
protected function getPath()
|
protected function getPath()
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Doc\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Doc\DocController;
|
use Icinga\Module\Doc\DocController;
|
||||||
|
|
||||||
class Doc_IndexController extends DocController
|
/**
|
||||||
|
* Documentation module index
|
||||||
|
*/
|
||||||
|
class IndexController extends DocController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Documentation module landing page
|
||||||
|
*
|
||||||
|
* Lists documentation links
|
||||||
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Doc\Controllers;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Module\Doc\DocController;
|
use Icinga\Module\Doc\DocController;
|
||||||
use Icinga\Module\Doc\Exception\DocException;
|
use Icinga\Module\Doc\Exception\DocException;
|
||||||
use Icinga\File\Ini\Parser;
|
|
||||||
|
|
||||||
class Doc_ModuleController extends DocController
|
class ModuleController extends DocController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the path to a module documentation
|
* Get the path to a module documentation
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Doc\Controllers;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Module\Doc\DocController;
|
use Icinga\Module\Doc\DocController;
|
||||||
use Icinga\Module\Doc\DocParser;
|
use Icinga\Module\Doc\DocParser;
|
||||||
use Icinga\Module\Doc\Exception\DocException;
|
use Icinga\Module\Doc\Exception\DocException;
|
||||||
|
use Icinga\Module\Doc\Renderer\DocSearchRenderer;
|
||||||
use Icinga\Module\Doc\Search\DocSearch;
|
use Icinga\Module\Doc\Search\DocSearch;
|
||||||
use Icinga\Module\Doc\Search\DocSearchIterator;
|
use Icinga\Module\Doc\Search\DocSearchIterator;
|
||||||
use Icinga\Module\Doc\Renderer\DocSearchRenderer;
|
|
||||||
|
|
||||||
class Doc_SearchController extends DocController
|
class SearchController extends DocController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Render search
|
* Render search
|
||||||
@ -77,9 +79,7 @@ class Doc_SearchController extends DocController
|
|||||||
/**
|
/**
|
||||||
* Get the path to Icinga Web 2's documentation
|
* Get the path to Icinga Web 2's documentation
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
|
||||||
* @throws Zend_Controller_Action_Exception If Icinga Web 2's documentation is not available
|
|
||||||
*/
|
*/
|
||||||
protected function getWebPath()
|
protected function getWebPath()
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Doc\Controllers;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Web\Controller;
|
use Icinga\Web\Controller;
|
||||||
use Icinga\Web\Widget;
|
use Icinga\Web\Widget;
|
||||||
|
|
||||||
class Doc_StyleController extends Controller
|
class StyleController extends Controller
|
||||||
{
|
{
|
||||||
public function guideAction()
|
public function guideAction()
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
|
use stdClass;
|
||||||
|
use DateInterval;
|
||||||
|
use DatePeriod;
|
||||||
|
use DateTime;
|
||||||
|
use Zend_Controller_Action_Exception;
|
||||||
use Icinga\Chart\GridChart;
|
use Icinga\Chart\GridChart;
|
||||||
use Icinga\Chart\Unit\LinearUnit;
|
use Icinga\Chart\Unit\LinearUnit;
|
||||||
use Icinga\Chart\Unit\StaticAxis;
|
use Icinga\Chart\Unit\StaticAxis;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Web\Widget\SelectBox;
|
use Icinga\Module\Monitoring\Web\Widget\SelectBox;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
|
||||||
class Monitoring_AlertsummaryController extends Controller
|
class AlertsummaryController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
@ -95,7 +103,7 @@ class Monitoring_AlertsummaryController extends Controller
|
|||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$query->addFilter(
|
$query->addFilter(
|
||||||
new Icinga\Data\Filter\FilterExpression(
|
new FilterExpression(
|
||||||
'notification_start_time',
|
'notification_start_time',
|
||||||
'>=',
|
'>=',
|
||||||
$this->getBeginDate($interval)->format('Y-m-d H:i:s')
|
$this->getBeginDate($interval)->format('Y-m-d H:i:s')
|
||||||
@ -144,7 +152,7 @@ class Monitoring_AlertsummaryController extends Controller
|
|||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$query->addFilter(
|
$query->addFilter(
|
||||||
new Icinga\Data\Filter\FilterExpression(
|
new FilterExpression(
|
||||||
'notification_start_time',
|
'notification_start_time',
|
||||||
'>=',
|
'>=',
|
||||||
$beginDate->format('Y-m-d H:i:s')
|
$beginDate->format('Y-m-d H:i:s')
|
||||||
@ -212,7 +220,7 @@ class Monitoring_AlertsummaryController extends Controller
|
|||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$query->addFilter(
|
$query->addFilter(
|
||||||
new Icinga\Data\Filter\FilterExpression(
|
new FilterExpression(
|
||||||
'notification_start_time',
|
'notification_start_time',
|
||||||
'>=',
|
'>=',
|
||||||
$this->getBeginDate($interval)->format('Y-m-d H:i:s')
|
$this->getBeginDate($interval)->format('Y-m-d H:i:s')
|
||||||
@ -263,7 +271,7 @@ class Monitoring_AlertsummaryController extends Controller
|
|||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$query->addFilter(
|
$query->addFilter(
|
||||||
new Icinga\Data\Filter\FilterExpression(
|
new FilterExpression(
|
||||||
'timestamp',
|
'timestamp',
|
||||||
'>=',
|
'>=',
|
||||||
$this->getBeginDate($interval)->getTimestamp()
|
$this->getBeginDate($interval)->getTimestamp()
|
||||||
@ -271,7 +279,7 @@ class Monitoring_AlertsummaryController extends Controller
|
|||||||
);
|
);
|
||||||
|
|
||||||
$query->addFilter(
|
$query->addFilter(
|
||||||
new Icinga\Data\Filter\FilterExpression(
|
new FilterExpression(
|
||||||
'state',
|
'state',
|
||||||
'>',
|
'>',
|
||||||
0
|
0
|
||||||
@ -329,7 +337,7 @@ class Monitoring_AlertsummaryController extends Controller
|
|||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$query->addFilter(
|
$query->addFilter(
|
||||||
new Icinga\Data\Filter\FilterExpression(
|
new FilterExpression(
|
||||||
'notification_start_time',
|
'notification_start_time',
|
||||||
'>=',
|
'>=',
|
||||||
$this->getBeginDate($interval)->format('Y-m-d H:i:s')
|
$this->getBeginDate($interval)->format('Y-m-d H:i:s')
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Controller;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Chart\GridChart;
|
use Icinga\Chart\GridChart;
|
||||||
use Icinga\Chart\PieChart;
|
use Icinga\Chart\PieChart;
|
||||||
use Icinga\Chart\Unit\StaticAxis;
|
|
||||||
use Icinga\Chart\Unit\LogarithmicUnit;
|
use Icinga\Chart\Unit\LogarithmicUnit;
|
||||||
use Icinga\Chart\Unit\LinearUnit;
|
use Icinga\Chart\Unit\StaticAxis;
|
||||||
|
use Icinga\Module\Monitoring\Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Monitoring_CommandController
|
* @TODO(el): Fix and reuse the controller or remove it: https://dev.icinga.org/issues/10019
|
||||||
*
|
|
||||||
* Interface to send commands and display forms
|
|
||||||
*/
|
*/
|
||||||
|
class ChartController extends Controller
|
||||||
class Monitoring_ChartController extends Controller
|
|
||||||
{
|
{
|
||||||
private function drawLogChart1()
|
private function drawLogChart1()
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
@ -9,12 +11,12 @@ use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|||||||
/**
|
/**
|
||||||
* Display detailed information about a comment
|
* Display detailed information about a comment
|
||||||
*/
|
*/
|
||||||
class Monitoring_CommentController extends Controller
|
class CommentController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The fetched comment
|
* The fetched comment
|
||||||
*
|
*
|
||||||
* @var stdClass
|
* @var object
|
||||||
*/
|
*/
|
||||||
protected $comment;
|
protected $comment;
|
||||||
|
|
||||||
@ -41,19 +43,16 @@ class Monitoring_CommentController extends Controller
|
|||||||
))->where('comment_internal_id', $commentId);
|
))->where('comment_internal_id', $commentId);
|
||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$this->comment = $query->getQuery()->fetchRow();
|
if (false === $this->comment = $query->fetchRow()) {
|
||||||
if ($this->comment === false) {
|
|
||||||
$this->httpNotFound($this->translate('Comment not found'));
|
$this->httpNotFound($this->translate('Comment not found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getTabs()->add(
|
$this->getTabs()->add(
|
||||||
'comment',
|
'comment',
|
||||||
array(
|
array(
|
||||||
'title' => $this->translate(
|
'icon' => 'comment',
|
||||||
'Display detailed information about a comment.'
|
|
||||||
),
|
|
||||||
'icon' => 'comment',
|
|
||||||
'label' => $this->translate('Comment'),
|
'label' => $this->translate('Comment'),
|
||||||
|
'title' => $this->translate('Display detailed information about a comment.'),
|
||||||
'url' =>'monitoring/comments/show'
|
'url' =>'monitoring/comments/show'
|
||||||
)
|
)
|
||||||
)->activate('comment')->extend(new DashboardAction());
|
)->activate('comment')->extend(new DashboardAction());
|
||||||
@ -64,37 +63,19 @@ class Monitoring_CommentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function showAction()
|
public function showAction()
|
||||||
{
|
{
|
||||||
$listCommentsLink = Url::fromPath('monitoring/list/comments')
|
|
||||||
->setQueryString('comment_type=(comment|ack)');
|
|
||||||
|
|
||||||
$this->view->comment = $this->comment;
|
$this->view->comment = $this->comment;
|
||||||
|
|
||||||
if ($this->hasPermission('monitoring/command/comment/delete')) {
|
if ($this->hasPermission('monitoring/command/comment/delete')) {
|
||||||
$this->view->delCommentForm = $this->createDelCommentForm();
|
$listUrl = Url::fromPath('monitoring/list/comments')->setQueryString('comment_type=(comment|ack)');
|
||||||
$this->view->delCommentForm->populate(
|
$form = new DeleteCommentCommandForm();
|
||||||
array(
|
$form
|
||||||
'redirect' => $listCommentsLink,
|
->populate(array(
|
||||||
'comment_id' => $this->comment->id,
|
'comment_id' => $this->comment->id,
|
||||||
'comment_is_service' => isset($this->comment->service_description)
|
'comment_is_service' => isset($this->comment->service_description),
|
||||||
)
|
'redirect' => $listUrl
|
||||||
);
|
))
|
||||||
|
->handleRequest();
|
||||||
|
$this->view->delCommentForm = $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a command form to delete a single comment
|
|
||||||
*
|
|
||||||
* @return DeleteCommentsCommandForm
|
|
||||||
*/
|
|
||||||
private function createDelCommentForm()
|
|
||||||
{
|
|
||||||
$this->assertPermission('monitoring/command/comment/delete');
|
|
||||||
|
|
||||||
$delCommentForm = new DeleteCommentCommandForm();
|
|
||||||
$delCommentForm->setAction(
|
|
||||||
Url::fromPath('monitoring/comment/show')
|
|
||||||
->setParam('comment_id', $this->comment->id)
|
|
||||||
);
|
|
||||||
$delCommentForm->handleRequest();
|
|
||||||
return $delCommentForm;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Data\Filter\Filter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display detailed information about a comment
|
* Display detailed information about comments
|
||||||
*/
|
*/
|
||||||
class Monitoring_CommentsController extends Controller
|
class CommentsController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The fetched comments
|
* The comments view
|
||||||
*
|
*
|
||||||
* @var array
|
* @var \Icinga\Module\Monitoring\DataView\Comment
|
||||||
*/
|
*/
|
||||||
protected $comments;
|
protected $comments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all comments matching the current filter and add tabs
|
* Filter from request
|
||||||
*
|
*
|
||||||
* @throws Zend_Controller_Action_Exception
|
* @var Filter
|
||||||
|
*/
|
||||||
|
protected $filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch all comments matching the current filter and add tabs
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->filter = Filter::fromQueryString(str_replace(
|
$this->filter = Filter::fromQueryString(str_replace(
|
||||||
'comment_id',
|
'comment_id',
|
||||||
'comment_internal_id',
|
'comment_internal_id',
|
||||||
(string)$this->params
|
(string) $this->params
|
||||||
));
|
));
|
||||||
$query = $this->backend->select()->from('comment', array(
|
$query = $this->backend->select()->from('comment', array(
|
||||||
'id' => 'comment_internal_id',
|
'id' => 'comment_internal_id',
|
||||||
@ -46,19 +53,16 @@ class Monitoring_CommentsController extends Controller
|
|||||||
))->addFilter($this->filter);
|
))->addFilter($this->filter);
|
||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$this->comments = $query->getQuery()->fetchAll();
|
$this->comments = $query;
|
||||||
if (false === $this->comments) {
|
|
||||||
throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getTabs()->add(
|
$this->getTabs()->add(
|
||||||
'comments',
|
'comments',
|
||||||
array(
|
array(
|
||||||
|
'icon' => 'comment',
|
||||||
|
'label' => $this->translate('Comments') . sprintf(' (%d)', $query->count()),
|
||||||
'title' => $this->translate(
|
'title' => $this->translate(
|
||||||
'Display detailed information about multiple comments.'
|
'Display detailed information about multiple comments.'
|
||||||
),
|
),
|
||||||
'icon' => 'comment',
|
|
||||||
'label' => $this->translate('Comments') . sprintf(' (%d)', count($this->comments)),
|
|
||||||
'url' =>'monitoring/comments/show'
|
'url' =>'monitoring/comments/show'
|
||||||
)
|
)
|
||||||
)->activate('comments');
|
)->activate('comments');
|
||||||
@ -71,9 +75,9 @@ class Monitoring_CommentsController extends Controller
|
|||||||
{
|
{
|
||||||
$this->view->comments = $this->comments;
|
$this->view->comments = $this->comments;
|
||||||
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
|
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
|
||||||
->setQueryString($this->filter->toQueryString());
|
->setQueryString($this->filter->toQueryString());
|
||||||
$this->view->removeAllLink = Url::fromPath('monitoring/comments/delete-all')
|
$this->view->removeAllLink = Url::fromPath('monitoring/comments/delete-all')
|
||||||
->setParams($this->params);
|
->setParams($this->params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,14 +93,14 @@ class Monitoring_CommentsController extends Controller
|
|||||||
$delCommentForm->setTitle($this->view->translate('Remove all Comments'));
|
$delCommentForm->setTitle($this->view->translate('Remove all Comments'));
|
||||||
$delCommentForm->addDescription(sprintf(
|
$delCommentForm->addDescription(sprintf(
|
||||||
$this->translate('Confirm removal of %d comments.'),
|
$this->translate('Confirm removal of %d comments.'),
|
||||||
count($this->comments)
|
$this->comments->count()
|
||||||
));
|
));
|
||||||
$delCommentForm->setComments($this->comments)
|
$delCommentForm->setComments($this->comments->fetchAll())
|
||||||
->setRedirectUrl($listCommentsLink)
|
->setRedirectUrl($listCommentsLink)
|
||||||
->handleRequest();
|
->handleRequest();
|
||||||
$this->view->delCommentForm = $delCommentForm;
|
$this->view->delCommentForm = $delCommentForm;
|
||||||
$this->view->comments = $this->comments;
|
$this->view->comments = $this->comments;
|
||||||
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
|
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
|
||||||
->setQueryString($this->filter->toQueryString());
|
->setQueryString($this->filter->toQueryString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Forms\ConfirmRemovalForm;
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Web\Controller;
|
|
||||||
use Icinga\Web\Notification;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm;
|
use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Config\InstanceConfigForm;
|
use Icinga\Module\Monitoring\Forms\Config\InstanceConfigForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Config\SecurityConfigForm;
|
use Icinga\Module\Monitoring\Forms\Config\SecurityConfigForm;
|
||||||
|
use Icinga\Web\Controller;
|
||||||
|
use Icinga\Web\Notification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration controller for editing monitoring resources
|
* Configuration controller for editing monitoring resources
|
||||||
*/
|
*/
|
||||||
class Monitoring_ConfigController extends Controller
|
class ConfigController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a list of available backends and instances
|
* Display a list of available backends and instances
|
||||||
|
@ -1,33 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Object\Service;
|
|
||||||
use Icinga\Module\Monitoring\Object\Host;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
|
||||||
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
|
use Icinga\Module\Monitoring\Object\Host;
|
||||||
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display detailed information about a downtime
|
* Display detailed information about a downtime
|
||||||
*/
|
*/
|
||||||
class Monitoring_DowntimeController extends Controller
|
class DowntimeController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The fetched downtime
|
* The fetched downtime
|
||||||
*
|
*
|
||||||
* @var stdClass
|
* @var object
|
||||||
*/
|
*/
|
||||||
protected $downtime;
|
protected $downtime;
|
||||||
|
|
||||||
/**
|
|
||||||
* If the downtime is a service or not
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
protected $isService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the downtime matching the given id and add tabs
|
* Fetch the downtime matching the given id and add tabs
|
||||||
*/
|
*/
|
||||||
@ -58,29 +52,20 @@ class Monitoring_DowntimeController extends Controller
|
|||||||
))->where('downtime_internal_id', $downtimeId);
|
))->where('downtime_internal_id', $downtimeId);
|
||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$this->downtime = $query->getQuery()->fetchRow();
|
if (false === $this->downtime = $query->fetchRow()) {
|
||||||
if ($this->downtime === false) {
|
|
||||||
$this->httpNotFound($this->translate('Downtime not found'));
|
$this->httpNotFound($this->translate('Downtime not found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->downtime->service_description)) {
|
$this->getTabs()->add(
|
||||||
$this->isService = true;
|
'downtime',
|
||||||
} else {
|
array(
|
||||||
$this->isService = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getTabs()
|
'icon' => 'plug',
|
||||||
->add(
|
'label' => $this->translate('Downtime'),
|
||||||
'downtime',
|
'title' => $this->translate('Display detailed information about a downtime.'),
|
||||||
array(
|
'url' =>'monitoring/downtimes/show'
|
||||||
'title' => $this->translate(
|
)
|
||||||
'Display detailed information about a downtime.'
|
)->activate('downtime')->extend(new DashboardAction());
|
||||||
),
|
|
||||||
'icon' => 'plug',
|
|
||||||
'label' => $this->translate('Downtime'),
|
|
||||||
'url' =>'monitoring/downtimes/show'
|
|
||||||
)
|
|
||||||
)->activate('downtime')->extend(new DashboardAction());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,52 +73,27 @@ class Monitoring_DowntimeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function showAction()
|
public function showAction()
|
||||||
{
|
{
|
||||||
|
$isService = isset($this->downtime->service_description);
|
||||||
$this->view->downtime = $this->downtime;
|
$this->view->downtime = $this->downtime;
|
||||||
$this->view->isService = $this->isService;
|
$this->view->isService = $isService;
|
||||||
$this->view->stateName = isset($this->downtime->service_description) ?
|
|
||||||
Service::getStateText($this->downtime->service_state) :
|
|
||||||
Host::getStateText($this->downtime->host_state);
|
|
||||||
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes');
|
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes');
|
||||||
$this->view->showHostLink = Url::fromPath('monitoring/host/show')
|
$this->view->showHostLink = Url::fromPath('monitoring/host/show')->setParam('host', $this->downtime->host_name);
|
||||||
->setParam('host', $this->downtime->host_name);
|
|
||||||
$this->view->showServiceLink = Url::fromPath('monitoring/service/show')
|
$this->view->showServiceLink = Url::fromPath('monitoring/service/show')
|
||||||
->setParam('host', $this->downtime->host_name)
|
->setParam('host', $this->downtime->host_name)
|
||||||
->setParam('service', $this->downtime->service_description);
|
->setParam('service', $this->downtime->service_description);
|
||||||
|
$this->view->stateName = $isService ? Service::getStateText($this->downtime->service_state)
|
||||||
|
: Host::getStateText($this->downtime->host_state);
|
||||||
|
|
||||||
if ($this->hasPermission('monitoring/command/downtime/delete')) {
|
if ($this->hasPermission('monitoring/command/downtime/delete')) {
|
||||||
$this->view->delDowntimeForm = $this->createDelDowntimeForm();
|
$form = new DeleteDowntimeCommandForm();
|
||||||
$this->view->delDowntimeForm->populate(
|
$form
|
||||||
array(
|
->populate(array(
|
||||||
'redirect' => Url::fromPath('monitoring/list/downtimes'),
|
'downtime_id' => $this->downtime->id,
|
||||||
'downtime_id' => $this->downtime->id,
|
'downtime_is_service' => $isService,
|
||||||
'downtime_is_service' => $this->isService
|
'redirect' => Url::fromPath('monitoring/list/downtimes'),
|
||||||
)
|
))
|
||||||
);
|
->handleRequest();
|
||||||
|
$this->view->delDowntimeForm = $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Receive DeleteDowntimeCommandForm post from other controller
|
|
||||||
*/
|
|
||||||
public function removeAction()
|
|
||||||
{
|
|
||||||
$this->assertHttpMethod('POST');
|
|
||||||
$this->createDelDowntimeForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a command form to delete a single comment
|
|
||||||
*
|
|
||||||
* @return DeleteDowntimeCommandForm
|
|
||||||
*/
|
|
||||||
private function createDelDowntimeForm()
|
|
||||||
{
|
|
||||||
$this->assertPermission('monitoring/command/downtime/delete');
|
|
||||||
$delDowntimeForm = new DeleteDowntimeCommandForm();
|
|
||||||
$delDowntimeForm->setAction(
|
|
||||||
Url::fromPath('monitoring/downtime/show')
|
|
||||||
->setParam('downtime_id', $this->downtime->id)
|
|
||||||
);
|
|
||||||
$delDowntimeForm->handleRequest();
|
|
||||||
return $delDowntimeForm;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Object\Service;
|
|
||||||
use Icinga\Module\Monitoring\Object\Host;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimesCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimesCommandForm;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display detailed information about a downtime
|
* Display detailed information about downtimes
|
||||||
*/
|
*/
|
||||||
class Monitoring_DowntimesController extends Controller
|
class DowntimesController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The fetched downtimes
|
* The downtimes view
|
||||||
*
|
*
|
||||||
* @var array
|
* @var \Icinga\Module\Monitoring\DataView\Downtime
|
||||||
*/
|
*/
|
||||||
protected $downtimes;
|
protected $downtimes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A filter matching all current downtimes
|
* Filter from request
|
||||||
*
|
*
|
||||||
* @var Filter
|
* @var Filter
|
||||||
*/
|
*/
|
||||||
@ -29,15 +29,13 @@ class Monitoring_DowntimesController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all downtimes matching the current filter and add tabs
|
* Fetch all downtimes matching the current filter and add tabs
|
||||||
*
|
|
||||||
* @throws Zend_Controller_Action_Exception
|
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->filter = Filter::fromQueryString(str_replace(
|
$this->filter = Filter::fromQueryString(str_replace(
|
||||||
'downtime_id',
|
'downtime_id',
|
||||||
'downtime_internal_id',
|
'downtime_internal_id',
|
||||||
(string)$this->params
|
(string) $this->params
|
||||||
));
|
));
|
||||||
$query = $this->backend->select()->from('downtime', array(
|
$query = $this->backend->select()->from('downtime', array(
|
||||||
'id' => 'downtime_internal_id',
|
'id' => 'downtime_internal_id',
|
||||||
@ -62,38 +60,17 @@ class Monitoring_DowntimesController extends Controller
|
|||||||
))->addFilter($this->filter);
|
))->addFilter($this->filter);
|
||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$this->downtimes = $query->getQuery()->fetchAll();
|
$this->downtimes = $query;
|
||||||
if (false === $this->downtimes) {
|
|
||||||
throw new Zend_Controller_Action_Exception(
|
|
||||||
$this->translate('Downtime not found')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getTabs()->add(
|
$this->getTabs()->add(
|
||||||
'downtimes',
|
'downtimes',
|
||||||
array(
|
array(
|
||||||
'title' => $this->translate(
|
|
||||||
'Display detailed information about multiple downtimes.'
|
|
||||||
),
|
|
||||||
'icon' => 'plug',
|
'icon' => 'plug',
|
||||||
'label' => $this->translate('Downtimes') . sprintf(' (%d)', count($this->downtimes)),
|
'label' => $this->translate('Downtimes') . sprintf(' (%d)', $query->count()),
|
||||||
|
'title' => $this->translate('Display detailed information about multiple downtimes.'),
|
||||||
'url' =>'monitoring/downtimes/show'
|
'url' =>'monitoring/downtimes/show'
|
||||||
)
|
)
|
||||||
)->activate('downtimes');
|
)->activate('downtimes');
|
||||||
|
|
||||||
foreach ($this->downtimes as $downtime) {
|
|
||||||
if (isset($downtime->service_description)) {
|
|
||||||
$downtime->isService = true;
|
|
||||||
} else {
|
|
||||||
$downtime->isService = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($downtime->isService) {
|
|
||||||
$downtime->stateText = Service::getStateText($downtime->service_state);
|
|
||||||
} else {
|
|
||||||
$downtime->stateText = Host::getStateText($downtime->host_state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,9 +80,8 @@ class Monitoring_DowntimesController extends Controller
|
|||||||
{
|
{
|
||||||
$this->view->downtimes = $this->downtimes;
|
$this->view->downtimes = $this->downtimes;
|
||||||
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
|
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
|
||||||
->setQueryString($this->filter->toQueryString());
|
->setQueryString($this->filter->toQueryString());
|
||||||
$this->view->removeAllLink = Url::fromPath('monitoring/downtimes/delete-all')
|
$this->view->removeAllLink = Url::fromPath('monitoring/downtimes/delete-all')->setParams($this->params);
|
||||||
->setParams($this->params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,10 +97,10 @@ class Monitoring_DowntimesController extends Controller
|
|||||||
$delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes'));
|
$delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes'));
|
||||||
$delDowntimeForm->addDescription(sprintf(
|
$delDowntimeForm->addDescription(sprintf(
|
||||||
$this->translate('Confirm removal of %d downtimes.'),
|
$this->translate('Confirm removal of %d downtimes.'),
|
||||||
count($this->downtimes)
|
$this->downtimes->count()
|
||||||
));
|
));
|
||||||
$delDowntimeForm->setRedirectUrl(Url::fromPath('monitoring/list/downtimes'));
|
$delDowntimeForm->setRedirectUrl(Url::fromPath('monitoring/list/downtimes'));
|
||||||
$delDowntimeForm->setDowntimes($this->downtimes)->handleRequest();
|
$delDowntimeForm->setDowntimes($this->downtimes->fetchAll())->handleRequest();
|
||||||
$this->view->delDowntimeForm = $delDowntimeForm;
|
$this->view->delDowntimeForm = $delDowntimeForm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||||
@ -11,11 +13,11 @@ use Icinga\Module\Monitoring\Object\Host;
|
|||||||
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
|
|
||||||
class Monitoring_HostController extends MonitoredObjectController
|
class HostController extends MonitoredObjectController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* {@inheritdoc}
|
||||||
* @see MonitoredObjectController::$commandRedirectUrl For the property documentation.
|
|
||||||
*/
|
*/
|
||||||
protected $commandRedirectUrl = 'monitoring/host/show';
|
protected $commandRedirectUrl = 'monitoring/host/show';
|
||||||
|
|
||||||
@ -25,9 +27,7 @@ class Monitoring_HostController extends MonitoredObjectController
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$host = new Host($this->backend, $this->params->getRequired('host'));
|
$host = new Host($this->backend, $this->params->getRequired('host'));
|
||||||
|
|
||||||
$this->applyRestriction('monitoring/filter/objects', $host);
|
$this->applyRestriction('monitoring/filter/objects', $host);
|
||||||
|
|
||||||
if ($host->fetch() === false) {
|
if ($host->fetch() === false) {
|
||||||
$this->httpNotFound($this->translate('Host not found'));
|
$this->httpNotFound($this->translate('Host not found'));
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Data\Filter\FilterEqual;
|
use Icinga\Data\Filter\FilterEqual;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
||||||
use Icinga\Module\Monitoring\Object\HostList;
|
use Icinga\Module\Monitoring\Object\HostList;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
|
||||||
class Monitoring_HostsController extends Controller
|
class HostsController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var HostList
|
* @var HostList
|
||||||
@ -166,18 +168,6 @@ class Monitoring_HostsController extends Controller
|
|||||||
$this->handleCommandForm($form);
|
$this->handleCommandForm($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a comment
|
|
||||||
*/
|
|
||||||
public function deleteCommentAction()
|
|
||||||
{
|
|
||||||
$this->assertPermission('monitoring/command/comment/delete');
|
|
||||||
|
|
||||||
$form = new DeleteCommentCommandForm();
|
|
||||||
$form->setTitle($this->translate('Delete Host Comments'));
|
|
||||||
$this->handleCommandForm($form);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acknowledge host problems
|
* Acknowledge host problems
|
||||||
*/
|
*/
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Controller;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
|
use Zend_Form;
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Module\Monitoring\Backend;
|
use Icinga\Module\Monitoring\Backend;
|
||||||
|
use Icinga\Module\Monitoring\Controller;
|
||||||
|
use Icinga\Module\Monitoring\DataView\DataView;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
|
||||||
|
use Icinga\Module\Monitoring\Forms\StatehistoryForm;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
use Icinga\Web\Widget\Tabs;
|
use Icinga\Web\Widget\Tabs;
|
||||||
use Icinga\Data\Filter\Filter;
|
|
||||||
use Icinga\Module\Monitoring\Forms\StatehistoryForm;
|
|
||||||
use Icinga\Module\Monitoring\DataView\DataView;
|
|
||||||
|
|
||||||
class Monitoring_ListController extends Controller
|
class ListController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @see ActionController::init
|
* @see ActionController::init
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Instance\DisableNotificationsExpireCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Instance\DisableNotificationsExpireCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Instance\ToggleInstanceFeaturesCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Instance\ToggleInstanceFeaturesCommandForm;
|
||||||
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display process and performance information of the monitoring host and program-wide commands
|
* Display process and performance information of the monitoring host and program-wide commands
|
||||||
*/
|
*/
|
||||||
class Monitoring_ProcessController extends Controller
|
class ProcessController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Add tabs
|
* Add tabs
|
||||||
@ -122,20 +124,4 @@ class Monitoring_ProcessController extends Controller
|
|||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo should be dropped later
|
|
||||||
*/
|
|
||||||
public function performanceAction()
|
|
||||||
{
|
|
||||||
$this->getTabs()->activate('performance');
|
|
||||||
$this->setAutorefreshInterval(10);
|
|
||||||
$this->view->runtimevariables = (object) $this->backend->select()
|
|
||||||
->from('runtimevariables', array('varname', 'varvalue'))
|
|
||||||
->getQuery()->fetchPairs();
|
|
||||||
|
|
||||||
$this->view->checkperformance = $this->backend->select()
|
|
||||||
->from('runtimesummary')
|
|
||||||
->getQuery()->fetchAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||||
@ -11,11 +13,10 @@ use Icinga\Module\Monitoring\Object\Service;
|
|||||||
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
|
|
||||||
class Monitoring_ServiceController extends MonitoredObjectController
|
class ServiceController extends MonitoredObjectController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* {@inheritdoc}
|
||||||
* @see MonitoredObjectController::$commandRedirectUrl For the property documentation.
|
|
||||||
*/
|
*/
|
||||||
protected $commandRedirectUrl = 'monitoring/service/show';
|
protected $commandRedirectUrl = 'monitoring/service/show';
|
||||||
|
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
||||||
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
|
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
||||||
use Icinga\Module\Monitoring\Object\ServiceList;
|
use Icinga\Module\Monitoring\Object\ServiceList;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
|
||||||
class Monitoring_ServicesController extends Controller
|
class ServicesController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ServiceList
|
* @var ServiceList
|
||||||
@ -180,20 +181,6 @@ class Monitoring_ServicesController extends Controller
|
|||||||
$this->handleCommandForm($form);
|
$this->handleCommandForm($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a comment
|
|
||||||
*/
|
|
||||||
public function deleteCommentAction()
|
|
||||||
{
|
|
||||||
$this->assertPermission('monitoring/command/comment/delete');
|
|
||||||
|
|
||||||
$form = new DeleteCommentCommandForm();
|
|
||||||
$form->setTitle($this->translate('Delete Service Comments'));
|
|
||||||
$this->handleCommandForm($form);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acknowledge service problems
|
* Acknowledge service problems
|
||||||
*/
|
*/
|
||||||
|
@ -1,60 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Backend;
|
use Icinga\Module\Monitoring\Backend;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Monitoring_ShowController
|
* Class Monitoring_ShowController
|
||||||
*
|
*
|
||||||
* Actions for show context
|
* Actions for show context
|
||||||
*/
|
*/
|
||||||
class Monitoring_ShowController extends Controller
|
class ShowController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Backend
|
* @var Backend
|
||||||
*/
|
*/
|
||||||
protected $backend;
|
protected $backend;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function serviceAction()
|
|
||||||
{
|
|
||||||
$this->redirectNow(Url::fromRequest()->setPath('monitoring/service/show'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function hostAction()
|
|
||||||
{
|
|
||||||
$this->redirectNow(Url::fromRequest()->setPath('monitoring/host/show'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function historyAction()
|
|
||||||
{
|
|
||||||
if ($this->params->has('service')) {
|
|
||||||
$this->redirectNow(Url::fromRequest()->setPath('monitoring/service/history'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->redirectNow(Url::fromRequest()->setPath('monitoring/host/history'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function contactAction()
|
public function contactAction()
|
||||||
{
|
{
|
||||||
$contactName = $this->getParam('contact_name');
|
$contactName = $this->params->getRequired('contact_name');
|
||||||
|
|
||||||
if (! $contactName) {
|
|
||||||
throw new Zend_Controller_Action_Exception(
|
|
||||||
$this->translate('The parameter `contact_name\' is required'),
|
|
||||||
404
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = $this->backend->select()->from('contact', array(
|
$query = $this->backend->select()->from('contact', array(
|
||||||
'contact_name',
|
'contact_name',
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Controller as MonitoringController;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|
||||||
use Icinga\Web\Url;
|
|
||||||
|
|
||||||
class Monitoring_TacticalController extends MonitoringController
|
use Icinga\Module\Monitoring\Controller;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
|
||||||
|
class TacticalController extends Controller
|
||||||
{
|
{
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
use Icinga\Util\Format;
|
|
||||||
|
use DateInterval;
|
||||||
|
use DateTime;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Timeline\TimeLine;
|
use Icinga\Module\Monitoring\Timeline\TimeLine;
|
||||||
use Icinga\Module\Monitoring\Timeline\TimeRange;
|
use Icinga\Module\Monitoring\Timeline\TimeRange;
|
||||||
use Icinga\Module\Monitoring\Web\Widget\SelectBox;
|
use Icinga\Module\Monitoring\Web\Widget\SelectBox;
|
||||||
|
use Icinga\Util\Format;
|
||||||
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
|
|
||||||
class Monitoring_TimelineController extends Controller
|
class TimelineController extends Controller
|
||||||
{
|
{
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
|
@ -1,25 +1,19 @@
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
<?php if (! $this->compact): ?>
|
<?php if (! $this->compact): ?>
|
||||||
<?= $this->tabs; ?>
|
<?= $this->tabs ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
<?= $this->render('partials/comment/comments-header.phtml') ?>
|
||||||
<div data-base-target='_next'>
|
|
||||||
<?= $this->render('partials/comment/comments-header.phtml'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content multi-commands">
|
<div class="content multi-commands">
|
||||||
<h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3>
|
<h3><?= $this->icon('reschedule') ?><?= $this->translate('Commands') ?></h3>
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
sprintf(
|
sprintf($this->translate('Remove %d comments'), $comments->count()),
|
||||||
$this->translate('Remove %d comments'),
|
|
||||||
count($comments)
|
|
||||||
),
|
|
||||||
$removeAllLink,
|
$removeAllLink,
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
'icon' => 'trash',
|
'icon' => 'trash',
|
||||||
'title' => $this->translate('Remove all selected comments.')
|
'title' => $this->translate('Remove all selected comments')
|
||||||
)
|
)
|
||||||
) ?>
|
) ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
<?php if (! $this->compact): ?>
|
||||||
<?php if (! $this->compact): ?>
|
<?= $this->tabs ?>
|
||||||
<?= $this->tabs; ?>
|
<?php endif ?>
|
||||||
<?php endif ?>
|
<?= $this->render('partials/downtime/downtimes-header.phtml') ?>
|
||||||
|
|
||||||
<?= $this->render('partials/downtime/downtimes-header.phtml'); ?>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content multi-commands">
|
<div class="content multi-commands">
|
||||||
<h3><?= $this->translate('Commands') ?> </h3>
|
<h3><?= $this->icon('reschedule') ?><?= $this->translate('Commands') ?></h3>
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
sprintf(
|
sprintf($this->translate('Remove all %d scheduled downtimes'), $downtimes->count()),
|
||||||
$this->translate('Remove all %d scheduled downtimes'),
|
|
||||||
count($downtimes)
|
|
||||||
),
|
|
||||||
$removeAllLink,
|
$removeAllLink,
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
'icon' => 'trash'
|
'icon' => 'trash',
|
||||||
|
'title' => $this->translate('Remove all selected downtimes')
|
||||||
)
|
)
|
||||||
) ?>
|
) ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,27 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
switch ($comment->type) {
|
switch ($comment->type) {
|
||||||
case 'flapping':
|
case 'flapping':
|
||||||
$icon = 'flapping';
|
$icon = 'flapping';
|
||||||
$title = $this->translate('Flapping');
|
$title = $this->translate('Flapping');
|
||||||
$tooltip = $this->translate('Comment was caused by a flapping host or service.');
|
$tooltip = $this->translate('Comment was caused by a flapping host or service');
|
||||||
break;
|
break;
|
||||||
case 'comment':
|
case 'comment':
|
||||||
$icon = 'user';
|
$icon = 'user';
|
||||||
$title = $this->translate('User Comment');
|
$title = $this->translate('User Comment');
|
||||||
$tooltip = $this->translate('Comment was created by an user.');
|
$tooltip = $this->translate('Comment was created by an user');
|
||||||
break;
|
break;
|
||||||
case 'downtime':
|
case 'downtime':
|
||||||
$icon = 'plug';
|
$icon = 'plug';
|
||||||
$title = $this->translate('Downtime');
|
$title = $this->translate('Downtime');
|
||||||
$tooltip = $this->translate('Comment was caused by a downtime.');
|
$tooltip = $this->translate('Comment was caused by a downtime');
|
||||||
break;
|
break;
|
||||||
case 'ack':
|
case 'ack':
|
||||||
$icon = 'ok';
|
$icon = 'ok';
|
||||||
$title = $this->translate('Acknowledgement');
|
$title = $this->translate('Acknowledgement');
|
||||||
$tooltip = $this->translate('Comment was caused by an acknowledgement.');
|
$tooltip = $this->translate('Comment was caused by an acknowledgement');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<strong><?= $this->escape($title); ?></strong><br>
|
<strong><?= $this->escape($title) ?></strong>
|
||||||
|
<br>
|
||||||
<?= $this->icon($icon, $tooltip) ?>
|
<?= $this->icon($icon, $tooltip) ?>
|
||||||
<?= $this->timeAgo($comment->timestamp, $this->compact); ?>
|
<?= $this->timeAgo($comment->timestamp, $this->compact) ?>
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<?php if ($comment->objecttype === 'service'): ?>
|
<?php if ($comment->objecttype === 'service'): ?>
|
||||||
<?= $this->icon('service', $this->translate('Service')); ?>
|
<?= $this->icon('service', $this->translate('Service')) ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
'%s: %s',
|
'%s: %s',
|
||||||
$comment->host_display_name,
|
$comment->host_display_name,
|
||||||
$comment->service_display_name
|
$comment->service_display_name
|
||||||
) ?>
|
) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= $this->icon('host', $this->translate('Host')); ?>
|
<?= $this->icon('host', $this->translate('Host')) ?>
|
||||||
<?= $this->link()->host($comment->host_name, $comment->host_display_name); ?>
|
<?= $this->link()->host($comment->host_name, $comment->host_display_name) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<?= $this->icon('comment', $this->translate('Comment')); ?> <?= isset($comment->author)
|
<?= $this->icon('comment', $this->translate('Comment')) ?>
|
||||||
? '[' . $this->escape($comment->author) . '] '
|
<?php if (isset($comment->author)): ?>
|
||||||
: '';
|
[<?= $this->escape($comment->author) ?>]
|
||||||
?><?= $this->escape($comment->comment); ?>
|
<?php endif ?>
|
||||||
|
<?= $this->escape($comment->comment) ?>
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
<table class="action">
|
<table class="action" data-base-target="_next">
|
||||||
<?php $i = 0; foreach ($comments as $comment):
|
<tbody>
|
||||||
if (++ $i > 5) {
|
<?php
|
||||||
continue;
|
foreach ($comments as $i => $comment):
|
||||||
|
if ($i > 5) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$this->comment = $comment;
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr class="state invalid">
|
<tr class="state invalid">
|
||||||
<td class="state" style="width: 12em;">
|
<td class="state" style="width: 12em;">
|
||||||
<?= $this->render('partials/comment/comment-description.phtml'); ?>
|
<?= $this->partial('partials/comment/comment-description.phtml', array('comment' => $comment)) ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= $this->render('partials/comment/comment-detail.phtml'); ?>
|
<?= $this->partial('partials/comment/comment-detail.phtml', array('comment' => $comment)) ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach ?>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php if ($comments->count() > 5): ?>
|
||||||
<p>
|
<p>
|
||||||
<?php if ($i > 5): ?>
|
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
sprintf($this->translate('show all %d comments'), $i),
|
sprintf($this->translate('List all %d comments'), $comments->count()),
|
||||||
$listAllLink,
|
$listAllLink,
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
'icon' => $i > 5 ? 'down-open' : '',
|
'data-base-target' => '_next',
|
||||||
'data-base-target' => "_next"
|
'icon' => 'down-open'
|
||||||
)
|
)
|
||||||
) ?>
|
) ?>
|
||||||
<?php endif ?>
|
|
||||||
</p>
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
|
@ -1,95 +1,111 @@
|
|||||||
<table class="action" data-base-target="_next">
|
<?php
|
||||||
|
use Icinga\Module\Monitoring\Object\Host;
|
||||||
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
|
?>
|
||||||
|
<table class="action" data-base-target="_next">
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php $i = 0; foreach ($downtimes as $downtime):
|
<?php
|
||||||
if (++ $i > 5) {
|
foreach ($this->downtimes as $i => $downtime):
|
||||||
|
if ($i > 5) {
|
||||||
break;
|
break;
|
||||||
} ?>
|
}
|
||||||
<tr class="state <?= $downtime->stateText ?>">
|
if ($downtime->objecttype === 'service') {
|
||||||
<td class="state">
|
$isService = true;
|
||||||
<?php if ($downtime->start <= time() && ! $downtime->is_in_effect): ?>
|
$stateText = Service::getStateText($downtime->service_state);
|
||||||
<strong><?= $this->translate('Ends'); ?></strong>
|
} else {
|
||||||
<br>
|
$isService = false;
|
||||||
<?= $this->timeUntil($downtime->is_flexible ? $downtime->scheduled_end : $downtime->end, $this->compact) ?>
|
$stateText = Host::getStateText($downtime->host_state);
|
||||||
<?php else: ?>
|
}
|
||||||
<strong><?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?></strong>
|
?>
|
||||||
<br>
|
<tr class="state <?= $stateText . ($downtime->is_in_effect ? ' handled' : '') ?>">
|
||||||
<?= $this->timeUntil($downtime->is_in_effect ? $downtime->end : $downtime->start, $this->compact) ?>
|
<td class="state">
|
||||||
<?php endif; ?>
|
<?php if ($downtime->start <= time() && ! $downtime->is_in_effect): ?>
|
||||||
</td>
|
<strong><?= $this->translate('Ends') ?></strong>
|
||||||
<td class="name oneline">
|
<br>
|
||||||
<?php if ($downtime->isService): ?>
|
<?= $this->timeUntil(
|
||||||
<?= $this->icon('service', $this->translate('Service')) ?>
|
$downtime->is_flexible ? $downtime->scheduled_end : $downtime->end, $this->compact
|
||||||
<?= $this->link()->service(
|
) ?>
|
||||||
$downtime->service_description,
|
<?php else: ?>
|
||||||
$downtime->service_display_name,
|
<strong>
|
||||||
$downtime->host_name,
|
<?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts') ?>
|
||||||
$downtime->host_display_name
|
</strong>
|
||||||
); ?>
|
<br>
|
||||||
<?php else: ?>
|
<?= $this->timeUntil($downtime->is_in_effect ? $downtime->end : $downtime->start, $this->compact) ?>
|
||||||
<?= $this->icon('host', $this->translate('Host')) ?>
|
<?php endif ?>
|
||||||
<?= $this->link()->host($downtime->host_name, $downtime->host_display_name); ?>
|
</td>
|
||||||
<?php endif; ?>
|
<td class="name oneline">
|
||||||
|
<?php if ($isService): ?>
|
||||||
|
<?= $this->icon('service', $this->translate('Service')) ?>
|
||||||
|
<?= $this->link()->service(
|
||||||
|
$downtime->service_description,
|
||||||
|
$downtime->service_display_name,
|
||||||
|
$downtime->host_name,
|
||||||
|
$downtime->host_display_name
|
||||||
|
) ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?= $this->icon('host', $this->translate('Host')) ?>
|
||||||
|
<?= $this->link()->host($downtime->host_name, $downtime->host_display_name) ?>
|
||||||
|
<?php endif ?>
|
||||||
<br>
|
<br>
|
||||||
<?php if ($downtime->is_flexible): ?>
|
<?php if ($downtime->is_flexible): ?>
|
||||||
<?php if ($downtime->is_in_effect): ?>
|
<?php if ($downtime->is_in_effect): ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->isService
|
$isService
|
||||||
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
|
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
|
||||||
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
|
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
|
||||||
$this->formatDate($downtime->start),
|
$this->formatDate($downtime->start),
|
||||||
$this->formatTime($downtime->start),
|
$this->formatTime($downtime->start),
|
||||||
$this->formatDuration($downtime->duration),
|
$this->formatDuration($downtime->duration),
|
||||||
$this->formatDate($downtime->end),
|
$this->formatDate($downtime->end),
|
||||||
$this->formatTime($downtime->end)
|
$this->formatTime($downtime->end)
|
||||||
); ?>
|
) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->isService
|
$isService
|
||||||
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
|
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
|
||||||
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
|
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
|
||||||
$this->formatDateTime($downtime->scheduled_start),
|
$this->formatDateTime($downtime->scheduled_start),
|
||||||
$this->formatDateTime($downtime->scheduled_end),
|
$this->formatDateTime($downtime->scheduled_end),
|
||||||
$this->formatDuration($downtime->duration)
|
$this->formatDuration($downtime->duration)
|
||||||
); ?>
|
) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php if ($downtime->is_in_effect): ?>
|
<?php if ($downtime->is_in_effect): ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->isService
|
$isService
|
||||||
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
|
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
|
||||||
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
|
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
|
||||||
$this->formatDate($downtime->start),
|
$this->formatDate($downtime->start),
|
||||||
$this->formatTime($downtime->start),
|
$this->formatTime($downtime->start),
|
||||||
$this->formatDate($downtime->end),
|
$this->formatDate($downtime->end),
|
||||||
$this->formatTime($downtime->end)
|
$this->formatTime($downtime->end)
|
||||||
); ?>
|
) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->isService
|
$isService
|
||||||
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
|
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
|
||||||
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
|
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
|
||||||
$this->formatDate($downtime->scheduled_start),
|
$this->formatDate($downtime->scheduled_start),
|
||||||
$this->formatTime($downtime->scheduled_start),
|
$this->formatTime($downtime->scheduled_start),
|
||||||
$this->formatDate($downtime->scheduled_end),
|
$this->formatDate($downtime->scheduled_end),
|
||||||
$this->formatTime($downtime->scheduled_end)
|
$this->formatTime($downtime->scheduled_end)
|
||||||
); ?>
|
) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php if ($downtimes->count() > 5): ?>
|
||||||
<?php if (count($downtimes) > 5): ?>
|
|
||||||
<p>
|
<p>
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
sprintf($this->translate('List all %d downtimes'), $i),
|
sprintf($this->translate('List all %d downtimes'), $downtimes->count()),
|
||||||
$listAllLink,
|
$listAllLink,
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
'icon' => 'down-open',
|
'data-base-target' => '_next',
|
||||||
'data-base-target' => "_next"
|
'icon' => 'down-open'
|
||||||
)
|
)
|
||||||
) ?>
|
) ?>
|
||||||
</p>
|
</p>
|
||||||
|
@ -1,110 +0,0 @@
|
|||||||
<?php if (! $this->compact): ?>
|
|
||||||
<div class="controls">
|
|
||||||
<?= $this->tabs; ?>
|
|
||||||
</div>
|
|
||||||
<?php endif;
|
|
||||||
|
|
||||||
$rv = $this->runtimeVariables()->create($this->runtimevariables);
|
|
||||||
$cp = $this->checkPerformance()->create($this->checkperformance);
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="content processinfo">
|
|
||||||
|
|
||||||
<h4>Object summaries</h4>
|
|
||||||
<table class="table-bordered table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 300px;"> </td>
|
|
||||||
<td># overall / scheduled</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong>Hosts</strong>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?= $rv->total_hosts; ?>
|
|
||||||
/ <?= $rv->total_scheduled_hosts; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong>Services</strong>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?= $rv->total_services; ?>
|
|
||||||
/ <?= $rv->total_scheduled_services; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong>Average services per host</strong>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?= sprintf('%.2f', $rv->average_services_per_host); ?>
|
|
||||||
/ <?= sprintf('%.2f', $rv->average_scheduled_services_per_host); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h4>Active checks</h4>
|
|
||||||
<table class="table-bordered table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 300px;"> </td>
|
|
||||||
<td>#</td>
|
|
||||||
<td>Latency</td>
|
|
||||||
<td>Execution time</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong>Host Checks</strong>
|
|
||||||
</td>
|
|
||||||
<td><?= $cp->host_active_count; ?></td>
|
|
||||||
<td><?= sprintf('%.3f', $cp->host_active_latency_avg); ?>s</td>
|
|
||||||
<td><?= sprintf('%.3f', $cp->host_active_execution_avg); ?>s</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong>Service Checks</strong>
|
|
||||||
</td>
|
|
||||||
<td><?= $cp->service_active_count; ?></td>
|
|
||||||
<td><?= sprintf('%.3f', $cp->service_active_latency_avg); ?>s</td>
|
|
||||||
<td><?= sprintf('%.3f', $cp->service_active_execution_avg); ?>s</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h4>Passive checks</h4>
|
|
||||||
<table class="table-bordered table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 300px;"> </td>
|
|
||||||
<td>#</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong>Host Checks</strong>
|
|
||||||
</td>
|
|
||||||
<td><?= $cp->host_passive_count; ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong>Service Checks</strong>
|
|
||||||
</td>
|
|
||||||
<td><?= $cp->service_passive_count; ?></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
use Icinga\Web\Controller;
|
namespace Icinga\Module\Setup\Controllers;
|
||||||
use Icinga\Module\Setup\WebWizard;
|
|
||||||
|
|
||||||
class Setup_IndexController extends Controller
|
use Icinga\Module\Setup\WebWizard;
|
||||||
|
use Icinga\Web\Controller;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Whether the controller requires the user to be authenticated
|
* Whether the controller requires the user to be authenticated
|
||||||
|
@ -22,9 +22,9 @@ require_once 'Mockery/Loader.php';
|
|||||||
$mockeryLoader = new \Mockery\Loader;
|
$mockeryLoader = new \Mockery\Loader;
|
||||||
$mockeryLoader->register();
|
$mockeryLoader->register();
|
||||||
|
|
||||||
require_once($libraryPath . '/Icinga/Application/Loader.php');
|
require_once($libraryPath . '/Icinga/Application/ClassLoader.php');
|
||||||
|
|
||||||
$loader = new Icinga\Application\Loader();
|
$loader = new Icinga\Application\ClassLoader();
|
||||||
$loader->registerNamespace('Tests', $testLibraryPath);
|
$loader->registerNamespace('Tests', $testLibraryPath);
|
||||||
$loader->registerNamespace('Icinga', $libraryPath . '/Icinga');
|
$loader->registerNamespace('Icinga', $libraryPath . '/Icinga');
|
||||||
$loader->registerNamespace('Icinga\\Forms', $applicationPath . '/forms');
|
$loader->registerNamespace('Icinga\\Forms', $applicationPath . '/forms');
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
namespace Tests\Icinga\Application;
|
namespace Tests\Icinga\Application;
|
||||||
|
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
use Icinga\Application\Loader;
|
use Icinga\Application\ClassLoader;
|
||||||
|
|
||||||
class LoaderTest extends BaseTestCase
|
class ClassLoaderTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
private static $classFile = 'test/My/Library/TestStruct.php';
|
private static $classFile = 'test/My/Library/TestStruct.php';
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ EOD;
|
|||||||
|
|
||||||
public function testObjectCreation1()
|
public function testObjectCreation1()
|
||||||
{
|
{
|
||||||
$loader = new Loader();
|
$loader = new ClassLoader();
|
||||||
$loader->register();
|
$loader->register();
|
||||||
|
|
||||||
$check = false;
|
$check = false;
|
||||||
@ -56,7 +56,7 @@ EOD;
|
|||||||
}
|
}
|
||||||
$this->assertTrue($check);
|
$this->assertTrue($check);
|
||||||
|
|
||||||
$loader->unRegister();
|
$loader->unregister();
|
||||||
|
|
||||||
$check = true;
|
$check = true;
|
||||||
foreach (spl_autoload_functions() as $functions) {
|
foreach (spl_autoload_functions() as $functions) {
|
||||||
@ -71,7 +71,7 @@ EOD;
|
|||||||
|
|
||||||
public function testNamespaces()
|
public function testNamespaces()
|
||||||
{
|
{
|
||||||
$loader = new Loader();
|
$loader = new ClassLoader();
|
||||||
$loader->registerNamespace('Test\\Laola', '/tmp');
|
$loader->registerNamespace('Test\\Laola', '/tmp');
|
||||||
$loader->registerNamespace('Dings\\Var', '/var/tmp');
|
$loader->registerNamespace('Dings\\Var', '/var/tmp');
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ EOD;
|
|||||||
$classFile = $this->baseDir. self::$classFile;
|
$classFile = $this->baseDir. self::$classFile;
|
||||||
$this->assertFileExists($classFile);
|
$this->assertFileExists($classFile);
|
||||||
|
|
||||||
$loader = new Loader();
|
$loader = new ClassLoader();
|
||||||
$loader->registerNamespace('My\\Library', dirname($classFile));
|
$loader->registerNamespace('My\\Library', dirname($classFile));
|
||||||
$this->assertFalse($loader->loadClass('DOES\\NOT\\EXISTS'));
|
$this->assertFalse($loader->loadClass('DOES\\NOT\\EXISTS'));
|
||||||
$this->assertTrue($loader->loadClass('My\\Library\\TestStruct'));
|
$this->assertTrue($loader->loadClass('My\\Library\\TestStruct'));
|
||||||
@ -100,20 +100,11 @@ EOD;
|
|||||||
$classFile = $this->baseDir. self::$classFile;
|
$classFile = $this->baseDir. self::$classFile;
|
||||||
$this->assertFileExists($classFile);
|
$this->assertFileExists($classFile);
|
||||||
|
|
||||||
$loader = new Loader();
|
$loader = new ClassLoader();
|
||||||
$loader->registerNamespace('My\\Library', dirname($classFile));
|
$loader->registerNamespace('My\\Library', dirname($classFile));
|
||||||
$loader->register();
|
$loader->register();
|
||||||
|
|
||||||
$o = new \My\Library\TestStruct();
|
$o = new \My\Library\TestStruct();
|
||||||
$this->assertTrue($o->testFlag());
|
$this->assertTrue($o->testFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Icinga\Exception\ProgrammingError
|
|
||||||
*/
|
|
||||||
public function testNonexistingDirectory()
|
|
||||||
{
|
|
||||||
$loader = new Loader();
|
|
||||||
$loader->registerNamespace('My\\Library', '/trullalla/123');
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user