JobsController: refactor, cleanup

This commit is contained in:
Thomas Gelf 2017-08-16 14:14:30 +02:00
parent 23d599053e
commit 4c177fc4ea
2 changed files with 7 additions and 60 deletions

View File

@ -3,27 +3,18 @@
namespace Icinga\Module\Director\Controllers;
use Icinga\Module\Director\Web\Controller\ActionController;
use Icinga\Module\Director\Web\Table\JobTable;
use Icinga\Module\Director\Web\Tabs\ImportTabs;
class JobsController extends ActionController
{
public function indexAction()
{
$this->setAutoRefreshInterval(10);
$this->view->title = $this->translate('Jobs');
$this->setImportTabs()->activate('jobs');
$this->addTitle($this->translate('Jobs'))
->setAutoRefreshInterval(10)
->addAddLink($this->translate('Add a new Job'), 'director/job/add')
->tabs(new ImportTabs())->activate('jobs');
$this->view->addLink = $this->view->qlink(
$this->translate('Add'),
'director/job',
null,
array('class' => 'icon-plus')
);
$this->view->table = $this->applyPaginationLimits(
$this->loadTable('job')
->setConnection($this->db())
);
$this->setViewScript('list/table');
(new JobTable($this->db()))->renderTo($this);
}
}

View File

@ -1,44 +0,0 @@
<div class="controls">
<?= $this->tabs ?>
<h1><?= $this->escape($this->title) ?></h1>
<span class="action-links">
<?= $this->actionLinks ?>
</span>
</div>
<div class="content">
<?php if ($job->disabled === 'y'): ?>
<p class="error"><?= sprintf(
$this->translate(
'This job would run every %ds. It has been disabled and will therefore not be executed as scheduled'
),
$job->run_interval
) ?>
</p>
<?php else: ?>
<p>
<?php //$class = $job->job(); echo $class::getDescription() ?>
<?php if ($job->isPending()): ?>
<?= sprintf($this->translate('This job runs every %ds and is currently pending'), $job->run_interval) ?>
<?php else: ?>
<?= sprintf($this->translate('This job runs every %ds.'), $job->run_interval) ?>
<?php endif ?>
</p>
<?php endif ?>
<?php if ($job->ts_last_attempt): ?>
<?php if ($job->last_attempt_succeeded): ?>
<p><?= sprintf(
$this->translate('The last attempt succeeded at %s'),
$job->ts_last_attempt
) ?></p>
<?php else: ?>
<p class="error"><?= sprintf(
$this->translate('The last attempt failed at %s: %s'),
$job->ts_last_attempt,
$this->escape($job->ts_last_error)
) ?></p>
<?php endif ?>
<?php else: ?>
<?= $this->translate('This job has not been executed yet') ?>
<?php endif ?>
</div>