index: show and link jobs on dashboard

This commit is contained in:
Thomas Gelf 2016-04-22 14:31:41 +02:00
parent cf1e5d88a8
commit 37d3c5aa04
2 changed files with 29 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Controllers;
use Exception;
use Icinga\Module\Director\Objects\DirectorJob;
use Icinga\Module\Director\Objects\SyncRule;
use Icinga\Module\Director\Web\Controller\ActionController;
@ -31,7 +32,8 @@ class IndexController extends ActionController
'label' => $this->translate('Overview')
))->activate('overview');
$this->fetchSyncState();
$this->fetchSyncState()
->fetchJobState();
}
}
@ -56,6 +58,31 @@ class IndexController extends ActionController
}
$this->view->syncState = $state;
return $this;
}
protected function fetchJobState()
{
$jobs = DirectorJob::loadAll($this->db());
if (count($jobs) > 0) {
$state = 'ok';
} else {
$state = null;
}
foreach ($jobs as $job) {
if ($job->isPending()) {
$state = 'pending';
} elseif (! $job->lastAttemptSucceeded()) {
$state = 'critical';
break;
}
}
$this->view->jobState = $state;
return $this;
}
protected function hasDeploymentEndpoint()

View File

@ -103,6 +103,7 @@ $all = array(
$this->translate('Do more with your data') => array(
array('database', $this->translate('Import data sources'), 'director/list/importsource', $this->translate('Define and manage imports from various data sources')),
array('flapping', $this->translate('Synchronize'), 'director/list/syncrule', $this->translate('Define how imported data should be synchronized with Icinga'), $this->syncState),
array('clock', $this->translate('Jobs'), 'director/jobs', $this->translate('Schedule and automate Import, Syncronization, Config Deployment, Housekeeping and more'), $this->jobState),
array('sort-name-up', $this->translate('Provide data lists'), 'director/data/lists', $this->translate('Provide data lists to make life easier for your users')),
array('edit', $this->translate('Define data fields'), 'director/data/fields', $this->translate('Data fields make sure that configuration fits your rules')),
)