Skip to content

Commit 74bb945

Browse files
Add csv/json export support for parents and children tab
1 parent 22603ba commit 74bb945

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

application/controllers/HostController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function servicesAction(): \Generator
234234
$this->setAutorefreshInterval(10);
235235
}
236236

237-
public function parentsAction(): void
237+
public function parentsAction(): \Generator
238238
{
239239
$nodesQuery = $this->fetchNodes(true);
240240

@@ -275,6 +275,8 @@ public function parentsAction(): void
275275

276276
$nodesQuery->filter($filter);
277277

278+
yield $this->export($nodesQuery);
279+
278280
$this->addControl($paginationControl);
279281
$this->addControl($sortControl);
280282
$this->addControl($limitControl);
@@ -293,7 +295,7 @@ public function parentsAction(): void
293295
$this->setAutorefreshInterval(10);
294296
}
295297

296-
public function childrenAction(): void
298+
public function childrenAction(): \Generator
297299
{
298300
$nodesQuery = $this->fetchNodes();
299301

@@ -337,6 +339,8 @@ public function childrenAction(): void
337339

338340
$nodesQuery->filter($filter);
339341

342+
yield $this->export($nodesQuery);
343+
340344
$this->addControl($paginationControl);
341345
$this->addControl($sortControl);
342346
$this->addControl($limitControl);

application/controllers/ServiceController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function indexAction(): void
100100
$this->setAutorefreshInterval(10);
101101
}
102102

103-
public function parentsAction(): void
103+
public function parentsAction(): \Generator
104104
{
105105
$nodesQuery = $this->fetchNodes(true);
106106

@@ -142,6 +142,8 @@ public function parentsAction(): void
142142

143143
$nodesQuery->filter($filter);
144144

145+
yield $this->export($nodesQuery);
146+
145147
$this->addControl($paginationControl);
146148
$this->addControl($sortControl);
147149
$this->addControl($limitControl);
@@ -160,7 +162,7 @@ public function parentsAction(): void
160162
$this->setAutorefreshInterval(10);
161163
}
162164

163-
public function childrenAction(): void
165+
public function childrenAction(): \Generator
164166
{
165167
$nodesQuery = $this->fetchNodes();
166168

@@ -205,6 +207,8 @@ public function childrenAction(): void
205207

206208
$nodesQuery->filter($filter);
207209

210+
yield $this->export($nodesQuery);
211+
208212
$this->addControl($paginationControl);
209213
$this->addControl($sortControl);
210214
$this->addControl($limitControl);

library/Icingadb/Data/CsvResultSetUtils.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DateTime;
88
use DateTimeZone;
9+
use Icinga\Module\Icingadb\Model\DependencyNode;
910
use Icinga\Module\Icingadb\Model\Host;
1011
use Icinga\Module\Icingadb\Model\Service;
1112
use ipl\Orm\Model;
@@ -67,7 +68,8 @@ protected function extractKeysAndValues(Model $model, string $path = ''): array
6768

6869
public static function stream(Query $query): void
6970
{
70-
if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
71+
$model = $query->getModel();
72+
if ($model instanceof Host || $model instanceof Service || $model instanceof DependencyNode) {
7173
$query->setResultSetClass(VolatileCsvResults::class);
7274
} else {
7375
$query->setResultSetClass(__CLASS__);

library/Icingadb/Data/JsonResultSetUtils.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DateTime;
88
use DateTimeZone;
9+
use Icinga\Module\Icingadb\Model\DependencyNode;
910
use Icinga\Module\Icingadb\Model\Host;
1011
use Icinga\Module\Icingadb\Model\Service;
1112
use Icinga\Util\Json;
@@ -61,7 +62,8 @@ protected function createObject(Model $model): array
6162

6263
public static function stream(Query $query): void
6364
{
64-
if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
65+
$model = $query->getModel();
66+
if ($model instanceof Host || $model instanceof Service || $model instanceof DependencyNode) {
6567
$query->setResultSetClass(VolatileJsonResults::class);
6668
} else {
6769
$query->setResultSetClass(__CLASS__);

0 commit comments

Comments
 (0)