mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
Merge pull request #2985 from Mikesch-mp/json-export
Export JSON with .json extension
This commit is contained in:
commit
b0f0464ec4
@ -8,6 +8,7 @@ use Icinga\Exception\QueryException;
|
|||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Data\Filterable;
|
use Icinga\Data\Filterable;
|
||||||
use Icinga\File\Csv;
|
use Icinga\File\Csv;
|
||||||
|
use Icinga\Util\Json;
|
||||||
use Icinga\Web\Controller as IcingaWebController;
|
use Icinga\Web\Controller as IcingaWebController;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
@ -39,8 +40,13 @@ class Controller extends IcingaWebController
|
|||||||
}
|
}
|
||||||
if ($this->_getParam('format') === 'json'
|
if ($this->_getParam('format') === 'json'
|
||||||
|| $this->_request->getHeader('Accept') === 'application/json') {
|
|| $this->_request->getHeader('Accept') === 'application/json') {
|
||||||
header('Content-type: application/json');
|
$response = $this->getResponse();
|
||||||
echo json_encode($query->getQuery()->fetchAll());
|
$response
|
||||||
|
->setHeader('Content-Type', 'application/json')
|
||||||
|
->setHeader('Cache-Control', 'no-store')
|
||||||
|
->setHeader('Content-Disposition', 'inline; filename=' . $this->getRequest()->getActionName() . '.json')
|
||||||
|
->appendBody(Json::encode($query->getQuery()->fetchAll()))
|
||||||
|
->sendResponse();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if ($this->_getParam('format') === 'csv'
|
if ($this->_getParam('format') === 'csv'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user