mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
monitoring: Fix mess in CommentsController and the related view script
This commit is contained in:
parent
78701ab2b6
commit
2533ebc8d5
@ -9,28 +9,33 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
/**
|
||||
* Display detailed information about a comment
|
||||
* Display detailed information about comments
|
||||
*/
|
||||
class CommentsController extends Controller
|
||||
{
|
||||
/**
|
||||
* The fetched comments
|
||||
* The comments view
|
||||
*
|
||||
* @var array
|
||||
* @var \Icinga\Module\Monitoring\DataView\Comment
|
||||
*/
|
||||
protected $comments;
|
||||
|
||||
/**
|
||||
* Fetch all comments matching the current filter and add tabs
|
||||
* Filter from request
|
||||
*
|
||||
* @throws Zend_Controller_Action_Exception
|
||||
* @var Filter
|
||||
*/
|
||||
protected $filter;
|
||||
|
||||
/**
|
||||
* Fetch all comments matching the current filter and add tabs
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->filter = Filter::fromQueryString(str_replace(
|
||||
'comment_id',
|
||||
'comment_internal_id',
|
||||
(string)$this->params
|
||||
(string) $this->params
|
||||
));
|
||||
$query = $this->backend->select()->from('comment', array(
|
||||
'id' => 'comment_internal_id',
|
||||
@ -48,19 +53,16 @@ class CommentsController extends Controller
|
||||
))->addFilter($this->filter);
|
||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||
|
||||
$this->comments = $query->getQuery()->fetchAll();
|
||||
if (false === $this->comments) {
|
||||
throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
|
||||
}
|
||||
$this->comments = $query;
|
||||
|
||||
$this->getTabs()->add(
|
||||
'comments',
|
||||
array(
|
||||
'icon' => 'comment',
|
||||
'label' => $this->translate('Comments') . sprintf(' (%d)', $query->count()),
|
||||
'title' => $this->translate(
|
||||
'Display detailed information about multiple comments.'
|
||||
),
|
||||
'icon' => 'comment',
|
||||
'label' => $this->translate('Comments') . sprintf(' (%d)', count($this->comments)),
|
||||
'url' =>'monitoring/comments/show'
|
||||
)
|
||||
)->activate('comments');
|
||||
@ -73,9 +75,9 @@ class CommentsController extends Controller
|
||||
{
|
||||
$this->view->comments = $this->comments;
|
||||
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
|
||||
->setQueryString($this->filter->toQueryString());
|
||||
->setQueryString($this->filter->toQueryString());
|
||||
$this->view->removeAllLink = Url::fromPath('monitoring/comments/delete-all')
|
||||
->setParams($this->params);
|
||||
->setParams($this->params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,14 +93,14 @@ class CommentsController extends Controller
|
||||
$delCommentForm->setTitle($this->view->translate('Remove all Comments'));
|
||||
$delCommentForm->addDescription(sprintf(
|
||||
$this->translate('Confirm removal of %d comments.'),
|
||||
count($this->comments)
|
||||
$this->comments->count()
|
||||
));
|
||||
$delCommentForm->setComments($this->comments)
|
||||
$delCommentForm->setComments($this->comments->fetchAll())
|
||||
->setRedirectUrl($listCommentsLink)
|
||||
->handleRequest();
|
||||
$this->view->delCommentForm = $delCommentForm;
|
||||
$this->view->comments = $this->comments;
|
||||
$this->view->listAllLink = Url::fromPath('monitoring/list/comments')
|
||||
->setQueryString($this->filter->toQueryString());
|
||||
->setQueryString($this->filter->toQueryString());
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,23 @@
|
||||
<div class="controls">
|
||||
<?php if (! $this->compact): ?>
|
||||
<?= $this->tabs; ?>
|
||||
<?php endif ?>
|
||||
|
||||
<div data-base-target='_next'>
|
||||
<?= $this->render('partials/comment/comments-header.phtml'); ?>
|
||||
</div>
|
||||
<?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 multi-commands">
|
||||
<h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3>
|
||||
<h3><?= $this->icon('reschedule') ?><?= $this->translate('Commands') ?></h3>
|
||||
<?= $this->qlink(
|
||||
sprintf(
|
||||
$this->translate('Remove %d comments'),
|
||||
count($comments)
|
||||
$comments->count()
|
||||
),
|
||||
$removeAllLink,
|
||||
null,
|
||||
array(
|
||||
'icon' => 'trash',
|
||||
'icon' => 'trash',
|
||||
'title' => $this->translate('Remove all selected comments.')
|
||||
)
|
||||
) ?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user