Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- $('.drop-down').setDropDown();
- if ($('@trace-panel_nodes-elements input').size() < 3) {
- $('@trace-panel_nodes-elements input').iCheck('disable');
- }
- if ($('@trace-panel_protocols-elements input').size() < 3) {
- $('@trace-panel_protocols-elements input').iCheck('disable');
- }
- $('#export_pdf').click(function() {
- var view = $('#trace-panel_switch-view').find('.switcher-button_selected').attr('data-view');
- if (view === 'list') {
- $('.trace-panel_switch-button_tree').trigger('click');
- }
- var html_source = $('@calltrace-frame').html();
- $('@export_pdf_html').val(html_source);
- $('@export_pdf_form').submit();
- if (view === 'list') {
- $('.trace-panel_switch-button_list').trigger('click');
- }
- return false;
- });
- if (!$('#trace-panel_switch-view').length) {
- return false;
- }
- $('#trace-panel_switch-view').setSwitcher().addHandler(function() {
- switch ($(this).attr('data-view')) {
- case 'tree':
- switchTree();
- break;
- case 'list':
- switchList();
- break;
- }
- });
- var calltraceFrame = $('@calltrace-frame'),
- topFrame = $('@top-frame'),
- middleFrame = $('@middle-frame'),
- bottomFrame = $('@bottom-frame'),
- xdrId = $('@xdr_id').val(),
- table = $('@table').val(),
- probeid = $('@probeid').val(),
- Calltrace,
- PacketsXdr,
- PacketsPdu,
- PacketsPduDetails,
- i, max,
- _templateNodeListItem = App.getTemplate('template_node_list-item'),
- _templateProtocolItem = App.getTemplate('template_protocol-item'),
- fieldsXDR = [],
- textFieldsXDR = $(App.stringToXML($('#xdr-fields-data').html())).find('div'),
- xdrList,
- pduList,
- detailsPdu,
- chunks;
- calltraceFrame.on("startLoading", function() {
- var $holder = $(".calltrace-view"),
- $topPanel = $("#top-panel"),
- $frame = $holder.find("@calltrace-frame"),
- $packetAnalyzer = $(".packet-analyzer"),
- topPanelHeight = $topPanel.height(),
- windowHeight = $(window).height();
- if ($frame.children().length > 0) {
- return;
- }
- $packetAnalyzer.hide();
- $holder.css({
- height: windowHeight - topPanelHeight
- }).addClass("calltrace-view_loading");
- }).trigger("startLoading");
- calltraceFrame.on("stopLoading", function() {
- var $holder = $(".calltrace-view"),
- $packetAnalyzer = $(".packet-analyzer");
- $packetAnalyzer.show();
- $holder.removeAttr("style").removeClass("calltrace-view_loading");
- });
- for (i = 0, max = textFieldsXDR.length; i < max; i += 1) {
- fieldsXDR.push({
- display: textFieldsXDR[i].childNodes[0].nodeValue,
- rank: textFieldsXDR[i].getAttribute('rank'),
- column: textFieldsXDR[i].getAttribute('column')
- });
- }
- var getChunkByXdrId = function(id) {
- var ids = [];
- for (var i in chunks) {
- if (chunks[i].xdr_id === (id + '')) {
- ids.push(i.toLowerCase());
- }
- }
- return ids;
- };
- var switchList = function() {
- calltraceFrame.empty().hide();
- PacketsXdr = topFrame.show().PacketsXdr({
- showLoaders: false,
- fields: fieldsXDR
- });
- PacketsPdu = middleFrame.show().PacketsPdu({
- showLoaders: false
- });
- PacketsPduDetails = bottomFrame.show().PacketsPduDetails();
- PacketsPdu.on('selectRow', function(packetId, chunk, probeid) {
- PacketsPduDetails.get(packetId, chunk, probeid);
- });
- PacketsXdr.on('selectRow', function(params) {
- var chunkIds = getChunkByXdrId(params.id);
- PacketsPdu.lightReset();
- for (var i = 0; i < chunkIds.length; i += 1) {
- PacketsPdu.lightRow(middleFrame.find('tr.data[data-id="' + chunkIds[i] + '"]'));
- }
- });
- PacketsXdr.pasteFromArray(xdrList);
- PacketsPdu.pasteFromXml(pduList.stdout, chunks, function() {
- PacketsPdu.selectRow(middleFrame.find('tr.data').first());
- });
- updateFrames();
- };
- var switchTree = function() {
- if (!calltraceFrame) {
- App.showError('No data');
- return false;
- }
- Calltrace = calltraceFrame.show().Calltrace();
- PacketsPduDetails = bottomFrame.show().PacketsPduDetails();
- Calltrace.on('selectPacket', function(packetId, chunk, probeid) {
- PacketsPduDetails.get(packetId, chunk, probeid);
- });
- $('@trace-panel_nodes-elements').empty();
- Calltrace.on('addNode', function(node) {
- $('@trace-panel_nodes-elements').append(_templateNodeListItem(node)); //.iCheck();
- $('@trace-panel_nodes-elements input[type=checkbox]').iCheck();
- });
- $('@trace-panel_protocols-elements').empty();
- Calltrace.on('addProtocol', function(protocol) {
- $('@trace-panel_protocols-elements').append(_templateProtocolItem({
- protocol: protocol
- }));
- $('@trace-panel_protocols-elements input[type=checkbox]').iCheck();
- });
- Calltrace.on('blockProtocols', function() {
- $('@trace-panel_protocols-elements input').each(function() {
- if ($(this).is(':checked')) {
- $(this).iCheck('disable');
- }
- });
- });
- Calltrace.on('unblockProtocols', function() {
- $('@trace-panel_protocols-elements input').each(function() {
- if ($(this).is(':checked')) {
- $(this).iCheck('enable');
- }
- });
- });
- Calltrace.on('blockNodes', function() {
- $('@trace-panel_nodes-elements input').each(function() {
- if ($(this).is(':checked')) {
- $(this).iCheck('disable');
- }
- });
- });
- Calltrace.on('unblockNodes', function() {
- $('@trace-panel_nodes-elements input').each(function() {
- if ($(this).is(':checked')) {
- $(this).iCheck('enable');
- }
- });
- });
- Calltrace.pasteFromXml(detailsPdu.stdout, chunks);
- Calltrace.selectNode($('.packets-trace_item').first());
- topFrame.empty().hide();
- middleFrame.empty().hide();
- updateFrames();
- };
- $.post(App.baseURL() + 'calltrace/get_pdu_by_xdr/', {
- id: xdrId,
- table: table,
- probeid: probeid
- }, function(result) {
- if (result.error) {
- App.showError(result.error);
- return;
- }
- xdrList = result.xdr_list;
- pduList = result.list_pdu;
- detailsPdu = result.details_pdu;
- chunks = result.chunks;
- switchTree();
- calltraceFrame.trigger('stopLoading');
- }, 'json').error(function(xhr) {
- App.showError(xhr);
- });
- $('@trace-panel_show_name-protocol').on('ifClicked', function() {
- if (!$(this).is(':checked')) {
- Calltrace.showNameProtocol();
- } else {
- Calltrace.hideNameProtocol();
- }
- });
- $('@trace-panel_show_name-message').on('ifClicked', function() {
- if (!$(this).is(':checked')) {
- Calltrace.showNameMessage();
- } else {
- Calltrace.hideNameMessage();
- }
- });
- $('@trace-panel_show_remainig-time').on('ifClicked', function() {
- if (!$(this).is(':checked')) {
- Calltrace.showRemainingTime();
- } else {
- Calltrace.hideRemainingTime();
- }
- });
- $('@trace-panel_show_absolute-time').on('ifClicked', function() {
- if (!$(this).is(':checked')) {
- Calltrace.showAbsoluteTime();
- } else {
- Calltrace.hideAbsoluteTime();
- }
- });
- $('@trace-panel_nodes-elements input[type=checkbox]').iCheck();
- $('@trace-panel_nodes-elements')
- .on('ifChecked', 'input', function() {
- Calltrace.showNode($(this).attr('data-node'));
- })
- .on('ifUnchecked', 'input', function() {
- Calltrace.hideNode($(this).attr('data-node'));
- });
- $('@trace-panel_protocols-elements')
- .on('ifChecked', 'input', function() {
- Calltrace.showProtocol($(this).attr('data-protocol'));
- })
- .on('ifUnchecked', 'input', function() {
- Calltrace.hideProtocol($(this).attr('data-protocol'));
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement