From f66ab8dae2f3d0418759f81a3a64dc9517a62449 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:31 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- library/Director/Dashboard/Dashlet/JobDashlet.php | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 library/Director/Dashboard/Dashlet/JobDashlet.php (limited to 'library/Director/Dashboard/Dashlet/JobDashlet.php') diff --git a/library/Director/Dashboard/Dashlet/JobDashlet.php b/library/Director/Dashboard/Dashlet/JobDashlet.php new file mode 100644 index 0000000..d7452e0 --- /dev/null +++ b/library/Director/Dashboard/Dashlet/JobDashlet.php @@ -0,0 +1,65 @@ +translate('Jobs'); + } + + public function listCssClasses() + { + try { + return $this->fetchStateClass(); + } catch (Exception $e) { + return 'state-critical'; + } + } + + public function getSummary() + { + return $this->translate( + 'Schedule and automate Import, Syncronization, Config Deployment,' + . ' Housekeeping and more' + ); + } + + protected function fetchStateClass() + { + /** @var DirectorJob[] $jobs */ + $jobs = DirectorJob::loadAll($this->db); + if (count($jobs) > 0) { + $state = 'state-ok'; + } else { + $state = null; + } + + foreach ($jobs as $job) { + if ($job->isPending()) { + $state = 'state-pending'; + } elseif (! $job->lastAttemptSucceeded()) { + $state = 'state-critical'; + break; + } + } + + return $state; + } + + public function getUrl() + { + return 'director/jobs'; + } + + public function listRequiredPermissions() + { + return array('director/admin'); + } +} -- cgit v1.2.3