os-firewall: add apply action and assign an acl for this controller. for https://github.com/opnsense/plugins/issues/1720

This commit is contained in:
Ad Schellevis
2020-03-10 15:17:52 +01:00
committed by Ad Schellevis
parent efeb8c1b6f
commit 8ab9605961
3 changed files with 37 additions and 3 deletions
@@ -27,7 +27,8 @@
*/
namespace OPNsense\Firewall\Api;
use \OPNsense\Base\ApiMutableModelControllerBase;
use OPNsense\Base\ApiMutableModelControllerBase;
use OPNsense\Core\Backend;
class FilterController extends ApiMutableModelControllerBase
{
@@ -63,4 +64,13 @@ class FilterController extends ApiMutableModelControllerBase
{
return $this->toggleBase("rules.rule", $uuid, $enabled);
}
}
public function applyAction()
{
if ($this->request->isPost()) {
return array("status" => (new Backend())->configdRun('filter reload'));
} else {
return array("status" => "error");
}
}
}
@@ -0,0 +1,9 @@
<acl>
<page-filter-api>
<name>Firewall: Rules: API</name>
<patterns>
<pattern>ui/firewall/filter/*</pattern>
<pattern>api/firewall/filter/*</pattern>
</patterns>
</page-filter-api>
</acl>
@@ -19,6 +19,8 @@
}
});
}
$("#reconfigureAct").SimpleActionButton();
});
</script>
@@ -29,7 +31,7 @@
<div class="tab-content content-box">
<div id="rules" class="tab-pane fade in active">
<!-- tab page "filter rules" -->
<table id="grid-rules" class="table table-condensed table-hover table-striped" data-editDialog="DialogFilterRule">
<table id="grid-rules" class="table table-condensed table-hover table-striped" data-editDialog="DialogFilterRule" data-editAlert="FilterRuleChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
@@ -51,6 +53,19 @@
</tr>
</tfoot>
</table>
<div class="col-md-12">
<div id="FilterRuleChangeMessage" class="alert alert-info" style="display: none" role="alert">
{{ lang._('After changing settings, please remember to apply them with the button below') }}
</div>
<hr/>
<button class="btn btn-primary" id="reconfigureAct"
data-endpoint='/api/firewall/filter/apply'
data-label="{{ lang._('Apply') }}"
data-error-title="{{ lang._('Filter load error') }}"
type="button"
></button>
<br/><br/>
</div>
</div>
</div>