$( document ).ready(function() { $(document).foundation(); // Refresh var refresh_on = setInterval(refresh_visibility, 5000); // Controls $( "#visibilitySwitch" ).click(function() { if (this.checked) { refresh_on = setInterval(refresh_visibility, 5000); } else { clearInterval(refresh_on); } }); $( "#clear_visibility" ).click(function() { $.get( "visibility/clear", function( data ) { alert(data); }); }); // Visibility selection $( "#visibility_selected" ).selectable(); $( "#vservices" ).selectable(); $( "#visibility_selected" ).on( "selectableselected", function() { var vselected = []; $(".ui-selected", this).each(function() { vselected.push(this.innerHTML); }); set_visibility(vselected); }); $( "#visibility_selected" ).on( "selectableunselected", function() { var vselected = []; $(".ui-selected", this).each(function() { vselected.push(this.innerHTML); }); set_visibility(vselected); }); var vse = [] ; $("ol#vservices > li.ui-widget-content.ui-selectee", this).each(function() { vse.push(this.innerHTML) }); for (var i=0; i li", this).each(function() { if (vse[i] === this.innerHTML.replace(/-/g, '_')) { $(this).addClass("ui-selected"); } }); } $( "#visibility_accordion" ).accordion({collapsible: true, active: false}); }); function set_visibility(vselected) { var services = {}; var y = []; vselected.forEach(function(element) { var x = {}; x['name'] = element y.push(x) }); services['services'] = y $.ajax({ type: "POST", url: "visibility/set", data: JSON.stringify(services), contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function(data){alert(data);}, failure: function(errMsg) { alert(errMsg); } }); } function refresh_visibility() { $.get( "visibility/get/stats/all", function( data ) { // Response Times var head1 = '
Service
'; var head2 = '
Min(ms)
'; var head3 = '
Avg(ms)
'; var head4 = '
Max(ms)
'; var content = head1 + head2 + head3 + head4; for (var i=0; i' + o.name + '
' + o.min + '
' + o.avg + '
' + o.max + '
'; } $( ".tracing_rt" ).html( content ); // System Counts content = '" ; $( ".system_counts" ).html( content ); // Distinct update_distinct('request_urls', data) update_distinct('user_agents', data) update_distinct('status_codes', data) update_distinct('op_names', data) update_distinct('node_ids', data) update_distinct('upstream_clusters', data) // Tracing Charts, URL count $(".span_urls_all").empty(); var el = document.createElement("div"); $(".span_urls_all").append(el); var data1 = []; for (var i=0; i'; var mdiv = '
'; var m_html = portlet + mdiv + ''; $("#metrics_graphs").append(m_html); data1 = []; var x_values = []; var y_values = []; for (var j=0; j' + metric.prefix + '
' + metric.suffix; var layout = { title: m_title }; Plotly.newPlot(metric.name, data1, layout); } }); $.get( "visibility/metrics", function( data ) { $( ".service_metrics" ).html( data ); }); } function update_distinct(dkey, data) { content = ''; for (var i=0; i'; } var container = '.' + dkey; $(container).html(content); }