From 3ce99c94d8a1fcef508e9b587bdd8a232af1af79 Mon Sep 17 00:00:00 2001 From: stevenA Date: Mon, 10 Jan 2022 14:00:07 +0100 Subject: [PATCH] Fix reversion - not returning to correct page after save Settings and device save require different r=treatment on reload after save --- assets/js/sccp_manager.js | 14 +++++++------- module.xml | 3 ++- sccpManTraits/ajaxHelper.php | 19 +++---------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index c31cd6f..b1b1d8f 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -86,11 +86,6 @@ $(document).ready(function () { url: 'ajax.php?module=sccp_manager&command=' + snd_command, data: vdata, success: function (data) { - // FreePbx handles first and returns its own values removing data sent - // so ajaxHandler echos data before return, and appends the ";#;" separator - // FreePbx own data is the second json after the separator - // without this this function fails as have 2 json fields. - data = JSON.parse(data.split(';#;')[0]); if (data.status === true) { if (data.table_reload === true) { $('table').bootstrapTable('refresh'); @@ -105,8 +100,13 @@ $(document).ready(function () { // If posting warning, allow time to read var toastDelay = (data.toastFlag == 'success') ? 500 : 1500; if (data.reload === true) { - //Need setTimout or reload will kill Toast - setTimeout(function(){location.replace(newLocation);location.reload()},toastDelay); + setTimeout(function(){ + location.replace(newLocation); + if (data.search == `?display=sccpsettings`) { + location.reload(); + } + }, + toastDelay); } } } else { diff --git a/module.xml b/module.xml index 012fff5..af15d68 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.29 + 14.3.0.30 setup SCCP Connectivity Steve Lad, Alex GP @@ -35,6 +35,7 @@ * Version 14.3.0.27 * - Standardise treatment of SIP and SCCP hardware. * Version 14.3.0.28 * - Fix issue with RNav which caused exception with new device * Version 14.3.0.29 * - Fix issue reloading page after saving settings and not restarting devices. + * Version 14.3.0.30 * - Fix reversion in 29. Not returning to correct page when saving device. https://github.com/chan-sccp/sccp_manager diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 63607c1..2aa2d97 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -56,12 +56,11 @@ trait ajaxHelper { // TODO: Need to be more specific on reload and only reload if critical settings changed. $res = $this->aminterface->core_sccp_reload(); - return true; + return array('status' => true, 'message' => 'Data saved', 'reload' => true, 'toastFlag' => 'success', 'search' => '?display=sccpsettings', 'hash' => ''); break; case 'save_sip_device': case 'save_device': - $this->saveSccpDevice($request); - return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice'); + return $this->saveSccpDevice($request); break; case 'save_ruser': //$res = $request; @@ -515,15 +514,6 @@ trait ajaxHelper { // rewrite sccp.conf $this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]); $this->createDefaultSccpXml(); - - $toastFlag = 'success'; - $msg = 'Data saved'; - $search = '?display=sccpsettings'; - $hash = ''; - - echo json_encode(array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash)). ";#;" ; - ob_flush(); - flush(); } public function getMyConfig($var = null, $id = "noid") { @@ -782,10 +772,7 @@ trait ajaxHelper { } } $search = '?display=sccp_phone'; - echo json_encode(array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash)). ";#;" ; - ob_flush(); - flush(); - return true; + return array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash); } }