diff --git a/application/controllers/ServicegroupController.php b/application/controllers/ServicegroupController.php index 89fb8296..d6ebc194 100644 --- a/application/controllers/ServicegroupController.php +++ b/application/controllers/ServicegroupController.php @@ -10,7 +10,7 @@ use Icinga\Module\Icingadb\Model\ServicegroupSummary; use Icinga\Module\Icingadb\Redis\VolatileStateResults; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\ItemList\ServiceList; -use Icinga\Module\Icingadb\Widget\ItemList\ServicegroupList; +use Icinga\Module\Icingadb\Widget\ItemTable\ServicegroupTableRow; use ipl\Html\Html; use ipl\Stdlib\Filter; @@ -72,16 +72,10 @@ class ServicegroupController extends Controller // ICINGAWEB_EXPORT_FORMAT is not set yet and $this->format is inaccessible, yeah... if ($this->getRequest()->getParam('format') === 'pdf') { - $this->addContent((new ServicegroupList([$this->servicegroup])) - ->setViewMode('minimal') - ->setDetailActionsDisabled() - ->setNoSubjectLink()); + $this->addContent(new ServicegroupTableRow($this->servicegroup)); $this->addContent(Html::tag('h2', null, t('Services'))); } else { - $this->addControl((new ServicegroupList([$this->servicegroup])) - ->setViewMode('minimal') - ->setDetailActionsDisabled() - ->setNoSubjectLink()); + $this->addControl(new ServicegroupTableRow($this->servicegroup)); } $this->addControl($paginationControl); diff --git a/application/controllers/ServicegroupsController.php b/application/controllers/ServicegroupsController.php index 76c48fb9..1109e972 100644 --- a/application/controllers/ServicegroupsController.php +++ b/application/controllers/ServicegroupsController.php @@ -9,7 +9,7 @@ use Icinga\Module\Icingadb\Model\Servicegroup; use Icinga\Module\Icingadb\Model\ServicegroupSummary; use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions; use Icinga\Module\Icingadb\Web\Controller; -use Icinga\Module\Icingadb\Widget\ItemList\ServicegroupList; +use Icinga\Module\Icingadb\Widget\ItemTable\ServicegroupTable; use Icinga\Module\Icingadb\Widget\ShowMore; use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher; use ipl\Web\Control\LimitControl; @@ -77,7 +77,7 @@ class ServicegroupsController extends Controller $results = $servicegroups->execute(); $this->addContent( - (new ServicegroupList($results))->setBaseFilter($filter) + (new ServicegroupTable($results))->setBaseFilter($filter) ); if ($compact) { diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 751bb385..93219654 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -8,7 +8,7 @@ use Icinga\Exception\NotFoundError; use Icinga\Module\Icingadb\Model\User; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\UserDetail; -use Icinga\Module\Icingadb\Widget\ItemList\UserList; +use Icinga\Module\Icingadb\Widget\ItemTable\UserTableRow; use ipl\Stdlib\Filter; class UserController extends Controller @@ -40,7 +40,7 @@ class UserController extends Controller public function indexAction() { - $this->addControl((new UserList([$this->user]))->setNoSubjectLink()->setDetailActionsDisabled()); + $this->addControl(new UserTableRow($this->user)); $this->addContent(new UserDetail($this->user)); $this->setAutorefreshInterval(10); diff --git a/application/controllers/UsergroupController.php b/application/controllers/UsergroupController.php index e1d4ae20..8c3fed8b 100644 --- a/application/controllers/UsergroupController.php +++ b/application/controllers/UsergroupController.php @@ -8,7 +8,7 @@ use Icinga\Exception\NotFoundError; use Icinga\Module\Icingadb\Model\Usergroup; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\UsergroupDetail; -use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList; +use Icinga\Module\Icingadb\Widget\ItemTable\UsergroupTableRow; use ipl\Stdlib\Filter; class UsergroupController extends Controller @@ -40,7 +40,7 @@ class UsergroupController extends Controller public function indexAction() { - $this->addControl((new UsergroupList([$this->usergroup]))->setNoSubjectLink()->setDetailActionsDisabled()); + $this->addControl(new UsergroupTableRow($this->usergroup)); $this->addContent(new UsergroupDetail($this->usergroup)); $this->setAutorefreshInterval(10); diff --git a/application/controllers/UsergroupsController.php b/application/controllers/UsergroupsController.php index 947500db..99a73a96 100644 --- a/application/controllers/UsergroupsController.php +++ b/application/controllers/UsergroupsController.php @@ -8,7 +8,7 @@ use GuzzleHttp\Psr7\ServerRequest; use Icinga\Module\Icingadb\Model\Usergroup; use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions; use Icinga\Module\Icingadb\Web\Controller; -use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList; +use Icinga\Module\Icingadb\Widget\ItemTable\UsergroupTable; use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher; use ipl\Web\Control\LimitControl; use ipl\Web\Control\SortControl; @@ -64,7 +64,7 @@ class UsergroupsController extends Controller $this->addControl($limitControl); $this->addControl($searchBar); - $this->addContent(new UsergroupList($usergroups)); + $this->addContent(new UsergroupTable($usergroups)); if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) { $this->sendMultipartUpdate(); diff --git a/application/controllers/UsersController.php b/application/controllers/UsersController.php index 37849941..83ee96dc 100644 --- a/application/controllers/UsersController.php +++ b/application/controllers/UsersController.php @@ -8,7 +8,7 @@ use GuzzleHttp\Psr7\ServerRequest; use Icinga\Module\Icingadb\Model\User; use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions; use Icinga\Module\Icingadb\Web\Controller; -use Icinga\Module\Icingadb\Widget\ItemList\UserList; +use Icinga\Module\Icingadb\Widget\ItemTable\UserTable; use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher; use ipl\Web\Control\LimitControl; use ipl\Web\Control\SortControl; @@ -66,7 +66,7 @@ class UsersController extends Controller $this->addControl($limitControl); $this->addControl($searchBar); - $this->addContent(new UserList($users)); + $this->addContent(new UserTable($users)); if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) { $this->sendMultipartUpdate(); diff --git a/library/Icingadb/Widget/Detail/EventDetail.php b/library/Icingadb/Widget/Detail/EventDetail.php index 198f4849..e4eb47eb 100644 --- a/library/Icingadb/Widget/Detail/EventDetail.php +++ b/library/Icingadb/Widget/Detail/EventDetail.php @@ -27,7 +27,7 @@ use Icinga\Module\Icingadb\Model\StateHistory; use Icinga\Module\Icingadb\Util\PluginOutput; use Icinga\Module\Icingadb\Widget\EmptyState; use ipl\Web\Widget\HorizontalKeyValue; -use Icinga\Module\Icingadb\Widget\ItemList\UserList; +use Icinga\Module\Icingadb\Widget\ItemTable\UserTable; use Icinga\Module\Icingadb\Widget\PluginOutputContainer; use Icinga\Module\Icingadb\Widget\ShowMore; use ipl\Html\BaseHtmlElement; @@ -159,7 +159,7 @@ class EventDetail extends BaseHtmlElement $users = $users->execute(); /** @var ResultSet $users */ - $notifiedUsers[] = new UserList($users); + $notifiedUsers[] = new UserTable($users); $notifiedUsers[] = (new ShowMore( $users, Links::users()->addParams(['notification_history.id' => bin2hex($notification->id)]), diff --git a/library/Icingadb/Widget/Detail/UserDetail.php b/library/Icingadb/Widget/Detail/UserDetail.php index bfdfa46e..06b07dd0 100644 --- a/library/Icingadb/Widget/Detail/UserDetail.php +++ b/library/Icingadb/Widget/Detail/UserDetail.php @@ -12,7 +12,7 @@ use Icinga\Module\Icingadb\Model\User; use Icinga\Module\Icingadb\Widget\EmptyState; use ipl\Html\Attributes; use ipl\Web\Widget\HorizontalKeyValue; -use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList; +use Icinga\Module\Icingadb\Widget\ItemTable\UsergroupTable; use Icinga\Module\Icingadb\Widget\ShowMore; use ipl\Html\BaseHtmlElement; use ipl\Html\HtmlElement; @@ -84,7 +84,7 @@ class UserDetail extends BaseHtmlElement return [ new HtmlElement('h2', null, Text::create(t('Groups'))), - new UsergroupList($userGroups), + new UsergroupTable($userGroups), $showMoreLink ]; } diff --git a/library/Icingadb/Widget/Detail/UsergroupDetail.php b/library/Icingadb/Widget/Detail/UsergroupDetail.php index f2cdebe9..85ab5f99 100644 --- a/library/Icingadb/Widget/Detail/UsergroupDetail.php +++ b/library/Icingadb/Widget/Detail/UsergroupDetail.php @@ -10,7 +10,7 @@ use Icinga\Module\Icingadb\Common\Links; use Icinga\Module\Icingadb\Hook\ExtensionHook\ObjectDetailExtensionHook; use Icinga\Module\Icingadb\Model\Usergroup; use Icinga\Module\Icingadb\Widget\EmptyState; -use Icinga\Module\Icingadb\Widget\ItemList\UserList; +use Icinga\Module\Icingadb\Widget\ItemTable\UserTable; use Icinga\Module\Icingadb\Widget\ShowMore; use ipl\Html\Attributes; use ipl\Html\BaseHtmlElement; @@ -74,7 +74,7 @@ class UsergroupDetail extends BaseHtmlElement return [ new HtmlElement('h2', null, Text::create(t('Users'))), - new UserList($users), + new UserTable($users), $showMoreLink ]; } diff --git a/library/Icingadb/Widget/ItemList/ServicegroupList.php b/library/Icingadb/Widget/ItemList/ServicegroupList.php deleted file mode 100644 index fa612f1c..00000000 --- a/library/Icingadb/Widget/ItemList/ServicegroupList.php +++ /dev/null @@ -1,33 +0,0 @@ - 'servicegroup-list item-table']; - - protected function init() - { - parent::init(); - - $this->getAttributes()->get('class')->removeValue('item-list'); - $this->setDetailUrl(Url::fromPath('icingadb/servicegroup')); - } - - protected function getItemClass(): string - { - $this->addAttributes(['class' => $this->getViewMode()]); - - return ServicegroupListItem::class; - } -} diff --git a/library/Icingadb/Widget/ItemList/UserList.php b/library/Icingadb/Widget/ItemList/UserList.php deleted file mode 100644 index 826a467f..00000000 --- a/library/Icingadb/Widget/ItemList/UserList.php +++ /dev/null @@ -1,29 +0,0 @@ - 'user-list item-table']; - - protected function init() - { - parent::init(); - - $this->getAttributes()->get('class')->removeValue('item-list'); - $this->setDetailUrl(Url::fromPath('icingadb/user')); - } - - protected function getItemClass(): string - { - return UserListItem::class; - } -} diff --git a/library/Icingadb/Widget/ItemList/UsergroupList.php b/library/Icingadb/Widget/ItemList/UsergroupList.php deleted file mode 100644 index 2e95368a..00000000 --- a/library/Icingadb/Widget/ItemList/UsergroupList.php +++ /dev/null @@ -1,29 +0,0 @@ - 'usergroup-list item-table']; - - protected function init() - { - parent::init(); - - $this->getAttributes()->get('class')->removeValue('item-list'); - $this->setDetailUrl(Url::fromPath('icingadb/usergroup')); - } - - protected function getItemClass(): string - { - return UsergroupListItem::class; - } -} diff --git a/library/Icingadb/Widget/ItemTable/ServicegroupTable.php b/library/Icingadb/Widget/ItemTable/ServicegroupTable.php new file mode 100644 index 00000000..98769de0 --- /dev/null +++ b/library/Icingadb/Widget/ItemTable/ServicegroupTable.php @@ -0,0 +1,23 @@ + 'servicegroup-table']; + + protected function init() + { + $this->setDetailUrl(Url::fromPath('icingadb/servicegroup')); + } + + protected function getItemClass(): string + { + return ServicegroupTableRow::class; + } +} diff --git a/library/Icingadb/Widget/ItemList/ServicegroupListItem.php b/library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php similarity index 56% rename from library/Icingadb/Widget/ItemList/ServicegroupListItem.php rename to library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php index 6a8320c2..dcaf27b3 100644 --- a/library/Icingadb/Widget/ItemList/ServicegroupListItem.php +++ b/library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php @@ -2,11 +2,10 @@ /* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */ -namespace Icinga\Module\Icingadb\Widget\ItemList; +namespace Icinga\Module\Icingadb\Widget\ItemTable; use Icinga\Module\Icingadb\Common\BaseTableRowItem; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Model\Servicegroup; use Icinga\Module\Icingadb\Widget\Detail\ServiceStatistics; use ipl\Html\Attributes; @@ -21,16 +20,17 @@ use ipl\Web\Widget\Link; * Servicegroup item of a servicegroup list. Represents one database row. * * @property Servicegroup $item - * @property ServicegroupList $list + * @property ServicegroupTable $table */ -class ServicegroupListItem extends BaseTableRowItem +class ServicegroupTableRow extends BaseTableRowItem { - use NoSubjectLink; + protected $defaultAttributes = ['class' => 'servicegroup-table-row']; protected function init() { - $this->setNoSubjectLink($this->list->getNoSubjectLink()); - $this->list->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name)); + if (isset($this->table)) { + $this->table->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name)); + } } protected function assembleColumns(HtmlDocument $columns) @@ -38,31 +38,26 @@ class ServicegroupListItem extends BaseTableRowItem $serviceStats = new ServiceStatistics($this->item); $serviceStats->setBaseFilter(Filter::equal('servicegroup.name', $this->item->name)); - if ($this->list->hasBaseFilter()) { + if (isset($this->table) && $this->table->hasBaseFilter()) { $serviceStats->setBaseFilter( - Filter::all($serviceStats->getBaseFilter(), $this->list->getBaseFilter()) + Filter::all($serviceStats->getBaseFilter(), $this->table->getBaseFilter()) ); } - $columns->addFrom($serviceStats, function (BaseHtmlElement $item) { - $item->getAttributes()->add(['class' => 'col']); - $item->setTag('div'); - return $item; - }); + $columns->addHtml($this->createColumn($serviceStats)); } protected function assembleTitle(BaseHtmlElement $title) { $title->addHtml( - $this->getNoSubjectLink() - ? new HtmlElement( + isset($this->table) + ? new Link($this->item->display_name, Links::servicegroup($this->item), ['class' => 'subject']) + : new HtmlElement( 'span', Attributes::create(['class' => 'subject']), Text::create($this->item->display_name) - ) - : new Link($this->item->display_name, Links::servicegroup($this->item), ['class' => 'subject']), - new HtmlElement('br'), - Text::create($this->item->name) + ), + new HtmlElement('span', null, Text::create($this->item->name)) ); } } diff --git a/library/Icingadb/Widget/ItemTable/UserTable.php b/library/Icingadb/Widget/ItemTable/UserTable.php new file mode 100644 index 00000000..0a363fbf --- /dev/null +++ b/library/Icingadb/Widget/ItemTable/UserTable.php @@ -0,0 +1,23 @@ + 'user-table']; + + protected function init() + { + $this->setDetailUrl(Url::fromPath('icingadb/user')); + } + + protected function getItemClass(): string + { + return UserTableRow::class; + } +} diff --git a/library/Icingadb/Widget/ItemList/UserListItem.php b/library/Icingadb/Widget/ItemTable/UserTableRow.php similarity index 63% rename from library/Icingadb/Widget/ItemList/UserListItem.php rename to library/Icingadb/Widget/ItemTable/UserTableRow.php index e43692f8..3ec469ec 100644 --- a/library/Icingadb/Widget/ItemList/UserListItem.php +++ b/library/Icingadb/Widget/ItemTable/UserTableRow.php @@ -2,11 +2,10 @@ /* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */ -namespace Icinga\Module\Icingadb\Widget\ItemList; +namespace Icinga\Module\Icingadb\Widget\ItemTable; use Icinga\Module\Icingadb\Common\BaseTableRowItem; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Model\User; use ipl\Html\Attributes; use ipl\Html\BaseHtmlElement; @@ -20,16 +19,17 @@ use ipl\Web\Widget\Link; * User item of a user list. Represents one database row. * * @property User $item - * @property UserList $list + * @property UserTable $table */ -class UserListItem extends BaseTableRowItem +class UserTableRow extends BaseTableRowItem { - use NoSubjectLink; + protected $defaultAttributes = ['class' => 'user-table-row']; protected function init() { - $this->setNoSubjectLink($this->list->getNoSubjectLink()); - $this->list->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name)); + if (isset($this->table)) { + $this->table->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name)); + } } protected function assembleVisual(BaseHtmlElement $visual) @@ -44,15 +44,14 @@ class UserListItem extends BaseTableRowItem protected function assembleTitle(BaseHtmlElement $title) { $title->addHtml( - $this->getNoSubjectLink() - ? new HtmlElement( + isset($this->table) + ? new Link($this->item->display_name, Links::user($this->item), ['class' => 'subject']) + : new HtmlElement( 'span', Attributes::create(['class' => 'subject']), Text::create($this->item->display_name) - ) - : new Link($this->item->display_name, Links::user($this->item), ['class' => 'subject']), - new HtmlElement('br'), - Text::create($this->item->name) + ), + new HtmlElement('span', null, Text::create($this->item->name)) ); } diff --git a/library/Icingadb/Widget/ItemTable/UsergroupTable.php b/library/Icingadb/Widget/ItemTable/UsergroupTable.php new file mode 100644 index 00000000..e166fed5 --- /dev/null +++ b/library/Icingadb/Widget/ItemTable/UsergroupTable.php @@ -0,0 +1,23 @@ + 'usergroup-table']; + + protected function init() + { + $this->setDetailUrl(Url::fromPath('icingadb/usergroup')); + } + + protected function getItemClass(): string + { + return UsergroupTableRow::class; + } +} diff --git a/library/Icingadb/Widget/ItemList/UsergroupListItem.php b/library/Icingadb/Widget/ItemTable/UsergroupTableRow.php similarity index 63% rename from library/Icingadb/Widget/ItemList/UsergroupListItem.php rename to library/Icingadb/Widget/ItemTable/UsergroupTableRow.php index f8c800d7..c9b6c5a7 100644 --- a/library/Icingadb/Widget/ItemList/UsergroupListItem.php +++ b/library/Icingadb/Widget/ItemTable/UsergroupTableRow.php @@ -2,11 +2,10 @@ /* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */ -namespace Icinga\Module\Icingadb\Widget\ItemList; +namespace Icinga\Module\Icingadb\Widget\ItemTable; use Icinga\Module\Icingadb\Common\BaseTableRowItem; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Model\Usergroup; use ipl\Html\Attributes; use ipl\Html\BaseHtmlElement; @@ -20,16 +19,17 @@ use ipl\Web\Widget\Link; * Usergroup item of a usergroup list. Represents one database row. * * @property Usergroup $item - * @property UsergroupList $list + * @property UsergroupTable $table */ -class UsergroupListItem extends BaseTableRowItem +class UsergroupTableRow extends BaseTableRowItem { - use NoSubjectLink; + protected $defaultAttributes = ['class' => 'usergroup-table-row']; protected function init() { - $this->setNoSubjectLink($this->list->getNoSubjectLink()); - $this->list->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name)); + if (isset($this->table)) { + $this->table->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name)); + } } protected function assembleVisual(BaseHtmlElement $visual) @@ -44,15 +44,14 @@ class UsergroupListItem extends BaseTableRowItem protected function assembleTitle(BaseHtmlElement $title) { $title->addHtml( - $this->getNoSubjectLink() - ? new HtmlElement( + isset($this->table) + ? new Link($this->item->display_name, Links::usergroup($this->item), ['class' => 'subject']) + : new HtmlElement( 'span', Attributes::create(['class' => 'subject']), Text::create($this->item->display_name) - ) - : new Link($this->item->display_name, Links::usergroup($this->item), ['class' => 'subject']), - new HtmlElement('br'), - Text::create($this->item->name) + ), + new HtmlElement('span', null, Text::create($this->item->name)) ); } diff --git a/public/css/common.less b/public/css/common.less index 8ceeb0e2..0ba98615 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -318,10 +318,17 @@ div.show-more { &.servicegroup-table { --columns: 1; } + + &.user-table, // TODO: make them lists..... + &.usergroup-table { + --columns: 0; + } } .hostgroup-table, -.servicegroup-table { +.servicegroup-table, +.usergroup-table, +.user-table { .title .content > * { display: block; max-width: fit-content; @@ -333,7 +340,9 @@ div.show-more { } .controls .hostgroup-table-row, -.controls .servicegroup-table-row { +.controls .servicegroup-table-row, +.controls .usergroup-table-row, +.controls .user-table-row { .title .content { display: inline-flex; align-items: center;