- New style of information message
This commit is contained in:
parent
e4e720a182
commit
91d3fe1558
|
@ -662,7 +662,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
|
|
||||||
public function ajaxHandler() {
|
public function ajaxHandler() {
|
||||||
$request = $_REQUEST;
|
$request = $_REQUEST;
|
||||||
$msg = '';
|
$msg = array();
|
||||||
$cmd_id = $request['command'];
|
$cmd_id = $request['command'];
|
||||||
switch ($cmd_id) {
|
switch ($cmd_id) {
|
||||||
case 'savesettings':
|
case 'savesettings':
|
||||||
|
@ -677,7 +677,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
|
|
||||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload'));
|
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload'));
|
||||||
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone'));
|
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone'));
|
||||||
$msg = '<p>Config Saved: ' . $res['Response'] . ".</p> <p>Info :" . $res['data']."</p>";
|
$msg []= 'Config Saved: ' . $res['Response'];
|
||||||
|
$msg []= 'Info :' . $res['data'];
|
||||||
// needreload();
|
// needreload();
|
||||||
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
|
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
|
||||||
return array('status' => true, 'message' => $msg, 'reload' => true);
|
return array('status' => true, 'message' => $msg, 'reload' => true);
|
||||||
|
@ -757,17 +758,21 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
case 'reset_token':
|
case 'reset_token':
|
||||||
case 'reset_dev':
|
case 'reset_dev':
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
$msgr = array();
|
||||||
|
$msgr[] = 'Reset command send';
|
||||||
if (!empty($request['name'])) {
|
if (!empty($request['name'])) {
|
||||||
foreach ($request['name'] as $idv) {
|
foreach ($request['name'] as $idv) {
|
||||||
$msg = strpos($idv, 'SEP-');
|
$msg = strpos($idv, 'SEP-');
|
||||||
if (!(strpos($idv, 'SEP') === false)) {
|
if (!(strpos($idv, 'SEP') === false)) {
|
||||||
if ($cmd_id == 'reset_token') {
|
if ($cmd_id == 'reset_token') {
|
||||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $idv));
|
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $idv));
|
||||||
|
$msgr[] = $msg .' '. $res['Response'] . ' ' . $res['data'];
|
||||||
} else {
|
} else {
|
||||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv));
|
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv));
|
||||||
|
$msgr[] = $msg .' '. $res['Response'] . ' ' . $res['data'];
|
||||||
}
|
}
|
||||||
// $msg = print_r($this->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv)), 1);
|
// $msg = print_r($this->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv)), 1);
|
||||||
$msg = $res['Response'] . ' ' . $res['data'];
|
// $msg = $res['Response'] . ' ' . $res['data'];
|
||||||
}
|
}
|
||||||
if ($idv == 'all') {
|
if ($idv == 'all') {
|
||||||
$dev_list = $this->srvinterface->sccp_get_active_device();
|
$dev_list = $this->srvinterface->sccp_get_active_device();
|
||||||
|
@ -775,11 +780,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
if ($cmd_id == 'reset_token') {
|
if ($cmd_id == 'reset_token') {
|
||||||
if (($data['token'] == 'Rej') || ($data['status'] == 'Token ')) {
|
if (($data['token'] == 'Rej') || ($data['status'] == 'Token ')) {
|
||||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $key));
|
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $key));
|
||||||
$msg .= 'Send Token reset to :' . $key . ' ';
|
// $msg .= 'Send Token reset to :' . $key . ' <br>';
|
||||||
|
$msgr[] = 'Send Token reset to :' . $key ;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $key));
|
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $key));
|
||||||
$msg .= $res['Response'] . ' ' . $res['data'] . ' ';
|
// $msg .= $res['Response'] . ' ' . $res['data'] . ' <br>';
|
||||||
|
$msgr[] = $res['Response'] . ' ' . $res['data'];
|
||||||
}
|
}
|
||||||
// $msg .= $res['Response'] . ' ' . $res['data'] . ' ';
|
// $msg .= $res['Response'] . ' ' . $res['data'] . ' ';
|
||||||
}
|
}
|
||||||
|
@ -787,7 +794,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
|
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
|
||||||
return array('status' => true, 'message' => 'Reset command send ' . $msg, 'reload' => true);
|
return array('status' => true, 'message' => $msgr, 'reload' => true);
|
||||||
|
// return array('status' => true, 'message' => 'Reset command send <br>' . $msg, 'reload' => true);
|
||||||
// }
|
// }
|
||||||
break;
|
break;
|
||||||
case 'update_button_label':
|
case 'update_button_label':
|
||||||
|
|
|
@ -83,16 +83,12 @@ $(document).ready(function () {
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.status === true) {
|
if (data.status === true) {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
bs_alert(data.message);
|
bs_alert(data.message,data.status);
|
||||||
} else {
|
} else {
|
||||||
bs_alert('Data Save');
|
bs_alert('Data Save',data.status);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(data.message)) {
|
bs_alert(data.message,data.status);
|
||||||
data.message.forEach(function (entry) {
|
|
||||||
fpbxToast(entry, 'error', 'error');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -123,7 +119,7 @@ $(document).ready(function () {
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.status === true) {
|
if (data.status === true) {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
var old_style = bs_alert(data.message, data.reload);
|
var old_style = bs_alert(data.message, data.status, data.reload);
|
||||||
}
|
}
|
||||||
if (data.table_reload === true) {
|
if (data.table_reload === true) {
|
||||||
$('table').bootstrapTable('refresh');
|
$('table').bootstrapTable('refresh');
|
||||||
|
@ -146,11 +142,7 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(data.message)) {
|
bs_alert(data.message,data.status);
|
||||||
data.message.forEach(function (entry) {
|
|
||||||
fpbxToast(entry, 'error', 'error');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -202,7 +194,7 @@ $(document).ready(function () {
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
if (data.status === true) {
|
if (data.status === true) {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
var old_style = bs_alert(data.message, data.reload);
|
var old_style = bs_alert(data.message, data.status, data.reload);
|
||||||
}
|
}
|
||||||
if (data.table_reload === true) {
|
if (data.table_reload === true) {
|
||||||
$('table').bootstrapTable('refresh');
|
$('table').bootstrapTable('refresh');
|
||||||
|
@ -211,11 +203,7 @@ $(document).ready(function () {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(data.message)) {
|
bs_alert(data.message,data.status);
|
||||||
data.message.forEach(function (entry) {
|
|
||||||
fpbxToast(entry, 'error', 'error');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +633,7 @@ $(document).ready(function () {
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
if (data.status === true) {
|
if (data.status === true) {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
var old_style = bs_alert(data.message, data.reload);
|
var old_style = bs_alert(data.message, data.status,data.reload);
|
||||||
}
|
}
|
||||||
if (data.table_reload === true) {
|
if (data.table_reload === true) {
|
||||||
$('table').bootstrapTable('refresh');
|
$('table').bootstrapTable('refresh');
|
||||||
|
@ -656,14 +644,15 @@ $(document).ready(function () {
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(data.message)) {
|
if (Array.isArray(data.message)) {
|
||||||
data.message.forEach(function (entry) {
|
data.message.forEach(function (entry) {
|
||||||
fpbxToast(entry, 'error', 'error');
|
bs_alert(entry,data.status);
|
||||||
|
//fpbxToast(entry, 'error', 'error');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
bs_alert(data.message);
|
bs_alert(data.message,data.status);
|
||||||
} else {
|
} else {
|
||||||
if (data) {
|
if (data) {
|
||||||
bs_alert(data);
|
bs_alert(data,data.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -751,7 +740,7 @@ $("table").on("post-body.bs.table", function () {
|
||||||
});
|
});
|
||||||
toggle_reload_button("show");
|
toggle_reload_button("show");
|
||||||
} else {
|
} else {
|
||||||
bs_alert(data.message);
|
bs_alert(data.message, data.status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1001,25 +990,51 @@ var theForm = document.editIax;
|
||||||
return unescape(result);
|
return unescape(result);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
function bs_test() {
|
function bs_page_reload() {
|
||||||
// alert('asasasasas');
|
|
||||||
window.location.reload(false);
|
window.location.reload(false);
|
||||||
}
|
}
|
||||||
function bs_alert(data, reload)
|
function bs_alert(data, status, reload)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (document.getElementById('hwalert') === null) {
|
if (document.getElementById('hwalert') === null) {
|
||||||
alert(data);
|
if (Array.isArray(data)) {
|
||||||
|
data.forEach(function (entry) {
|
||||||
|
alert(entry);
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
alert(data);
|
||||||
|
}
|
||||||
return true; // Old style
|
return true; // Old style
|
||||||
} else {
|
} else {
|
||||||
var modal = $("#hwalert");
|
var modal = $("#hwalert");
|
||||||
modal.find('.modal-title').text('Success operation ');
|
if (typeof status != "undefined") {
|
||||||
modal.find('.modal-body').text(data);
|
if (status === true) {
|
||||||
|
modal.find('.modal-title').text('Operation result');
|
||||||
|
} else {
|
||||||
|
modal.find('.modal-title').text('Erroe operation ');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
modal.find('.modal-title').text('Operation result');
|
||||||
|
}
|
||||||
|
// var modal2 = modal.find('.modal-title');
|
||||||
|
// console.log(modal2);
|
||||||
|
// modal.find('.modal-body').text(data);
|
||||||
|
var modal2 = modal.find('.modal-body');
|
||||||
|
var msg_html = '';
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
data.forEach(function(entry) {
|
||||||
|
msg_html = msg_html + '<p>'+ entry + '</p>';
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
msg_html = data;
|
||||||
|
}
|
||||||
|
modal2[0].innerHTML = msg_html;
|
||||||
if (typeof reload != "undefined") {
|
if (typeof reload != "undefined") {
|
||||||
if (reload === true) {
|
if (reload === true) {
|
||||||
$("#hwalert").on('hidden.bs.modal', bs_test);
|
$("#hwalert").on('hidden.bs.modal', bs_page_reload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#hwalert").modal('show');
|
modal.modal('show');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue