Skip to content

Commit ddaa6e3

Browse files
committed
wip
1 parent a9ffcd2 commit ddaa6e3

File tree

6 files changed

+49
-24
lines changed

6 files changed

+49
-24
lines changed

library/Kubernetes/Common/BaseListItem.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
use Icinga\Module\Kubernetes\Web\Factory;
88
use Icinga\Module\Kubernetes\Web\MoveFavoriteForm;
9+
use ipl\Html\Attributes;
910
use ipl\Html\BaseHtmlElement;
1011
use ipl\Html\Html;
1112
use ipl\Html\HtmlElement;
13+
use ipl\Web\Widget\Icon;
1214
use Ramsey\Uuid\Uuid;
1315

1416
/**
@@ -52,7 +54,8 @@ protected function init(): void
5254

5355
protected function assemble(): void
5456
{
55-
if (isset($this->item->favorite->priority)) {
57+
$draggable = isset($this->item->favorite->priority);
58+
if ($draggable) {
5659
$this->add(
5760
(new MoveFavoriteForm())
5861
->setAction(
@@ -61,13 +64,23 @@ protected function assemble(): void
6164
->populate([
6265
'uuid' => Uuid::fromBytes($this->item->uuid)->toString(),
6366
'priority' => $this->item->favorite->priority,
64-
]),
67+
])
68+
->setAttribute('data-base-target', '_self'),
6569
);
70+
// TODO wait for feedback how to style
71+
// $div = Html::tag('div', Attributes::create(['class' => 'vertical-align']));
72+
// $div->addHtml(new Icon('bars', ['data-drag-initiator' => true]));
73+
// $this->add($div);
6674
}
6775
$this->add([
6876
$this->createVisual(),
6977
$this->createMain()
7078
]);
79+
if ($draggable) {
80+
$div = Html::tag('div', Attributes::create(['class' => 'vertical-align']));
81+
$div->addHtml(new Icon('bars', ['data-drag-initiator' => true]));
82+
$this->add($div);
83+
}
7184
}
7285

7386
protected function createVisual(): ?BaseHtmlElement

library/Kubernetes/Web/Factory.php

+15-13
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,20 @@ public static function getKindFromModel(Model $model): string
297297
{
298298
$kind = match (true) {
299299
$model instanceof ConfigMap,
300-
$model instanceof CronJob,
301-
$model instanceof DaemonSet,
302-
$model instanceof Deployment,
303-
$model instanceof Ingress,
304-
$model instanceof Job,
305-
$model instanceof PersistentVolume,
306-
$model instanceof PersistentVolumeClaim,
307-
$model instanceof Pod,
308-
$model instanceof ReplicaSet,
309-
$model instanceof Secret,
310-
$model instanceof Service,
311-
$model instanceof StatefulSet => basename(str_replace('\\', '/', get_class($model))),
312-
default => null
300+
$model instanceof CronJob,
301+
$model instanceof DaemonSet,
302+
$model instanceof Deployment,
303+
$model instanceof Ingress,
304+
$model instanceof Job,
305+
$model instanceof Node,
306+
$model instanceof PersistentVolume,
307+
$model instanceof PersistentVolumeClaim,
308+
$model instanceof Pod,
309+
$model instanceof ReplicaSet,
310+
$model instanceof Secret,
311+
$model instanceof Service,
312+
$model instanceof StatefulSet => basename(str_replace('\\', '/', get_class($model))),
313+
default => null
313314
};
314315

315316
return strtolower(str_replace(['_', '-'], '', $kind));
@@ -336,6 +337,7 @@ public static function fetchResource(string $kind, Connection $db = null): ?Quer
336337
'deployment' => Deployment::on($database),
337338
'ingress' => Ingress::on($database),
338339
'job' => Job::on($database),
340+
'node' => Node::on($database),
339341
'persistentvolume' => PersistentVolume::on($database),
340342
'persistentvolumeclaim' => PersistentVolumeClaim::on($database),
341343
'pod' => Pod::on($database),

library/Kubernetes/Web/PodListItem.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ protected function assembleFooter(BaseHtmlElement $footer): void
8484
(new Icon('life-ring'))->addAttributes(['title' => $this->translate('Quality of Service')]),
8585
$this->item->qos
8686
),
87-
(new HorizontalKeyValue(
88-
$this->translate('IP'),
89-
$this->item->ip ?? $this->translate('None')
90-
))
91-
->addAttributes(['class' => 'push-left']),
92-
new HorizontalKeyValue(new Icon('share-nodes'), $this->item->node_name ?? $this->translate('None'))
87+
// (new HorizontalKeyValue(
88+
// $this->translate('IP'),
89+
// $this->item->ip ?? $this->translate('None')
90+
// ))
91+
// ->addAttributes(['class' => 'push-left']),
92+
// new HorizontalKeyValue(new Icon('share-nodes'), $this->item->node_name ?? $this->translate('None'))
9393
);
9494
}
9595
}

public/css/action-list.less

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
}
1212

1313
&[favorite-list] {
14-
[data-action-item]:hover {
14+
[data-drag-initiator]:hover {
1515
cursor: grab;
16+
color: var(--text-color, var(--white, #ffffff));
1617
}
1718
}
1819

public/css/lists.less

+9-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ footer {
6565
// which also defines rules for this class, assumes a height of two lines.
6666
display: block;
6767
height: 1.5em;
68-
white-space: nowrap;
68+
white-space: pre-wrap;
6969
}
7070

7171
.title {
@@ -117,3 +117,11 @@ footer {
117117
overflow: visible;
118118
}
119119
}
120+
121+
.vertical-align {
122+
display: flex;
123+
flex-direction: column;
124+
align-items: center;
125+
justify-content: center;
126+
padding-left: 0.5em;
127+
}

public/js/action-list.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@
611611
Sortable.create(favoriteList, {
612612
scroll: true,
613613
direction: 'vertical',
614-
draggable: '.list-item'
614+
draggable: '.list-item',
615+
handle: '[data-drag-initiator]',
615616
});
616617
}
617618

0 commit comments

Comments
 (0)