mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
This was easy because only README.md and doc/01-About.md were redacted manually, everything else via: git ls-files -z |xargs -0 perl -pi -e 's/Icinga GmbH \| GPLv2/Icinga GmbH | GPLv2+/' This is legal because we have only merged PRs with label:cla/signed or made by Icinga staff: https://github.com/Icinga/icingadb-web/pulls?page=1&q=is%3Apr+is%3Aclosed+-label%3Acla%2Fsigned+-author%3Anilmerg This has no risk for us in people distributing their own version under GPLv3 only. After all, we won't take their patches anyway, unless they sign our CLA. This is the cleanest solution for having e.g. these in one address space: * Icinga Web, GPLv2+ * K8s Web, AGPLv3 * Thirdparty, some LGPLv3 and Apache-2.0 Apropos, K8s Web is even v3-licensed on purpose, to have a stronger protection against cloud ops.
91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
<?php
|
|
|
|
/* Icinga DB Web | (c) 2025 Icinga GmbH | GPLv2+ */
|
|
|
|
namespace Icinga\Module\Icingadb\View;
|
|
|
|
use Icinga\Module\Icingadb\Model\RedundancyGroup;
|
|
use Icinga\Module\Icingadb\Widget\DependencyNodeStatistics;
|
|
use ipl\Html\Attributes;
|
|
use ipl\Html\Html;
|
|
use ipl\Html\HtmlDocument;
|
|
use ipl\Html\HtmlElement;
|
|
use ipl\Html\Text;
|
|
use ipl\I18n\Translation;
|
|
use ipl\Web\Common\ItemRenderer;
|
|
use ipl\Web\Url;
|
|
use ipl\Web\Widget\Link;
|
|
use ipl\Web\Widget\StateBall;
|
|
use ipl\Web\Widget\TimeSince;
|
|
|
|
/** @implements ItemRenderer<RedundancyGroup> */
|
|
class RedundancyGroupRenderer implements ItemRenderer
|
|
{
|
|
use Translation;
|
|
|
|
public function assembleAttributes($item, Attributes $attributes, string $layout): void
|
|
{
|
|
$attributes->get('class')->addValue('redundancy-group');
|
|
}
|
|
|
|
public function assembleVisual($item, HtmlDocument $visual, string $layout): void
|
|
{
|
|
$ballSize = StateBall::SIZE_LARGE;
|
|
if ($layout === 'minimal' || $layout === 'header') {
|
|
$ballSize = StateBall::SIZE_BIG;
|
|
}
|
|
|
|
$stateBall = new StateBall($item->state->getStateText(), $ballSize);
|
|
$stateBall->add($item->state->getIcon());
|
|
|
|
$visual->addHtml($stateBall);
|
|
}
|
|
|
|
public function assembleCaption($item, HtmlDocument $caption, string $layout): void
|
|
{
|
|
$caption->addHtml(new DependencyNodeStatistics($item->summary));
|
|
}
|
|
|
|
public function assembleFooter($item, HtmlDocument $footer, string $layout): void
|
|
{
|
|
}
|
|
|
|
public function assembleTitle($item, HtmlDocument $title, string $layout): void
|
|
{
|
|
if ($layout === 'header') {
|
|
$subject = new HtmlElement(
|
|
'span',
|
|
Attributes::create(['class' => 'subject']),
|
|
Text::create($item->display_name)
|
|
);
|
|
} else {
|
|
$subject = new Link(
|
|
$item->display_name,
|
|
Url::fromPath('icingadb/redundancygroup', ['id' => bin2hex($item->id)]),
|
|
['class' => 'subject']
|
|
);
|
|
}
|
|
|
|
if ($item->state->failed) {
|
|
$title->addHtml(Html::sprintf(
|
|
$this->translate('%s has no working objects', '<groupname> has ...'),
|
|
$subject
|
|
));
|
|
} else {
|
|
$title->addHtml(Html::sprintf(
|
|
$this->translate('%s has working objects', '<groupname> has ...'),
|
|
$subject
|
|
));
|
|
}
|
|
}
|
|
|
|
public function assembleExtendedInfo($item, HtmlDocument $info, string $layout): void
|
|
{
|
|
$info->addHtml(new TimeSince($item->state->last_state_change->getTimestamp()));
|
|
}
|
|
|
|
public function assemble($item, string $name, HtmlDocument $element, string $layout): bool
|
|
{
|
|
return $name === 'icon-image'; // Always add the icon-image section
|
|
}
|
|
}
|