ServicetemplateController: add templates action...
...re-structure code, enable autoRefresh
This commit is contained in:
parent
6c943e4d06
commit
6ca1ec2951
|
@ -2,9 +2,12 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Controllers;
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Objects\IcingaService;
|
use Icinga\Module\Director\Objects\IcingaService;
|
||||||
use Icinga\Module\Director\Web\Controller\Extension\DirectorDb;
|
use Icinga\Module\Director\Web\Controller\Extension\DirectorDb;
|
||||||
|
use Icinga\Module\Director\Web\Table\ApplyRulesTable;
|
||||||
use Icinga\Module\Director\Web\Table\ObjectsTableService;
|
use Icinga\Module\Director\Web\Table\ObjectsTableService;
|
||||||
|
use Icinga\Module\Director\Web\Table\TemplatesTable;
|
||||||
use Icinga\Module\Director\Web\Table\TemplateUsageTable;
|
use Icinga\Module\Director\Web\Table\TemplateUsageTable;
|
||||||
use ipl\Html\FormattedString;
|
use ipl\Html\FormattedString;
|
||||||
use ipl\Html\Html;
|
use ipl\Html\Html;
|
||||||
|
@ -21,11 +24,53 @@ class ServicetemplateController extends CompatController
|
||||||
$template = $this->requireTemplate();
|
$template = $this->requireTemplate();
|
||||||
$this
|
$this
|
||||||
->addSingleTab($this->translate('Single Services'))
|
->addSingleTab($this->translate('Single Services'))
|
||||||
|
->setAutorefreshInterval(10)
|
||||||
->addTitle(
|
->addTitle(
|
||||||
$this->translate('Services based on %s'),
|
$this->translate('Services based on %s'),
|
||||||
$template->getObjectName()
|
$template->getObjectName()
|
||||||
);
|
)->addBackToUsageLink($template);
|
||||||
|
|
||||||
|
$table = new ObjectsTableService($this->db());
|
||||||
|
$table->setAuth($this->Auth());
|
||||||
|
$table->filterTemplate($template, $this->params->get('inheritance', 'direct'));
|
||||||
|
$table->renderTo($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function templatesAction()
|
||||||
|
{
|
||||||
|
$template = $this->requireTemplate();
|
||||||
|
$this
|
||||||
|
->addSingleTab($this->translate('Service Templates'))
|
||||||
|
->setAutorefreshInterval(10)
|
||||||
|
->addTitle(
|
||||||
|
$this->translate('Service templates based on %s'),
|
||||||
|
$template->getObjectName()
|
||||||
|
)->addBackToUsageLink($template);
|
||||||
|
|
||||||
|
$table = TemplatesTable::create('service', $this->db());
|
||||||
|
$table->filterTemplate($template, $this->params->get('inheritance', 'direct'));
|
||||||
|
$table->renderTo($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyrulesAction()
|
||||||
|
{
|
||||||
|
$template = $this->requireTemplate();
|
||||||
|
$this
|
||||||
|
->addSingleTab($this->translate('Applied services'))
|
||||||
|
->setAutorefreshInterval(10)
|
||||||
|
->addTitle(
|
||||||
|
$this->translate('Service Apply Rules based on %s'),
|
||||||
|
$template->getObjectName()
|
||||||
|
)->addBackToUsageLink($template);
|
||||||
|
|
||||||
|
$table = new ApplyRulesTable($this->db());
|
||||||
|
$table->setType('service');
|
||||||
|
$table->filterTemplate($template, $this->params->get('inheritance', 'direct'));
|
||||||
|
$table->renderTo($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addBackToUsageLink(IcingaObject $template)
|
||||||
|
{
|
||||||
$this->actions()->add(
|
$this->actions()->add(
|
||||||
Link::create(
|
Link::create(
|
||||||
$this->translate('Back'),
|
$this->translate('Back'),
|
||||||
|
@ -35,25 +80,7 @@ class ServicetemplateController extends CompatController
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$table = new ObjectsTableService($this->db());
|
return $this;
|
||||||
$table->setAuth($this->Auth());
|
|
||||||
$table->filterTemplate($template, $this->params->get('inheritance', 'direct'));
|
|
||||||
$table->renderTo($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applyrulesAction()
|
|
||||||
{
|
|
||||||
$template = $this->requireTemplate();
|
|
||||||
$this
|
|
||||||
->addSingleTab($this->translate('Single Services'))
|
|
||||||
->addTitle(
|
|
||||||
$this->translate('Services based on %s'),
|
|
||||||
$template->getObjectName()
|
|
||||||
);
|
|
||||||
|
|
||||||
$table = new ObjectsTableService($this->db());
|
|
||||||
$table->filterTemplate($template);
|
|
||||||
$this->content()->add($table);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function usageAction()
|
public function usageAction()
|
||||||
|
@ -61,12 +88,10 @@ class ServicetemplateController extends CompatController
|
||||||
$template = $this->requireTemplate();
|
$template = $this->requireTemplate();
|
||||||
$templateName = $template->getObjectName();
|
$templateName = $template->getObjectName();
|
||||||
|
|
||||||
$this->addSingleTab(
|
$this
|
||||||
$this->translate('Service Template Usage')
|
->addSingleTab($this->translate('Service Template Usage'))
|
||||||
)->addTitle(
|
->addTitle($this->translate('Template: %s'), $templateName)
|
||||||
$this->translate('Template: %s'),
|
->setAutorefreshInterval(10);
|
||||||
$templateName
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->actions()->add([
|
$this->actions()->add([
|
||||||
Link::create(
|
Link::create(
|
||||||
|
|
Loading…
Reference in New Issue