Skip to content

Commit

Permalink
Fix detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
jrauh01 committed Jan 15, 2025
1 parent 5a56a8b commit b9fb480
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 55 deletions.
3 changes: 2 additions & 1 deletion application/controllers/DaemonsetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\DaemonSetDetail;
use Icinga\Module\Kubernetes\Web\DaemonSetList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

Expand All @@ -33,7 +34,7 @@ public function indexAction(): void
$this->httpNotFound($this->translate('Daemon Set not found'));
}

$this->addControl(new DaemonSetList([$daemonSet]));
$this->addControl((new DaemonSetList([$daemonSet]))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED));

$this->addContent(new DaemonSetDetail($daemonSet));
}
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/DeploymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\DeploymentDetail;
use Icinga\Module\Kubernetes\Web\DeploymentList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

Expand All @@ -33,7 +34,7 @@ public function indexAction(): void
$this->httpNotFound($this->translate('Deployment not found'));
}

$this->addControl(new DeploymentList([$deployment]));
$this->addControl((new DeploymentList([$deployment]))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED));

$this->addContent(new DeploymentDetail($deployment));
}
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/JobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\JobDetail;
use Icinga\Module\Kubernetes\Web\JobList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

Expand All @@ -33,7 +34,7 @@ public function indexAction(): void
$this->httpNotFound($this->translate('Job not found'));
}

$this->addControl(new JobList([$job]));
$this->addControl((new JobList([$job]))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED));

$this->addContent(new JobDetail($job));
}
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\NodeDetail;
use Icinga\Module\Kubernetes\Web\NodeList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

Expand All @@ -33,7 +34,7 @@ public function indexAction(): void
$this->httpNotFound($this->translate('Node not found'));
}

$this->addControl(new NodeList([$node]));
$this->addControl((new NodeList([$node]))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED));

$this->addContent(new NodeDetail($node));
}
Expand Down
5 changes: 3 additions & 2 deletions application/controllers/PodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\PodDetail;
use Icinga\Module\Kubernetes\Web\PodList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

Expand All @@ -32,8 +33,8 @@ public function indexAction(): void
if ($pod === null) {
$this->httpNotFound($this->translate('Pod not found'));
}

$this->addControl(new PodList([$pod]));
$this->addControl((new PodList([$pod]))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED));

$this->addContent(new PodDetail($pod));
}
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/ReplicasetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\ReplicaSetDetail;
use Icinga\Module\Kubernetes\Web\ReplicaSetList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

Expand All @@ -33,7 +34,7 @@ public function indexAction(): void
$this->httpNotFound($this->translate('Replica Set not found'));
}

$this->addControl(new ReplicaSetList([$replicaSet]));
$this->addControl((new ReplicaSetList([$replicaSet]))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED));

$this->addContent(new ReplicaSetDetail($replicaSet));
}
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/StatefulsetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Icinga\Module\Kubernetes\Web\Controller;
use Icinga\Module\Kubernetes\Web\StatefulSetDetail;
use Icinga\Module\Kubernetes\Web\StatefulSetList;
use Icinga\Module\Kubernetes\Web\ViewModeSwitcher;
use ipl\Stdlib\Filter;
use Ramsey\Uuid\Uuid;

Expand All @@ -33,7 +34,7 @@ public function indexAction(): void
$this->httpNotFound($this->translate('Stateful Set not found'));
}

$this->addControl(new StatefulSetList([$statefulSet]));
$this->addControl((new StatefulSetList([$statefulSet]))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED));

$this->addContent(new StatefulSetDetail($statefulSet));
}
Expand Down
5 changes: 4 additions & 1 deletion library/Kubernetes/Common/BaseItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ protected function assemble(): void
Filter::equal('id', Uuid::fromBytes($item->uuid)->toString())
)
]);
$listItem->setViewMode($this->getViewMode());

if ($this->getViewMode() !== null) {
$listItem->setViewMode($this->getViewMode());
}

$this->addHtml(
$listItem
Expand Down
10 changes: 6 additions & 4 deletions library/Kubernetes/Web/CronJobDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Jobs'))),
new JobList(Auth::getInstance()->withRestrictions(
(new JobList(Auth::getInstance()->withRestrictions(
Auth::SHOW_JOBS,
$this->cronJob->job
))
)))
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -80,8 +81,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->cronJob->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->cronJob->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
10 changes: 6 additions & 4 deletions library/Kubernetes/Web/DaemonSetDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Pods'))),
new PodList(Auth::getInstance()->withRestrictions(
(new PodList(Auth::getInstance()->withRestrictions(
Auth::SHOW_PODS,
$this->daemonSet->pod->with(['node'])
))
)))
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -101,8 +102,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->daemonSet->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->daemonSet->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
10 changes: 6 additions & 4 deletions library/Kubernetes/Web/DeploymentDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Replica Sets'))),
new ReplicaSetList(Auth::getInstance()->withRestrictions(
(new ReplicaSetList(Auth::getInstance()->withRestrictions(
Auth::SHOW_REPLICA_SETS,
$this->deployment->replica_set
))
)))
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -103,8 +104,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->deployment->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->deployment->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
2 changes: 1 addition & 1 deletion library/Kubernetes/Web/EventDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Referent'))),
Factory::createList($this->event->reference_kind, Filter::equal('uuid', $this->event->reference_uuid))
Factory::createList($this->event->reference_kind, Filter::equal('uuid', $this->event->reference_uuid)) // TODO fix with restrictions
)
);

Expand Down
10 changes: 6 additions & 4 deletions library/Kubernetes/Web/JobDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Pods'))),
new PodList(Auth::getInstance()->withRestrictions(
(new PodList(Auth::getInstance()->withRestrictions(
Auth::SHOW_PODS,
$this->job->pod->with(['node'])
))
)))
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -99,8 +100,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text('Events')),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->job->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->job->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
5 changes: 3 additions & 2 deletions library/Kubernetes/Web/NamespaceDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->namespace->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->namespace->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
5 changes: 3 additions & 2 deletions library/Kubernetes/Web/NodeDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->node->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->node->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
10 changes: 6 additions & 4 deletions library/Kubernetes/Web/PersistentVolumeClaimDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Pods'))),
new PodList(Auth::getInstance()->withRestrictions(
(new PodList(Auth::getInstance()->withRestrictions(
Auth::SHOW_PODS,
$this->pvc->pod
))
)))
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -85,8 +86,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->pvc->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->pvc->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
10 changes: 6 additions & 4 deletions library/Kubernetes/Web/PersistentVolumeDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ protected function assemble(): void
'section',
new Attributes(['class' => 'persistent-volume-claims']),
new HtmlElement('h2', null, new Text($this->translate('Claims'))),
new PersistentVolumeClaimList(Auth::getInstance()->withRestrictions(
(new PersistentVolumeClaimList(Auth::getInstance()->withRestrictions(
Auth::SHOW_PERSISTENT_VOLUME_CLAIMS,
$this->persistentVolume->pvc
))
)))
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -79,8 +80,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->persistentVolume->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->persistentVolume->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
11 changes: 5 additions & 6 deletions library/Kubernetes/Web/PodDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Icinga\Module\Kubernetes\Model\Container;
use Icinga\Module\Kubernetes\Model\Event;
use Icinga\Module\Kubernetes\Model\Pod;
use Icinga\Module\Kubernetes\Model\PodOwner;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlDocument;
Expand All @@ -24,7 +23,6 @@
use ipl\Web\Widget\EmptyState;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\StateBall;
use Ramsey\Uuid\Uuid;

class PodDetail extends BaseHtmlElement
{
Expand Down Expand Up @@ -123,10 +121,10 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Persistent Volume Claims'))),
new PersistentVolumeClaimList(Auth::getInstance()->withRestrictions(
(new PersistentVolumeClaimList(Auth::getInstance()->withRestrictions(
Auth::SHOW_PERSISTENT_VOLUME_CLAIMS,
$this->pod->pvc
))
)))->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -135,8 +133,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text('Events')),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->pod->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->pod->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
10 changes: 6 additions & 4 deletions library/Kubernetes/Web/ReplicaSetDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Pods'))),
new PodList(Auth::getInstance()->withRestrictions(
(new PodList(Auth::getInstance()->withRestrictions(
Auth::SHOW_PODS,
$this->replicaSet->pod->with(['node'])
))
)))
->setViewMode(ViewModeSwitcher::VIEW_MODE_DETAILED)
));
}

Expand All @@ -94,8 +95,9 @@ protected function assemble(): void
'section',
null,
new HtmlElement('h2', null, new Text($this->translate('Events'))),
new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->replicaSet->uuid)))
(new EventList(Event::on(Database::connection())
->filter(Filter::equal('reference_uuid', $this->replicaSet->uuid))))
->setViewMode(ViewModeSwitcher::VIEW_MODE_COMMON)
));
}

Expand Down
Loading

0 comments on commit b9fb480

Please sign in to comment.