diff --git a/library/Kubernetes/Web/IngressList.php b/library/Kubernetes/Web/IngressList.php index 53351527..c5ec9b74 100644 --- a/library/Kubernetes/Web/IngressList.php +++ b/library/Kubernetes/Web/IngressList.php @@ -8,6 +8,8 @@ class IngressList extends BaseItemList { + protected $defaultAttributes = ['class' => 'ingress-list']; + protected function getItemClass(): string { return IngressListItem::class; diff --git a/library/Kubernetes/Web/IngressListItem.php b/library/Kubernetes/Web/IngressListItem.php index 927fdfa8..366b7ec7 100644 --- a/library/Kubernetes/Web/IngressListItem.php +++ b/library/Kubernetes/Web/IngressListItem.php @@ -8,11 +8,13 @@ use Icinga\Module\Kubernetes\Common\Links; use ipl\Html\Attributes; use ipl\Html\BaseHtmlElement; +use ipl\Html\HtmlDocument; use ipl\Html\HtmlElement; +use ipl\Html\Text; use ipl\I18n\Translation; +use ipl\Web\Widget\HorizontalKeyValue; use ipl\Web\Widget\Link; use ipl\Web\Widget\TimeAgo; -use ipl\Web\Widget\VerticalKeyValue; class IngressListItem extends BaseListItem { @@ -20,26 +22,54 @@ class IngressListItem extends BaseListItem protected function assembleHeader(BaseHtmlElement $header): void { - $header - ->addHtml($this->createTitle()) - ->addHtml(new TimeAgo($this->item->created->getTimestamp())); + $header->addHtml( + $this->createTitle(), + new TimeAgo($this->item->created->getTimestamp()) + ); } protected function assembleMain(BaseHtmlElement $main): void { + $main->addHtml( + $this->createHeader(), + $this->createFooter() + ); + } - $main->addHtml($this->createHeader()); - - $keyValue = new HtmlElement('div', new Attributes(['class' => 'key-value'])); + protected function assembleFooter(BaseHtmlElement $footer): void + { + $hosts = []; foreach ($this->item->ingress_rule as $rule) { - $keyValue->addHtml(new VerticalKeyValue($this->translate('Host'), $rule->host ?: '-')); + if ($rule->host !== null) { + $hosts[] = $rule->host; + } } - $keyValue->addHtml(new VerticalKeyValue($this->translate('Namespace'), $this->item->namespace)); - $main->addHtml($keyValue); + + $footer->addHtml( + new HorizontalKeyValue( + $this->translate('Host'), + ! empty($hosts) ? implode(', ', $hosts) : '-' + ) + ); } protected function assembleTitle(BaseHtmlElement $title): void { - $title->addHtml(new Link($this->item->name, Links::ingress($this->item), ['class' => 'subject'])); + $title->addHtml( + new HtmlElement( + 'span', + new Attributes(['class' => 'namespace-badge']), + new HtmlElement('i', new Attributes(['class' => 'icon kicon-namespace'])), + new Text($this->item->namespace) + ), + new Link( + (new HtmlDocument())->addHtml( + new HtmlElement('i', new Attributes(['class' => 'icon kicon-ingress'])), + new Text($this->item->name) + ), + Links::ingress($this->item), + new Attributes(['class' => 'subject']) + ) + ); } } diff --git a/public/css/lists.less b/public/css/lists.less index 8f6288f0..ff036842 100644 --- a/public/css/lists.less +++ b/public/css/lists.less @@ -81,6 +81,7 @@ footer { .config-map-list, .cronjob-list, +.ingress-list, .secret-list, .service-list { > .list-item > .visual {