Skip to content

Commit

Permalink
Merge branch 'master' into feature/improve-multi-select-view-8565
Browse files Browse the repository at this point in the history
Conflicts:
	modules/monitoring/application/controllers/HostsController.php
	modules/monitoring/application/controllers/ServicesController.php
	modules/monitoring/application/views/scripts/hosts/show.phtml
	modules/monitoring/application/views/scripts/list/hosts.phtml
	modules/monitoring/application/views/scripts/partials/host/objects-header.phtml
	modules/monitoring/application/views/scripts/partials/service/objects-header.phtml
	modules/monitoring/application/views/scripts/services/show.phtml
	modules/monitoring/public/css/module.less
	public/js/icinga/behavior/tooltip.js
  • Loading branch information
majentsch committed May 11, 2015
2 parents 2efea21 + cf8376f commit 25f3970
Show file tree
Hide file tree
Showing 338 changed files with 14,351 additions and 6,083 deletions.
2 changes: 1 addition & 1 deletion .puppet/profiles/icingaweb2_dev/manifests/init.pp
Expand Up @@ -90,7 +90,7 @@
source => $name,
}

icingaweb2::config::general { [ 'config', 'resources' ]:
icingaweb2::config::general { [ 'config', 'resources', 'roles' ]:
source => $name,
replace => false,
}
Expand Down
3 changes: 3 additions & 0 deletions .puppet/profiles/icingaweb2_dev/templates/roles.ini.erb
@@ -0,0 +1,3 @@
[admins]
users = icingaadmin
permissions = *
5 changes: 3 additions & 2 deletions AUTHORS
@@ -1,5 +1,6 @@
Alexander Fuhr <alexander.fuhr@netways.de>
Alexander Klimov <alexander.klimov@netways.de>
ayoubabid <ayoubabid@users.noreply.github.com>
baufrecht <baufrecht@users.noreply.github.com>
Bernd Erk <bernd.erk@icinga.org>
Boden Garman <boden.garman@spintel.net.au>
Expand All @@ -11,8 +12,9 @@ Goran Rakic <grakic@devbase.net>
Gunnar Beutner <gunnar.beutner@netways.de>
Jannis Moßhammer <jannis.mosshammer@netways.de>
Johannes Meyer <johannes.meyer@netways.de>
Marius Hein <marius.hein@netways.de>
Louis Sautier <sautier.louis@gmail.com>
Marcus Cobden <marcus@marcuscobden.co.uk>
Marius Hein <marius.hein@netways.de>
Markus Frosch <markus@lazyfrosch.de>
Matthias Jentsch <matthias.jentsch@netways.de>
Michael Friedrich <michael.friedrich@netways.de>
Expand All @@ -22,4 +24,3 @@ Sylph Lin <sylph.lin@gmail.com>
Thomas Gelf <thomas.gelf@netways.de>
Tom Ford <exptom@users.noreply.github.com>
Ulf Lange <mopp@gmx.net>
ayoubabid <ayoubabid@users.noreply.github.com>
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
v2.0.0-beta2
v2.0.0-beta3
8 changes: 4 additions & 4 deletions application/controllers/AuthenticationController.php
Expand Up @@ -102,21 +102,21 @@ public function loginAction()
$this->view->form->addError(
$this->translate(
'No authentication methods available. Did you create'
. ' authentication.ini when setting up Icinga Web 2?'
. ' authentication.ini when setting up Icinga Web 2?'
)
);
} else if ($backendsTried === $backendsWithError) {
$this->view->form->addError(
$this->translate(
'All configured authentication methods failed.'
. ' Please check the system log or Icinga Web 2 log for more information.'
. ' Please check the system log or Icinga Web 2 log for more information.'
)
);
} elseif ($backendsWithError) {
$this->view->form->addError(
$this->translate(
'Please note that not all authentication methods were available.'
. ' Check the system log or Icinga Web 2 log for more information.'
. ' Check the system log or Icinga Web 2 log for more information.'
)
);
}
Expand Down Expand Up @@ -144,7 +144,7 @@ public function loginAction()
$this->view->form->addError($e->getMessage());
}

