Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
119 additions
and
38 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
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,61 @@ | ||
<?php | ||
|
||
/* Icinga Kubernetes Web | (c) 2023 Icinga GmbH | GPLv2 */ | ||
|
||
namespace Icinga\Module\Kubernetes\Web; | ||
|
||
use Icinga\Module\Kubernetes\Common\Icons; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Table; | ||
use ipl\Html\Text; | ||
use ipl\I18n\Translation; | ||
|
||
class PortTable extends Table | ||
{ | ||
use Translation; | ||
|
||
protected $columnDefinitions; | ||
|
||
protected $defaultAttributes = [ | ||
'class' => 'common-table collapsible' | ||
]; | ||
|
||
protected $resource; | ||
|
||
public function __construct($resource, array $columnDefinitions) | ||
{ | ||
$this->resource = $resource; | ||
$this->columnDefinitions = $columnDefinitions; | ||
} | ||
|
||
public function assemble() | ||
{ | ||
$this->addWrapper( | ||
new HtmlElement( | ||
'section', | ||
null, | ||
new HtmlElement('h2', null, new Text($this->translate('Ports'))) | ||
) | ||
); | ||
|
||
$header = new HtmlElement('tr'); | ||
foreach ($this->columnDefinitions as $label) { | ||
$header->addHtml(new HtmlElement('th', null, Text::create($label))); | ||
} | ||
$this->getHeader()->addHtml($header); | ||
|
||
foreach ($this->resource as $resource) { | ||
$row = new HtmlElement('tr'); | ||
foreach ($this->columnDefinitions as $column => $_) { | ||
$value = $resource->$column; | ||
if (is_bool($value)) { | ||
$content = Icons::ready($value); | ||
} else { | ||
$content = Text::create($value); | ||
} | ||
$row->addHtml(new HtmlElement('td', null, $content)); | ||
} | ||
$this->addHtml($row); | ||
} | ||
} | ||
} |
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