Merge pull request #4155 from Icinga/feature/transmit-author-when-removing-downtimes-comments-and-acks-2281
Transmit author when removing downtimes comments and acks
This commit is contained in:
commit
d3baedb766
|
@ -94,6 +94,7 @@ class DeleteCommentCommandForm extends CommandForm
|
|||
{
|
||||
$cmd = new DeleteCommentCommand();
|
||||
$cmd
|
||||
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||
->setCommentId($this->getElement('comment_id')->getValue())
|
||||
->setCommentName($this->getElement('comment_name')->getValue())
|
||||
->setIsService($this->getElement('comment_is_service')->getValue());
|
||||
|
|
|
@ -73,6 +73,7 @@ class DeleteCommentsCommandForm extends CommandForm
|
|||
$cmd
|
||||
->setCommentId($comment->id)
|
||||
->setCommentName($comment->name)
|
||||
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||
->setIsService(isset($comment->service_description));
|
||||
$this->getTransport($this->request)->send($cmd);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ class DeleteDowntimeCommandForm extends CommandForm
|
|||
{
|
||||
$cmd = new DeleteDowntimeCommand();
|
||||
$cmd
|
||||
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||
->setDowntimeId($this->getElement('downtime_id')->getValue())
|
||||
->setDowntimeName($this->getElement('downtime_name')->getValue())
|
||||
->setIsService($this->getElement('downtime_is_service')->getValue());
|
||||
|
|
|
@ -73,6 +73,7 @@ class DeleteDowntimesCommandForm extends CommandForm
|
|||
$delDowntime
|
||||
->setDowntimeId($downtime->id)
|
||||
->setDowntimeName($downtime->name)
|
||||
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||
->setIsService(isset($downtime->service_description));
|
||||
$this->getTransport($this->request)->send($delDowntime);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm
|
|||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||
$removeAck = new RemoveAcknowledgementCommand();
|
||||
$removeAck->setObject($object);
|
||||
$removeAck->setAuthor($this->Auth()->getUser()->getUsername());
|
||||
$this->getTransport($this->request)->send($removeAck);
|
||||
}
|
||||
Notification::success(mtp(
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2020 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\Command\Object;
|
||||
|
||||
trait CommandAuthor
|
||||
{
|
||||
/**
|
||||
* Author of the command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $author;
|
||||
|
||||
/**
|
||||
* Set the author
|
||||
*
|
||||
* @param string $author
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
$this->author = (string) $author;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,8 @@ use Icinga\Module\Monitoring\Command\IcingaCommand;
|
|||
*/
|
||||
class DeleteCommentCommand extends IcingaCommand
|
||||
{
|
||||
use CommandAuthor;
|
||||
|
||||
/**
|
||||
* ID of the comment that is to be deleted
|
||||
*
|
||||
|
|
|
@ -10,6 +10,8 @@ use Icinga\Module\Monitoring\Command\IcingaCommand;
|
|||
*/
|
||||
class DeleteDowntimeCommand extends IcingaCommand
|
||||
{
|
||||
use CommandAuthor;
|
||||
|
||||
/**
|
||||
* ID of the downtime that is to be deleted
|
||||
*
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace Icinga\Module\Monitoring\Command\Object;
|
|||
*/
|
||||
class RemoveAcknowledgementCommand extends ObjectCommand
|
||||
{
|
||||
use CommandAuthor;
|
||||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation.
|
||||
|
|
|
@ -8,12 +8,7 @@ namespace Icinga\Module\Monitoring\Command\Object;
|
|||
*/
|
||||
abstract class WithCommentCommand extends ObjectCommand
|
||||
{
|
||||
/**
|
||||
* Author of the comment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $author;
|
||||
use CommandAuthor;
|
||||
|
||||
/**
|
||||
* Comment
|
||||
|
@ -22,29 +17,6 @@ abstract class WithCommentCommand extends ObjectCommand
|
|||
*/
|
||||
protected $comment;
|
||||
|
||||
/**
|
||||
* Set the author
|
||||
*
|
||||
* @param string $author
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
$this->author = (string) $author;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the comment
|
||||
*
|
||||
|
|
|
@ -237,25 +237,27 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
public function renderDeleteComment(DeleteCommentCommand $command)
|
||||
{
|
||||
$endpoint = 'actions/remove-comment';
|
||||
$data = array(
|
||||
'comment' => $command->getCommentName()
|
||||
);
|
||||
$data = [
|
||||
'author' => $command->getAuthor(),
|
||||
'comment' => $command->getCommentName()
|
||||
];
|
||||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
|
||||
{
|
||||
$endpoint = 'actions/remove-downtime';
|
||||
$data = array(
|
||||
'downtime' => $command->getDowntimeName()
|
||||
);
|
||||
$data = [
|
||||
'author' => $command->getAuthor(),
|
||||
'downtime' => $command->getDowntimeName()
|
||||
];
|
||||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderRemoveAcknowledgement(RemoveAcknowledgementCommand $command)
|
||||
{
|
||||
$endpoint = 'actions/remove-acknowledgement';
|
||||
$data = array();
|
||||
$data = ['author' => $command->getAuthor()];
|
||||
$this->applyFilter($data, $command->getObject());
|
||||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue