mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
(trafficshaper) work in progress traffic shaper, add initial rule configuration
This commit is contained in:
parent
93a3c51cc6
commit
ce244e804c
@ -189,4 +189,37 @@ class SettingsController extends ApiControllerBase
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* search traffic shaper rules
|
||||
* @return array
|
||||
*/
|
||||
public function searchRulesAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// fetch query parameters
|
||||
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
|
||||
$currentPage = $this->request->getPost('current', 'int', 1);
|
||||
$sortBy = array("number");
|
||||
$sortDescending = false;
|
||||
|
||||
if ($this->request->hasPost('sort') && is_array($this->request->getPost("sort"))) {
|
||||
$sortBy = array_keys($this->request->getPost("sort"));
|
||||
if ($this->request->getPost("sort")[$sortBy[0]] == "desc") {
|
||||
$sortDescending = true;
|
||||
}
|
||||
}
|
||||
|
||||
$searchPhrase = $this->request->getPost('searchPhrase', 'string', '');
|
||||
|
||||
// create model and fetch query resuls
|
||||
$fields = array("interface", "proto","source","destination","description","origin");
|
||||
$mdlShaper = new TrafficShaper();
|
||||
$grid = new UIModelGrid($mdlShaper->rules->rule);
|
||||
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,13 +3,29 @@
|
||||
<id>pipe.bandwidth</id>
|
||||
<label>bandwidth</label>
|
||||
<type>text</type>
|
||||
<help>test
|
||||
</help>
|
||||
<help>Total bandwidth for this pipe</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>pipe.bandwidthMetric</id>
|
||||
<label>Enable traffic management.</label>
|
||||
<label>bandwidth Metric</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[test]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>pipe.queue</id>
|
||||
<label>queue</label>
|
||||
<type>text</type>
|
||||
<help>test</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>pipe.mask</id>
|
||||
<label>mask</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[Dynamic queue creation by source or destination address]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>pipe.description</id>
|
||||
<label>description</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
@ -9,13 +9,14 @@
|
||||
<number type="IntegerField">
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage></ValidationMessage>
|
||||
<ValidationMessage>Pipe number must be between 1...65535</ValidationMessage>
|
||||
<Required>Y</Required>
|
||||
</number>
|
||||
<bandwidth type="IntegerField">
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>899795</MaximumValue>
|
||||
<ValidationMessage>Bandwidth out of range</ValidationMessage>
|
||||
</bandwidth>
|
||||
<bandwidthMetric type="OptionField">
|
||||
<Required>Y</Required>
|
||||
@ -29,19 +30,23 @@
|
||||
</bandwidthMetric>
|
||||
<queue type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>2</MinimumValue>
|
||||
<MaximumValue>100</MaximumValue>
|
||||
<ValidationMessage>queue size should be between 2...100</ValidationMessage>
|
||||
</queue>
|
||||
<queueMetric type="OptionField">
|
||||
<Required>N</Required>
|
||||
<default>slots</default>
|
||||
<mask type="OptionField">
|
||||
<Required>Y</Required>
|
||||
<default>none</default>
|
||||
<OptionValues>
|
||||
<slots>Slots</slots>
|
||||
<bit>bit/s</bit>
|
||||
<Kbit>Kbit/s</Kbit>
|
||||
<Mbit>Mbit/s</Mbit>
|
||||
<none></none>
|
||||
<source>source</source>
|
||||
<destination>destination</destination>
|
||||
</OptionValues>
|
||||
</queueMetric>
|
||||
</mask>
|
||||
<origin type="TextField">
|
||||
<Required>N</Required>
|
||||
<mask>/^([a-z,A-Z,1-9]){0,30}$/</mask>
|
||||
<ValidationMessage>origin should be regular text of max 30 characters</ValidationMessage>
|
||||
</origin>
|
||||
<description type="TextField">
|
||||
<Required>N</Required>
|
||||
@ -50,12 +55,10 @@
|
||||
</pipes>
|
||||
<rules>
|
||||
<rule type="ArrayField">
|
||||
<pipe type="IntegerField">
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage></ValidationMessage>
|
||||
<interface type="TextField">
|
||||
<Required>Y</Required>
|
||||
</pipe>
|
||||
<default>wan</default>
|
||||
</interface>
|
||||
<proto type="OptionField">
|
||||
<Required>Y</Required>
|
||||
<default>ip</default>
|
||||
@ -65,13 +68,28 @@
|
||||
<tcp>tcp</tcp>
|
||||
</OptionValues>
|
||||
</proto>
|
||||
<interface type="TextField">
|
||||
<source type="TextField">
|
||||
<Required>Y</Required>
|
||||
<default>wan</default>
|
||||
</interface>
|
||||
<default>any</default>
|
||||
</source>
|
||||
<destination type="TextField">
|
||||
<Required>Y</Required>
|
||||
<default>any</default>
|
||||
</destination>
|
||||
<target type="IntegerField">
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage></ValidationMessage>
|
||||
<Required>Y</Required>
|
||||
</target>
|
||||
<description type="TextField">
|
||||
<Required>N</Required>
|
||||
</description>
|
||||
<origin type="TextField">
|
||||
<Required>N</Required>
|
||||
<mask>/^([a-z,A-Z,1-9]){0,30}$/</mask>
|
||||
<ValidationMessage>origin should be regular text of max 30 characters</ValidationMessage>
|
||||
</origin>
|
||||
</rule>
|
||||
</rules>
|
||||
</items>
|
||||
|
||||
@ -34,6 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
/*************************************************************************************************************
|
||||
* manage bandwidth pipes
|
||||
*************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Render pipe grid using searchPipes api
|
||||
*/
|
||||
@ -41,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
ajax: true,
|
||||
selection: true,
|
||||
multiSelect: true,
|
||||
rowCount:[7,14,20,-1],
|
||||
url: '/api/trafficshaper/settings/searchPipes',
|
||||
formatters: {
|
||||
"commands": function(column, row)
|
||||
@ -167,38 +172,113 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
});
|
||||
|
||||
/*************************************************************************************************************
|
||||
*
|
||||
*************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Render rules grid using searchPipes api
|
||||
*/
|
||||
var gridRules =$("#grid-rules").bootgrid({
|
||||
ajax: true,
|
||||
selection: true,
|
||||
multiSelect: true,
|
||||
rowCount:[7,14,20,-1],
|
||||
url: '/api/trafficshaper/settings/searchRules',
|
||||
formatters: {
|
||||
"commands": function(column, row)
|
||||
{
|
||||
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.uuid + "\"><span class=\"fa fa-pencil\"></span></button> " +
|
||||
"<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.uuid + "\"><span class=\"fa fa-trash-o\"></span></button>";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<table id="grid-pipes" class="table table-condensed table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="number" data-type="number">Number</th>
|
||||
<th data-column-id="bandwidth" data-type="number">Bandwidth</th>
|
||||
<th data-column-id="bandwidthMetric" data-type="string">BandwidthMetric</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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<button type="button" id="addPipe" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span></button>
|
||||
<button type="button" id="deletePipes" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-12" id="content">
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
<li class="active"><a data-toggle="tab" href="#pipes">{{ lang._('Pipes') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#rules">{{ lang._('Rules') }}</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="pipes" class="tab-pane fade in active">
|
||||
<!-- tab page "pipes" -->
|
||||
<table id="grid-pipes" class="table table-condensed table-hover table-striped table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="origin" data-type="string">Origin</th>
|
||||
<th data-column-id="number" data-type="number">Number</th>
|
||||
<th data-column-id="bandwidth" data-type="number">Bandwidth</th>
|
||||
<th data-column-id="bandwidthMetric" data-type="string">BandwidthMetric</th>
|
||||
<th data-column-id="mask" data-type="string">mask</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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<button type="button" id="addPipe" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span></button>
|
||||
<button type="button" id="deletePipes" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div id="rules" class="tab-pane fade in">
|
||||
<!-- tab page "rules" -->
|
||||
<table id="grid-rules" class="table table-condensed table-hover table-striped table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<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="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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{# include dialogs #}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user