diff --git a/www/vicidial/AST_latency_gaps_report.php b/www/vicidial/AST_latency_gaps_report.php index 22668c6b..4d5c51a4 100644 --- a/www/vicidial/AST_latency_gaps_report.php +++ b/www/vicidial/AST_latency_gaps_report.php @@ -5,6 +5,7 @@ # # CHANGES # 230430-1952 - First build +# 230516-2024 - Fix for graphs # $startMS = microtime(); @@ -254,10 +255,6 @@ $HEADER.="-->\n"; $HEADER.=" \n"; $HEADER.="\n"; $HEADER.="\n"; -$HEADER.="\n"; -$HEADER.="\n"; -$HEADER.="\n"; -$HEADER.="\n"; $HEADER.="\n"; $HEADER.="\n"; $HEADER.="\n"; diff --git a/www/vicidial/dygraph_vici.css b/www/vicidial/dygraph_vici.css new file mode 100644 index 00000000..4442e0d7 --- /dev/null +++ b/www/vicidial/dygraph_vici.css @@ -0,0 +1,50 @@ +.dygraph-legend { + font-family: Arial, Helvetica, serif; + font-size: 10pt; + font-weight: bold; + } +.dygraph-title { + font-family: Arial, Helvetica, serif; + color: #000; + text-shadow: #999 2px 2px 2px; +} +dygraph-axis-label { + font-family: Arial, Helvetica, serif; + font-size: 10pt; + color: #900; + text-shadow: #999 1px 1px 1px; +} +.dygraph-axis-label-x { + font-family: Arial, Helvetica, serif; + font-size: 10pt; + color: #900; + text-shadow: #999 1px 1px 1px; +} + +.dygraph-axis-label-y { + font-family: Arial, Helvetica, serif; + font-size: 10pt; + color: #900; + text-shadow: #999 1px 1px 1px; +} +.dygraph-xlabel { + font-family: Arial, Helvetica, serif; + font-size: 12pt; + font-weight: bold; + text-shadow: #999 1px 1px 1px; +} + +.dygraph-ylabel { + font-family: Arial, Helvetica, serif; + font-size: 12pt; + font-weight: bold; + text-shadow: #999 1px 1px 1px; +} + +.loading_text { + font-family: Arial, Helvetica, serif; + font-size: 36pt; + font-weight: bold; + color: #009; + text-shadow: #999 5px 5px 5px; +} diff --git a/www/vicidial/dygraph_vici.js b/www/vicidial/dygraph_vici.js new file mode 100644 index 00000000..6f60e5c2 --- /dev/null +++ b/www/vicidial/dygraph_vici.js @@ -0,0 +1,114 @@ +var RawGraphData=""; +function DrawGraph(user, LogDate, IPAddress, API_action) + { + document.getElementById('loading_please_wait').style.display='block'; + document.getElementById('chart_div').style.display='none'; + + var xmlhttp=false; + /*@cc_on @*/ + /*@if (@_jscript_version >= 5) + // JScript gives us Conditional compilation, we can cope with old IE versions. + // and security blocked creation of the objects. + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } + @end @*/ + if (!xmlhttp && typeof XMLHttpRequest!='undefined') + { + xmlhttp = new XMLHttpRequest(); + } + if (xmlhttp) + { + var GraphQuery = "user=" + user + "&log_date=" + LogDate + "&web_ip=" + IPAddress + "&ACTION="+API_action; + // alert(GraphQuery); + xmlhttp.open('POST', 'dygraph_functions.php'); + xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttp.send(GraphQuery); + xmlhttp.onreadystatechange = function() + { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) + { + RawGraphData = xmlhttp.responseText; + + if (API_action=="all_agent_latency" || API_action=="latency_gaps") + { + var LSL_value=1; + var stacked=1; + } + else + { + var LSL_value=0; + var stacked=0; + } + + var graphTitle='Latency'; + if (!user.match("---ALL---")) + { + graphTitle+=' for agent '+user; + } + else + { + graphTitle+=' for ALL agents'; + } + + graphTitle+=' for '+LogDate; + + if (!IPAddress.match("---ALL---")) + { + graphTitle+=' on IP address '+IPAddress; + } + //var graph_data=[]; + //var maxLatency=0; + //var graph_array=RawGraphData.split("|"); + //alert(graph_array.length); + //for (var i=0; imaxLatency) + // { + // maxLatency=parseInt(dataset[1]); + // } + // } + if (!LatencyGraph) + { + // alert(RawGraphData); + var LatencyGraph=new Dygraph(document.getElementById("latency_graph_div"), RawGraphData, + { + title: graphTitle, + labelsDiv: document.getElementById("legend_div"), + drawPoints: true, + showRoller: false, + resizable: "both", + // legend: 'follow', + // legendFollowOffsetX: 5, + // legendFollowOffsetY: -5, + labelsSeparateLines: LSL_value, + connectSeparatedPoints: false, + drawGapEdgePoints: false, + ylabel: 'Latency', + xlabel: 'Time (HH:mm:ss)', + strokeWidth: 1.5 + } ); + } + else + { + LatencyGraph.updateOptions( {'file': RawGraphData, title: graphTitle} ); + } + + document.getElementById('loading_please_wait').style.display='none'; + document.getElementById('chart_div').style.display='block'; + } + } + } + + + + }