diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php index 5f3a13abb..c53ebc73b 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php @@ -79,12 +79,19 @@ class ServiceController extends ApiControllerBase public function statusAction() { $backend = new Backend(); + $mdlProxy = new Proxy(); $response = $backend->configdRun("proxy status"); if (strpos($response, "not running") > 0) { - $status = "stopped"; + if ($mdlProxy->general->enabled->__toString() == 1) { + $status = "stopped"; + } else { + $status = "disabled"; + } } elseif (strpos($response, "is running") > 0) { $status = "running"; + } elseif ($mdlProxy->general->enabled->__toString() == 0) { + $status = "disabled"; } else { $status = "unkown"; } diff --git a/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt b/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt index 4994f802a..f461b18b7 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt @@ -30,23 +30,21 @@ POSSIBILITY OF SUCH DAMAGE. $( document ).ready(function() { - data_get_map = {'frm_proxy':"/api/proxy/settings/get"}; + var data_get_map = {'frm_proxy':"/api/proxy/settings/get"}; + + // load initial data - $.each(data_get_map, function(data_index, data_url) { - ajaxGet(url=data_url,sendData={},callback=function(data,status) { - if (status == "success") { - $("form").each(function( index ) { - if ( $(this).attr('id').split('-')[0] == data_index) { - // related form found, load data - setFormData($(this).attr('id'),data); - } - }); - } + mapDataToFormUI(data_get_map).done(function(){ + formatTokenizersUI(); + $('.selectpicker').selectpicker('refresh'); + // request service status on load and update status box + ajaxCall(url="/api/proxy/service/status", sendData={}, callback=function(data,status) { + updateServiceStatusUI("proxy",data['responseText']); }); }); - // form event handlers + // form save event handlers for all defined forms $('[id*="save_"]').each(function(){ $(this).click(function() { var frm_id = $(this).closest("form").attr("id"); @@ -69,100 +67,18 @@ POSSIBILITY OF SUCH DAMAGE. message: JSON.stringify(data), draggable: true }); + } else { + // request service status after successful save and update status box + ajaxCall(url="/api/proxy/service/status", sendData={}, callback=function(data,status) { + updateServiceStatusUI("proxy",data['responseText']); + }); } }); - }); }); }); - // handle help messages show/hide - $('[id*="show_all_help"]').click(function() { - $('[id*="show_all_help"]').toggleClass("fa-toggle-on fa-toggle-off"); - $('[id*="show_all_help"]').toggleClass("text-success text-danger"); - if ($('[id*="show_all_help"]').hasClass("fa-toggle-on")) { - $('[for*="help_for"]').addClass("show"); - $('[for*="help_for"]').removeClass("hidden"); - } else { - $('[for*="help_for"]').addClass("hidden"); - $('[for*="help_for"]').removeClass("show"); - } - }); - - // handle advanced show/hide - $('[data-advanced*="true"]').hide(function(){ - $('[data-advanced*="true"]').after("