Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
654def3e
Commit
654def3e
authored
May 27, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(trafficshaper) add initial rule setup to shaper UI
parent
afa6209b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
165 additions
and
41 deletions
+165
-41
IndexController.php
...pp/controllers/OPNsense/TrafficShaper/IndexController.php
+3
-0
dialogRule.xml
...p/controllers/OPNsense/TrafficShaper/forms/dialogRule.xml
+44
-0
index.volt
src/opnsense/mvc/app/views/OPNsense/TrafficShaper/index.volt
+118
-41
No files found.
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/IndexController.php
View file @
654def3e
...
...
@@ -37,7 +37,10 @@ class IndexController extends \OPNsense\Base\IndexController
public
function
indexAction
()
{
$this
->
view
->
title
=
"Traffic Shaper"
;
// include dialog form definitions
$this
->
view
->
formDialogPipe
=
$this
->
getForm
(
"dialogPipe"
);
$this
->
view
->
formDialogRule
=
$this
->
getForm
(
"dialogRule"
);
// choose template
$this
->
view
->
pick
(
'OPNsense/TrafficShaper/index'
);
}
}
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/forms/dialogRule.xml
0 → 100644
View file @
654def3e
<form>
<field>
<id>
rule.sequence
</id>
<label>
sequence
</label>
<type>
text
</type>
<help>
order in which the rule will be evaluated
</help>
</field>
<field>
<id>
rule.interface
</id>
<label>
interface
</label>
<type>
text
</type>
<help></help>
</field>
<field>
<id>
rule.proto
</id>
<label>
proto
</label>
<type>
dropdown
</type>
<help></help>
</field>
<field>
<id>
rule.source
</id>
<label>
source
</label>
<type>
text
</type>
<help></help>
</field>
<field>
<id>
rule.destination
</id>
<label>
destination
</label>
<type>
text
</type>
<help></help>
</field>
<field>
<id>
rule.target
</id>
<label>
target
</label>
<type>
dropdown
</type>
<help></help>
</field>
<field>
<id>
rule.description
</id>
<label>
description
</label>
<type>
text
</type>
<help></help>
</field>
</form>
\ No newline at end of file
src/opnsense/mvc/app/views/OPNsense/TrafficShaper/index.volt
View file @
654def3e
...
...
@@ -66,7 +66,6 @@ POSSIBILITY OF SUCH DAMAGE.
var uuid=$(this).data("row-id");
mapDataToFormUI({'frm_DialogPipe':"/api/trafficshaper/settings/getPipe/"+uuid}).done(function(){
// update selectors
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
// clear validation errors (if any)
clearFormValidation('frm_DialogPipe');
...
...
@@ -81,23 +80,13 @@ POSSIBILITY OF SUCH DAMAGE.
// delete item
gridPipes.find(".command-delete").on("click", function(e)
{
var uuid = $(this).data("row-id");
BootstrapDialog.confirm({
title: 'Remove',
message: 'Remove selected item?',
type: BootstrapDialog.TYPE_DANGER,
btnCancelLabel: 'Cancel',
btnOKLabel: 'Yes',
btnOKClass: 'btn-primary',
callback: function(result) {
if(result) {
var url = "/api/trafficshaper/settings/delPipe/" + uuid;
ajaxCall(url=url,sendData={},callback=function(data,status){
var uuid=$(this).data("row-id");
stdDialogRemoveItem('Remove selected item?',function() {
ajaxCall(url="/api/trafficshaper/settings/delPipe/" + uuid,
sendData={},callback=function(data,status){
// reload grid after delete
$("#grid-pipes").bootgrid("reload");
});
}
}
});
}).end();
});
...
...
@@ -128,28 +117,18 @@ POSSIBILITY OF SUCH DAMAGE.
* Delete list of uuids on click event
*/
$("#deletePipes").click(function(){
BootstrapDialog.confirm({
title: 'Remove',
message: 'Remove selected items?',
type: BootstrapDialog.TYPE_DANGER,
btnCancelLabel: 'Cancel',
btnOKLabel: 'Yes',
btnOKClass: 'btn-primary',
callback: function(result) {
if(result) {
stdDialogRemoveItem("Remove selected items?",function(){
var rows =$("#grid-pipes").bootgrid('getSelectedRows');
if (rows != undefined){
var deferreds = [];
$.each(rows, function(key,uuid){
deferreds.push(ajaxCall(url="/api/trafficshaper/settings/delPipe/" + uuid, sendData={}
));
deferreds.push(ajaxCall(url="/api/trafficshaper/settings/delPipe/" + uuid, sendData={},null
));
});
// refresh after load
$.when.apply(null, deferreds).done(function(){
$("#grid-pipes").bootgrid("reload");
});
}
}
}
});
});
...
...
@@ -159,7 +138,6 @@ POSSIBILITY OF SUCH DAMAGE.
$("#addPipe").click(function(){
mapDataToFormUI({'frm_DialogPipe':"/api/trafficshaper/settings/getPipe/"}).done(function(){
// update selectors
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
// clear validation errors (if any)
clearFormValidation('frm_DialogPipe');
...
...
@@ -173,9 +151,31 @@ POSSIBILITY OF SUCH DAMAGE.
});
/*************************************************************************************************************
*
*
manage rules
*************************************************************************************************************/
/**
* save form data to end point for existing rule
*/
function saveRule(uuid) {
saveFormToEndpoint(url="/api/trafficshaper/settings/setRule/"+uuid,
formid="frm_DialogRule", callback_ok=function(){
$("#DialogRule").modal('hide');
$("#grid-rules").bootgrid("reload");
});
}
/**
* save form data to end point for new pipe
*/
function addRule() {
saveFormToEndpoint(url="/api/trafficshaper/settings/addRule/",
formid="frm_DialogRule", callback_ok=function(){
$("#DialogRule").modal('hide');
$("#grid-rules").bootgrid("reload");
});
}
/**
* Render rules grid using searchPipes api
*/
...
...
@@ -194,6 +194,78 @@ POSSIBILITY OF SUCH DAMAGE.
}
});
/**
* Link rule grid command controls (edit/delete)
*/
gridRules.on("loaded.rs.jquery.bootgrid", function(){
// edit item
gridRules.find(".command-edit").on("click", function(e)
{
var uuid=$(this).data("row-id");
mapDataToFormUI({'frm_DialogRule':"/api/trafficshaper/settings/getRule/"+uuid}).done(function(){
// update selectors
$('.selectpicker').selectpicker('refresh');
// clear validation errors (if any)
clearFormValidation('frm_DialogRule');
});
// show dialog for pipe edit
$('#DialogRule').modal();
// curry uuid to save action
$("#btn_DialogRule_save").unbind('click').click(saveRule.bind(undefined, uuid));
}).end();
// delete item
gridRules.find(".command-delete").on("click", function(e)
{
var uuid = $(this).data("row-id");
stdDialogRemoveItem("Remove selected item?",function(){
ajaxCall(url="/api/trafficshaper/settings/delRule/" + uuid,
sendData={},callback=function(data,status){
// reload grid after delete
$("#grid-rules").bootgrid("reload");
});
});
}).end();
});
/**
* Add new rule on click event
*/
$("#addRule").click(function(){
mapDataToFormUI({'frm_DialogRule':"/api/trafficshaper/settings/getRule/"}).done(function(){
// update selectors
$('.selectpicker').selectpicker('refresh');
// clear validation errors (if any)
clearFormValidation('frm_DialogRule');
});
// show dialog for pipe edit
$('#DialogRule').modal();
// curry uuid to save action
$("#btn_DialogRule_save").unbind('click').click(addRule);
});
/**
* Delete list of uuids on click event
*/
$("#deleteRules").click(function(){
stdDialogRemoveItem("Remove selected items?",function(){
var rows =$("#grid-rules").bootgrid('getSelectedRows');
if (rows != undefined){
var deferreds = [];
$.each(rows, function(key,uuid){
deferreds.push(ajaxCall(url="/api/trafficshaper/settings/delRule/" + uuid, sendData={},null));
});
// refresh after load
$.when.apply(null, deferreds).done(function(){
$("#grid-rules").bootgrid("reload");
});
}
});
});
});
...
...
@@ -246,11 +318,13 @@ POSSIBILITY OF SUCH DAMAGE.
<table id="grid-rules" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th data-column-id="sequence" data-type="number">#</th>
<th data-column-id="origin" data-type="string">Origin</th>
<th data-column-id="interface" data-type="string">Interface</th>
<th data-column-id="proto" data-type="string">Protocol</th>
<th data-column-id="source" data-type="string">Source</th>
<th data-column-id="destination" data-type="string">Destination</th>
<th data-column-id="target" data-type="string">target</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
...
...
@@ -267,6 +341,8 @@ POSSIBILITY OF SUCH DAMAGE.
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<button type="button" id="addRule" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span></button>
<button type="button" id="deleteRules" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
...
...
@@ -283,4 +359,5 @@ POSSIBILITY OF SUCH DAMAGE.
{# include dialogs #}
{{ partial("layout_partials/base_dialog",['fields':formDialogPipe,'id':'DialogPipe','label':'Edit pipe'])}}
{{ partial("layout_partials/base_dialog",['fields':formDialogRule,'id':'DialogRule','label':'Edit rule'])}}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment