Commit 9f9ac874 authored by Jos Schellevis's avatar Jos Schellevis

(trafficshaper) add enable/disable rowtoggle option

parent 5b132f5a
......@@ -162,6 +162,36 @@ class SettingsController extends ApiControllerBase
return $result;
}
/**
* toggle pipe by uuid (enable/disable)
* @param $uuid item unique id
* @return array status
*/
public function togglePipeAction($uuid)
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
$mdlShaper = new TrafficShaper();
if ($uuid != null) {
$node = $mdlShaper->getNodeByReference('pipes.pipe.' . $uuid);
if ($node != null) {
if ($node->enabled->__toString() == "1") {
$result['result'] = "Disabled";
$node->enabled = "0";
} else {
$result['result'] = "Enabled";
$node->enabled = "1";
}
// if item has toggled, serialize to config and save
$mdlShaper->serializeToConfig($disable_validation = true);
Config::getInstance()->save();
}
}
}
return $result;
}
/**
* search traffic shaper pipes
* @return array
......@@ -186,7 +216,7 @@ class SettingsController extends ApiControllerBase
$searchPhrase = $this->request->getPost('searchPhrase', 'string', '');
// create model and fetch query resuls
$fields = array("number", "bandwidth","bandwidthMetric","description","mask","origin");
$fields = array("enabled","number", "bandwidth","bandwidthMetric","description","mask","origin");
$mdlShaper = new TrafficShaper();
$grid = new UIModelGrid($mdlShaper->pipes->pipe);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase);
......@@ -220,7 +250,7 @@ class SettingsController extends ApiControllerBase
$searchPhrase = $this->request->getPost('searchPhrase', 'string', '');
// create model and fetch query resuls
$fields = array("number", "pipe","weight","description","mask","origin");
$fields = array("enabled","number", "pipe","weight","description","mask","origin");
$mdlShaper = new TrafficShaper();
$grid = new UIModelGrid($mdlShaper->queues->queue);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase);
......@@ -313,6 +343,36 @@ class SettingsController extends ApiControllerBase
return $result;
}
/**
* toggle queue by uuid (enable/disable)
* @param $uuid item unique id
* @return array status
*/
public function toggleQueueAction($uuid)
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
$mdlShaper = new TrafficShaper();
if ($uuid != null) {
$node = $mdlShaper->getNodeByReference('queues.queue.'.$uuid);
if ($node != null) {
if ($node->enabled->__toString() == "1") {
$result['result'] = "Disabled";
$node->enabled = "0";
} else {
$result['result'] = "Enabled";
$node->enabled = "1";
}
// if item has toggled, serialize to config and save
$mdlShaper->serializeToConfig($disable_validation = true);
Config::getInstance()->save();
}
}
}
return $result;
}
/**
* search traffic shaper rules
* @return array
......
......@@ -44,7 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
get:'/api/trafficshaper/settings/getPipe/',
set:'/api/trafficshaper/settings/setPipe/',
add:'/api/trafficshaper/settings/addPipe/',
del:'/api/trafficshaper/settings/delPipe/'
del:'/api/trafficshaper/settings/delPipe/',
toggle:'/api/trafficshaper/settings/togglePipe/'
}
);
......@@ -53,7 +54,8 @@ POSSIBILITY OF SUCH DAMAGE.
get:'/api/trafficshaper/settings/getQueue/',
set:'/api/trafficshaper/settings/setQueue/',
add:'/api/trafficshaper/settings/addQueue/',
del:'/api/trafficshaper/settings/delQueue/'
del:'/api/trafficshaper/settings/delQueue/',
toggle:'/api/trafficshaper/settings/toggleQueue/'
}
);
......@@ -108,12 +110,13 @@ POSSIBILITY OF SUCH DAMAGE.
<thead>
<tr>
<th data-column-id="origin" data-type="string" data-visible="false">Origin</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">Enabled</th>
<th data-column-id="number" data-type="number" data-visible="false">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="bandwidthMetric" data-type="string">Metric</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="commands" data-width="7em" 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>
......@@ -136,11 +139,12 @@ POSSIBILITY OF SUCH DAMAGE.
<thead>
<tr>
<th data-column-id="origin" data-type="string" data-visible="false">Origin</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">Enabled</th>
<th data-column-id="number" data-type="number" data-visible="false">Number</th>
<th data-column-id="pipe" data-type="string">Pipe</th>
<th data-column-id="weight" data-type="string">Weight</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="commands" data-width="7em" 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>
......@@ -170,7 +174,7 @@ POSSIBILITY OF SUCH DAMAGE.
<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="commands" data-width="7em" 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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment