*/ 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', ' has ...'), $subject )); } else { $title->addHtml(Html::sprintf( $this->translate('%s has working objects', ' 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 } }