mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
SyncruleController: add summary tab, reordered
This commit is contained in:
parent
d4c2c7bc36
commit
b77f71f22a
@ -12,14 +12,49 @@ use Icinga\Web\Url;
|
|||||||
|
|
||||||
class SyncruleController extends ActionController
|
class SyncruleController extends ActionController
|
||||||
{
|
{
|
||||||
|
public function indexAction()
|
||||||
|
{
|
||||||
|
$id = $this->params->get('id');
|
||||||
|
$this->prepareRuleTabs($id)->activate('show');
|
||||||
|
$rule = $this->view->rule = SyncRule::load($id, $this->db());
|
||||||
|
$this->view->title = sprintf(
|
||||||
|
$this->translate('Sync rule: %s'),
|
||||||
|
$rule->rule_name
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($lastRunId = $rule->getLastSyncRunId()) {
|
||||||
|
$this->loadSyncRun($lastRunId);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->view->run = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function addAction()
|
public function addAction()
|
||||||
{
|
{
|
||||||
$this->indexAction();
|
$this->editAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editAction()
|
public function editAction()
|
||||||
{
|
{
|
||||||
$this->indexAction();
|
$form = $this->view->form = $this->loadForm('syncRule')
|
||||||
|
->setSuccessUrl('director/list/syncrule')
|
||||||
|
->setDb($this->db());
|
||||||
|
|
||||||
|
if ($id = $this->params->get('id')) {
|
||||||
|
$this->prepareRuleTabs($id)->activate('edit');
|
||||||
|
$form->loadObject($id);
|
||||||
|
$this->view->title = sprintf(
|
||||||
|
$this->translate('Sync rule: %s'),
|
||||||
|
$form->getObject()->rule_name
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->view->title = $this->translate('Add sync rule');
|
||||||
|
$this->prepareRuleTabs()->activate('add');
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->handleRequest();
|
||||||
|
$this->setViewScript('object/form');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
public function runAction()
|
||||||
@ -44,28 +79,6 @@ class SyncruleController extends ActionController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function indexAction()
|
|
||||||
{
|
|
||||||
$form = $this->view->form = $this->loadForm('syncRule')
|
|
||||||
->setSuccessUrl('director/list/syncrule')
|
|
||||||
->setDb($this->db());
|
|
||||||
|
|
||||||
if ($id = $this->params->get('id')) {
|
|
||||||
$this->prepareRuleTabs($id)->activate('edit');
|
|
||||||
$form->loadObject($id);
|
|
||||||
$this->view->title = sprintf(
|
|
||||||
$this->translate('Sync rule: %s'),
|
|
||||||
$form->getObject()->rule_name
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->view->title = $this->translate('Add sync rule');
|
|
||||||
$this->prepareRuleTabs()->activate('add');
|
|
||||||
}
|
|
||||||
|
|
||||||
$form->handleRequest();
|
|
||||||
$this->setViewScript('object/form');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function propertyAction()
|
public function propertyAction()
|
||||||
{
|
{
|
||||||
$this->view->stayHere = true;
|
$this->view->stayHere = true;
|
||||||
@ -164,35 +177,49 @@ class SyncruleController extends ActionController
|
|||||||
->setConnection($this->db());
|
->setConnection($this->db());
|
||||||
|
|
||||||
if ($runId = $this->params->get('run_id')) {
|
if ($runId = $this->params->get('run_id')) {
|
||||||
$this->view->run = SyncRun::load($runId, $db);
|
$this->loadSyncRun($runId);
|
||||||
if ($this->view->run->last_former_activity !== null) {
|
}
|
||||||
$this->view->formerId = $db->fetchActivityLogIdByChecksum(
|
}
|
||||||
$this->view->run->last_former_activity
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->view->lastId = $db->fetchActivityLogIdByChecksum(
|
protected function loadSyncRun($id)
|
||||||
$this->view->run->last_related_activity
|
{
|
||||||
);
|
$db = $this->db();
|
||||||
}
|
$this->view->run = SyncRun::load($id, $db);
|
||||||
|
if ($this->view->run->last_former_activity !== null) {
|
||||||
|
$this->view->formerId = $db->fetchActivityLogIdByChecksum(
|
||||||
|
$this->view->run->last_former_activity
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->view->lastId = $db->fetchActivityLogIdByChecksum(
|
||||||
|
$this->view->run->last_related_activity
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prepareRuleTabs($ruleId = null)
|
protected function prepareRuleTabs($ruleId = null)
|
||||||
{
|
{
|
||||||
if ($ruleId) {
|
if ($ruleId) {
|
||||||
return $this->getTabs()->add('edit', array(
|
$tabs = $this->getTabs()->add('show', array(
|
||||||
'url' => 'director/syncrule/edit',
|
'url' => 'director/syncrule',
|
||||||
'urlParams' => array('id' => $ruleId),
|
'urlParams' => array('id' => $ruleId),
|
||||||
'label' => $this->translate('Sync rule'),
|
'label' => $this->translate('Sync rule'),
|
||||||
|
))->add('edit', array(
|
||||||
|
'url' => 'director/syncrule/edit',
|
||||||
|
'urlParams' => array('id' => $ruleId),
|
||||||
|
'label' => $this->translate('Modify'),
|
||||||
))->add('property', array(
|
))->add('property', array(
|
||||||
'label' => $this->translate('Properties'),
|
'label' => $this->translate('Properties'),
|
||||||
'url' => 'director/syncrule/property',
|
'url' => 'director/syncrule/property',
|
||||||
'urlParams' => array('rule_id' => $ruleId)
|
'urlParams' => array('rule_id' => $ruleId)
|
||||||
))->add('history', array(
|
));
|
||||||
|
|
||||||
|
$tabs->add('history', array(
|
||||||
'label' => $this->translate('History'),
|
'label' => $this->translate('History'),
|
||||||
'url' => 'director/syncrule/history',
|
'url' => 'director/syncrule/history',
|
||||||
'urlParams' => array('id' => $ruleId)
|
'urlParams' => array('id' => $ruleId)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
return $tabs;
|
||||||
} else {
|
} else {
|
||||||
return $this->getTabs()->add('add', array(
|
return $this->getTabs()->add('add', array(
|
||||||
'url' => 'director/syncrule/add',
|
'url' => 'director/syncrule/add',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user