diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Web/Table/DeploymentLogTable.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/Web/Table/DeploymentLogTable.php')
-rw-r--r-- | library/Director/Web/Table/DeploymentLogTable.php | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/library/Director/Web/Table/DeploymentLogTable.php b/library/Director/Web/Table/DeploymentLogTable.php new file mode 100644 index 0000000..2d5cb94 --- /dev/null +++ b/library/Director/Web/Table/DeploymentLogTable.php @@ -0,0 +1,90 @@ +<?php + +namespace Icinga\Module\Director\Web\Table; + +use gipfl\IcingaWeb2\Link; +use gipfl\IcingaWeb2\Table\ZfQueryBasedTable; +use Icinga\Date\DateFormatter; + +class DeploymentLogTable extends ZfQueryBasedTable +{ + use DbHelper; + + protected $activeStageName; + + public function setActiveStageName($name) + { + $this->activeStageName = $name; + return $this; + } + + public function assemble() + { + $this->getAttributes()->add('class', 'deployment-log'); + } + + public function renderRow($row) + { + $this->splitByDay($row->start_time); + + $shortSum = $this->getShortChecksum($row->config_checksum); + $tr = $this::tr([ + $this::td(Link::create( + $shortSum === null ? $row->peer_identity : [$row->peer_identity, " ($shortSum)"], + 'director/deployment', + ['id' => $row->id] + )), + $this::td(DateFormatter::formatTime($row->start_time)) + ])->addAttributes(['class' => $this->getMyRowClasses($row)]); + + return $tr; + } + + protected function getMyRowClasses($row) + { + if ($row->startup_succeeded === 'y') { + $classes = ['succeeded']; + } elseif ($row->startup_succeeded === 'n') { + $classes = ['failed']; + } elseif ($row->stage_collected === null) { + $classes = ['pending']; + } elseif ($row->dump_succeeded === 'y') { + $classes = ['sent']; + } else { + // TODO: does this ever be stored? + $classes = ['notsent']; + } + + if ($this->activeStageName !== null + && $row->stage_name === $this->activeStageName + ) { + $classes[] = 'running'; + } + + return $classes; + } + + public function getColumns() + { + $columns = [ + 'id' => 'l.id', + 'peer_identity' => 'l.peer_identity', + 'start_time' => 'UNIX_TIMESTAMP(l.start_time)', + 'stage_collected' => 'l.stage_collected', + 'dump_succeeded' => 'l.dump_succeeded', + 'stage_name' => 'l.stage_name', + 'startup_succeeded' => 'l.startup_succeeded', + 'config_checksum' => 'l.config_checksum', + ]; + + return $columns; + } + + public function prepareQuery() + { + return $this->db()->select()->from( + array('l' => 'director_deployment_log'), + $this->getColumns() + )->order('l.start_time DESC')->limit(100); + } +} |