Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ingress list #76

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/Kubernetes/Web/IngressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class IngressList extends BaseItemList
{
protected $defaultAttributes = ['class' => 'ingress-list'];

protected function getItemClass(): string
{
return IngressListItem::class;
Expand Down
52 changes: 41 additions & 11 deletions library/Kubernetes/Web/IngressListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,68 @@
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
{
use Translation;

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'])
)
);
}
}
1 change: 1 addition & 0 deletions public/css/lists.less
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ footer {

.config-map-list,
.cronjob-list,
.ingress-list,
.secret-list,
.service-list {
> .list-item > .visual {
Expand Down
Loading