Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment widget #102

Merged
merged 7 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,4 @@
$this->provideCssFile('labels.less');
$this->provideCssFile('lists.less');
$this->provideCssFile('widgets.less');
$this->provideCssFile('environment-widget.less');
3 changes: 2 additions & 1 deletion library/Kubernetes/Web/CronJobDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ protected function assemble(): void
$this->translate('Last Schedule Time') => $lastScheduleTime
])),
new Labels($this->cronJob->label),
new Annotations($this->cronJob->annotation)
new Annotations($this->cronJob->annotation),
new CronJobEnvironment($this->cronJob),
);

if (Auth::getInstance()->hasPermission(Auth::SHOW_JOBS)) {
Expand Down
46 changes: 46 additions & 0 deletions library/Kubernetes/Web/CronJobEnvironment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */

namespace Icinga\Module\Kubernetes\Web;

use Icinga\Module\Kubernetes\Model\CronJob;
use ipl\Html\Attributes;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\I18n\Translation;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

class CronJobEnvironment implements ValidHtml
{
use Translation;

public function __construct(protected CronJob $cronJob)
{
}

public function render(): ValidHtml
{
$childrenFilter = Filter::all(
Filter::equal('namespace', $this->cronJob->namespace),
Filter::equal('job.owner.owner_uuid', (string) Uuid::fromBytes($this->cronJob->uuid))
);

$jobs = $this->cronJob->job
->filter($childrenFilter)
->limit(3);

return (new HtmlDocument())
->addHtml(
new HtmlElement(
'h2',
new Attributes(['class' => 'environment-widget-title']),
new Text($this->translate('Environment'))
),
new Environment($this->cronJob, null, $jobs, null, $childrenFilter)
);
}
}
3 changes: 2 additions & 1 deletion library/Kubernetes/Web/DaemonSetDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ protected function assemble(): void
])),
new Labels($this->daemonSet->label),
new Annotations($this->daemonSet->annotation),
new ConditionTable($this->daemonSet, (new DaemonSetCondition())->getColumnDefinitions())
new ConditionTable($this->daemonSet, (new DaemonSetCondition())->getColumnDefinitions()),
new DaemonSetEnvironment($this->daemonSet),
);

if (Auth::getInstance()->hasPermission(Auth::SHOW_PODS)) {
Expand Down
48 changes: 48 additions & 0 deletions library/Kubernetes/Web/DaemonSetEnvironment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */

namespace Icinga\Module\Kubernetes\Web;

use Icinga\Module\Kubernetes\Common\Database;
use Icinga\Module\Kubernetes\Model\DaemonSet;
use Icinga\Module\Kubernetes\Model\Pod;
use ipl\Html\Attributes;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\I18n\Translation;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

class DaemonSetEnvironment implements ValidHtml
{
use Translation;

public function __construct(protected DaemonSet $daemonSet)
{
}

public function render(): ValidHtml
{
$childrenFilter = Filter::all(
Filter::equal('namespace', $this->daemonSet->namespace),
Filter::equal('pod.owner.owner_uuid', (string) Uuid::fromBytes($this->daemonSet->uuid))
);

$pods = Pod::on(Database::connection())
->filter($childrenFilter)
->limit(3);

return (new HtmlDocument())
->addHtml(
new HtmlElement(
'h2',
new Attributes(['class' => 'environment-widget-title']),
new Text($this->translate('Environment'))
),
new Environment($this->daemonSet, null, $pods, null, $childrenFilter)
);
}
}
3 changes: 2 additions & 1 deletion library/Kubernetes/Web/DeploymentDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ protected function assemble(): void
])),
new Labels($this->deployment->label),
new Annotations($this->deployment->annotation),
new DeploymentConditions($this->deployment)
new DeploymentConditions($this->deployment),
new DeploymentEnvironment($this->deployment),
);

if (Auth::getInstance()->hasPermission(Auth::SHOW_REPLICA_SETS)) {
Expand Down
48 changes: 48 additions & 0 deletions library/Kubernetes/Web/DeploymentEnvironment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */

namespace Icinga\Module\Kubernetes\Web;

use Icinga\Module\Kubernetes\Common\Database;
use Icinga\Module\Kubernetes\Model\Deployment;
use Icinga\Module\Kubernetes\Model\ReplicaSet;
use ipl\Html\Attributes;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\I18n\Translation;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

class DeploymentEnvironment implements ValidHtml
{
use Translation;

public function __construct(protected Deployment $deployment)
{
}

public function render(): ValidHtml
{
$childrenFilter = Filter::all(
Filter::equal('namespace', $this->deployment->namespace),
Filter::equal('replica_set.owner.owner_uuid', (string) Uuid::fromBytes($this->deployment->uuid))
);

$replicaSets = ReplicaSet::on(Database::connection())
->filter($childrenFilter)
->limit(3);

return (new HtmlDocument())
->addHtml(
new HtmlElement(
'h2',
new Attributes(['class' => 'environment-widget-title']),
new Text($this->translate('Environment'))
),
new Environment($this->deployment, null, $replicaSets, $childrenFilter)
);
}
}
Loading
Loading