Skip to content

Commit b610ff4

Browse files
committed
Add icinga state for services
1 parent 07b5df8 commit b610ff4

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

application/controllers/ServiceController.php

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Icinga\Module\Kubernetes\Web\Controller;
1212
use Icinga\Module\Kubernetes\Web\QuickActions;
1313
use Icinga\Module\Kubernetes\Web\ServiceDetail;
14+
use Icinga\Module\Kubernetes\Web\ServiceList;
15+
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
1416
use ipl\Stdlib\Filter;
1517
use Ramsey\Uuid\Uuid;
1618

@@ -43,6 +45,12 @@ public function indexAction(): void
4345
$this->httpNotFound($this->translate('Service not found'));
4446
}
4547

48+
$this->addControl(
49+
(new ServiceList([$service]))
50+
->setActionList(false)
51+
->setViewMode(ViewModeSwitcher::VIEW_MODE_MINIMAL)
52+
);
53+
4654
$this->addControl(new QuickActions($service, $favorite));
4755

4856
$this->addContent(new ServiceDetail($service));

library/Kubernetes/Model/Service.php

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public function getColumnDefinitions(): array
8383
'allocate_load_balancer_node_ports' => $this->translate('Allocated Load Balancer Node Ports'),
8484
'load_balancer_class' => $this->translate('Load Balancer Class'),
8585
'internal_traffic_policy' => $this->translate('Internal Traffic Policy'),
86+
'icinga_state' => $this->translate('Icinga State'),
87+
'icinga_state_reason' => $this->translate('Icinga State Reason'),
8688
'yaml' => $this->translate('YAML'),
8789
'created' => $this->translate('Created At')
8890
];
@@ -110,6 +112,8 @@ public function getColumns(): array
110112
'allocate_load_balancer_node_ports',
111113
'load_balancer_class',
112114
'internal_traffic_policy',
115+
'icinga_state',
116+
'icinga_state_reason',
113117
'yaml',
114118
'created'
115119
];

library/Kubernetes/Web/ServiceDetail.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ protected function assemble(): void
7171
),
7272
$this->translate('Load Balancer Class') => $this->service->load_balancer_class ??
7373
new EmptyState($this->translate('None')),
74-
$this->translate('Internal Traffic Policy') => $this->service->internal_traffic_policy
74+
$this->translate('Internal Traffic Policy') => $this->service->internal_traffic_policy,
75+
$this->translate('Icinga State') => new DetailState($this->service->icinga_state),
76+
$this->translate('Icinga State Reason') => new IcingaStateReason(
77+
$this->service->icinga_state_reason
78+
)
7579
])),
7680
new Labels($this->service->label),
7781
new Annotations($this->service->annotation),

library/Kubernetes/Web/ServiceListItem.php

+4-12
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
namespace Icinga\Module\Kubernetes\Web;
66

77
use Icinga\Module\Kubernetes\Common\BaseListItem;
8+
use Icinga\Module\Kubernetes\Common\DefaultListItemCaption;
89
use Icinga\Module\Kubernetes\Common\DefaultListItemHeader;
910
use Icinga\Module\Kubernetes\Common\DefaultListItemMain;
11+
use Icinga\Module\Kubernetes\Common\DefaultListItemVisual;
1012
use Icinga\Module\Kubernetes\Common\Links;
1113
use ipl\Html\Attributes;
1214
use ipl\Html\BaseHtmlElement;
@@ -16,19 +18,14 @@
1618
use ipl\I18n\Translation;
1719
use ipl\Web\Widget\HorizontalKeyValue;
1820
use ipl\Web\Widget\Link;
19-
use ipl\Web\Widget\StateBall;
2021

2122
class ServiceListItem extends BaseListItem
2223
{
2324
use Translation;
2425
use DefaultListItemHeader;
26+
use DefaultListItemCaption;
2527
use DefaultListItemMain;
26-
27-
protected function assembleCaption(BaseHtmlElement $caption): void
28-
{
29-
// TODO add state reason then replace function by DefaultListItemCaption trait
30-
$caption->addHtml(new Text('Placeholder for Icinga State Reason'));
31-
}
28+
use DefaultListItemVisual;
3229

3330
protected function assembleFooter(BaseHtmlElement $footer): void
3431
{
@@ -58,9 +55,4 @@ protected function assembleTitle(BaseHtmlElement $title): void
5855
)
5956
);
6057
}
61-
62-
protected function assembleVisual(BaseHtmlElement $visual): void
63-
{
64-
$visual->addHtml(new StateBall('none', StateBall::SIZE_MEDIUM));
65-
}
6658
}

0 commit comments

Comments
 (0)