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 = new DeleteCommentCommand();
|
||||||
$cmd
|
$cmd
|
||||||
|
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||||
->setCommentId($this->getElement('comment_id')->getValue())
|
->setCommentId($this->getElement('comment_id')->getValue())
|
||||||
->setCommentName($this->getElement('comment_name')->getValue())
|
->setCommentName($this->getElement('comment_name')->getValue())
|
||||||
->setIsService($this->getElement('comment_is_service')->getValue());
|
->setIsService($this->getElement('comment_is_service')->getValue());
|
||||||
|
|
|
@ -73,6 +73,7 @@ class DeleteCommentsCommandForm extends CommandForm
|
||||||
$cmd
|
$cmd
|
||||||
->setCommentId($comment->id)
|
->setCommentId($comment->id)
|
||||||
->setCommentName($comment->name)
|
->setCommentName($comment->name)
|
||||||
|
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||||
->setIsService(isset($comment->service_description));
|
->setIsService(isset($comment->service_description));
|
||||||
$this->getTransport($this->request)->send($cmd);
|
$this->getTransport($this->request)->send($cmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ class DeleteDowntimeCommandForm extends CommandForm
|
||||||
{
|
{
|
||||||
$cmd = new DeleteDowntimeCommand();
|
$cmd = new DeleteDowntimeCommand();
|
||||||
$cmd
|
$cmd
|
||||||
|
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||||
->setDowntimeId($this->getElement('downtime_id')->getValue())
|
->setDowntimeId($this->getElement('downtime_id')->getValue())
|
||||||
->setDowntimeName($this->getElement('downtime_name')->getValue())
|
->setDowntimeName($this->getElement('downtime_name')->getValue())
|
||||||
->setIsService($this->getElement('downtime_is_service')->getValue());
|
->setIsService($this->getElement('downtime_is_service')->getValue());
|
||||||
|
|
|
@ -73,6 +73,7 @@ class DeleteDowntimesCommandForm extends CommandForm
|
||||||
$delDowntime
|
$delDowntime
|
||||||
->setDowntimeId($downtime->id)
|
->setDowntimeId($downtime->id)
|
||||||
->setDowntimeName($downtime->name)
|
->setDowntimeName($downtime->name)
|
||||||
|
->setAuthor($this->Auth()->getUser()->getUsername())
|
||||||
->setIsService(isset($downtime->service_description));
|
->setIsService(isset($downtime->service_description));
|
||||||
$this->getTransport($this->request)->send($delDowntime);
|
$this->getTransport($this->request)->send($delDowntime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
$removeAck = new RemoveAcknowledgementCommand();
|
$removeAck = new RemoveAcknowledgementCommand();
|
||||||
$removeAck->setObject($object);
|
$removeAck->setObject($object);
|
||||||
|
$removeAck->setAuthor($this->Auth()->getUser()->getUsername());
|
||||||
$this->getTransport($this->request)->send($removeAck);
|
$this->getTransport($this->request)->send($removeAck);
|
||||||
}
|
}
|
||||||
Notification::success(mtp(
|
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
|
class DeleteCommentCommand extends IcingaCommand
|
||||||
{
|
{
|
||||||
|
use CommandAuthor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID of the comment that is to be deleted
|
* ID of the comment that is to be deleted
|
||||||
*
|
*
|
||||||
|
|
|
@ -10,6 +10,8 @@ use Icinga\Module\Monitoring\Command\IcingaCommand;
|
||||||
*/
|
*/
|
||||||
class DeleteDowntimeCommand extends IcingaCommand
|
class DeleteDowntimeCommand extends IcingaCommand
|
||||||
{
|
{
|
||||||
|
use CommandAuthor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID of the downtime that is to be deleted
|
* ID of the downtime that is to be deleted
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace Icinga\Module\Monitoring\Command\Object;
|
||||||
*/
|
*/
|
||||||
class RemoveAcknowledgementCommand extends ObjectCommand
|
class RemoveAcknowledgementCommand extends ObjectCommand
|
||||||
{
|
{
|
||||||
|
use CommandAuthor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation.
|
* @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
|
abstract class WithCommentCommand extends ObjectCommand
|
||||||
{
|
{
|
||||||
/**
|
use CommandAuthor;
|
||||||
* Author of the comment
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $author;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment
|
* Comment
|
||||||
|
@ -22,29 +17,6 @@ abstract class WithCommentCommand extends ObjectCommand
|
||||||
*/
|
*/
|
||||||
protected $comment;
|
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
|
* Set the comment
|
||||||
*
|
*
|
||||||
|
|
|
@ -237,25 +237,27 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
||||||
public function renderDeleteComment(DeleteCommentCommand $command)
|
public function renderDeleteComment(DeleteCommentCommand $command)
|
||||||
{
|
{
|
||||||
$endpoint = 'actions/remove-comment';
|
$endpoint = 'actions/remove-comment';
|
||||||
$data = array(
|
$data = [
|
||||||
'comment' => $command->getCommentName()
|
'author' => $command->getAuthor(),
|
||||||
);
|
'comment' => $command->getCommentName()
|
||||||
|
];
|
||||||
return IcingaApiCommand::create($endpoint, $data);
|
return IcingaApiCommand::create($endpoint, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
|
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
|
||||||
{
|
{
|
||||||
$endpoint = 'actions/remove-downtime';
|
$endpoint = 'actions/remove-downtime';
|
||||||
$data = array(
|
$data = [
|
||||||
'downtime' => $command->getDowntimeName()
|
'author' => $command->getAuthor(),
|
||||||
);
|
'downtime' => $command->getDowntimeName()
|
||||||
|
];
|
||||||
return IcingaApiCommand::create($endpoint, $data);
|
return IcingaApiCommand::create($endpoint, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderRemoveAcknowledgement(RemoveAcknowledgementCommand $command)
|
public function renderRemoveAcknowledgement(RemoveAcknowledgementCommand $command)
|
||||||
{
|
{
|
||||||
$endpoint = 'actions/remove-acknowledgement';
|
$endpoint = 'actions/remove-acknowledgement';
|
||||||
$data = array();
|
$data = ['author' => $command->getAuthor()];
|
||||||
$this->applyFilter($data, $command->getObject());
|
$this->applyFilter($data, $command->getObject());
|
||||||
return IcingaApiCommand::create($endpoint, $data);
|
return IcingaApiCommand::create($endpoint, $data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue