mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 00:04:05 +02:00
Add action bar with download as json option for service apply rules and templates
related to issue #1811
This commit is contained in:
parent
b8bf12b951
commit
03519c25e8
@ -74,6 +74,8 @@ abstract class ObjectsController extends ActionController
|
|||||||
|
|
||||||
if ($request->getActionName() === 'templates') {
|
if ($request->getActionName() === 'templates') {
|
||||||
$table->filterObjectType('template');
|
$table->filterObjectType('template');
|
||||||
|
} else if ($request->getActionName() === 'applyrules') {
|
||||||
|
$table->filterObjectType('apply');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (new IcingaObjectsHandler(
|
return (new IcingaObjectsHandler(
|
||||||
@ -210,6 +212,17 @@ abstract class ObjectsController extends ActionController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$type = $this->getType();
|
$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();
|
$shortType = IcingaObject::createByType($type)->getShortTableName();
|
||||||
$this
|
$this
|
||||||
->assertPermission('director/admin')
|
->assertPermission('director/admin')
|
||||||
@ -248,7 +261,23 @@ abstract class ObjectsController extends ActionController
|
|||||||
*/
|
*/
|
||||||
public function applyrulesAction()
|
public function applyrulesAction()
|
||||||
{
|
{
|
||||||
|
if ($this->getRequest()->isApiRequest()) {
|
||||||
|
$this->apiRequestHandler()->dispatch();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$type = $this->getType();
|
$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));
|
$tType = $this->translate(ucfirst($type));
|
||||||
$this
|
$this
|
||||||
->assertApplyRulePermission()
|
->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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user