Fix reversion - not returning to correct page after save

Settings and device save require different r=treatment on reload after save
This commit is contained in:
stevenA 2022-01-10 14:00:07 +01:00
parent 70b318019e
commit 3ce99c94d8
3 changed files with 12 additions and 24 deletions

View file

@ -86,11 +86,6 @@ $(document).ready(function () {
url: 'ajax.php?module=sccp_manager&command=' + snd_command, url: 'ajax.php?module=sccp_manager&command=' + snd_command,
data: vdata, data: vdata,
success: function (data) { 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.status === true) {
if (data.table_reload === true) { if (data.table_reload === true) {
$('table').bootstrapTable('refresh'); $('table').bootstrapTable('refresh');
@ -105,8 +100,13 @@ $(document).ready(function () {
// If posting warning, allow time to read // If posting warning, allow time to read
var toastDelay = (data.toastFlag == 'success') ? 500 : 1500; var toastDelay = (data.toastFlag == 'success') ? 500 : 1500;
if (data.reload === true) { if (data.reload === true) {
//Need setTimout or reload will kill Toast setTimeout(function(){
setTimeout(function(){location.replace(newLocation);location.reload()},toastDelay); location.replace(newLocation);
if (data.search == `?display=sccpsettings`) {
location.reload();
}
},
toastDelay);
} }
} }
} else { } else {

View file

@ -1,7 +1,7 @@
<module> <module>
<rawname>sccp_manager</rawname> <rawname>sccp_manager</rawname>
<name>SCCP Manager</name> <name>SCCP Manager</name>
<version>14.3.0.29</version> <version>14.3.0.30</version>
<type>setup</type> <type>setup</type>
<category>SCCP Connectivity</category> <category>SCCP Connectivity</category>
<publisher>Steve Lad, Alex GP</publisher> <publisher>Steve Lad, Alex GP</publisher>
@ -35,6 +35,7 @@
* Version 14.3.0.27 * - Standardise treatment of SIP and SCCP hardware. * 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.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.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.
</changelog> </changelog>
<location>https://github.com/chan-sccp/sccp_manager</location> <location>https://github.com/chan-sccp/sccp_manager</location>
<supported> <supported>

View file

@ -56,12 +56,11 @@ trait ajaxHelper {
// TODO: Need to be more specific on reload and only reload if critical settings changed. // TODO: Need to be more specific on reload and only reload if critical settings changed.
$res = $this->aminterface->core_sccp_reload(); $res = $this->aminterface->core_sccp_reload();
return true; return array('status' => true, 'message' => 'Data saved', 'reload' => true, 'toastFlag' => 'success', 'search' => '?display=sccpsettings', 'hash' => '');
break; break;
case 'save_sip_device': case 'save_sip_device':
case 'save_device': case 'save_device':
$this->saveSccpDevice($request); return $this->saveSccpDevice($request);
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice');
break; break;
case 'save_ruser': case 'save_ruser':
//$res = $request; //$res = $request;
@ -515,15 +514,6 @@ trait ajaxHelper {
// rewrite sccp.conf // rewrite sccp.conf
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]); $this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
$this->createDefaultSccpXml(); $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") { public function getMyConfig($var = null, $id = "noid") {
@ -782,10 +772,7 @@ trait ajaxHelper {
} }
} }
$search = '?display=sccp_phone'; $search = '?display=sccp_phone';
echo json_encode(array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash)). ";#;" ; return array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash);
ob_flush();
flush();
return true;
} }
} }