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
9f9ac874
Commit
9f9ac874
authored
Jun 23, 2015
by
Jos Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(trafficshaper) add enable/disable rowtoggle option
parent
5b132f5a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
8 deletions
+72
-8
SettingsController.php
...rollers/OPNsense/TrafficShaper/Api/SettingsController.php
+62
-2
index.volt
src/opnsense/mvc/app/views/OPNsense/TrafficShaper/index.volt
+10
-6
No files found.
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php
View file @
9f9ac874
...
@@ -162,6 +162,36 @@ class SettingsController extends ApiControllerBase
...
@@ -162,6 +162,36 @@ class SettingsController extends ApiControllerBase
return
$result
;
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
* search traffic shaper pipes
* @return array
* @return array
...
@@ -186,7 +216,7 @@ class SettingsController extends ApiControllerBase
...
@@ -186,7 +216,7 @@ class SettingsController extends ApiControllerBase
$searchPhrase
=
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
);
$searchPhrase
=
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
);
// create model and fetch query resuls
// 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
();
$mdlShaper
=
new
TrafficShaper
();
$grid
=
new
UIModelGrid
(
$mdlShaper
->
pipes
->
pipe
);
$grid
=
new
UIModelGrid
(
$mdlShaper
->
pipes
->
pipe
);
return
$grid
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
return
$grid
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
...
@@ -220,7 +250,7 @@ class SettingsController extends ApiControllerBase
...
@@ -220,7 +250,7 @@ class SettingsController extends ApiControllerBase
$searchPhrase
=
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
);
$searchPhrase
=
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
);
// create model and fetch query resuls
// 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
();
$mdlShaper
=
new
TrafficShaper
();
$grid
=
new
UIModelGrid
(
$mdlShaper
->
queues
->
queue
);
$grid
=
new
UIModelGrid
(
$mdlShaper
->
queues
->
queue
);
return
$grid
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
return
$grid
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
...
@@ -313,6 +343,36 @@ class SettingsController extends ApiControllerBase
...
@@ -313,6 +343,36 @@ class SettingsController extends ApiControllerBase
return
$result
;
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
* search traffic shaper rules
* @return array
* @return array
...
...
src/opnsense/mvc/app/views/OPNsense/TrafficShaper/index.volt
View file @
9f9ac874
...
@@ -44,7 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
...
@@ -44,7 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
get:'/api/trafficshaper/settings/getPipe/',
get:'/api/trafficshaper/settings/getPipe/',
set:'/api/trafficshaper/settings/setPipe/',
set:'/api/trafficshaper/settings/setPipe/',
add:'/api/trafficshaper/settings/addPipe/',
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.
...
@@ -53,7 +54,8 @@ POSSIBILITY OF SUCH DAMAGE.
get:'/api/trafficshaper/settings/getQueue/',
get:'/api/trafficshaper/settings/getQueue/',
set:'/api/trafficshaper/settings/setQueue/',
set:'/api/trafficshaper/settings/setQueue/',
add:'/api/trafficshaper/settings/addQueue/',
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.
...
@@ -108,12 +110,13 @@ POSSIBILITY OF SUCH DAMAGE.
<thead>
<thead>
<tr>
<tr>
<th data-column-id="origin" data-type="string" data-visible="false">Origin</th>
<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="number" data-type="number" data-visible="false">Number</th>
<th data-column-id="bandwidth" data-type="number">Bandwidth</th>
<th data-column-id="bandwidth" data-type="number">Bandwidth</th>
<th data-column-id="bandwidthMetric" data-type="string">
Bandwidth
Metric</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="mask" data-type="string">Mask</th>
<th data-column-id="description" data-type="string">Description</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>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
</tr>
</tr>
</thead>
</thead>
...
@@ -136,11 +139,12 @@ POSSIBILITY OF SUCH DAMAGE.
...
@@ -136,11 +139,12 @@ POSSIBILITY OF SUCH DAMAGE.
<thead>
<thead>
<tr>
<tr>
<th data-column-id="origin" data-type="string" data-visible="false">Origin</th>
<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="number" data-type="number" data-visible="false">Number</th>
<th data-column-id="pipe" data-type="string">Pipe</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="weight" data-type="string">Weight</th>
<th data-column-id="description" data-type="string">Description</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>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
</tr>
</tr>
</thead>
</thead>
...
@@ -170,7 +174,7 @@ POSSIBILITY OF SUCH DAMAGE.
...
@@ -170,7 +174,7 @@ POSSIBILITY OF SUCH DAMAGE.
<th data-column-id="destination" data-type="string">Destination</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="target" data-type="string">Target</th>
<th data-column-id="description" data-type="string">Description</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>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
</tr>
</tr>
</thead>
</thead>
...
...
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