2017-08-16 19:11:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Web\Widget;
|
|
|
|
|
2018-05-08 19:54:00 +02:00
|
|
|
use dipl\Html\HtmlDocument;
|
2017-08-16 19:11:30 +02:00
|
|
|
use Icinga\Module\Director\Core\CoreApi;
|
|
|
|
use Icinga\Module\Director\Db;
|
|
|
|
use Icinga\Module\Director\Forms\DeployConfigForm;
|
|
|
|
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
2017-10-09 15:23:27 +02:00
|
|
|
use dipl\Html\Html;
|
|
|
|
use dipl\Html\Link;
|
|
|
|
use dipl\Translation\TranslationHelper;
|
|
|
|
use dipl\Web\Widget\NameValueTable;
|
2017-08-16 19:11:30 +02:00
|
|
|
|
2018-05-08 19:54:00 +02:00
|
|
|
class DeployedConfigInfoHeader extends HtmlDocument
|
2017-08-16 19:11:30 +02:00
|
|
|
{
|
|
|
|
use TranslationHelper;
|
|
|
|
|
|
|
|
/** @var IcingaConfig */
|
|
|
|
protected $config;
|
|
|
|
|
|
|
|
/** @var int */
|
|
|
|
protected $deploymentId;
|
|
|
|
|
|
|
|
/** @var Db */
|
|
|
|
protected $db;
|
|
|
|
|
|
|
|
/** @var CoreApi */
|
|
|
|
protected $api;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
IcingaConfig $config,
|
|
|
|
Db $db,
|
|
|
|
CoreApi $api,
|
|
|
|
$deploymentId = null
|
|
|
|
) {
|
|
|
|
$this->config = $config;
|
|
|
|
$this->db = $db;
|
|
|
|
$this->api = $api;
|
|
|
|
if ($deploymentId) {
|
|
|
|
$this->deploymentId = (int) $deploymentId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 19:54:00 +02:00
|
|
|
/**
|
|
|
|
* @throws \Icinga\Exception\IcingaException
|
|
|
|
* @throws \Zend_Form_Exception
|
|
|
|
*/
|
|
|
|
protected function assemble()
|
2017-08-16 19:11:30 +02:00
|
|
|
{
|
|
|
|
$config = $this->config;
|
|
|
|
$deployForm = DeployConfigForm::load()
|
|
|
|
->setDb($this->db)
|
|
|
|
->setApi($this->api)
|
|
|
|
->setChecksum($config->getHexChecksum())
|
|
|
|
->setDeploymentId($this->deploymentId)
|
|
|
|
->setAttrib('class', 'inline')
|
|
|
|
->handleRequest();
|
|
|
|
|
|
|
|
$links = new NameValueTable();
|
|
|
|
$links->addNameValueRow(
|
|
|
|
$this->translate('Actions'),
|
|
|
|
[
|
|
|
|
$deployForm,
|
2018-05-08 19:54:00 +02:00
|
|
|
Html::tag('br'),
|
2017-08-16 19:11:30 +02:00
|
|
|
Link::create(
|
|
|
|
$this->translate('Last related activity'),
|
2017-08-18 16:55:10 +02:00
|
|
|
'director/config/activity',
|
2017-08-16 19:11:30 +02:00
|
|
|
['checksum' => $config->getLastActivityHexChecksum()],
|
|
|
|
['class' => 'icon-clock', 'data-base-target' => '_next']
|
|
|
|
),
|
2018-05-08 19:54:00 +02:00
|
|
|
Html::tag('br'),
|
2017-08-16 19:11:30 +02:00
|
|
|
Link::create(
|
|
|
|
$this->translate('Diff with other config'),
|
|
|
|
'director/config/diff',
|
|
|
|
['left' => $config->getHexChecksum()],
|
|
|
|
['class' => 'icon-flapping', 'data-base-target' => '_self']
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)->addNameValueRow(
|
|
|
|
$this->translate('Statistics'),
|
|
|
|
sprintf(
|
|
|
|
$this->translate('%d files rendered in %0.2fs'),
|
|
|
|
count($config->getFiles()),
|
|
|
|
$config->getDuration() / 1000
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->add($links);
|
|
|
|
}
|
|
|
|
}
|