mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
JobController: populate and restructure actions
This commit is contained in:
parent
e79e123e19
commit
17345a3df8
@ -3,7 +3,7 @@
|
|||||||
namespace Icinga\Module\Director\Controllers;
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
use Icinga\Module\Director\Objects\Job;
|
use Icinga\Module\Director\Objects\DirectorJob;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
@ -15,16 +15,25 @@ class JobController extends ActionController
|
|||||||
$this->indexAction();
|
$this->indexAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$this->indexAction();
|
if (! ($id = $this->params->get('id'))) {
|
||||||
|
return $this->editAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->prepareTabs($id)->activate('show');
|
||||||
|
$this->view->job = DirectorJob::load($id, $this->db());
|
||||||
|
$this->view->title = sprintf(
|
||||||
|
$this->translate('Job: %s'),
|
||||||
|
$this->view->job->job_name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
public function runAction()
|
||||||
{
|
{
|
||||||
// TODO: Form, POST
|
// TODO: Form, POST
|
||||||
$id = $this->params->get('id');
|
$id = $this->params->get('id');
|
||||||
$job = Job::load($id, $this->db());
|
$job = DirectorJob::load($id, $this->db());
|
||||||
if ($job->run()) {
|
if ($job->run()) {
|
||||||
Notification::success('Job has successfully been completed');
|
Notification::success('Job has successfully been completed');
|
||||||
$this->redirectNow(
|
$this->redirectNow(
|
||||||
@ -38,7 +47,7 @@ class JobController extends ActionController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function indexAction()
|
public function editAction()
|
||||||
{
|
{
|
||||||
$form = $this->view->form = $this->loadForm('directorJob')
|
$form = $this->view->form = $this->loadForm('directorJob')
|
||||||
->setSuccessUrl('director/job')
|
->setSuccessUrl('director/job')
|
||||||
@ -63,15 +72,19 @@ class JobController extends ActionController
|
|||||||
protected function prepareTabs($id = null)
|
protected function prepareTabs($id = null)
|
||||||
{
|
{
|
||||||
if ($id) {
|
if ($id) {
|
||||||
return $this->getTabs()->add('edit', array(
|
return $this->getTabs()->add('show', array(
|
||||||
'url' => 'director/job/edit',
|
'url' => 'director/job',
|
||||||
'urlParams' => array('id' => $id),
|
'urlParams' => array('id' => $id),
|
||||||
'label' => $this->translate('Job'),
|
'label' => $this->translate('Job'),
|
||||||
|
))->add('edit', array(
|
||||||
|
'url' => 'director/job/edit',
|
||||||
|
'urlParams' => array('id' => $id),
|
||||||
|
'label' => $this->translate('Config'),
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return $this->getTabs()->add('add', array(
|
return $this->getTabs()->add('add', array(
|
||||||
'url' => 'director/job/add',
|
'url' => 'director/job/add',
|
||||||
'label' => $this->translate('Job'),
|
'label' => $this->translate('Add a job'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user