parent
0b479e3796
commit
aff2398c81
|
@ -4,21 +4,21 @@
|
|||
/**
|
||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
|
@ -26,32 +26,36 @@
|
|||
|
||||
# namespace Icinga\Application\Controllers;
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Authentication\Credentials;
|
||||
use Icinga\Authentication\Manager as AuthManager;
|
||||
use Icinga\Form\Authentication\LoginForm;
|
||||
use \Icinga\Web\Controller\ActionController;
|
||||
use \Icinga\Authentication\Credentials;
|
||||
use \Icinga\Authentication\Manager as AuthManager;
|
||||
use \Icinga\Form\Authentication\LoginForm;
|
||||
use \Icinga\Exception\ConfigurationError;
|
||||
|
||||
|
||||
/**
|
||||
* Class AuthenticationController
|
||||
* @package Icinga\Application\Controllers
|
||||
* Application wide controller for authentication
|
||||
*/
|
||||
class AuthenticationController extends ActionController
|
||||
{
|
||||
/**
|
||||
* Flag indicates authentication handling
|
||||
* This controller handles authentication
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $handlesAuthentication = true;
|
||||
|
||||
/**
|
||||
* Flag indicates session modification
|
||||
* This controller modifies the session
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @see \Icinga\Web\Controller\ActionController::$modifiesSession
|
||||
*/
|
||||
protected $modifiesSession = true;
|
||||
|
||||
/**
|
||||
* Action to handle login
|
||||
* Log into the application
|
||||
*/
|
||||
public function loginAction()
|
||||
{
|
||||
|
@ -62,7 +66,7 @@ class AuthenticationController extends ActionController
|
|||
|
||||
try {
|
||||
$auth = AuthManager::getInstance(null, array(
|
||||
"writeSession" => true
|
||||
'writeSession' => $this->modifiesSession
|
||||
));
|
||||
|
||||
if ($auth->isAuthenticated()) {
|
||||
|
@ -74,30 +78,28 @@ class AuthenticationController extends ActionController
|
|||
$credentials->setPassword($this->view->form->getValue('password'));
|
||||
|
||||
if (!$auth->authenticate($credentials)) {
|
||||
$this->view->form->getElement('password')->addError(t('Please provide a valid username and password'));
|
||||
$this->view->form->getElement('password')
|
||||
->addError(t('Please provide a valid username and password'));
|
||||
} else {
|
||||
$this->redirectNow('index?_render=body');
|
||||
}
|
||||
}
|
||||
} catch (\Icinga\Exception\ConfigurationError $configError) {
|
||||
} catch (ConfigurationError $configError) {
|
||||
$this->view->errorInfo = $configError->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action handle logout
|
||||
* Log out the current user
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
$auth = AuthManager::getInstance(null, array(
|
||||
"writeSession" => true
|
||||
'writeSession' => $this->modifiesSession
|
||||
));
|
||||
$this->replaceLayout = true;
|
||||
$auth->removeAuthorization();
|
||||
$this->redirect('login');
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -4,67 +4,66 @@
|
|||
/**
|
||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Application\Benchmark;
|
||||
use Icinga\Authentication\Manager;
|
||||
use Icinga\Web\Controller\BaseConfigController;
|
||||
use Icinga\Web\Widget\Tab;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
|
||||
use Icinga\Application\Icinga;
|
||||
use \Icinga\Application\Benchmark;
|
||||
use \Icinga\Authentication\Manager;
|
||||
use \Icinga\Web\Controller\BaseConfigController;
|
||||
use \Icinga\Web\Widget\Tab;
|
||||
use \Icinga\Web\Url;
|
||||
use \Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
|
||||
use \Icinga\Application\Icinga;
|
||||
|
||||
/**
|
||||
* Application wide controller for application preferences
|
||||
*
|
||||
*/
|
||||
class ConfigController extends BaseConfigController
|
||||
{
|
||||
/**
|
||||
* Create tabs for this configuration controller
|
||||
*
|
||||
* @return array
|
||||
* @see BaseConfigController::createProvidedTabs
|
||||
* @return array
|
||||
*
|
||||
* @see BaseConfigController::createProvidedTabs()
|
||||
*/
|
||||
public static function createProvidedTabs()
|
||||
{
|
||||
return array(
|
||||
"index" => new Tab(
|
||||
'index' => new Tab(
|
||||
array(
|
||||
"name" => "index",
|
||||
"title" => "Configuration",
|
||||
"iconCls" => "wrench",
|
||||
"url" => Url::fromPath("/config")
|
||||
'name' => 'index',
|
||||
'title' => 'Configuration',
|
||||
'iconCls' => 'wrench',
|
||||
'url' => Url::fromPath('/config')
|
||||
)
|
||||
),
|
||||
"modules" => new Tab(
|
||||
'modules' => new Tab(
|
||||
array(
|
||||
"name" => "modules",
|
||||
"title" => "Modules",
|
||||
"iconCls" => "puzzle-piece",
|
||||
"url" => Url::fromPath("/config/moduleoverview")
|
||||
'name' => 'modules',
|
||||
'title' => 'Modules',
|
||||
'iconCls' => 'puzzle-piece',
|
||||
'url' => Url::fromPath('/config/moduleoverview')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +94,6 @@ class ConfigController extends BaseConfigController
|
|||
$manager = Icinga::app()->getModuleManager();
|
||||
$manager->enableModule($this->_getParam('name'));
|
||||
$manager->loadModule($this->_getParam('name'));
|
||||
|
||||
$this->redirectNow('config/moduleoverview?_render=body');
|
||||
}
|
||||
|
||||
|
@ -109,4 +107,4 @@ class ConfigController extends BaseConfigController
|
|||
$this->redirectNow('config/moduleoverview?_render=body');
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Widget\Dashboard;
|
||||
use \Icinga\Web\Controller\ActionController;
|
||||
use \Icinga\Web\Url;
|
||||
use \Icinga\Application\Icinga;
|
||||
use \Icinga\Web\Widget\Dashboard;
|
||||
use \Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Form\Dashboard\AddUrlForm;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use \Icinga\Form\Dashboard\AddUrlForm;
|
||||
use \Icinga\Exception\ConfigurationError;
|
||||
|
||||
/**
|
||||
* Handle creation, removal and displaying of dashboards, panes and components
|
||||
|
@ -42,13 +42,12 @@ use Icinga\Exception\ConfigurationError;
|
|||
*/
|
||||
class DashboardController extends ActionController
|
||||
{
|
||||
|
||||
/**
|
||||
* Retrieve a dashboard from the provided config
|
||||
*
|
||||
* @param string $config The config to read the dashboard from, or 'dashboard/dashboard' if none is given
|
||||
* @param string $config The config to read the dashboard from, or 'dashboard/dashboard' if none is given
|
||||
*
|
||||
* @return Dashboard
|
||||
* @return \Icinga\Web\Widget\Dashboard
|
||||
*/
|
||||
private function getDashboard($config = 'dashboard/dashboard')
|
||||
{
|
||||
|
@ -59,7 +58,6 @@ class DashboardController extends ActionController
|
|||
|
||||
/**
|
||||
* Remove a component from the pane identified by the 'pane' parameter
|
||||
*
|
||||
*/
|
||||
public function removecomponentAction()
|
||||
{
|
||||
|
@ -72,24 +70,20 @@ class DashboardController extends ActionController
|
|||
)->store();
|
||||
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $pane)));
|
||||
} catch (ConfigurationError $exc ) {
|
||||
|
||||
$this->_helper->viewRenderer('show_configuration');
|
||||
$this->view->exceptionMessage = $exc->getMessage();
|
||||
$this->view->iniConfigurationString = $dashboard->toIni();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the form for adding new components or add the new component if submitted
|
||||
*
|
||||
*/
|
||||
public function addurlAction()
|
||||
{
|
||||
$form = new AddUrlForm();
|
||||
$form->setRequest($this->_request);
|
||||
$this->view->form = $form;
|
||||
|
||||
if ($form->isSubmittedAndValid()) {
|
||||
$dashboard = $this->getDashboard();
|
||||
$dashboard->setComponentUrl(
|
||||
|
@ -115,12 +109,10 @@ class DashboardController extends ActionController
|
|||
*
|
||||
* If no pane is submitted or the submitted one doesn't exist, the default pane is
|
||||
* displayed (normally the first one)
|
||||
*
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$dashboard = $this->getDashboard();
|
||||
|
||||
if ($this->_getParam('pane')) {
|
||||
$pane = $this->_getParam('pane');
|
||||
$dashboard->activate($pane);
|
||||
|
@ -137,5 +129,4 @@ class DashboardController extends ActionController
|
|||
$this->view->dashboard = $dashboard;
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
/**
|
||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
|
@ -26,21 +26,19 @@
|
|||
|
||||
# namespace Icinga\Application\Controllers;
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use \Icinga\Web\Controller\ActionController;
|
||||
|
||||
/**
|
||||
* Class ErrorController
|
||||
* @package Icinga\Application\Controllers
|
||||
* Application wide controller for displaying exceptions
|
||||
*/
|
||||
class ErrorController extends ActionController
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Display exception
|
||||
*/
|
||||
public function errorAction()
|
||||
{
|
||||
$errors = $this->_getParam('error_handler');
|
||||
|
||||
switch ($errors->type) {
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||
|
@ -59,9 +57,7 @@ class ErrorController extends ActionController
|
|||
if ($this->getInvokeArg('displayExceptions') == true) {
|
||||
$this->view->exception = $errors->exception;
|
||||
}
|
||||
|
||||
$this->view->request = $errors->request;
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -29,22 +29,16 @@
|
|||
|
||||
# namespace Icinga\Application\Controllers;
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Application\Icinga;
|
||||
use \Icinga\Web\Controller\ActionController;
|
||||
use \Icinga\Application\Icinga;
|
||||
|
||||
/**
|
||||
* Class IndexController
|
||||
* Application wide index controller
|
||||
*/
|
||||
class IndexController extends ActionController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $modifiesSession = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* Always authenticate
|
||||
*/
|
||||
public function preDispatch()
|
||||
{
|
||||
|
@ -55,11 +49,10 @@ class IndexController extends ActionController
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Application's start page
|
||||
*/
|
||||
public function welcomeAction()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -3,24 +3,24 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga 2 Web.
|
||||
*
|
||||
*
|
||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
|
@ -33,26 +33,25 @@ use \Icinga\Web\Url;
|
|||
|
||||
/**
|
||||
* Application wide preference controller for user preferences
|
||||
*
|
||||
*/
|
||||
class PreferenceController extends BasePreferenceController
|
||||
{
|
||||
|
||||
/**
|
||||
* Create tabs for this preference controller
|
||||
*
|
||||
* @return array
|
||||
* @see BasePreferenceController::createProvidedTabs
|
||||
* @return array
|
||||
*
|
||||
* @see BasePreferenceController::createProvidedTabs()
|
||||
*/
|
||||
public static function createProvidedTabs()
|
||||
{
|
||||
return array(
|
||||
"preference" => new Tab(
|
||||
'preference' => new Tab(
|
||||
array(
|
||||
"name" => "preferences",
|
||||
"iconCls" => "user",
|
||||
"title" => "Preferences",
|
||||
"url" => Url::fromPath("/preference")
|
||||
'name' => 'preferences',
|
||||
'iconCls' => 'user',
|
||||
'title' => 'Preferences',
|
||||
'url' => Url::fromPath('/preference')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -60,11 +59,10 @@ class PreferenceController extends BasePreferenceController
|
|||
|
||||
/**
|
||||
* @TODO: Implement User preferences (feature #5425)
|
||||
*
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -27,13 +27,15 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Application\Icinga,
|
||||
Zend_Controller_Action_Exception as ActionException;
|
||||
use \Zend_Controller_Action_Exception as ActionException;
|
||||
use \Icinga\Web\Controller\ActionController;
|
||||
use \Icinga\Application\Icinga;
|
||||
|
||||
class StaticController extends ActionController
|
||||
{
|
||||
|
||||
/**
|
||||
* @TODO: Bug #4572
|
||||
*/
|
||||
protected $handlesAuthentication = true;
|
||||
|
||||
public function init()
|
||||
|
@ -45,11 +47,10 @@ class StaticController extends ActionController
|
|||
private function getModuleList()
|
||||
{
|
||||
$modules = Icinga::app()->getModuleManager()->getLoadedModules();
|
||||
|
||||
// preliminary static definition
|
||||
$result = array();
|
||||
foreach ($modules as $name => $module) {
|
||||
$hasJs = file_exists($module->getBasedir() . "/public/js/$name.js");
|
||||
$hasJs = file_exists($module->getBasedir() . '/public/js/' . $name . '.js');
|
||||
$result[] = array(
|
||||
'name' => $name,
|
||||
'active' => true,
|
||||
|
@ -62,11 +63,10 @@ class StaticController extends ActionController
|
|||
|
||||
public function modulelistAction()
|
||||
{
|
||||
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->getResponse()->setHeader("Content-Type","application/json");
|
||||
echo "define(function() { return ".json_encode($this->getModuleList(),true)."; })";
|
||||
$this->getResponse()->setHeader('Content-Type', 'application/json');
|
||||
echo 'define(function() { return ' . json_encode($this->getModuleList(), true) . '; })';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class StaticController extends ActionController
|
|||
{
|
||||
$module = $this->_getParam('module_name');
|
||||
$file = $this->_getParam('file');
|
||||
|
||||
|
||||
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
||||
|
||||
$filePath = $basedir . '/public/img/' . $file;
|
||||
|
@ -112,14 +112,14 @@ class StaticController extends ActionController
|
|||
$file = $this->_getParam('file');
|
||||
|
||||
if (!Icinga::app()->getModuleManager()->hasEnabled($module)) {
|
||||
echo "/** Module not enabled **/";
|
||||
echo '/** Module not enabled **/';
|
||||
return;
|
||||
}
|
||||
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
||||
|
||||
$filePath = $basedir . '/public/js/' . $file;
|
||||
if (!file_exists($filePath)) {
|
||||
echo "/** Module has no js files **/";
|
||||
echo '/** Module has no js files **/';
|
||||
return;
|
||||
}
|
||||
$hash = md5_file($filePath);
|
||||
|
@ -143,10 +143,7 @@ class StaticController extends ActionController
|
|||
} else {
|
||||
readfile($filePath);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
Loading…
Reference in New Issue