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
cdf02767
Commit
cdf02767
authored
Mar 09, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work in progress proxy feature
parent
e6fce622
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
22 deletions
+54
-22
ServiceController.php
.../app/controllers/OPNsense/Proxy/Api/ServiceController.php
+19
-0
IndexController.php
...se/mvc/app/controllers/OPNsense/Proxy/IndexController.php
+1
-0
index.volt
src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt
+26
-19
opnsense_ui.js
src/opnsense/www/js/opnsense_ui.js
+8
-3
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php
View file @
cdf02767
...
...
@@ -91,4 +91,23 @@ class ServiceController extends ApiControllerBase
return
array
(
"status"
=>
$status
);
}
/**
* reconfigure squid, generate config and reload
*/
public
function
reconfigureAction
()
{
$backend
=
new
Backend
();
$backend
->
sendEvent
(
"template reload OPNsense.Proxy"
);
$runStatus
=
$this
->
statusAction
();
if
(
$runStatus
==
"running"
)
{
$backend
->
sendEvent
(
"service reconfigure proxy"
);
}
else
{
$this
->
startAction
();
}
return
array
(
"status"
=>
"ok"
);
}
}
src/opnsense/mvc/app/controllers/OPNsense/Proxy/IndexController.php
View file @
cdf02767
...
...
@@ -36,6 +36,7 @@ class IndexController extends \OPNsense\Base\IndexController
{
public
function
indexAction
()
{
$this
->
view
->
title
=
"Proxy"
;
$this
->
view
->
pick
(
'OPNsense/Proxy/index'
);
}
}
src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt
View file @
cdf02767
...
...
@@ -10,24 +10,26 @@
// form event handlers
$("#save").click(function(){
data = getFormData("frm_general");
ajaxCall(url="/api/proxy/settings/set",sendData=data,callback=function(data,status){
if ( status == "success") {
handleFormValidation("frm_general",data['validations']);
if (data['validations'] != undefined) {
saveFormToEndpoint(url="/api/proxy/settings/set",formid="frm_general",callback_ok=function(){
// on correct save, perform reconfigure. set progress animation when reloading
$("#frm_general_progress").addClass("fa fa-spinner fa-pulse");
//
ajaxCall(url="/api/proxy/service/reconfigure", sendData={}, callback=function(data,status){
// when done, disable progress animation.
$("#frm_general_progress").removeClass("fa fa-spinner fa-pulse");
if (status != "success" || data['status'] != 'ok' ) {
// fix error handling
BootstrapDialog.show({
type:BootstrapDialog.TYPE_WARNING,
title: '
Input validation
',
message:
'Please correct validation errors in form'
title: '
Proxy
',
message:
JSON.stringify(data)
});
}
}
// TODO: implement error handling
//alert(status);
});
});
});
});
...
...
@@ -42,24 +44,29 @@
<div class="content-box tab-content">
<div id="tabGeneral" class="tab-pane fade in active">
<form id="frm_general" class="form-inline">
<table class="table table-striped">
<table class="table table-striped
table-condensed table-responsive
">
<colgroup>
<col class="col-md-3">
<col class="col-md-4">
<col class="col-md-5">
<col class="col-md-3"
/
>
<col class="col-md-4"
/
>
<col class="col-md-5"
/
>
</colgroup>
<tbody>
{{ partial("layout_partials/form_input_tr",
['id': 'general.enabled',
'label':'enabled',
'type':'checkbox',
'help':'gfvjhgghfh'
'help':'test'
])
}}
{{ partial("layout_partials/form_input_tr",
['id': 'general.port',
'label':'port',
'type':'text'
])
}}
{{ partial("layout_partials/form_input_tr", ['id': 'general.port','label':'test','type':'text']) }}
<tr>
<td colspan="3"><button class="btn btn-primary" id="save" type="button">
Save
</button></td>
<td colspan="3"><button class="btn btn-primary" id="save" type="button">
Apply <i id="frm_general_progress" class=""></i>
</button></td>
</tr>
</tbody>
</table>
...
...
src/opnsense/www/js/opnsense_ui.js
View file @
cdf02767
...
...
@@ -7,20 +7,25 @@
* @param url endpoint url
* @param formid parent id to grep input data from
*/
function
saveFormToEndpoint
(
url
,
formid
)
{
function
saveFormToEndpoint
(
url
,
formid
,
callback_ok
)
{
data
=
getFormData
(
formid
);
ajaxCall
(
url
=
url
,
sendData
=
data
,
callback
=
function
(
data
,
status
){
if
(
status
==
"
success
"
)
{
// update field validation
handleFormValidation
(
formid
,
data
[
'
validations
'
]);
// if there are validation issues, update our screen and show a dialog.
if
(
data
[
'
validations
'
]
!=
undefined
)
{
// update field validation
handleFormValidation
(
formid
,
data
[
'
validations
'
]);
BootstrapDialog
.
show
({
type
:
BootstrapDialog
.
TYPE_WARNING
,
title
:
'
Input validation
'
,
message
:
'
Please correct validation errors in form
'
});
}
else
if
(
callback_ok
!=
undefined
)
{
// execute callback function
callback_ok
();
}
}
else
{
// error handling, show internal errors
// Normally the form should only return validation issues, if other things go wrong throw an error.
...
...
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