mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-05-30 19:40:10 +02:00
Improve up downtime command form properties
Use a flag instead of a enumeration in delete downtime command form, to remove needless boilerplate. refs #8624
This commit is contained in:
parent
b35dd4ddfe
commit
ffd12e325c
@ -21,7 +21,7 @@ class DeleteDowntimeCommandForm extends CommandForm
|
|||||||
$this->setAttrib('class', 'inline');
|
$this->setAttrib('class', 'inline');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see \Icinga\Web\Form::createElements() For the method documentation.
|
* @see \Icinga\Web\Form::createElements() For the method documentation.
|
||||||
*/
|
*/
|
||||||
|
@ -10,46 +10,38 @@ use Icinga\Module\Monitoring\Command\IcingaCommand;
|
|||||||
*/
|
*/
|
||||||
class DeleteDowntimeCommand extends IcingaCommand
|
class DeleteDowntimeCommand extends IcingaCommand
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Downtime for a host
|
|
||||||
*/
|
|
||||||
const DOWNTIME_TYPE_HOST = 'host';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Downtime for a service
|
|
||||||
*/
|
|
||||||
const DOWNTIME_TYPE_SERVICE = 'service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID of the downtime that is to be deleted
|
* ID of the downtime that is to be deleted
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $downtimeId;
|
protected $downtimeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* If the command affects a service downtime
|
||||||
*
|
*
|
||||||
* @var type
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $downtimeType = self::DOWNTIME_TYPE_HOST;
|
protected $isService = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the downtime type, either host or service
|
* Set if this command affects a service
|
||||||
*
|
*
|
||||||
* @param string $type the downtime type
|
* @param type $value
|
||||||
*/
|
*/
|
||||||
public function setDowntimeType($type)
|
public function setIsService($value = true)
|
||||||
{
|
{
|
||||||
$this->downtimeType = $type;
|
$this->isService = (bool) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Return whether the command affects a service
|
||||||
|
*
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function getDowntimeType()
|
public function getIsService()
|
||||||
{
|
{
|
||||||
return $this->downtimeType;
|
return $this->isService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,14 +332,9 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface
|
|||||||
|
|
||||||
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
|
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
|
||||||
{
|
{
|
||||||
if ($command->getDowntimeType() === 'host') {
|
|
||||||
$commandString = 'DEL_HOST_DOWNTIME';
|
|
||||||
} else {
|
|
||||||
$commandString = 'DEL_SVC_DOWNTIME';
|
|
||||||
}
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s;%u',
|
'%s;%u',
|
||||||
$commandString,
|
$command->getIsService() ? 'DEL_SVC_DOWNTIME' : 'DEL_HOST_DOWNTIME',
|
||||||
$command->getDowntimeId()
|
$command->getDowntimeId()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user