Merge branch 'master' into feature/user-and-group-management-8826

This commit is contained in:
Johannes Meyer 2015-05-12 15:39:02 +02:00
commit c91d3e52ac
52 changed files with 1769 additions and 298 deletions

View File

@ -1 +1 @@
v2.0.0-beta2
v2.0.0-beta3

View File

@ -34,7 +34,11 @@ class ErrorController extends ActionController
$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!'),

View File

@ -152,3 +152,4 @@ class LogFileIterator implements Iterator
$this->valid = false;
}
}
}

View File

@ -413,30 +413,30 @@ class User
/**
* Whether the user has a given permission
*
* @param string $permission
* @param string $requiredPermission
*
* @return bool
*/
public function can($permission)
public function can($requiredPermission)
{
if (isset($this->permissions['*']) || isset($this->permissions[$permission])) {
if (isset($this->permissions['*']) || isset($this->permissions[$requiredPermission])) {
return true;
}
// If the permission to check contains a wildcard, grant the permission if any permit related to the permission
// matches
$any = strpos($permission, '*');
foreach ($this->permissions as $permitted) {
if ($any !== false) {
$any = strpos($requiredPermission, '*');
foreach ($this->permissions as $grantedPermission) {
if ($any !== false && strpos($grantedPermission, '*') === false) {
$wildcard = $any;
} else {
// If the permit contains a wildcard, grant the permission if it's related to the permit
$wildcard = strpos($permitted, '*');
$wildcard = strpos($grantedPermission, '*');
}
if ($wildcard !== false) {
if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) {
if (substr($requiredPermission, 0, $wildcard) === substr($grantedPermission, 0, $wildcard)) {
return true;
}
} elseif ($permission === $permitted) {
} elseif ($requiredPermission === $grantedPermission) {
return true;
}
}

View File

@ -15,24 +15,50 @@ use Icinga\Web\Widget\Limiter;
*/
class Controller extends ModuleActionController
{
/**
* @see ActionController::init
*/
public function init()
{
parent::init();
$request = $this->getRequest();
$url = Url::fromRequest();
if ($request->isPost() && ($sort = $request->getPost('sort'))) {
$url->setParam('sort', $sort);
if ($dir = $request->getPost('dir')) {
$url->setParam('dir', $dir);
} else {
$url->removeParam('dir');
}
$this->redirectNow($url);
}
}
/**
* Create a SortBox widget at the `sortBox' view property
*
* In case the current view has been requested as compact this method does nothing.
*
* @param array $columns An array containing the sort columns, with the
* @param array $columns An array containing the sort columns, with the
* submit value as the key and the label as the value
* @param Sortable $query Query to set on the newly created SortBox
*
* @return $this
*/
protected function setupSortControl(array $columns)
protected function setupSortControl(array $columns, Sortable $query = null)
{
if (! $this->view->compact) {
$req = $this->getRequest();
$this->view->sortBox = SortBox::create(
$this->view->sortBox = $sortBox = SortBox::create(
'sortbox-' . $req->getActionName(),
$columns
)->applyRequest($req);
)->setRequest($req);
if ($query !== null) {
$sortBox->setQuery($query);
}
$sortBox->handleRequest();
}
return $this;

View File

@ -234,7 +234,8 @@ class Menu implements RecursiveIterator
$section = $this->add(t('System'), array(
'icon' => 'wrench',
'priority' => 200
'priority' => 200,
'renderer' => 'ProblemMenuItemRenderer'
));
$section->add(t('User-Management'), array(
'url' => 'user/list',
@ -474,6 +475,26 @@ class Menu implements RecursiveIterator
return $this->permission;
}
/**
* Get parent menu
*
* @return \Icinga\Web\Menu
*/
public function getParent()
{
return $this->parent;
}
/**
* Get submenus
*
* @return array
*/
public function getSubMenus()
{
return $this->subMenus;
}
/**
* Set permission a user is required to have granted to display the menu item
*

View File

@ -0,0 +1,64 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Web\Menu;
use Icinga\Web\Menu;
class ProblemMenuItemRenderer extends MenuItemRenderer
{
/**
* Set of summarized problems from submenus
*
* @var array
*/
protected $summary = array();
/**
* Renders the html content of a single menu item and summarizes submenu problems
*
* @param Menu $menu
*
* @return string
*/
public function render(Menu $menu)
{
if ($menu->getParent() !== null && $menu->hasSubMenus()) {
/** @var $submenu Menu */
foreach ($menu->getSubMenus() as $submenu) {
$renderer = $submenu->getRenderer();
if (method_exists($renderer, 'getSummary')) {
if ($renderer->getSummary() !== null) {
$this->summary[] = $renderer->getSummary();
}
}
}
}
return $this->getBadge() . $this->createLink($menu);
}
/**
* Get the problem badge
*
* @return string
*/
protected function getBadge()
{
if (count($this->summary) > 0) {
$problems = 0;
$titles = array();
foreach ($this->summary as $summary) {
$problems += $summary['problems'];
$titles[] = $summary['title'];
}
return sprintf(
'<div title="%s" class="badge-container"><span class="badge badge-critical">%s</span></div>',
implode(', ', $titles),
$problems
);
}
return '';
}
}

View File

@ -5,6 +5,8 @@ namespace Icinga\Web\Widget;
use Icinga\Web\Form;
use Icinga\Web\Request;
use Icinga\Data\Sortable;
use Icinga\Application\Icinga;
/**
* SortBox widget
@ -14,7 +16,7 @@ use Icinga\Web\Request;
* submission of sorting changes and draws an additional submit button when JavaScript is disabled.
*
* The constructor takes an string for the component name and an array containing the select options, where the key is
* the value to be submitted and the value is the label that will be shown. You then should call applyRequest in order
* the value to be submitted and the value is the label that will be shown. You then should call setRequest in order
* to make sure the form is correctly populated when a request with a sort parameter is being made.
*
* Example:
@ -23,7 +25,7 @@ use Icinga\Web\Request;
* $this->getRequest()->getActionName(),
* $columns
* );
* $this->view->sortControl->applyRequest($this->getRequest());
* $this->view->sortControl->setRequest($this->getRequest());
* </code></pre>
*/
class SortBox extends AbstractWidget
@ -49,6 +51,13 @@ class SortBox extends AbstractWidget
*/
protected $request;
/**
* What to apply sort parameters on
*
* @var Sortable
*/
protected $query = null;
/**
* Create a SortBox with the entries from $sortFields
*
@ -81,12 +90,36 @@ class SortBox extends AbstractWidget
*
* @return $this
*/
public function applyRequest($request)
public function setRequest($request)
{
$this->request = $request;
return $this;
}
/**
* @param Sortable $query
*
* @return $this
*/
public function setQuery(Sortable $query)
{
$this->query = $query;
return $this;
}
public function handleRequest(Request $request = null)
{
if ($this->query !== null) {
if ($request === null) {
$request = Icinga::app()->getFrontController()->getRequest();
}
if ($sort = $request->getParam('sort')) {
$this->query->order($sort, $request->getParam('dir'));
}
}
return $this;
}
/**
* Render this SortBox as HTML
*

View File

@ -24,7 +24,7 @@ class DashboardAction implements Tabextension
'dashboard',
array(
'icon' => 'dashboard',
'label' => 'Add To Dashboard',
'label' => t('Add To Dashboard'),
'url' => Url::fromPath('dashboard/new-dashlet'),
'urlParams' => array(
'url' => rawurlencode(Url::fromRequest()->getRelativeUrl())

View File

@ -22,7 +22,7 @@ class DashboardSettings implements Tabextension
'dashboard_add',
array(
'icon' => 'img/icons/dashboard.png',
'label' => t('Add To Dashboard'),
'label' => t('Add New Pane Or Dashlet'),
'url' => Url::fromPath('dashboard/new-dashlet')
)
);

View File

@ -0,0 +1,100 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Module\Monitoring\Controller;
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction;
/**
* Display detailed information about a comment
*/
class Monitoring_CommentController extends Controller
{
/**
* The fetched comment
*
* @var stdClass
*/
protected $comment;
/**
* Fetch the first comment with the given id and add tabs
*
* @throws Zend_Controller_Action_Exception
*/
public function init()
{
$commentId = $this->params->get('comment_id');
$this->comment = $this->backend->select()->from('comment', array(
'id' => 'comment_internal_id',
'objecttype' => 'comment_objecttype',
'comment' => 'comment_data',
'author' => 'comment_author_name',
'timestamp' => 'comment_timestamp',
'type' => 'comment_type',
'persistent' => 'comment_is_persistent',
'expiration' => 'comment_expiration',
'host_name',
'service_description',
'host_display_name',
'service_display_name'
))->where('comment_internal_id', $commentId)->getQuery()->fetchRow();
if (false === $this->comment) {
throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
}
$this->getTabs()->add(
'comment',
array(
'title' => $this->translate(
'Display detailed information about a comment.'
),
'icon' => 'comment',
'label' => $this->translate('Comment'),
'url' =>'monitoring/comments/show'
)
)->activate('comment')->extend(new DashboardAction());
}
/**
* Display comment detail view
*/
public function showAction()
{
$listCommentsLink = Url::fromPath('monitoring/list/comments')
->setQueryString('comment_type=(comment|ack)');
$this->view->comment = $this->comment;
if ($this->hasPermission('monitoring/command/comment/delete')) {
$this->view->delCommentForm = $this->createDelCommentForm();
$this->view->delCommentForm->populate(
array(
'redirect' => $listCommentsLink,
'comment_id' => $this->comment->id,
'comment_is_service' => isset($this->comment->service_description)
)
);
}
}
/**
* 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;
}
}

View File

@ -0,0 +1,100 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Module\Monitoring\Controller;
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm;
use Icinga\Web\Url;
use Icinga\Data\Filter\Filter;
/**
* Display detailed information about a comment
*/
class Monitoring_CommentsController extends Controller
{
/**
* The fetched comments
*
* @var array
*/
protected $comments;
/**
* Fetch all comments matching the current filter and add tabs
*
* @throws Zend_Controller_Action_Exception
*/
public function init()
{
$this->filter = Filter::fromQueryString(str_replace(
'comment_id',
'comment_internal_id',
(string)$this->params
));
$this->comments = $this->backend->select()->from('comment', array(
'id' => 'comment_internal_id',
'objecttype' => 'comment_objecttype',
'comment' => 'comment_data',
'author' => 'comment_author_name',
'timestamp' => 'comment_timestamp',
'type' => 'comment_type',
'persistent' => 'comment_is_persistent',
'expiration' => 'comment_expiration',
'host_name',
'service_description',
'host_display_name',
'service_display_name'
))->addFilter($this->filter)->getQuery()->fetchAll();
if (false === $this->comments) {
throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
}
$this->getTabs()->add(
'comments',
array(
'title' => $this->translate(
'Display detailed information about multiple comments.'
),
'icon' => 'comment',
'label' => $this->translate('Comments'),
'url' =>'monitoring/comments/show'
)
)->activate('comments');
}
/**
* Display the detail view for a comment list
*/
public function showAction()
{
$this->view->comments = $this->comments;
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
->setQueryString($this->filter->toQueryString());
$this->view->removeAllLink = Url::fromPath('monitoring/comments/delete-all')
->setParams($this->params);
}
/**
* Display the form for removing a comment list
*/
public function deleteAllAction()
{
$this->assertPermission('monitoring/command/comment/delete');
$listCommentsLink = Url::fromPath('monitoring/list/comments')
->setQueryString('comment_type=(comment|ack)');
$delCommentForm = new DeleteCommentsCommandForm();
$delCommentForm->setTitle($this->view->translate('Remove all Comments'));
$delCommentForm->addDescription(sprintf(
$this->translate('Confirm removal of %d comments.'),
count($this->comments)
));
$delCommentForm->setComments($this->comments)
->setRedirectUrl($listCommentsLink)
->handleRequest();
$this->view->delCommentForm = $delCommentForm;
$this->view->comments = $this->comments;
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
->setQueryString($this->filter->toQueryString());
}
}

View File

@ -0,0 +1,141 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
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\Command\Object\DeleteDowntimeCommand;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction;
/**
* Display detailed information about a downtime
*/
class Monitoring_DowntimeController extends Controller
{
/**
* The fetched downtime
*
* @var stdClass
*/
protected $downtime;
/**
* If the downtime is a service or not
*
* @var boolean
*/
protected $isService;
/**
* Fetch the downtime matching the given id and add tabs
*
* @throws Zend_Controller_Action_Exception
*/
public function init()
{
$downtimeId = $this->params->get('downtime_id');
$this->downtime = $this->backend->select()->from('downtime', array(
'id' => 'downtime_internal_id',
'objecttype' => 'downtime_objecttype',
'comment' => 'downtime_comment',
'author_name' => 'downtime_author_name',
'start' => 'downtime_start',
'scheduled_start' => 'downtime_scheduled_start',
'scheduled_end' => 'downtime_scheduled_end',
'end' => 'downtime_end',
'duration' => 'downtime_duration',
'is_flexible' => 'downtime_is_flexible',
'is_fixed' => 'downtime_is_fixed',
'is_in_effect' => 'downtime_is_in_effect',
'entry_time' => 'downtime_entry_time',
'host_state' => 'downtime_host_state',
'service_state' => 'downtime_service_state',
'host_name',
'host',
'service',
'service_description',
'host_display_name',
'service_display_name'
))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow();
if (false === $this->downtime) {
throw new Zend_Controller_Action_Exception($this->translate('Downtime not found'));
}
if (isset($this->downtime->service_description)) {
$this->isService = true;
} else {
$this->isService = false;
}
$this->getTabs()
->add(
'downtime',
array(
'title' => $this->translate(
'Display detailed information about a downtime.'
),
'icon' => 'plug',
'label' => $this->translate('Downtime'),
'url' =>'monitoring/downtimes/show'
)
)->activate('downtime')->extend(new DashboardAction());
}
/**
* Display the detail view for a downtime
*/
public function showAction()
{
$this->view->downtime = $this->downtime;
$this->view->isService = $this->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->showHostLink = Url::fromPath('monitoring/host/show')
->setParam('host', $this->downtime->host);
$this->view->showServiceLink = Url::fromPath('monitoring/service/show')
->setParam('host', $this->downtime->host)
->setParam('service', $this->downtime->service_description);
if ($this->hasPermission('monitoring/command/downtime/delete')) {
$this->view->delDowntimeForm = $this->createDelDowntimeForm();
$this->view->delDowntimeForm->populate(
array(
'redirect' => Url::fromPath('monitoring/list/downtimes'),
'downtime_id' => $this->downtime->id,
'downtime_is_service' => $this->isService
)
);
}
}
/**
* 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;
}
}

View File

@ -0,0 +1,130 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Data\Filter\Filter;
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\Web\Url;
/**
* Display detailed information about a downtime
*/
class Monitoring_DowntimesController extends Controller
{
/**
* The fetched downtimes
*
* @var array
*/
protected $downtimes;
/**
* A filter matching all current downtimes
*
* @var Filter
*/
protected $filter;
/**
* Fetch all downtimes matching the current filter and add tabs
*
* @throws Zend_Controller_Action_Exception
*/
public function init()
{
$this->filter = Filter::fromQueryString(str_replace(
'downtime_id',
'downtime_internal_id',
(string)$this->params
));
$this->downtimes = $this->backend->select()->from('downtime', array(
'id' => 'downtime_internal_id',
'objecttype' => 'downtime_objecttype',
'comment' => 'downtime_comment',
'author_name' => 'downtime_author_name',
'start' => 'downtime_start',
'scheduled_start' => 'downtime_scheduled_start',
'scheduled_end' => 'downtime_scheduled_end',
'end' => 'downtime_end',
'duration' => 'downtime_duration',
'is_flexible' => 'downtime_is_flexible',
'is_fixed' => 'downtime_is_fixed',
'is_in_effect' => 'downtime_is_in_effect',
'entry_time' => 'downtime_entry_time',
'host_state' => 'downtime_host_state',
'service_state' => 'downtime_service_state',
'host_name',
'host',
'service',
'service_description',
'host_display_name',
'service_display_name'
))->addFilter($this->filter)->getQuery()->fetchAll();
if (false === $this->downtimes) {
throw new Zend_Controller_Action_Exception(
$this->translate('Downtime not found')
);
}
$this->getTabs()->add(
'downtimes',
array(
'title' => $this->translate(
'Display detailed information about multiple downtimes.'
),
'icon' => 'plug',
'label' => $this->translate('Downtimes'),
'url' =>'monitoring/downtimes/show'
)
)->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);
}
}
}
/**
* Display the detail view for a downtime list
*/
public function showAction()
{
$this->view->downtimes = $this->downtimes;
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
->setQueryString($this->filter->toQueryString());
$this->view->removeAllLink = Url::fromPath('monitoring/downtimes/delete-all')
->setParams($this->params);
}
/**
* Display the form for removing a downtime list
*/
public function deleteAllAction()
{
$this->assertPermission('monitoring/command/downtime/delete');
$this->view->downtimes = $this->downtimes;
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
->setQueryString($this->filter->toQueryString());
$delDowntimeForm = new DeleteDowntimesCommandForm();
$delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes'));
$delDowntimeForm->addDescription(sprintf(
$this->translate('Confirm removal of %d downtimes.'),
count($this->downtimes)
));
$delDowntimeForm->setRedirectUrl(Url::fromPath('monitoring/list/downtimes'));
$delDowntimeForm->setDowntimes($this->downtimes)->handleRequest();
$this->view->delDowntimeForm = $delDowntimeForm;
}
}

View File

@ -1,6 +1,7 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Exception\MissingParameterException;
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
@ -26,12 +27,22 @@ class Monitoring_HostController extends MonitoredObjectController
*/
public function init()
{
if ($this->params->get('host') === null) {
throw new MissingParameterException(
$this->translate('Required parameter \'%s\' is missing'),
'host'
);
}
$host = new Host($this->backend, $this->params->get('host'));
$this->applyRestriction('monitoring/hosts/filter', $host);
if ($host->fetch() === false) {
throw new Zend_Controller_Action_Exception($this->translate('Host not found'));
throw new Zend_Controller_Action_Exception(
sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')),
404
);
}
$this->object = $host;
$this->createTabs();

View File

@ -20,6 +20,7 @@ class Monitoring_ListController extends Controller
*/
public function init()
{
parent::init();
$this->createTabs();
}
@ -41,25 +42,6 @@ class Monitoring_ListController extends Controller
return $query;
}
protected function hasBetterUrl()
{
$request = $this->getRequest();
$url = Url::fromRequest();
if ($this->getRequest()->isPost()) {
if ($request->getPost('sort')) {
$url->setParam('sort', $request->getPost('sort'));
if ($request->getPost('dir')) {
$url->setParam('dir', $request->getPost('dir'));
} else {
$url->removeParam('dir');
}
return $url;
}
}
return false;
}
/**
* Overwrite the backend to use (used for testing)
*
@ -75,10 +57,6 @@ class Monitoring_ListController extends Controller
*/
public function hostsAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
// Handle soft and hard states
if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') {
$stateColumn = 'host_hard_state';
@ -141,7 +119,7 @@ class Monitoring_ListController extends Controller
'host_display_name' => $this->translate('Hostname'),
'host_address' => $this->translate('Address'),
'host_last_check' => $this->translate('Last Check')
));
), $query);
}
/**
@ -149,10 +127,6 @@ class Monitoring_ListController extends Controller
*/
public function servicesAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
// Handle soft and hard states
if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') {
$stateColumn = 'service_hard_state';
@ -221,7 +195,7 @@ class Monitoring_ListController extends Controller
'host_display_name' => $this->translate('Hostname'),
'host_address' => $this->translate('Host Address'),
'host_last_check' => $this->translate('Last Host Check')
));
), $query);
$this->view->stats = $this->backend->select()->from('statusSummary', array(
'services_total',
@ -247,10 +221,6 @@ class Monitoring_ListController extends Controller
*/
public function downtimesAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab('downtimes', $this->translate('Downtimes'), $this->translate('List downtimes'));
$this->setAutorefreshInterval(12);
@ -291,10 +261,11 @@ class Monitoring_ListController extends Controller
'downtime_scheduled_start' => $this->translate('Scheduled Start'),
'downtime_scheduled_end' => $this->translate('Scheduled End'),
'downtime_duration' => $this->translate('Duration')
));
), $query);
if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) {
$this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
$this->view->delDowntimeForm->handleRequest();
}
}
@ -303,10 +274,6 @@ class Monitoring_ListController extends Controller
*/
public function notificationsAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab(
'notifications',
$this->translate('Notifications'),
@ -331,15 +298,11 @@ class Monitoring_ListController extends Controller
$this->setupPaginationControl($this->view->notifications);
$this->setupSortControl(array(
'notification_start_time' => $this->translate('Notification Start')
));
), $query);
}
public function contactsAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab('contacts', $this->translate('Contacts'), $this->translate('List contacts'));
$query = $this->backend->select()->from('contact', array(
@ -374,14 +337,11 @@ class Monitoring_ListController extends Controller
'contact_pager' => $this->translate('Pager Address / Number'),
'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'),
'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod')
));
), $query);
}
public function eventgridAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab('eventgrid', $this->translate('Event Grid'), $this->translate('Show the Event Grid'));
$form = new StatehistoryForm();
@ -421,10 +381,6 @@ class Monitoring_ListController extends Controller
public function contactgroupsAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab(
'contactgroups',
$this->translate('Contact Groups'),
@ -459,15 +415,11 @@ class Monitoring_ListController extends Controller
$this->setupSortControl(array(
'contactgroup_name' => $this->translate('Contactgroup Name'),
'contactgroup_alias' => $this->translate('Contactgroup Alias')
));
), $query);
}
public function commentsAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab('comments', $this->translate('Comments'), $this->translate('List comments'));
$this->setAutorefreshInterval(12);
@ -497,20 +449,18 @@ class Monitoring_ListController extends Controller
'service_display_name' => $this->translate('Service'),
'comment_type' => $this->translate('Comment Type'),
'comment_expiration' => $this->translate('Expiration')
)
),
$query
);
if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) {
$this->view->delCommentForm = new DeleteCommentCommandForm();
$this->view->delCommentForm->handleRequest();
}
}
public function servicegroupsAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab(
'servicegroups',
$this->translate('Service Groups'),
@ -561,15 +511,11 @@ class Monitoring_ListController extends Controller
'services_critical' => $this->translate('Services CRITICAL'),
'services_warning' => $this->translate('Services WARNING'),
'services_pending' => $this->translate('Services PENDING')
));
), $query);
}
public function hostgroupsAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab('hostgroups', $this->translate('Host Groups'), $this->translate('List host groups'));
$this->setAutorefreshInterval(12);
@ -616,15 +562,11 @@ class Monitoring_ListController extends Controller
'services_critical' => $this->translate('Services CRITICAL'),
'services_warning' => $this->translate('Services WARNING'),
'services_pending' => $this->translate('Services PENDING')
));
), $query);
}
public function eventhistoryAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab(
'eventhistory',
$this->translate('Event Overview'),
@ -652,14 +594,11 @@ class Monitoring_ListController extends Controller
$this->setupPaginationControl($this->view->history);
$this->setupSortControl(array(
'timestamp' => $this->translate('Occurence')
));
), $query);
}
public function servicegridAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}
$this->addTitleTab('servicegrid', $this->translate('Service Grid'), $this->translate('Show the Service Grid'));
$this->setAutorefreshInterval(15);
$query = $this->backend->select()->from('serviceStatus', array(
@ -673,7 +612,7 @@ class Monitoring_ListController extends Controller
$this->setupSortControl(array(
'host_name' => $this->translate('Hostname'),
'service_description' => $this->translate('Service description')
));
), $query);
$pivot = $query->pivot('service_description', 'host_name');
$this->view->pivot = $pivot;
$this->view->horizontalPaginator = $pivot->paginateXAxis();
@ -684,7 +623,10 @@ class Monitoring_ListController extends Controller
{
$editor = Widget::create('filterEditor')
->setQuery($query)
->preserveParams('limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns')
->preserveParams(
'limit', 'sort', 'dir', 'format', 'view', 'backend',
'stateType', 'addColumns', '_dev'
)
->ignoreParams('page')
->handleRequest($this->getRequest());
$query->applyFilter($editor->getFilter());
@ -692,9 +634,6 @@ class Monitoring_ListController extends Controller
$this->setupFilterControl($editor);
$this->view->filter = $editor->getFilter();
if ($sort = $this->params->get('sort')) {
$query->order($sort, $this->params->get('dir'));
}
$this->handleFormatRequest($query);
return $query;
}

View File

@ -49,8 +49,10 @@ class Monitoring_ProcessController extends Controller
array(
'is_currently_running',
'process_id',
'endpoint_name',
'program_start_time',
'status_update_time',
'program_version',
'last_command_check',
'last_log_rotation',
'global_service_event_handler',

View File

@ -1,6 +1,7 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Exception\MissingParameterException;
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
@ -25,12 +26,22 @@ class Monitoring_ServiceController extends MonitoredObjectController
*/
public function init()
{
if ($this->params->get('host') === null || $this->params->get('service') === null) {
throw new MissingParameterException(
$this->translate('One of the required parameters \'%s\' is missing'),
'host or service'
);
}
$service = new Service($this->backend, $this->params->get('host'), $this->params->get('service'));
$this->applyRestriction('monitoring/services/filter', $service);
if ($service->fetch() === false) {
throw new Zend_Controller_Action_Exception($this->translate('Service not found'));
throw new Zend_Controller_Action_Exception(
sprintf($this->translate('Service \'%s\' not found'), $this->params->get('service')),
404
);
}
$this->object = $service;
$this->createTabs();

View File

@ -4,12 +4,13 @@
namespace Icinga\Module\Monitoring\Forms\Command\Object;
use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand;
use Icinga\Module\Monitoring\Forms\Command\CommandForm;
use Icinga\Web\Notification;
/**
* Form for deleting host or service comments
*/
class DeleteCommentCommandForm extends ObjectsCommandForm
class DeleteCommentCommandForm extends CommandForm
{
/**
* (non-PHPDoc)
@ -26,23 +27,34 @@ class DeleteCommentCommandForm extends ObjectsCommandForm
*/
public function createElements(array $formData = array())
{
$this->addElements(array(
$this->addElements(
array(
'hidden',
'comment_id',
array(
'required' => true,
'decorators' => array('ViewHelper')
)
),
array(
'hidden',
'redirect',
'hidden',
'comment_id',
array(
'required' => true,
'validators' => array('NotEmpty'),
'decorators' => array('ViewHelper')
)
),
array(
'decorators' => array('ViewHelper')
'hidden',
'comment_is_service',
array(
'filters' => array('Boolean'),
'decorators' => array('ViewHelper')
)
),
array(
'hidden',
'redirect',
array(
'decorators' => array('ViewHelper')
)
)
)
));
);
return $this;
}
@ -74,14 +86,10 @@ class DeleteCommentCommandForm extends ObjectsCommandForm
*/
public function onSuccess()
{
foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
$delComment = new DeleteCommentCommand();
$delComment
->setObject($object)
->setCommentId($this->getElement('comment_id')->getValue());
$this->getTransport($this->request)->send($delComment);
}
$cmd = new DeleteCommentCommand();
$cmd->setIsService($this->getElement('comment_is_service')->getValue())
->setCommentId($this->getElement('comment_id')->getValue());
$this->getTransport($this->request)->send($cmd);
$redirect = $this->getElement('redirect')->getValue();
if (! empty($redirect)) {
$this->setRedirectUrl($redirect);

View File

@ -0,0 +1,88 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Forms\Command\Object;
use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand;
use \Icinga\Module\Monitoring\Forms\Command\CommandForm;
use Icinga\Web\Notification;
/**
* Form for deleting host or service comments
*/
class DeleteCommentsCommandForm extends CommandForm
{
/**
* The comments deleted on success
*
* @var array
*/
protected $comments;
/**
* (non-PHPDoc)
* @see \Zend_Form::init() For the method documentation.
*/
public function init()
{
$this->setAttrib('class', 'inline');
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::createElements() For the method documentation.
*/
public function createElements(array $formData = array())
{
$this->addElements(array(
array(
'hidden',
'redirect',
array('decorators' => array('ViewHelper'))
)
));
return $this;
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::getSubmitLabel() For the method documentation.
*/
public function getSubmitLabel()
{
return $this->translatePlural('Remove', 'Remove All', count($this->downtimes));
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
*/
public function onSuccess()
{
foreach ($this->comments as $comment) {
$cmd = new DeleteCommentCommand();
$cmd->setCommentId($comment->id)
->setIsService(isset($comment->service_description));
$this->getTransport($this->request)->send($cmd);
}
$redirect = $this->getElement('redirect')->getValue();
if (! empty($redirect)) {
$this->setRedirectUrl($redirect);
}
Notification::success($this->translate('Deleting comment..'));
return true;
}
/**
* Set the comments to be deleted upon success
*
* @param array $comments
*
* @return this fluent interface
*/
public function setComments(array $comments)
{
$this->comments = $comments;
return $this;
}
}

View File

@ -4,12 +4,13 @@
namespace Icinga\Module\Monitoring\Forms\Command\Object;
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
use \Icinga\Module\Monitoring\Forms\Command\CommandForm;
use Icinga\Web\Notification;
/**
* Form for deleting host or service downtimes
*/
class DeleteDowntimeCommandForm extends ObjectsCommandForm
class DeleteDowntimeCommandForm extends CommandForm
{
/**
* (non-PHPDoc)
@ -19,33 +20,44 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
{
$this->setAttrib('class', 'inline');
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::createElements() For the method documentation.
*/
public function createElements(array $formData = array())
{
$this->addElements(array(
$this->addElements(
array(
'hidden',
'downtime_id',
array(
'required' => true,
'decorators' => array('ViewHelper')
)
),
array(
'hidden',
'redirect',
'hidden',
'downtime_id',
array(
'required' => true,
'validators' => array('NotEmpty'),
'decorators' => array('ViewHelper')
)
),
array(
'decorators' => array('ViewHelper')
'hidden',
'downtime_is_service',
array(
'filters' => array('Boolean'),
'decorators' => array('ViewHelper')
)
),
array(
'hidden',
'redirect',
array(
'decorators' => array('ViewHelper')
)
)
)
));
);
return $this;
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::addSubmitButton() For the method documentation.
@ -67,26 +79,23 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
);
return $this;
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
*/
public function onSuccess()
{
foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
$delDowntime = new DeleteDowntimeCommand();
$delDowntime
->setObject($object)
->setDowntimeId($this->getElement('downtime_id')->getValue());
$this->getTransport($this->request)->send($delDowntime);
}
$cmd = new DeleteDowntimeCommand();
$cmd->setDowntimeId($this->getElement('downtime_id')->getValue());
$cmd->setIsService($this->getElement('downtime_is_service')->getValue());
$this->getTransport($this->request)->send($cmd);
$redirect = $this->getElement('redirect')->getValue();
if (! empty($redirect)) {
$this->setRedirectUrl($redirect);
}
Notification::success($this->translate('Deleting downtime..'));
Notification::success($this->translate('Deleting downtime.'));
return true;
}
}

View File

@ -0,0 +1,88 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Forms\Command\Object;
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
use \Icinga\Module\Monitoring\Forms\Command\CommandForm;
use Icinga\Web\Notification;
/**
* Form for deleting host or service downtimes
*/
class DeleteDowntimesCommandForm extends CommandForm
{
/**
* The downtimes to delete on success
*
* @var array
*/
protected $downtimes;
/**
* (non-PHPDoc)
* @see \Zend_Form::init() For the method documentation.
*/
public function init()
{
$this->setAttrib('class', 'inline');
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::createElements() For the method documentation.
*/
public function createElements(array $formData = array())
{
$this->addElements(array(
array(
'hidden',
'redirect',
array('decorators' => array('ViewHelper'))
)
));
return $this;
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::getSubmitLabel() For the method documentation.
*/
public function getSubmitLabel()
{
return $this->translatePlural('Remove', 'Remove All', count($this->downtimes));
}
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
*/
public function onSuccess()
{
foreach ($this->downtimes as $downtime) {
$delDowntime = new DeleteDowntimeCommand();
$delDowntime->setDowntimeId($downtime->id);
$delDowntime->setIsService(isset($downtime->service_description));
$this->getTransport($this->request)->send($delDowntime);
}
$redirect = $this->getElement('redirect')->getValue();
if (! empty($redirect)) {
$this->setRedirectUrl($redirect);
}
Notification::success($this->translate('Deleting downtime.'));
return true;
}
/**
* Set the downtimes to be deleted upon success
*
* @param type $downtimes
*
* @return $this
*/
public function setDowntimes(array $downtimes)
{
$this->downtimes = $downtimes;
return $this;
}
}

View File

@ -30,7 +30,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
*/
public function createElements(array $formData = array())
{
$toggleDisabled = $this->hasPermission('monitoring/command/feature/instance') ? null : '';
$toggleDisabled = $this->hasPermission('monitoring/command/feature/object') ? null : '';
$this->addElements(array(
array(
'checkbox',

View File

@ -0,0 +1,11 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<?= $this->render('partials/downtime/downtime-header.phtml'); ?>
</div>
<div class="content object-command">
<?= $delDowntimeForm; ?>
</div>

View File

@ -0,0 +1,81 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<div data-base-target='_next'>
<?= $this->render('partials/comment/comment-header.phtml'); ?>
</div>
</div>
<div class="content">
<h3><?= $this->translate('Comment detail information') ?></h3>
<table class="avp">
<tbody>
<tr data-base-target='_next'>
<?php if ($this->comment->objecttype === 'service'): ?>
<th> <?= $this->translate('Service') ?> </th>
<td>
<?= $this->icon('service', $this->translate('Service')); ?>
<?= $this->link()->service(
$this->comment->service_description,
$this->comment->service_display_name,
$this->comment->host_name,
$this->comment->host_display_name
);
?>
</td>
<?php else: ?>
<th> <?= $this->translate('Host') ?> </th>
<td>
<?= $this->icon('host', $this->translate('Host')); ?>
<?= $this->link()->host(
$this->comment->host_name,
$this->comment->host_display_name
);
?>
</td>
<?php endif ?>
</tr>
<tr>
<th><?= $this->translate('Author') ?></th>
<td><?= $this->icon('user', $this->translate('User')) ?> <?= $this->escape($this->comment->author) ?></td>
</tr>
<tr>
<th><?= $this->translate('Persistent') ?></th>
<td><?= $this->escape($this->comment->persistent) ? $this->translate('Yes') : $this->translate('No') ?></td>
</tr>
<tr>
<th><?= $this->translate('Created') ?></th>
<td><?= date('d.m.y H:i' ,$this->escape($this->comment->timestamp)) ?></td>
</tr>
<tr>
<th><?= $this->translate('Expires') ?></th>
<td>
<?= $this->comment->expiration ? sprintf(
$this->translate('This comment expires on %s at %s.'),
date('d.m.y', $this->comment->expiration),
date('H:i', $this->comment->expiration)
) : $this->translate('This comment does not expire.');
?>
</td>
</tr>
<?php if (isset($delCommentForm)): // Form is unset if the current user lacks the respective permission ?>
<tr class="newsection">
<th><?= $this->translate('Commands') ?></th>
<td>
<?= $delCommentForm ?>
</td>
</tr>
<?php endif ?>
</tbody>
</table>
</div>

View File

@ -0,0 +1,12 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<?= $this->render('partials/comment/comments-header.phtml'); ?>
</div>
<div class="content object-command">
<?= $delCommentForm ?>
</div>

View File

@ -0,0 +1,34 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<div data-base-target='_next'>
<?= $this->render('partials/comment/comments-header.phtml'); ?>
</div>
</div>
<div class="content">
<h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3>
<p>
<?= sprintf(
$this->translate('Issue commands to all %s selected comments.'),
'<b>' . count($comments) . '</b>'
)
?>
<div>
<?= $this->qlink(
sprintf(
$this->translate('Remove all %d scheduled comments'),
count($comments)
),
$removeAllLink,
null,
array(
'icon' => 'trash',
'title' => $this->translate('Remove all selected comments.')
)
) ?>
</div>
</p>
</div>

View File

@ -0,0 +1,11 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<?= $this->render('partials/downtime/downtime-header.phtml'); ?>
</div>
<div class="content object-command">
<?= $delDowntimeForm; ?>
</div>

View File

@ -0,0 +1,121 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<?= $this->render('partials/downtime/downtime-header.phtml'); ?>
</div>
<div class="content">
<h3><?= $this->translate('Downtime detail information') ?></h3>
<table class="avp">
<tbody>
<tr>
<th>
<?= $this->isService ? $this->translate('Service') : $this->translate('Host') ?>
</th>
<td data-base-target="_next">
<?php if ($this->isService): ?>
<?php
$link = $this->link()->service(
$downtime->service_description,
$downtime->service_display_name,
$downtime->host_name,
$downtime->host_display_name
);
$icon = $this->icon('service', $this->translate('Service'));
?>
<?php else: ?>
<?php
$icon = $this->icon('host', $this->translate('Host'));
$link = $this->link()->host($downtime->host_name, $downtime->host_display_name)
?>
<?php endif ?>
<?= $icon ?>
<?= $link ?>
</td>
</tr>
<tr title="<?= $this->translate('The name of the person who scheduled this downtime'); ?>">
<th><?= $this->translate('Author') ?></th>
<td><?= $this->icon('user', $this->translate('User')) ?> <?= $this->escape($this->downtime->author_name) ?></td>
</tr>
<tr title="<?= $this->translate('A comment, as entered by the author, associated with the scheduled downtime'); ?>">
<th><?= $this->translate('Comment') ?></th>
<td><?= $this->icon('comment', $this->translate('Comment')) ?> <?= $this->escape($this->downtime->comment) ?></td>
</tr>
<tr title="<?= $this->translate('Date and time this downtime was entered'); ?>">
<th><?= $this->translate('Entry Time') ?></th>
<td> <?= date('d.m.y H:i' ,$this->escape($this->downtime->entry_time)) ?></td>
</tr>
<tr class="newsection">
<th><?= $this->escape(
$this->downtime->is_flexible ?
$this->translate('Flexible') : $this->translate('Fixed')
); ?></th>
<td>
<?= $this->escape(
$this->downtime->is_flexible ?
$this->translate('Flexible downtimes have a hard start and end time,'
. ' but also an additional restriction on the duration in which '
. ' the host or service may actually be down.') :
$this->translate('Fixed downtimes have a static start and end time.')
); ?>
</td>
</tr>
<tr title="<?= $this->translate('The date/time the scheduled downtime is'
. ' supposed to start. If this is a flexible (non-fixed) downtime, '
. 'this refers to the earliest possible time that the downtime'
. ' can start'); ?>">
<th><?= $this->translate('Scheduled start') ?></th>
<td><?= date('d.m.y H:i', $this->downtime->scheduled_start) ?></td>
</tr>
<tr title="<?= $this->translate('The date/time the scheduled downtime is '
. 'supposed to end. If this is a flexible (non-fixed) downtime, '
. 'this refers to the last possible time that the downtime can '
. 'start'); ?>">
<th><?= $this->translate('Scheduled end') ?></th>
<td><?= date('d.m.y H:i', $this->downtime->scheduled_end) ?></td>
</tr>
<?php if ($this->downtime->is_flexible): ?>
<tr title="<?= $this->translate('Indicates the number of seconds that the '
. 'scheduled downtime should last. This is usually only needed if'
. ' this is a flexible downtime, which can start at a variable '
. 'time, but lasts for the specified duration'); ?>">
<th tit><?= $this->translate('Duration') ?></th>
<td><?= $this->format()->duration($this->escape($this->downtime->duration)); ?></td>
</tr>
<tr title="<?= $this->translate('he date/time the scheduled downtime was'
. ' actually started'); ?>">
<th><?= $this->translate('Actual start time') ?></th>
<td><?= date('d.m.y H:i', $downtime->start); ?></td>
</tr>
<tr title="<?= $this->translate('The date/time the scheduled downtime '
. 'actually ended'); ?>">
<th><?= $this->translate('Actual end time') ?></th>
<td><?= date('d.m.y H:i', $downtime->end); ?></td>
</tr>
<?php endif; ?>
<tr class="newsection">
<th><?= $this->translate('In effect') ?></th>
<td>
<?= $this->escape(
$this->downtime->is_in_effect ?
$this->translate('Yes') : $this->translate('No')
);
?>
</td>
</tr>
<?php if (isset($delDowntimeForm)): // Form is unset if the current user lacks the respective permission ?>
<tr class="newsection">
<th><?= $this->translate('Commands') ?></th>
<td>
<?= $delDowntimeForm ?>
</td>
</tr>
<?php endif ?>
</tbody>
</table>
</div>

View File

@ -0,0 +1,12 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<?= $this->render('partials/downtime/downtimes-header.phtml'); ?>
</div>
<div class="content object-command">
<?= $delDowntimeForm ?>
</div>

View File

@ -0,0 +1,33 @@
<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<?= $this->render('partials/downtime/downtimes-header.phtml'); ?>
</p>
</div>
<div class="content">
<h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3>
<p>
<?= sprintf(
$this->translate('Issue commands to all %s selected downtimes.'),
'<b>' . count($downtimes) . '</b>'
)
?>
<div>
<?= $this->qlink(
sprintf(
$this->translate('Remove all %d scheduled downtimes'),
count($downtimes)
),
$removeAllLink,
null,
array(
'icon' => 'trash',
'title' => $this->translate('Remove all selected downtimes.')
)
) ?>
</div>
</p>
</div>

View File

@ -1,6 +1,12 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs; ?>
<div class="dontprint">
<?= $this->render('list/components/selectioninfo.phtml'); ?>
</div>
<div class="tinystatesummary">
<?= $comments->getTotalItemCount() ?> <?= $this->translate('Comments') ?>:
</div>
<?= $this->sortBox; ?>
<?= $this->limiter; ?>
<?= $this->paginator; ?>
@ -15,57 +21,50 @@ if (count($comments) === 0) {
return;
}
?>
<table data-base-target="_next" class="action comments">
<table data-base-target="_next"
class="action comments multiselect"
data-icinga-multiselect-url="/icingaweb2/monitoring/comments/show"
data-icinga-multiselect-data="comment_id">
<tbody>
<?php foreach ($comments as $comment): ?>
<?php
switch ($comment->type) {
case 'flapping':
$icon = 'flapping';
$title = $this->translate('Flapping');
$tooltip = $this->translate('Comment was caused by a flapping host or service.');
break;
case 'comment':
$icon = 'user';
$title = $this->translate('User Comment');
$tooltip = $this->translate('Comment was created by an user.');
break;
case 'downtime':
$icon = 'plug';
$title = $this->translate('Downtime');
$tooltip = $this->translate('Comment was caused by a downtime.');
break;
case 'ack':
$icon = 'ok';
$title = $this->translate('Acknowledgement');
$tooltip = $this->translate('Comment was caused by an acknowledgement.');
break;
}
?>
<?php foreach ($comments as $comment):
$this->comment = $comment; ?>
<tr class="state invalid">
<td class="state" style="width: 12em;">
<?= $this->icon($icon, $tooltip) ?>
<br>
<strong><?= $this->escape($title); ?></strong>
<br>
<?= $this->prefixedTimeSince($comment->timestamp); ?>
<?= $this->render('partials/comment/comment-description.phtml'); ?>
</td>
<td>
<?php if ($comment->objecttype === 'service'): ?>
<?= $this->icon('service', $this->translate('Service')); ?>
<?= $this->link()->service(
$comment->service_description,
$comment->service_display_name,
$comment->host_name,
$comment->host_display_name
); ?>
<?= $this->qlink(
sprintf(
$this->translate('%s on %s', 'Service running on host'),
$comment->service_display_name,
$comment->host_display_name
),
'monitoring/comment/show',
array('comment_id' => $comment->id),
array('title' => sprintf(
$this->translate('Show detailed information for comment on %s for %s'),
$comment->service_display_name,
$comment->host_display_name
))) ?>
<?php else: ?>
<?= $this->icon('host', $this->translate('Host')); ?>
<?= $this->link()->host($comment->host_name, $comment->host_display_name); ?>
<?= $this->qlink(
$comment->host_display_name,
'monitoring/comment/show',
array('comment_id' => $comment->id),
array('title' => sprintf(
$this->translate('Show detailed information for comment on %s'),
$comment->host_display_name
))) ?>
<?php endif ?>
<br>
<?= $this->icon('comment', $this->translate('Comment')); ?> <?= isset($comment->author)
? '[' . $comment->author . '] '
? '[' . $this->escape($comment->author) . '] '
: '';
?><?= $this->escape($comment->comment); ?>
<br>
@ -84,17 +83,12 @@ if (count($comments) === 0) {
<td style="width: 2em" data-base-target="self">
<?php
$delCommentForm = clone $delCommentForm;
$delCommentForm->populate(array('comment_id' => $comment->id, 'redirect' => $this->url));
if ($comment->objecttype === 'host') {
$delCommentForm->setAction(
$this->url('monitoring/host/delete-comment', array('host' => $comment->host_name))
);
} else {
$delCommentForm->setAction($this->url('monitoring/service/delete-comment', array(
'host' => $comment->host_name,
'service' => $comment->service_description
)));
}
$delCommentForm->populate(
array(
'comment_id' => $comment->id,
'comment_is_service' => isset($comment->service_description)
)
);
echo $delCommentForm;
?>
</td>

View File

@ -5,6 +5,12 @@ use Icinga\Module\Monitoring\Object\Service;
if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs; ?>
<div class="dontprint">
<?= $this->render('list/components/selectioninfo.phtml'); ?>
</div>
<div class="tinystatesummary">
<?= $downtimes->getTotalItemCount() ?> <?= $this->translate('Downtimes') ?>
</div>
<?= $this->sortBox; ?>
<?= $this->limiter; ?>
<?= $this->paginator; ?>
@ -15,12 +21,15 @@ if (! $this->compact): ?>
<?php
if (count($downtimes) === 0) {
echo $this->translate('No downtimes found matching the filter') . '</div>';
echo $this->translate('No downtimes found matching the filter,'
. ' maybe the downtime already expired.') . '</div>';
return;
}
?>
<table data-base-target="_next" class="action">
<table data-base-target="_next"
class="action multiselect"
data-icinga-multiselect-url="/icingaweb2/monitoring/downtimes/show"
data-icinga-multiselect-data="downtime_id">
<tbody>
<?php foreach ($downtimes as $downtime): ?>
<?php
@ -48,15 +57,22 @@ if (count($downtimes) === 0) {
?>
</td>
<td>
<?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 ?>
<?php
if ($isService) {
echo $this->icon('service');
} else {
echo $this->icon('host');
}
?>
<?= $this->qlink(
sprintf($this->translate('%s on %s', 'Service running on host'), $downtime->service_display_name, $downtime->host_display_name),
'monitoring/downtime/show',
array('downtime_id' => $downtime->id),
array('title' => sprintf(
$this->translate('Show detailed information for downtime on %s for %s'),
$downtime->service_display_name,
$downtime->host_display_name
))) ?>
<br>
<?= $this->icon('comment', $this->translate('Comment')); ?> [<?= $this->escape($downtime->author_name) ?>] <?= $this->escape($downtime->comment) ?>
<br>
@ -112,15 +128,12 @@ if (count($downtimes) === 0) {
<td style="width: 2em" data-base-target="self">
<?php
$delDowntimeForm = clone $delDowntimeForm;
$delDowntimeForm->populate(array('downtime_id' => $downtime->id, 'redirect' => $this->url));
if (! $isService) {
$delDowntimeForm->setAction($this->url('monitoring/host/delete-downtime', array('host' => $downtime->host_name)));
} else {
$delDowntimeForm->setAction($this->url('monitoring/service/delete-downtime', array(
'host' => $downtime->host_name,
'service' => $downtime->service_description
)));
}
$delDowntimeForm->populate(
array(
'downtime_id' => $downtime->id,
'downtime_is_service' => isset($downtime->service_description)
)
);
echo $delDowntimeForm;
?>
</td>

View File

@ -0,0 +1,27 @@
<?php
switch ($comment->type) {
case 'flapping':
$icon = 'flapping';
$title = $this->translate('Flapping');
$tooltip = $this->translate('Comment was caused by a flapping host or service.');
break;
case 'comment':
$icon = 'user';
$title = $this->translate('User Comment');
$tooltip = $this->translate('Comment was created by an user.');
break;
case 'downtime':
$icon = 'plug';
$title = $this->translate('Downtime');
$tooltip = $this->translate('Comment was caused by a downtime.');
break;
case 'ack':
$icon = 'ok';
$title = $this->translate('Acknowledgement');
$tooltip = $this->translate('Comment was caused by an acknowledgement.');
break;
}
?>
<strong><?= $this->escape($title); ?></strong><br>
<?= $this->icon($icon, $tooltip) ?>
<?= $this->prefixedTimeSince($comment->timestamp); ?>

View File

@ -0,0 +1,18 @@
<?php if ($comment->objecttype === 'service'): ?>
<?= $this->icon('service', $this->translate('Service')); ?>
<?= $this->link()->service(
$comment->service_description,
$comment->service_display_name,
$comment->host_name,
$comment->host_display_name
); ?>
<?php else: ?>
<?= $this->icon('host', $this->translate('Host')); ?>
<?= $this->link()->host($comment->host_name, $comment->host_display_name); ?>
<?php endif ?>
<br>
<?= $this->icon('comment', $this->translate('Comment')); ?> <?= isset($comment->author)
? '[' . $this->escape($comment->author) . '] '
: '';
?><?= $this->escape($comment->comment); ?>

View File

@ -0,0 +1,10 @@
<table class="action">
<tr class="state invalid">
<td class="state" style="width: 12em;">
<?= $this->render('partials/comment/comment-description.phtml'); ?>
</td>
<td>
<?= $this->render('partials/comment/comment-detail.phtml'); ?>
</td>
</tr>
</table>

View File

@ -0,0 +1,30 @@
<table class="action">
<?php $i = 0; foreach ($comments as $comment):
if (++ $i > 5) {
continue;
}
$this->comment = $comment;
?>
<tr class="state invalid">
<td class="state" style="width: 12em;">
<?= $this->render('partials/comment/comment-description.phtml'); ?>
</td>
<td>
<?= $this->render('partials/comment/comment-detail.phtml'); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<p>
<?= $this->qlink(
sprintf($this->translate('List all %d comments …'), count($comments)),
$listAllLink,
null,
array(
'title' => $this->translate('List all'),
'data-base-target' => "_next"
)
) ?>
</p>

View File

@ -0,0 +1,67 @@
<table class="action">
<tr class="state <?= $stateName; ?><?= $downtime->is_in_effect ? ' handled' : ''; ?>">
<td class="state">
<strong><?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?></strong>
<br>
<?=
$this->dateTimeRenderer(
($downtime->is_in_effect ? $downtime->end : $downtime->start),
true
)->render(
$this->translate('on %s', 'datetime'),
$this->translate('at %s', 'time'),
$this->translate('in %s', 'timespan')
);
?>
</td>
<td>
<small>
<?php if ($downtime->is_flexible): ?>
<?php if ($downtime->is_in_effect): ?>
<?= sprintf(
$this->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 host downtime was started on %s at %s and lasts for %s until %s at %s.'),
date('d.m.y', $downtime->start),
date('H:i', $downtime->start),
$this->format()->duration($downtime->duration),
date('d.m.y', $downtime->end),
date('H:i', $downtime->end)
); ?>
<?php else: ?>
<?= sprintf(
$this->isService
? $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.'),
date('d.m.y H:i', $downtime->scheduled_start),
date('d.m.y H:i', $downtime->scheduled_end),
$this->format()->duration($downtime->duration)
); ?>
<?php endif ?>
<?php else: ?>
<?php if ($downtime->is_in_effect): ?>
<?= sprintf(
$this->isService
? $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.'),
date('d.m.y', $downtime->start),
date('H:i', $downtime->start),
date('d.m.y', $downtime->end),
date('H:i', $downtime->end)
); ?>
<?php else: ?>
<?= sprintf(
$this->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 host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
date('d.m.y', $downtime->scheduled_start),
date('H:i', $downtime->scheduled_start),
date('d.m.y', $downtime->scheduled_end),
date('H:i', $downtime->scheduled_end)
); ?>
<?php endif ?>
<?php endif ?>
</small>
</td>
</tr>
</table>

View File

@ -0,0 +1,92 @@
<table class="action">
<tbody>
<?php $i = 0; foreach ($downtimes as $downtime):
if (++ $i > 5) {
continue;
} ?>
<tr class="state <?= $downtime->stateText ?>">
<td class="state">
<strong><?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?></strong>
<br>
<?=
$this->dateTimeRenderer(
($downtime->is_in_effect ? $downtime->end : $downtime->start),
true
)->render(
$this->translate('on %s', 'datetime'),
$this->translate('at %s', 'time'),
$this->translate('in %s', 'timespan')
);
?>
</td>
<td class="name oneline">
<?php if ($downtime->isService): ?>
<?= $this->icon('service', $this->translate('Service')) ?>
<b><?= $downtime->service ?> on <?= $downtime->host_name ?>.</b>
<?php else: ?>
<?= $this->icon('host', $this->translate('Host')) ?>
<b><?= $downtime->host_name ?>.</b>
<?php endif; ?>
<?php if ($downtime->is_flexible): ?>
<?php if ($downtime->is_in_effect): ?>
<?= sprintf(
$this->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 host downtime was started on %s at %s and lasts for %s until %s at %s.'),
date('d.m.y', $downtime->start),
date('H:i', $downtime->start),
$this->format()->duration($downtime->duration),
date('d.m.y', $downtime->end),
date('H:i', $downtime->end)
); ?>
<?php else: ?>
<?= sprintf(
$this->isService
? $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.'),
date('d.m.y H:i', $downtime->scheduled_start),
date('d.m.y H:i', $downtime->scheduled_end),
$this->format()->duration($downtime->duration)
); ?>
<?php endif ?>
<?php else: ?>
<?php if ($downtime->is_in_effect): ?>
<?= sprintf(
$this->isService
? $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.'),
date('d.m.y', $downtime->start),
date('H:i', $downtime->start),
date('d.m.y', $downtime->end),
date('H:i', $downtime->end)
); ?>
<?php else: ?>
<?= sprintf(
$this->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 host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
date('d.m.y', $downtime->scheduled_start),
date('H:i', $downtime->scheduled_start),
date('d.m.y', $downtime->scheduled_end),
date('H:i', $downtime->scheduled_end)
); ?>
<?php endif ?>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p>
<?= $this->qlink(
sprintf($this->translate('List all %d downtimes …'), count($downtimes)),
$listAllLink,
null,
array(
'title' => $this->translate('List all'),
'data-base-target' => "_next"
)
) ?>
</p>

View File

@ -19,6 +19,12 @@ if (! $this->compact): ?>
<h2><?= $this->translate('Process Info') ?></h2>
<table class="avp">
<tbody>
<tr>
<th><?= $this->translate('Program Version') ?></th>
<td><?= $this->programStatus->program_version
? $this->programStatus->program_version
: $this->translate('N/A') ?></td>
</tr>
<tr>
<th><?= $this->translate('Program Start Time') ?></th>
<td><?= $this->dateFormat()->formatDateTime($this->programStatus->program_start_time) ?></td>
@ -49,19 +55,25 @@ if (! $this->compact): ?>
? $this->programStatus->global_host_event_handler
: $this->translate('N/A'); ?></td>
</tr>
<tr>
<th><?= $this->translate('Active Endpoint'); ?></th>
<td><?= $this->programStatus->endpoint_name
? $this->programStatus->endpoint_name
: $this->translate('N/A') ?></td>
</tr>
</tbody>
</table>
<?php if ((bool) $this->programStatus->is_currently_running === true): ?>
<div class="backend-running">
<?= sprintf(
$this->translate('%s has been up and running with PID %d since %s'),
$this->translate('Backend %s has been up and running with PID %d since %s'),
$this->backendName,
$this->programStatus->process_id,
$this->timeSince($this->programStatus->program_start_time)) ?>
</div>
<?php else: ?>
<div class="backend-not-running">
<?= sprintf($this->translate('%s is not running'), $this->backendName) ?>
<?= sprintf($this->translate('Backend %s is not running'), $this->backendName) ?>
</div>
<?php endif ?>
</div>

View File

@ -48,7 +48,12 @@ foreach ($object->comments as $comment) {
<td data-base-target="_self">
<?php if (isset($delCommentForm)) { // Form is unset if the current user lacks the respective permission
$delCommentForm = clone $delCommentForm;
$delCommentForm->populate(array('comment_id' => $comment->id));
$delCommentForm->populate(
array(
'comment_id' => $comment->id,
'comment_is_service' => isset($comment->service_description)
)
);
echo $delCommentForm;
} ?>
<span class="sr-only">(<?= $this->translate('Comment'); ?>): </span><?= str_replace(array('\r\n', '\n'), '<br>', $commentText); ?>

View File

@ -47,12 +47,15 @@ foreach ($object->downtimes as $downtime) {
) : $this->escape($downtime->comment);
if ((bool) $downtime->is_in_effect) {
$state = 'in downtime since ' . $this->timeSince($downtime->start);
$state = 'in downtime since ';
$time = $this->timeSince($downtime->start);
} else {
if ((bool) $downtime->is_fixed) {
$state = 'scheduled ' . $this->timeUntil($downtime->start);
$state = 'scheduled ';
$time = $this->timeUntil($downtime->start);
} else {
$state = 'scheduled flexible ' . $this->timeUntil($downtime->start);
$state = 'scheduled flexible ';
$time = $this->timeUntil($downtime->start);
}
}
@ -62,10 +65,22 @@ foreach ($object->downtimes as $downtime) {
<td data-base-target="_self">
<?php if (isset($delDowntimeForm)) { // Form is unset if the current user lacks the respective permission
$delDowntimeForm = clone $delDowntimeForm;
$delDowntimeForm->populate(array('downtime_id' => $downtime->id));
$delDowntimeForm->populate(
array(
'downtime_id' => $downtime->id,
'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE
)
);
echo $delDowntimeForm;
} ?>
<span class="sr-only"><?= $this->translate('Downtime'); ?></span><?= $state; ?> - <?= str_replace(array('\r\n', '\n'), '<br>', $commentText); ?>
<span class="sr-only"><?= $this->translate('Downtime'); ?></span>
<?=
$this->qlink(
$state,
'monitoring/downtime/show',
array('downtime_id' => $downtime->id),
array('data-base-target' => '_next')
) . $time ; ?> - <?= str_replace(array('\r\n', '\n'), '<br>', $commentText); ?>
</td>
</tr>
<?php } // endforeach ?>

View File

@ -208,7 +208,8 @@ $section->add($this->translate('Alert Summary'), array(
$section = $this->menuSection($this->translate('System'));
$section->add($this->translate('Monitoring Health'), array(
'url' => 'monitoring/process/info',
'priority' => 120
'priority' => 120,
'renderer' => 'Icinga\Module\Monitoring\Web\Menu\BackendAvailabilityMenuItemRenderer'
));
/*

View File

@ -12,6 +12,7 @@ class ProgramstatusQuery extends IdoQuery
'programstatus' => array(
'id' => 'programstatus_id',
'status_update_time' => 'UNIX_TIMESTAMP(programstatus.status_update_time)',
'program_version' => 'program_version',
'program_start_time' => 'UNIX_TIMESTAMP(programstatus.program_start_time)',
'program_end_time' => 'UNIX_TIMESTAMP(programstatus.program_end_time)',
'is_currently_running' => 'CASE WHEN (programstatus.is_currently_running = 0)
@ -26,6 +27,7 @@ class ProgramstatusQuery extends IdoQuery
END
END',
'process_id' => 'process_id',
'endpoint_name' => 'endpoint_name',
'daemon_mode' => 'daemon_mode',
'last_command_check' => 'UNIX_TIMESTAMP(programstatus.last_command_check)',
'last_log_rotation' => 'UNIX_TIMESTAMP(programstatus.last_log_rotation)',
@ -47,4 +49,16 @@ class ProgramstatusQuery extends IdoQuery
'global_service_event_handler' => 'global_service_event_handler',
)
);
protected function joinBaseTables()
{
parent::joinBaseTables();
if (version_compare($this->getIdoVersion(), '1.11.7', '<')) {
$this->columnMap['programstatus']['endpoint_name'] = '(0)';
}
if (version_compare($this->getIdoVersion(), '1.11.8', '<')) {
$this->columnMap['programstatus']['program_version'] = '(NULL)';
}
}
}

View File

@ -3,20 +3,13 @@
namespace Icinga\Module\Monitoring\Command\Object;
use Icinga\Module\Monitoring\Command\IcingaCommand;
/**
* Delete a host or service comment
*/
class DeleteCommentCommand extends ObjectCommand
class DeleteCommentCommand extends IcingaCommand
{
/**
* (non-PHPDoc)
* @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation.
*/
protected $allowedObjects = array(
self::TYPE_HOST,
self::TYPE_SERVICE
);
/**
* ID of the comment that is to be deleted
*
@ -24,6 +17,13 @@ class DeleteCommentCommand extends ObjectCommand
*/
protected $commentId;
/**
* The type of the comment, either 'host' or 'service'
*
* @var boolean
*/
protected $isService = false;
/**
* Set the ID of the comment that is to be deleted
*
@ -46,4 +46,27 @@ class DeleteCommentCommand extends ObjectCommand
{
return $this->commentId;
}
/**
* Whether the command affects a service comment
*
* @return boolean
*/
public function getIsService()
{
return $this->isService;
}
/**
* Set whether the command affects a service
*
* @param boolean $value The value, defaults to true
*
* @return this fluent interface
*/
public function setIsService($value = true)
{
$this->isService = (bool) $value;
return $this;
}
}

View File

@ -3,20 +3,13 @@
namespace Icinga\Module\Monitoring\Command\Object;
use Icinga\Module\Monitoring\Command\IcingaCommand;
/**
* Delete a host or service downtime
*/
class DeleteDowntimeCommand extends ObjectCommand
class DeleteDowntimeCommand extends IcingaCommand
{
/**
* (non-PHPDoc)
* @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation.
*/
protected $allowedObjects = array(
self::TYPE_HOST,
self::TYPE_SERVICE
);
/**
* ID of the downtime that is to be deleted
*
@ -24,6 +17,33 @@ class DeleteDowntimeCommand extends ObjectCommand
*/
protected $downtimeId;
/**
* If the command affects a service downtime
*
* @var boolean
*/
protected $isService = false;
/**
* Set if this command affects a service
*
* @param type $value
*/
public function setIsService($value = true)
{
$this->isService = (bool) $value;
}
/**
* Return whether the command affects a service
*
* @return type
*/
public function getIsService()
{
return $this->isService;
}
/**
* Set the ID of the downtime that is to be deleted
*

View File

@ -323,28 +323,18 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface
public function renderDeleteComment(DeleteCommentCommand $command)
{
if ($command->getObject()->getType() === $command::TYPE_HOST) {
$commandString = 'DEL_HOST_COMMENT';
} else {
$commandString = 'DEL_SVC_COMMENT';
}
return sprintf(
'%s;%u',
$commandString,
$command->getIsService() ? 'DEL_SVC_COMMENT' : 'DEL_HOST_COMMENT',
$command->getCommentId()
);
}
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
{
if ($command->getObject()->getType() === $command::TYPE_HOST) {
$commandString = 'DEL_HOST_DOWNTIME';
} else {
$commandString = 'DEL_SVC_DOWNTIME';
}
return sprintf(
'%s;%u',
$commandString,
$command->getIsService() ? 'DEL_SVC_DOWNTIME' : 'DEL_HOST_DOWNTIME',
$command->getDowntimeId()
);
}

View File

@ -62,7 +62,7 @@ abstract class MonitoredObjectController extends Controller
->handleRequest();
$this->view->checkNowForm = $checkNowForm;
}
if ( ! in_array((int) $this->object->state, array(0, 99))) {
if (! in_array((int) $this->object->state, array(0, 99))) {
if ((bool) $this->object->acknowledged) {
if ($auth->hasPermission('monitoring/command/remove-acknowledgement')) {
$removeAckForm = new RemoveAcknowledgementCommandForm();
@ -82,16 +82,12 @@ abstract class MonitoredObjectController extends Controller
$this->view->toggleFeaturesForm = $toggleFeaturesForm;
if (! empty($this->object->comments) && $auth->hasPermission('monitoring/command/comment/delete')) {
$delCommentForm = new DeleteCommentCommandForm();
$delCommentForm
->setObjects($this->object)
->handleRequest();
$delCommentForm->handleRequest();
$this->view->delCommentForm = $delCommentForm;
}
if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) {
$delDowntimeForm = new DeleteDowntimeCommandForm();
$delDowntimeForm
->setObjects($this->object)
->handleRequest();
$delDowntimeForm->handleRequest();
$this->view->delDowntimeForm = $delDowntimeForm;
}
$this->view->object = $this->object;
@ -137,26 +133,6 @@ abstract class MonitoredObjectController extends Controller
*/
abstract public function scheduleDowntimeAction();
/**
* Delete a comment
*/
public function deleteCommentAction()
{
$this->assertHttpMethod('POST');
$this->assertPermission('monitoring/command/comment/delete');
$this->handleCommandForm(new DeleteCommentCommandForm());
}
/**
* Delete a downtime
*/
public function deleteDowntimeAction()
{
$this->assertHttpMethod('POST');
$this->assertPermission('monitoring/command/downtime/delete');
$this->handleCommandForm(new DeleteDowntimeCommandForm());
}
/**
* Create tabs
*/

View File

@ -0,0 +1,62 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Web\Menu;
use Icinga\Web\Menu as Menu;
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Web\Menu\MenuItemRenderer;
class BackendAvailabilityMenuItemRenderer extends MenuItemRenderer
{
/**
* Checks whether the monitoring backend is running or not
*
* @return mixed
*/
protected function isCurrentlyRunning()
{
return MonitoringBackend::instance()->select()->from(
'programstatus',
array(
'is_currently_running'
)
)->getQuery()->fetchRow()->is_currently_running;
}
/**
* @see MenuItemRenderer::render()
*/
public function render(Menu $menu)
{
return $this->getBadge() . $this->createLink($menu);
}
protected function getBadge()
{
if (! (bool)$this->isCurrentlyRunning()) {
return sprintf(
'<div title="%s" class="badge-container"><span class="badge badge-critical">%s</span></div>',
mt('monitoring', 'monitoring backend is not running'),
1
);
}
return '';
}
/**
* Get the problem data for the summary
*
* @return array|null
*/
public function getSummary()
{
if (! (bool)$this->isCurrentlyRunning()) {
return array(
'problems' => 1,
'title' => mt('monitoring', 'monitoring backend is not running')
);
}
return null;
}
}

View File

@ -172,19 +172,15 @@ form.instance-features span.description, form.object-features span.description {
}
}
table.avp form.object-features div.header h4,
table.avp h4.customvar {
table.avp form.object-features div.header h4 {
margin: 0;
}
table.avp .customvar ul,
table.avp .customvar ul li {
table.avp .customvar ul {
list-style-type: none;
margin: 0;
margin-top: -0.5em;
margin-bottom: -0.5em;
padding: 0;
padding-left: 0.5em;
padding-left: 1.5em;
}
div.selection-info {
@ -218,3 +214,10 @@ hr.command-separator {
border: none;
border-bottom: 2px solid @colorPetrol;
}
div.backend-not-running {
background: @colorCritical;
color: white;
text-align: center;
padding: 0.1em;
}

View File

@ -303,6 +303,10 @@
var data = self.icinga.ui.getSelectionKeys($table);
var url = $table.data('icinga-multiselect-url');
if ($(event.target).closest('form').length) {
// allow form actions in table rows to pass through
return;
}
event.stopPropagation();
event.preventDefault();

View File

@ -66,12 +66,16 @@ class UserTest extends BaseTestCase
$user->setPermissions(array(
'test',
'test/some/specific',
'test/more/*'
'test/more/*',
'test/wildcard-with-wildcard/*'
));
$this->assertTrue($user->can('test'));
$this->assertTrue($user->can('test/some/specific'));
$this->assertTrue($user->can('test/more/everything'));
$this->assertTrue($user->can('test/wildcard-with-wildcard/*'));
$this->assertTrue($user->can('test/wildcard-with-wildcard/sub/sub'));
$this->assertFalse($user->can('not/test'));
$this->assertFalse($user->can('test/some/not/so/specific'));
$this->assertFalse($user->can('test/wildcard2/*'));
}
}