Calls Active: Show gateway name instead of uuid in Application data string, change to jQuery ajax refresh.
This commit is contained in:
parent
bc7e7f1551
commit
23f0d8ed1b
|
|
@ -45,11 +45,25 @@ else {
|
|||
$document['title'] = $text['title'];
|
||||
require_once "resources/header.php";
|
||||
|
||||
//load gateways into a session variable
|
||||
$sql = "select gateway_uuid, domain_uuid, gateway from v_gateways where enabled = 'true'";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as $row) {
|
||||
$_SESSION['gateways'][$row['gateway_uuid']] = $row['gateway'];
|
||||
}
|
||||
}
|
||||
unset($sql, $prep_statement, $result, $row);
|
||||
|
||||
//ajax for refresh
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//define refresh function, initial start
|
||||
var refresh = 1500;
|
||||
var source_url = 'calls_active_inc.php?';
|
||||
var timer_id;
|
||||
<?php
|
||||
if ($show == 'all') {
|
||||
echo "source_url = source_url + '&show=all';";
|
||||
|
|
@ -58,67 +72,26 @@ else {
|
|||
echo "source_url = source_url + '&debug';";
|
||||
}
|
||||
?>
|
||||
var interval_timer_id;
|
||||
var ajax_get = function () {
|
||||
$.ajax({
|
||||
url: source_url, success: function(response){
|
||||
$("#ajax_reponse").html(response);
|
||||
}
|
||||
});
|
||||
timer_id = setTimeout(ajax_get, refresh);
|
||||
};
|
||||
|
||||
function loadXmlHttp(url, id) {
|
||||
var f = this;
|
||||
f.xmlHttp = null;
|
||||
/*@cc_on @*/ // used here and below, limits try/catch to those IE browsers that both benefit from and support it
|
||||
/*@if(@_jscript_version >= 5) // prevents errors in old browsers that barf on try/catch & problems in IE if Active X disabled
|
||||
try {f.ie = window.ActiveXObject}catch(e){f.ie = false;}
|
||||
@end @*/
|
||||
if (window.XMLHttpRequest&&!f.ie||/^http/.test(window.location.href))
|
||||
f.xmlHttp = new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari, others, IE 7+ when live - this is the standard method
|
||||
else if (/(object)|(function)/.test(typeof createRequest))
|
||||
f.xmlHttp = createRequest(); // ICEBrowser, perhaps others
|
||||
else {
|
||||
f.xmlHttp = null;
|
||||
// Internet Explorer 5 to 6, includes IE 7+ when local //
|
||||
/*@cc_on @*/
|
||||
/*@if(@_jscript_version >= 5)
|
||||
try{f.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
|
||||
catch (e){try{f.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){f.xmlHttp=null;}}
|
||||
@end @*/
|
||||
}
|
||||
if(f.xmlHttp != null){
|
||||
f.el = document.getElementById(id);
|
||||
f.xmlHttp.open("GET",url,true);
|
||||
f.xmlHttp.onreadystatechange = function(){f.stateChanged();};
|
||||
f.xmlHttp.send(null);
|
||||
}
|
||||
}
|
||||
|
||||
loadXmlHttp.prototype.stateChanged=function () {
|
||||
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
|
||||
//this.el.innerHTML = this.xmlHttp.responseText;
|
||||
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText;
|
||||
}
|
||||
|
||||
var requestTime = function() {
|
||||
var url = source_url;
|
||||
new loadXmlHttp(url, 'ajax_reponse');
|
||||
refresh_start();
|
||||
}
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('load', requestTime, false);
|
||||
}
|
||||
else if (window.attachEvent) {
|
||||
window.attachEvent('onload', requestTime);
|
||||
}
|
||||
refresh_start();
|
||||
|
||||
//refresh controls
|
||||
function refresh_stop() {
|
||||
clearInterval(interval_timer_id);
|
||||
clearTimeout(timer_id);
|
||||
document.getElementById('refresh_state').innerHTML = "<img src='resources/images/refresh_paused.png' style='width: 16px; height: 16px; border: none; margin-top: 1px; cursor: pointer;' onclick='refresh_start();' alt=\"<?php echo $text['label-refresh_enable']?>\" title=\"<?php echo $text['label-refresh_enable']?>\">";
|
||||
}
|
||||
|
||||
function refresh_start() {
|
||||
if (document.getElementById('refresh_state')) { document.getElementById('refresh_state').innerHTML = "<img src='resources/images/refresh_active.gif' style='width: 16px; height: 16px; border: none; margin-top: 3px; cursor: pointer;' alt=\"<?php echo $text['label-refresh_pause']?>\" title=\"<?php echo $text['label-refresh_pause']?>\">"; }
|
||||
interval_timer_id = setInterval( function() {
|
||||
url = source_url;
|
||||
new loadXmlHttp(url, 'ajax_reponse');
|
||||
}, refresh);
|
||||
ajax_get();
|
||||
}
|
||||
|
||||
//call controls
|
||||
|
|
|
|||
|
|
@ -170,6 +170,13 @@ else {
|
|||
//remove the '+' because it breaks the call recording
|
||||
$cid_num = str_replace("+", "", $cid_num);
|
||||
|
||||
//replace gateway uuid with name
|
||||
if (sizeof($_SESSION['gateways']) > 0) {
|
||||
foreach ($_SESSION['gateways'] as $gateway_uuid => $gateway_name) {
|
||||
$application_data = str_replace($gateway_uuid, $gateway_name, $application_data);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td valign='top' class='".$row_style[$c]."'>".$sip_profile." </td>\n";
|
||||
echo "<td valign='top' class='".$row_style[$c]."'>".$created." </td>\n";
|
||||
|
|
|
|||
|
|
@ -147,6 +147,11 @@ else {
|
|||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//add new gateway to session variable
|
||||
if ($enabled == 'true') {
|
||||
$_SESSION['gateways'][$gateway_uuid] = $gateway;
|
||||
}
|
||||
|
||||
//synchronize the xml config
|
||||
save_gateway_xml();
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ if (strlen($_GET["id"])>0) {
|
|||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//remove gateway from session variable
|
||||
unset($_SESSION['gateways'][$gateway_uuid]);
|
||||
|
||||
//delete the xml file
|
||||
if ($_SESSION['switch']['sip_profiles']['dir'] != '') {
|
||||
$gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir']."/".$profile."/v_".$gateway_uuid.".xml";
|
||||
|
|
|
|||
|
|
@ -237,6 +237,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//add new gateway to session variable
|
||||
if ($enabled == 'true') {
|
||||
$_SESSION['gateways'][$gateway_uuid] = $gateway;
|
||||
}
|
||||
|
||||
} //if ($action == "add")
|
||||
|
||||
if ($action == "update" && permission_exists('gateway_edit')) {
|
||||
|
|
@ -277,6 +283,15 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
$sql .= "where gateway_uuid = '$gateway_uuid'";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//update gateway session variable
|
||||
if ($enabled == 'true') {
|
||||
$_SESSION['gateways'][$gateway_uuid] = $gateway;
|
||||
}
|
||||
else {
|
||||
unset($_SESSION['gateways'][$gateway_uuid]);
|
||||
}
|
||||
|
||||
} //if ($action == "update")
|
||||
|
||||
//remove xml file (if any) if not enabled
|
||||
|
|
|
|||
Loading…
Reference in New Issue