From ee1da31da0d6ca3826b257b3c00559187ce75ca3 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 7 Feb 2021 13:50:55 +0000 Subject: [PATCH] Code cleanup --- ajax/openvpn/activate_ovpncfg.php | 19 ++++++------------- app/js/custom.js | 14 +++----------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/ajax/openvpn/activate_ovpncfg.php b/ajax/openvpn/activate_ovpncfg.php index 2f1e808d..b8f822c2 100644 --- a/ajax/openvpn/activate_ovpncfg.php +++ b/ajax/openvpn/activate_ovpncfg.php @@ -1,12 +1,9 @@ addMessage('Attempting to restart OpenVPN', 'info'); - exec('sudo /bin/systemctl stop openvpn-client@client', $return); - exec('sudo /bin/systemctl enable openvpn-client@client', $return); - exec('sudo /bin/systemctl start openvpn-client@client', $return); + exec("sudo /bin/systemctl stop openvpn-client@client", $return); + sleep(1); + exec("sudo /bin/systemctl enable openvpn-client@client", $return); + sleep(1); + exec("sudo /bin/systemctl start openvpn-client@client", $return); - foreach ($return as $line) { - $status->addMessage($line, 'info'); - } - $return = $status; - $jsonData = ['return'=>$return]; - echo json_encode($jsonData); + echo json_encode($return); } diff --git a/app/js/custom.js b/app/js/custom.js index 92c73eba..b1f445ce 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -274,26 +274,18 @@ $('#ovpn-confirm-delete').on('show.bs.modal', function (e) { }); $('#ovpn-confirm-activate').on('click', '.btn-activate', function (e) { - //var modalDiv = $(e.delegateTarget); var cfg_id = $(this).data('recordId'); - console.log(cfg_id); - $.post('ajax/openvpn/activate_ovpncfg.php',{'cfg_id':cfg_id},function(data){ jsonData = JSON.parse(data); - console.log(jsonData); - //$(this).closest('js-openvpn-client-row').fadeOut(300); $("#ovpn-confirm-activate").modal('hide'); - if(jsonData['return'] == 0) { - // do something - } else if(jsonData['return'] == 2) { - // something else - } + setTimeout(function(){ + window.location.reload(); + },300); }); }); $('#ovpn-confirm-activate').on('shown.bs.modal', function (e) { var data = $(e.relatedTarget).data(); - console.log(data.recordId); $('.btn-activate', this).data('recordId', data.recordId); });