Add action bar with download as json option for service apply rules and templates

related to issue #1811
This commit is contained in:
Bernhard Friedreich 2019-04-16 23:30:40 +02:00 committed by Thomas Gelf
parent b8bf12b951
commit 03519c25e8
1 changed files with 33 additions and 1 deletions

View File

@ -74,6 +74,8 @@ abstract class ObjectsController extends ActionController
if ($request->getActionName() === 'templates') {
$table->filterObjectType('template');
} else if ($request->getActionName() === 'applyrules') {
$table->filterObjectType('apply');
}
return (new IcingaObjectsHandler(
@ -210,6 +212,17 @@ abstract class ObjectsController extends ActionController
return;
}
$type = $this->getType();
if ($this->params->get('format') === 'json') {
$filename = sprintf(
"director-${type}-templates_%s.json",
date('YmdHis')
);
$this->getResponse()->setHeader('Content-disposition', "attachment; filename=$filename", true);
$this->apiRequestHandler()->dispatch();
return;
}
$shortType = IcingaObject::createByType($type)->getShortTableName();
$this
->assertPermission('director/admin')
@ -248,7 +261,23 @@ abstract class ObjectsController extends ActionController
*/
public function applyrulesAction()
{
if ($this->getRequest()->isApiRequest()) {
$this->apiRequestHandler()->dispatch();
return;
}
$type = $this->getType();
if ($this->params->get('format') === 'json') {
$filename = sprintf(
"director-${type}-applyrules_%s.json",
date('YmdHis')
);
$this->getResponse()->setHeader('Content-disposition', "attachment; filename=$filename", true);
$this->apiRequestHandler()->dispatch();
return;
}
$tType = $this->translate(ucfirst($type));
$this
->assertApplyRulePermission()
@ -277,7 +306,10 @@ abstract class ObjectsController extends ActionController
)
);
$this->getApplyRulesTable()->renderTo($this);
$table = $this->getApplyRulesTable();
$table->renderTo($this);
(new AdditionalTableActions($this->getAuth(), $this->url(), $table))
->appendTo($this->actions());
}
/**