mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
56b8b398c2
commit
b3c1a7a1ed
@ -560,13 +560,59 @@ class Monitoring_CommandController extends ModuleActionController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendComment()
|
public function addcommentAction()
|
||||||
{
|
{
|
||||||
$author = "AUTHOR"; //@TODO: get from auth backend
|
$form = new SendCommand("Add comment");
|
||||||
$comment = $this->getMandatoryParameter("comment");
|
$form->addTextBox("author", "Author (Your name):", "", true);
|
||||||
$persistent = $this->_request->getPost("persistent", false) == "true";
|
$form->addTextBox("comment", "Comment:", "", false, true);
|
||||||
$commentObj = new \Icinga\Protocol\Commandpipe\Comment($author, $comment, $persistent);
|
$form->addCheckbox("persistent", "Persistent:", false);
|
||||||
$this->target->addComment($this->selectCommandTargets(), $commentObj);
|
|
||||||
|
if ($this->_request->isPost()) {
|
||||||
|
if ($form->isValid()) {
|
||||||
|
$comment = new Comment($form->getText("author"), $form->getText("comment"),
|
||||||
|
$form->isChecked("persistent"));
|
||||||
|
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
||||||
|
$this->target->addComment($targets, $comment);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$form->getElement("author")->setValue(Manager::getInstance()->getUser()->getUsername());
|
||||||
|
$form->setServices($this->getParameter("services", false));
|
||||||
|
$form->setHosts($this->getParameter("hosts"));
|
||||||
|
$form->setAction($this->view->url());
|
||||||
|
$form->addSubmitButton("Commit");
|
||||||
|
$this->view->form = $form;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deletecommentAction()
|
||||||
|
{
|
||||||
|
$form = new SendCommand("Delete comment");
|
||||||
|
// @TODO: How should this form look like?
|
||||||
|
|
||||||
|
if ($this->_request->isPost()) {
|
||||||
|
if ($form->isValid()) {
|
||||||
|
$comments = $form->getValue("comments");
|
||||||
|
if ($comments) {
|
||||||
|
// @TODO: Which data structure should be used to transmit comment details?
|
||||||
|
$this->target->removeComment($comments);
|
||||||
|
} else {
|
||||||
|
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
||||||
|
$this->target->removeComment($targets);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$comments = $this->getParameter("comments", false);
|
||||||
|
if ($comments) {
|
||||||
|
// @TODO: Which data structure should be used to transmit comment details?
|
||||||
|
} else {
|
||||||
|
$form->setServices($this->getParameter("services", false));
|
||||||
|
$form->setHosts($this->getParameter("hosts"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->setAction($this->view->url());
|
||||||
|
$form->addSubmitButton("Commit");
|
||||||
|
$this->view->form = $form;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendDeletecomment()
|
public function sendDeletecomment()
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
<?= $this->form ?>
|
@ -0,0 +1 @@
|
|||||||
|
<?= $this->form ?>
|
Loading…
x
Reference in New Issue
Block a user