$this->view->requiresExternalAuth = $triedOnlyExternalAuth && !$auth->isAuthenticated();
$this->view->requiresExternalAuth = $triedOnlyExternalAuth && ! $auth->isAuthenticated();
$this->view->requiresSetup = Icinga::app()->requiresSetup();
}

Expand Down
65 changes: 36 additions & 29 deletions application/controllers/ConfigController.php
Expand Up @@ -11,19 +11,19 @@
use Icinga\Forms\Config\ResourceConfigForm;
use Icinga\Forms\ConfirmRemovalForm;
use Icinga\Security\SecurityException;
use Icinga\Web\Controller\ActionController;
use Icinga\Web\Controller;
use Icinga\Web\Notification;
use Icinga\Web\Widget;

/**
* Application and module configuration
*/
class ConfigController extends ActionController
class ConfigController extends Controller
{
/**
* The first allowed config action according to the user's permissions
*
* @type string
* @var string
*/
protected $firstAllowedAction;

Expand All @@ -37,31 +37,31 @@ public function init()
$tabs = $this->getTabs();
$auth = $this->Auth();
$allowedActions = array();
if ($auth->hasPermission('system/config/application')) {
if ($auth->hasPermission('config/application/general')) {
$tabs->add('application', array(
'title' => $this->translate('Adjust the general configuration of Icinga Web 2'),
'label' => $this->translate('Application'),
'url' => 'config/application'
));
$allowedActions[] = 'application';
}
if ($auth->hasPermission('system/config/authentication')) {
if ($auth->hasPermission('config/application/authentication')) {
$tabs->add('authentication', array(
'title' => $this->translate('Configure how users authenticate with and log into Icinga Web 2'),
'label' => $this->translate('Authentication'),
'url' => 'config/authentication'
));
$allowedActions[] = 'authentication';
}
if ($auth->hasPermission('system/config/resources')) {
if ($auth->hasPermission('config/application/resources')) {
$tabs->add('resource', array(
'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'),
'label' => $this->translate('Resources'),
'url' => 'config/resource'
));
$allowedActions[] = 'resource';
}
if ($auth->hasPermission('system/config/roles')) {
if ($auth->hasPermission('config/application/roles')) {
$tabs->add('roles', array(
'title' => $this->translate(
'Configure roles to permit or restrict users and groups accessing Icinga Web 2'
Expand All @@ -72,7 +72,6 @@ public function init()
$allowedActions[] = 'roles';
}
$this->firstAllowedAction = array_shift($allowedActions);
$this->getTabs()->setTitle($this->translate('Config Navigation'));
}

public function devtoolsAction()
Expand Down Expand Up @@ -103,7 +102,7 @@ public function indexAction()
*/
public function applicationAction()
{
$this->assertPermission('system/config/application');
$this->assertPermission('config/application/general');
$form = new GeneralConfigForm();
$form->setIniConfig(Config::app());
$form->handleRequest();
Expand Down Expand Up @@ -131,39 +130,47 @@ public function modulesAction()
->order('enabled', 'desc')
->order('name')
->paginate();
$this->setupLimitControl();
$this->setupPaginationControl($this->view->modules);
// TODO: Not working
/*$this->setupSortControl(array(
'name' => $this->translate('Modulename'),
'path' => $this->translate('Installation Path'),
'enabled' => $this->translate('State')
));*/
}

public function moduleAction()
{
$name = $this->getParam('name');
$app = Icinga::app();
$manager = $app->getModuleManager();
$name = $this->getParam('name');
if ($manager->hasInstalled($name)) {
$this->view->moduleData = Icinga::app()
->getModuleManager()
->select()
->from('modules')
->where('name', $name)
->fetchRow();
$module = new Module($app, $name, $manager->getModuleDir($name));
$this->view->moduleData = $manager->select()->from('modules')->where('name', $name)->fetchRow();
if ($manager->hasLoaded($name)) {
$module = $manager->getModule($name);
} else {
$module = new Module($app, $name, $manager->getModuleDir($name));
}

$this->view->module = $module;
$this->view->tabs = $module->getConfigTabs()->activate('info');
} else {
$this->view->module = false;
$this->view->tabs = null;
}
$this->view->tabs = $module->getConfigTabs()->activate('info');
}

/**
* Enable a specific module provided by the 'name' param
*/
public function moduleenableAction()
{
$this->assertPermission('system/config/modules');
$this->assertPermission('config/modules');
$module = $this->getParam('name');
$manager = Icinga::app()->getModuleManager();
try {
$manager->enableModule($module);
$manager->loadModule($module);
Notification::success(sprintf($this->translate('Module "%s" enabled'), $module));
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
} catch (Exception $e) {
Expand All @@ -179,7 +186,7 @@ public function moduleenableAction()
*/
public function moduledisableAction()
{
$this->assertPermission('system/config/modules');
$this->assertPermission('config/modules');
$module = $this->getParam('name');
$manager = Icinga::app()->getModuleManager();
try {
Expand All @@ -199,7 +206,7 @@ public function moduledisableAction()
*/
public function authenticationAction()
{
$this->assertPermission('system/config/authentication');
$this->assertPermission('config/application/authentication');
$form = new AuthenticationBackendReorderForm();
$form->setIniConfig(Config::app('authentication'));
$form->handleRequest();
Expand All @@ -214,7 +221,7 @@ public function authenticationAction()
*/
public function createauthenticationbackendAction()
{
$this->assertPermission('system/config/authentication');
$this->assertPermission('config/application/authentication');
$form = new AuthenticationBackendConfigForm();
$form->setTitle($this->translate('Create New Authentication Backend'));
$form->addDescription($this->translate(
Expand All @@ -236,7 +243,7 @@ public function createauthenticationbackendAction()
*/
public function editauthenticationbackendAction()
{
$this->assertPermission('system/config/authentication');
$this->assertPermission('config/application/authentication');
$form = new AuthenticationBackendConfigForm();
$form->setTitle($this->translate('Edit Backend'));
$form->setIniConfig(Config::app('authentication'));
Expand All @@ -254,7 +261,7 @@ public function editauthenticationbackendAction()
*/
public function removeauthenticationbackendAction()
{
$this->assertPermission('system/config/authentication');
$this->assertPermission('config/application/authentication');
$form = new ConfirmRemovalForm(array(
'onSuccess' => function ($form) {
$configForm = new AuthenticationBackendConfigForm();
Expand Down Expand Up @@ -292,7 +299,7 @@ public function removeauthenticationbackendAction()
*/
public function resourceAction()
{
$this->assertPermission('system/config/resources');
$this->assertPermission('config/application/resources');
$this->view->resources = Config::app('resources', true)->keys();
$this->view->tabs->activate('resource');
}
Expand All @@ -302,7 +309,7 @@ public function resourceAction()
*/
public function createresourceAction()
{
$this->assertPermission('system/config/resources');
$this->assertPermission('config/application/resources');
$form = new ResourceConfigForm();
$form->setTitle($this->translate('Create A New Resource'));
$form->addDescription($this->translate('Resources are entities that provide data to Icinga Web 2.'));
Expand All @@ -319,7 +326,7 @@ public function createresourceAction()
*/
public function editresourceAction()
{
$this->assertPermission('system/config/resources');
$this->assertPermission('config/application/resources');
$form = new ResourceConfigForm();
$form->setTitle($this->translate('Edit Existing Resource'));
$form->setIniConfig(Config::app('resources'));
Expand All @@ -335,7 +342,7 @@ public function editresourceAction()
*/
public function removeresourceAction()
{
$this->assertPermission('system/config/resources');
$this->assertPermission('config/application/resources');
$form = new ConfirmRemovalForm(array(
'onSuccess' => function ($form) {
$configForm = new ResourceConfigForm();
Expand Down
32 changes: 22 additions & 10 deletions application/controllers/ErrorController.php
Expand Up @@ -3,6 +3,7 @@

use Icinga\Application\Icinga;
use Icinga\Application\Logger;
use Icinga\Exception\MissingParameterException;
use Icinga\Security\SecurityException;
use Icinga\Web\Controller\ActionController;

Expand Down Expand Up @@ -33,7 +34,11 @@ public function errorAction()
$path = preg_split('~/~', $path);
$path = array_shift($path);
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = $this->translate('Page not found.');
$title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage());
$this->view->title = 'Server error: ' . $title;
if ($this->getInvokeArg('displayExceptions')) {
$this->view->stackTrace = $exception->getTraceAsString();
}
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
$this->view->message .= ' ' . sprintf(
$this->translate('Enabling the "%s" module might help!'),
Expand All @@ -42,19 +47,26 @@ public function errorAction()
}

break;
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER:
if ($exception instanceof SecurityException) {
$this->getResponse()->setHttpResponseCode(403);
$this->view->message = $exception->getMessage();
break;
}
// Move to default
default:
switch (true) {
case $exception instanceof SecurityException:
$this->getResponse()->setHttpResponseCode(403);
break;
case $exception instanceof MissingParameterException:
$this->getResponse()->setHttpResponseCode(400);
$this->getResponse()->setHeader(
'X-Status-Reason',
'Missing parameter ' . $exception->getParameter()
);
break;
default:
$this->getResponse()->setHttpResponseCode(500);
break;
}
$title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage());
$this->getResponse()->setHttpResponseCode(500);
$this->view->title = 'Server error: ' . $title;
$this->view->message = $exception->getMessage();
if ($this->getInvokeArg('displayExceptions') == true) {
if ($this->getInvokeArg('displayExceptions')) {
$this->view->stackTrace = $exception->getTraceAsString();
}
break;
Expand Down
19 changes: 11 additions & 8 deletions application/controllers/ListController.php
Expand Up @@ -3,6 +3,9 @@

use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction;
use Icinga\Web\Widget\Tabextension\OutputFormat;
use Icinga\Application\Config;
use Icinga\Application\Logger;
use Icinga\Data\ConfigObject;
use Icinga\Protocol\File\FileReader;
Expand All @@ -28,7 +31,7 @@ protected function addTitleTab($action)
'list/'
. str_replace(' ', '', $action)
)
))->activate($action);
))->extend(new OutputFormat())->extend(new DashboardAction())->activate($action);
}

/**
Expand All @@ -41,16 +44,16 @@ public function applicationlogAction()
}

$this->addTitleTab('application log');
$pattern = '/^(?<datetime>[0-9]{4}(-[0-9]{2}){2}' // date
. 'T[0-9]{2}(:[0-9]{2}){2}([\\+\\-][0-9]{2}:[0-9]{2})?)' // time
. ' - (?<loglevel>[A-Za-z]+)' // loglevel
. ' - (?<message>.*)$/'; // message

$loggerWriter = Logger::getInstance()->getWriter();
$resource = new FileReader(new ConfigObject(array(
'filename' => $loggerWriter->getPath(),
'fields' => $pattern
'filename' => Config::app()->get('logging', 'file'),
'fields' => '/(?<!.)(?<datetime>[0-9]{4}(?:-[0-9]{2}){2}' // date
. 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time
. ' - (?<loglevel>[A-Za-z]+) - (?<message>.*)(?!.)/msS' // loglevel, message
)));
$this->view->logData = $resource->select()->order('DESC')->paginate();

$this->setupLimitControl();
$this->setupPaginationControl($this->view->logData);
}
}

0 comments on commit 25f3970

Please sign in to comment.