-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #355 from Icinga/feature/add-host-servicegroup-gri…
…d-views-221 Add `Host-/Servicegroup` grid views
- Loading branch information
Showing
20 changed files
with
816 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* Icinga DB Web | (c) 2023 Icinga GmbH | GPLv2 */ | ||
|
||
namespace Icinga\Module\Icingadb\Web\Control; | ||
|
||
/** | ||
* View mode switcher to toggle between grid and list view | ||
*/ | ||
class GridViewModeSwitcher extends ViewModeSwitcher | ||
{ | ||
/** @var string Default view mode */ | ||
public const DEFAULT_VIEW_MODE = 'list'; | ||
|
||
/** @var array View mode-icon pairs */ | ||
public static $viewModes = [ | ||
'list' => 'default', | ||
'grid' => 'grid' | ||
]; | ||
|
||
protected function getTitle(string $viewMode): string | ||
{ | ||
switch ($viewMode) { | ||
case 'list': | ||
$active = t('List view active'); | ||
$inactive = t('Switch to list view'); | ||
break; | ||
case 'grid': | ||
$active = t('Grid view active'); | ||
$inactive = t('Switch to grid view'); | ||
break; | ||
} | ||
|
||
return $viewMode === $this->getViewMode() ? $active : $inactive; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/* Icinga DB Web | (c) 2023 Icinga GmbH | GPLv2 */ | ||
|
||
namespace Icinga\Module\Icingadb\Widget\ItemTable; | ||
|
||
use Icinga\Module\Icingadb\Common\BaseTableRowItem; | ||
use Icinga\Module\Icingadb\Common\Links; | ||
use Icinga\Module\Icingadb\Model\Hostgroup; | ||
use ipl\Html\Attributes; | ||
use ipl\Html\BaseHtmlElement; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Text; | ||
use ipl\I18n\Translation; | ||
use ipl\Stdlib\Filter; | ||
use ipl\Web\Widget\Link; | ||
|
||
/** | ||
* Hostgroup item of a hostgroup list. Represents one database row. | ||
* | ||
* @property Hostgroup $item | ||
* @property HostgroupTable $table | ||
*/ | ||
abstract class BaseHostGroupItem extends BaseTableRowItem | ||
{ | ||
use Translation; | ||
|
||
protected function init() | ||
{ | ||
if (isset($this->table)) { | ||
$this->table->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name)); | ||
} | ||
} | ||
|
||
protected function createSubject(): BaseHtmlElement | ||
{ | ||
return isset($this->table) | ||
? new Link( | ||
$this->item->display_name, | ||
Links::hostgroup($this->item), | ||
[ | ||
'class' => 'subject', | ||
'title' => sprintf( | ||
$this->translate('List all hosts in the group "%s"'), | ||
$this->item->display_name | ||
) | ||
] | ||
) | ||
: new HtmlElement( | ||
'span', | ||
Attributes::create(['class' => 'subject']), | ||
Text::create($this->item->display_name) | ||
); | ||
} | ||
|
||
protected function createCaption(): BaseHtmlElement | ||
{ | ||
return new HtmlElement('span', null, Text::create($this->item->name)); | ||
} | ||
} |
Oops, something went wrong.