Skip to content

Commit 3ce99c9

Browse files
committed
Fix reversion - not returning to correct page after save
Settings and device save require different r=treatment on reload after save
1 parent 70b3180 commit 3ce99c9

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

assets/js/sccp_manager.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ $(document).ready(function () {
8686
url: 'ajax.php?module=sccp_manager&command=' + snd_command,
8787
data: vdata,
8888
success: function (data) {
89-
// FreePbx handles first and returns its own values removing data sent
90-
// so ajaxHandler echos data before return, and appends the ";#;" separator
91-
// FreePbx own data is the second json after the separator
92-
// without this this function fails as have 2 json fields.
93-
data = JSON.parse(data.split(';#;')[0]);
9489
if (data.status === true) {
9590
if (data.table_reload === true) {
9691
$('table').bootstrapTable('refresh');
@@ -105,8 +100,13 @@ $(document).ready(function () {
105100
// If posting warning, allow time to read
106101
var toastDelay = (data.toastFlag == 'success') ? 500 : 1500;
107102
if (data.reload === true) {
108-
//Need setTimout or reload will kill Toast
109-
setTimeout(function(){location.replace(newLocation);location.reload()},toastDelay);
103+
setTimeout(function(){
104+
location.replace(newLocation);
105+
if (data.search == `?display=sccpsettings`) {
106+
location.reload();
107+
}
108+
},
109+
toastDelay);
110110
}
111111
}
112112
} else {

module.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<module>
22
<rawname>sccp_manager</rawname>
33
<name>SCCP Manager</name>
4-
<version>14.3.0.29</version>
4+
<version>14.3.0.30</version>
55
<type>setup</type>
66
<category>SCCP Connectivity</category>
77
<publisher>Steve Lad, Alex GP</publisher>
@@ -35,6 +35,7 @@
3535
* Version 14.3.0.27 * - Standardise treatment of SIP and SCCP hardware.
3636
* Version 14.3.0.28 * - Fix issue with RNav which caused exception with new device
3737
* Version 14.3.0.29 * - Fix issue reloading page after saving settings and not restarting devices.
38+
* Version 14.3.0.30 * - Fix reversion in 29. Not returning to correct page when saving device.
3839
</changelog>
3940
<location>https://github.com/chan-sccp/sccp_manager</location>
4041
<supported>

sccpManTraits/ajaxHelper.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ public function ajaxHandler() {
5656

5757
// TODO: Need to be more specific on reload and only reload if critical settings changed.
5858
$res = $this->aminterface->core_sccp_reload();
59-
return true;
59+
return array('status' => true, 'message' => 'Data saved', 'reload' => true, 'toastFlag' => 'success', 'search' => '?display=sccpsettings', 'hash' => '');
6060
break;
6161
case 'save_sip_device':
6262
case 'save_device':
63-
$this->saveSccpDevice($request);
64-
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice');
63+
return $this->saveSccpDevice($request);
6564
break;
6665
case 'save_ruser':
6766
//$res = $request;
@@ -515,15 +514,6 @@ function handleSubmit($request, $validateonly = false) {
515514
// rewrite sccp.conf
516515
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
517516
$this->createDefaultSccpXml();
518-
519-
$toastFlag = 'success';
520-
$msg = 'Data saved';
521-
$search = '?display=sccpsettings';
522-
$hash = '';
523-
524-
echo json_encode(array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash)). ";#;" ;
525-
ob_flush();
526-
flush();
527517
}
528518

529519
public function getMyConfig($var = null, $id = "noid") {
@@ -782,10 +772,7 @@ function saveSccpDevice($get_settings, $validateonly = false) {
782772
}
783773
}
784774
$search = '?display=sccp_phone';
785-
echo json_encode(array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash)). ";#;" ;
786-
ob_flush();
787-
flush();
788-
return true;
775+
return array('status' => true, 'message' => $msg, 'reload' => true, 'toastFlag' => $toastFlag, 'search' => $search, 'hash' => $hash);
789776
}
790777

791778
}

0 commit comments

Comments
 (0)