From b805f7a6a92aac95307f8bf61f48f95263a35312 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:11:02 +0100 Subject: [PATCH 01/20] Relax Links::hostgroup() parameter type In order to support Hostgroup and Hostgroupsummary. --- library/Eagle/Common/Links.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Eagle/Common/Links.php b/library/Eagle/Common/Links.php index 8728aa16..7a8b6ac6 100644 --- a/library/Eagle/Common/Links.php +++ b/library/Eagle/Common/Links.php @@ -28,7 +28,7 @@ abstract class Links return Url::fromPath('eagle/host', ['name' => $host->name]); } - public static function hostgroup(Hostgroup $hostgroup) + public static function hostgroup($hostgroup) { return Url::fromPath('eagle/hostgroup', ['name' => $hostgroup->name]); } From 1cd840d491f51bd02192c74b2e36102af5923c0c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:28:28 +0100 Subject: [PATCH 02/20] Relax Links::servicegroup() parameter type In order to support Servicegroup and Servicegroupsummary. --- library/Eagle/Common/Links.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Eagle/Common/Links.php b/library/Eagle/Common/Links.php index 7a8b6ac6..6e3453a7 100644 --- a/library/Eagle/Common/Links.php +++ b/library/Eagle/Common/Links.php @@ -38,7 +38,7 @@ abstract class Links return Url::fromPath('eagle/service', ['name' => $service->name, 'host.name' => $host->name]); } - public static function servicegroup(Servicegroup $servicegroup) + public static function servicegroup($servicegroup) { return Url::fromPath('eagle/servicegroup', ['name' => $servicegroup->name]); } From 6cc08963d1d956798779f436401a7a56c2dcf820 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:29:06 +0100 Subject: [PATCH 03/20] ServicegroupSummary: Alias primary key for SELECTs --- library/Eagle/Model/ServicegroupSummary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Eagle/Model/ServicegroupSummary.php b/library/Eagle/Model/ServicegroupSummary.php index 2f6af318..dcbe321e 100644 --- a/library/Eagle/Model/ServicegroupSummary.php +++ b/library/Eagle/Model/ServicegroupSummary.php @@ -14,7 +14,7 @@ class ServicegroupSummary extends UnionModel public function getKeyName() { - return 'servicegroup_id'; + return ['id' => 'servicegroup_id']; } public function getColumns() From 268121d5eed276237627f8ce04d05d7e9bdb300d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:29:35 +0100 Subject: [PATCH 04/20] Hostgroupsummary: Alias primary key for SELECTs --- library/Eagle/Model/Hostgroupsummary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Eagle/Model/Hostgroupsummary.php b/library/Eagle/Model/Hostgroupsummary.php index 21b77e2e..a253006e 100644 --- a/library/Eagle/Model/Hostgroupsummary.php +++ b/library/Eagle/Model/Hostgroupsummary.php @@ -14,7 +14,7 @@ class Hostgroupsummary extends UnionModel public function getKeyName() { - return 'hostgroup_id'; + return ['id' => 'hostgroup_id']; } public function getColumns() From ba2bdbfcaae42c30076749094230ed15157e4d57 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:30:38 +0100 Subject: [PATCH 05/20] Introduce HostgroupController --- .../controllers/HostgroupController.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 application/controllers/HostgroupController.php diff --git a/application/controllers/HostgroupController.php b/application/controllers/HostgroupController.php new file mode 100644 index 00000000..b7991349 --- /dev/null +++ b/application/controllers/HostgroupController.php @@ -0,0 +1,67 @@ +setTitle($this->translate('Host Group')); + + $name = $this->params->shiftRequired('name'); + + $query = Hostgroupsummary::on($this->getDb()); + + FilterProcessor::apply( + new FilterExpression('hostgroup.name', '=', $name), + $query + ); + + $hostgroup = $query->first(); + if ($hostgroup === null) { + throw new NotFoundError($this->translate('Host group not found')); + } + + $this->hostgroup = $hostgroup; + } + public function indexAction() + { + $this->addControl((new HostgroupList([$this->hostgroup]))); + + $db = $this->getDb(); + + $hosts = Host::on($db)->with('state'); + + FilterProcessor::apply( + new FilterExpression('hostgroup.id', '=', $this->hostgroup->id), + $hosts + ); + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($hosts); + $viewModeSwitcher = $this->createViewModeSwitcher(); + + $hostList = (new HostList($hosts)) + ->setViewMode($viewModeSwitcher->getViewMode()); + + yield $this->export($hosts); + + $this->addControl($paginationControl); + $this->addControl($viewModeSwitcher); + $this->addControl($limitControl); + + $this->addContent($hostList); + } +} From 26b1061e5e710e73826bc78b0ab4c30f3c57373c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:30:56 +0100 Subject: [PATCH 06/20] Introduce ServicegroupController --- .../controllers/ServicegroupController.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 application/controllers/ServicegroupController.php diff --git a/application/controllers/ServicegroupController.php b/application/controllers/ServicegroupController.php new file mode 100644 index 00000000..98314476 --- /dev/null +++ b/application/controllers/ServicegroupController.php @@ -0,0 +1,71 @@ +setTitle($this->translate('Service Group')); + + $name = $this->params->shiftRequired('name'); + + $query = Servicegroupsummary::on($this->getDb()); + + FilterProcessor::apply( + new FilterExpression('servicegroup.name', '=', $name), + $query + ); + + $servicegroup = $query->first(); + if ($servicegroup === null) { + throw new NotFoundError($this->translate('Service group not found')); + } + + $this->servicegroup = $servicegroup; + } + public function indexAction() + { + $this->addControl((new ServicegroupList([$this->servicegroup]))); + + $db = $this->getDb(); + + $services = Service::on($db)->with([ + 'state', + 'host', + 'host.state' + ]); + + FilterProcessor::apply( + new FilterExpression('servicegroup.id', '=', $this->servicegroup->id), + $services + ); + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($services); + $viewModeSwitcher = $this->createViewModeSwitcher(); + + $serviceList = (new ServiceList($services)) + ->setViewMode($viewModeSwitcher->getViewMode()); + + yield $this->export($services); + + $this->addControl($paginationControl); + $this->addControl($viewModeSwitcher); + $this->addControl($limitControl); + + $this->addContent($serviceList); + } +} From 5956739507176bd3fd6ea83b79123eeed9b87bcc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:31:23 +0100 Subject: [PATCH 07/20] UserListItem: Flip name and display_name --- library/Eagle/Widget/ItemList/UserListItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Eagle/Widget/ItemList/UserListItem.php b/library/Eagle/Widget/ItemList/UserListItem.php index c3774abf..6d0579f7 100644 --- a/library/Eagle/Widget/ItemList/UserListItem.php +++ b/library/Eagle/Widget/ItemList/UserListItem.php @@ -25,9 +25,9 @@ class UserListItem extends BaseHtmlElement Html::tag('div', ['class' => 'user-ball'], $this->item->display_name[0]) ]), Html::tag('div', ['class' => 'title col'], [ - $this->item->name, + $this->item->display_name, Html::tag('br'), - $this->item->display_name + $this->item->name ]), Html::tag('div', ['class' => 'col'], $this->item->email), Html::tag('div', ['class' => 'col'], $this->item->pager) From 2ce5e347ed2e669151b79159aada71ea0ca34470 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:31:44 +0100 Subject: [PATCH 08/20] UsergroupListItem: Flip name and display_name --- library/Eagle/Widget/ItemList/UsergroupListItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Eagle/Widget/ItemList/UsergroupListItem.php b/library/Eagle/Widget/ItemList/UsergroupListItem.php index d85d7576..8b18438d 100644 --- a/library/Eagle/Widget/ItemList/UsergroupListItem.php +++ b/library/Eagle/Widget/ItemList/UsergroupListItem.php @@ -25,9 +25,9 @@ class UsergroupListItem extends BaseHtmlElement Html::tag('div', ['class' => 'usergroup-ball'], $this->item->display_name[0]) ]), Html::tag('div', ['class' => 'title col'], [ - $this->item->name, + $this->item->display_name, Html::tag('br'), - $this->item->display_name + $this->item->name ]) ]); } From 2fd5d023ab84cb795ba3ab42a76d8e0789f34f44 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:32:18 +0100 Subject: [PATCH 09/20] HostgroupListItem: Add link to hostgroup --- library/Eagle/Widget/ItemList/HostgroupListItem.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Eagle/Widget/ItemList/HostgroupListItem.php b/library/Eagle/Widget/ItemList/HostgroupListItem.php index 191d0ebd..009290e9 100644 --- a/library/Eagle/Widget/ItemList/HostgroupListItem.php +++ b/library/Eagle/Widget/ItemList/HostgroupListItem.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Eagle\Widget\ItemList; use Icinga\Chart\Donut; use Icinga\Module\Eagle\Common\BaseTableRowItem; +use Icinga\Module\Eagle\Common\Links; use Icinga\Module\Eagle\Widget\HostStateBadges; use Icinga\Module\Eagle\Widget\ServiceStateBadges; use Icinga\Module\Eagle\Widget\VerticalKeyValue; @@ -11,6 +12,7 @@ use ipl\Html\BaseHtmlElement; use ipl\Html\Html; use ipl\Html\HtmlDocument; use ipl\Html\HtmlString; +use ipl\Web\Widget\Link; class HostgroupListItem extends BaseTableRowItem { @@ -56,7 +58,7 @@ class HostgroupListItem extends BaseTableRowItem protected function assembleTitle(BaseHtmlElement $title) { $title->add([ - $this->item->display_name, + new Link($this->item->display_name, Links::hostgroup($this->item)), Html::tag('br'), $this->item->name ]); From aa8a67bd1ae060dc7a79c8ccdfc75b1c375335ef Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:32:39 +0100 Subject: [PATCH 10/20] ServicegroupListItem: Add link to servicegroup --- library/Eagle/Widget/ItemList/ServicegroupListItem.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Eagle/Widget/ItemList/ServicegroupListItem.php b/library/Eagle/Widget/ItemList/ServicegroupListItem.php index 4afeaddd..71e7fb89 100644 --- a/library/Eagle/Widget/ItemList/ServicegroupListItem.php +++ b/library/Eagle/Widget/ItemList/ServicegroupListItem.php @@ -4,12 +4,14 @@ namespace Icinga\Module\Eagle\Widget\ItemList; use Icinga\Chart\Donut; use Icinga\Module\Eagle\Common\BaseTableRowItem; +use Icinga\Module\Eagle\Common\Links; use Icinga\Module\Eagle\Widget\ServiceStateBadges; use Icinga\Module\Eagle\Widget\VerticalKeyValue; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; use ipl\Html\HtmlDocument; use ipl\Html\HtmlString; +use ipl\Web\Widget\Link; class ServicegroupListItem extends BaseTableRowItem { @@ -39,7 +41,7 @@ class ServicegroupListItem extends BaseTableRowItem protected function assembleTitle(BaseHtmlElement $title) { $title->add([ - $this->item->display_name, + new Link($this->item->display_name, Links::servicegroup($this->item)), Html::tag('br'), $this->item->name ]); From dc6634320a31b1dc372f437544d69f297499004c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:42:28 +0100 Subject: [PATCH 11/20] Add HostLinks::services() --- library/Eagle/Common/HostLinks.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Eagle/Common/HostLinks.php b/library/Eagle/Common/HostLinks.php index 55b9d2d4..99f01cb7 100644 --- a/library/Eagle/Common/HostLinks.php +++ b/library/Eagle/Common/HostLinks.php @@ -56,4 +56,9 @@ abstract class HostLinks { return Url::fromPath('eagle/host/send-custom-notification', ['name' => $host->name]); } + + public static function services(Host $host) + { + return Url::fromPath('eagle/host/services', ['name' => $host->name]); + } } From 8b13e6455910b99828730174b9f3dbcea4f77bc9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 4 Nov 2019 23:42:42 +0100 Subject: [PATCH 12/20] Host: Add services tab --- application/controllers/HostController.php | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index af681a13..ccddb384 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -9,11 +9,13 @@ use Icinga\Module\Eagle\Common\HostLinks; use Icinga\Module\Eagle\Common\Links; use Icinga\Module\Eagle\Model\History; use Icinga\Module\Eagle\Model\Host; +use Icinga\Module\Eagle\Model\Service; use Icinga\Module\Eagle\Web\Controller; use Icinga\Module\Eagle\Widget\Detail\ObjectDetail; use Icinga\Module\Eagle\Widget\Detail\QuickActions; use Icinga\Module\Eagle\Widget\HostList; use Icinga\Module\Eagle\Widget\ItemList\HistoryList; +use Icinga\Module\Eagle\Widget\ServiceList; class HostController extends Controller { @@ -92,6 +94,38 @@ class HostController extends Controller $this->addContent(new HistoryList($history)); } + public function servicesAction() + { + $this->addControl((new HostList([$this->host]))->setViewMode('compact')); + + $db = $this->getDb(); + + $services = Service::on($db)->with([ + 'state', + 'host', + 'host.state' + ]); + + $services + ->getSelectBase() + ->where(['service_host.id = ?' => $this->host->id]); + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($services); + $viewModeSwitcher = $this->createViewModeSwitcher(); + + yield $this->export($services); + + $serviceList = (new ServiceList($services)) + ->setViewMode($viewModeSwitcher->getViewMode()); + + $this->addControl($paginationControl); + $this->addControl($viewModeSwitcher); + $this->addControl($limitControl); + + $this->addContent($serviceList); + } + protected function createTabs() { return $this @@ -100,6 +134,10 @@ class HostController extends Controller 'label' => $this->translate('Host'), 'url' => Links::host($this->host) ]) + ->add('services', [ + 'label' => $this->translate('Services'), + 'url' => HostLinks::services($this->host) + ]) ->add('history', [ 'label' => $this->translate('History'), 'url' => HostLinks::history($this->host) From 4eb171e9feef5dae4943e44cbd27ba3dd4db0cce Mon Sep 17 00:00:00 2001 From: Florian Strohmaier Date: Thu, 31 Oct 2019 17:40:31 +0100 Subject: [PATCH 13/20] Introduce UserController --- application/controllers/UserController.php | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 application/controllers/UserController.php diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php new file mode 100644 index 00000000..e4d18ef5 --- /dev/null +++ b/application/controllers/UserController.php @@ -0,0 +1,58 @@ +setTitle($this->translate('User')); + + $name = $this->params->shiftRequired('name'); + + $query = User::on($this->getDb()); + $query->getSelectBase() + ->where(['name = ?' => $name]); + + $user = $query->first(); + if ($user === null) { + throw new NotFoundError($this->translate('User not found')); + } + + $this->user = $user; + } + + public function indexAction() + { + $this->addControl(new UserList([$this->user])); + + $this->addContent(Html::tag('h2', 'Details')); + $this->addContent(Html::tag('ul', ['class' => 'key-value-list'], [ + Html::tag('li', [ + Html::tag('span', ['class' => 'label'], 'E-Mail'), + Html::tag( + 'span', + ['class' => 'value'], + $this->user->email ?: Html::tag('span', ['class' => 'text-muted'], 'Unset') + ) + ]), + Html::tag('li', [ + Html::tag('span', ['class' => 'label'], 'Pager'), + Html::tag( + 'span', + ['class' => 'value'], + $this->user->pager ?: Html::tag('span', ['class' => 'text-muted'], 'Unset') + ) + ]) + ])); + } +} From dabdaf6f17e9f207b8c6b7996e36f6f83a4b0eab Mon Sep 17 00:00:00 2001 From: Florian Strohmaier Date: Thu, 31 Oct 2019 17:40:51 +0100 Subject: [PATCH 14/20] CSS: Style key-value-list --- public/css/widgets.less | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/public/css/widgets.less b/public/css/widgets.less index 1a1c6ccf..10ab5036 100644 --- a/public/css/widgets.less +++ b/public/css/widgets.less @@ -177,6 +177,7 @@ padding: 0; } } + .state-change { .state-ball { box-shadow: 0 0 0 1px white; @@ -191,3 +192,23 @@ background-color: white; } } + +.key-value-list { + list-style-type: none; + margin: 0; + padding: 0; + + li { + display: flex; + } + + li > span { + padding: .25em; + + &.label { + display: block; + padding-left: 0; + width: 12em; + } + } +} From 97805de423893850843582bea466ad85dee08cde Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 5 Nov 2019 00:04:20 +0100 Subject: [PATCH 15/20] UserListItem: Add link to user --- library/Eagle/Widget/ItemList/UserListItem.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Eagle/Widget/ItemList/UserListItem.php b/library/Eagle/Widget/ItemList/UserListItem.php index 6d0579f7..c10b04ec 100644 --- a/library/Eagle/Widget/ItemList/UserListItem.php +++ b/library/Eagle/Widget/ItemList/UserListItem.php @@ -2,8 +2,10 @@ namespace Icinga\Module\Eagle\Widget\ItemList; +use Icinga\Module\Eagle\Common\Links; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; +use ipl\Web\Widget\Link; class UserListItem extends BaseHtmlElement { @@ -25,7 +27,7 @@ class UserListItem extends BaseHtmlElement Html::tag('div', ['class' => 'user-ball'], $this->item->display_name[0]) ]), Html::tag('div', ['class' => 'title col'], [ - $this->item->display_name, + new Link($this->item->display_name, Links::user($this->item)), Html::tag('br'), $this->item->name ]), From 90b3151eadedd75ee40d9fec22a392a0ae53c742 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 5 Nov 2019 00:08:43 +0100 Subject: [PATCH 16/20] CSS: Style text-muted --- public/css/module.less | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/css/module.less b/public/css/module.less index b5c1c372..39bfd265 100644 --- a/public/css/module.less +++ b/public/css/module.less @@ -228,6 +228,10 @@ text-align: center; } +.text-muted { + color: @gray; +} + .comment-detail button { .button(); background-color: white; From 97d8bdb25b726463051c03e2b7570861e07f7983 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 5 Nov 2019 00:19:04 +0100 Subject: [PATCH 17/20] UsergroupListItem: Add link to usergroup --- library/Eagle/Widget/ItemList/UsergroupListItem.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Eagle/Widget/ItemList/UsergroupListItem.php b/library/Eagle/Widget/ItemList/UsergroupListItem.php index 8b18438d..d674f82a 100644 --- a/library/Eagle/Widget/ItemList/UsergroupListItem.php +++ b/library/Eagle/Widget/ItemList/UsergroupListItem.php @@ -2,8 +2,10 @@ namespace Icinga\Module\Eagle\Widget\ItemList; +use Icinga\Module\Eagle\Common\Links; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; +use ipl\Web\Widget\Link; class UsergroupListItem extends BaseHtmlElement { @@ -25,7 +27,7 @@ class UsergroupListItem extends BaseHtmlElement Html::tag('div', ['class' => 'usergroup-ball'], $this->item->display_name[0]) ]), Html::tag('div', ['class' => 'title col'], [ - $this->item->display_name, + new Link($this->item->display_name, Links::usergroup($this->item)), Html::tag('br'), $this->item->name ]) From 1ee9b6526fef01c0cbee2be473dec06eecf590f5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 5 Nov 2019 00:29:13 +0100 Subject: [PATCH 18/20] HostController: Add actions comments and downtimes --- application/controllers/HostController.php | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index ccddb384..ef1feae9 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -2,7 +2,6 @@ namespace Icinga\Module\Eagle\Controllers; -use Exception; use Icinga\Exception\NotFoundError; use Icinga\Module\Eagle\Common\CommandActions; use Icinga\Module\Eagle\Common\HostLinks; @@ -13,7 +12,9 @@ use Icinga\Module\Eagle\Model\Service; use Icinga\Module\Eagle\Web\Controller; use Icinga\Module\Eagle\Widget\Detail\ObjectDetail; use Icinga\Module\Eagle\Widget\Detail\QuickActions; +use Icinga\Module\Eagle\Widget\DowntimeList; use Icinga\Module\Eagle\Widget\HostList; +use Icinga\Module\Eagle\Widget\ItemList\CommentList; use Icinga\Module\Eagle\Widget\ItemList\HistoryList; use Icinga\Module\Eagle\Widget\ServiceList; @@ -61,6 +62,44 @@ class HostController extends Controller $this->addContent(new ObjectDetail($this->host)); } + public function commentsAction() + { + $this->setTitle($this->translate('Comments')); + + $this->addControl((new HostList([$this->host]))->setViewMode('compact')); + + $comments = $this->host->comment; + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($comments); + + yield $this->export($comments); + + $this->addControl($paginationControl); + $this->addControl($limitControl); + + $this->addContent(new CommentList($comments)); + } + + public function downtimesAction() + { + $this->setTitle($this->translate('Downtimes')); + + $this->addControl((new HostList([$this->host]))->setViewMode('compact')); + + $downtimes = $this->host->downtime; + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($downtimes); + + yield $this->export($downtimes); + + $this->addControl($paginationControl); + $this->addControl($limitControl); + + $this->addContent(new DowntimeList($downtimes)); + } + public function historyAction() { $this->addControl((new HostList([$this->host]))->setViewMode('compact')); From 0f0aa9f05bd341b9a9dd4b47df600ebbf870c148 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 5 Nov 2019 00:35:39 +0100 Subject: [PATCH 19/20] ServiceController: Add actions comments and downtimes --- application/controllers/ServiceController.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index ebde328c..237ed72b 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -12,6 +12,9 @@ use Icinga\Module\Eagle\Model\Service; use Icinga\Module\Eagle\Web\Controller; use Icinga\Module\Eagle\Widget\Detail\ObjectDetail; use Icinga\Module\Eagle\Widget\Detail\QuickActions; +use Icinga\Module\Eagle\Widget\DowntimeList; +use Icinga\Module\Eagle\Widget\HostList; +use Icinga\Module\Eagle\Widget\ItemList\CommentList; use Icinga\Module\Eagle\Widget\ItemList\HistoryList; use Icinga\Module\Eagle\Widget\ServiceList; use ipl\Sql\Sql; @@ -66,6 +69,44 @@ class ServiceController extends Controller $this->addContent(new ObjectDetail($this->service)); } + public function commentsAction() + { + $this->setTitle($this->translate('Comments')); + + $this->addControl((new ServiceList([$this->service]))->setViewMode('compact')); + + $comments = $this->service->comment; + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($comments); + + yield $this->export($comments); + + $this->addControl($paginationControl); + $this->addControl($limitControl); + + $this->addContent(new CommentList($comments)); + } + + public function downtimesAction() + { + $this->setTitle($this->translate('Downtimes')); + + $this->addControl((new ServiceList([$this->service]))->setViewMode('compact')); + + $downtimes = $this->service->downtime; + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($downtimes); + + yield $this->export($downtimes); + + $this->addControl($paginationControl); + $this->addControl($limitControl); + + $this->addContent(new DowntimeList($downtimes)); + } + public function historyAction() { $this->addControl((new ServiceList([$this->service]))->setViewMode('compact')); From 986516c8a70a38c91522029cc94fcf4c6e108862 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 5 Nov 2019 00:36:04 +0100 Subject: [PATCH 20/20] ObjectDetail: Use the limited query for downtimes --- library/Eagle/Widget/Detail/ObjectDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Eagle/Widget/Detail/ObjectDetail.php b/library/Eagle/Widget/Detail/ObjectDetail.php index c8261152..60640002 100644 --- a/library/Eagle/Widget/Detail/ObjectDetail.php +++ b/library/Eagle/Widget/Detail/ObjectDetail.php @@ -73,7 +73,7 @@ class ObjectDetail extends BaseHtmlElement return [ Html::tag('h2', 'Downtimes'), - new DowntimeList($this->object->downtime), + new DowntimeList($downtimes), new ShowMore($downtimes, $link) ]; }