<commit_before>/*
 * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
 */

define([
    'underscore',
    'contrail-view',
    'monitor/infrastructure/underlay/ui/js/underlay.utils'
], function (_, ContrailView, underlayUtils) {
    var UnderlayTabView = ContrailView.extend({
        el: $(contentContainer),

        render: function () {
            var self = this,
                viewConfig = this.attributes.viewConfig,
                callbackExecuted = false;
            this.renderView4Config(self.$el, self.model,
                 getUnderlayTabConfig(viewConfig), null, null, null,
                 function (underlayTabView) {
                    if(!callbackExecuted) {
                        self.listenToGraphModel(underlayTabView, viewConfig);
                        callbackExecuted = true;
                    }
                 }
            );
        },
        listenToGraphModel : function (underlayTabView, viewConfig) {
            var _this = this;
            graphModel = viewConfig.model;
            if(graphModel != null) {
                underlayTabView.listenTo(viewConfig.model.selectedElement().model(),
                    'change:nodeType', function (selectedElement) {
                   var nodeType = selectedElement['attributes']['nodeType'];
                   var nodeDetails = selectedElement['attributes']['nodeDetail'];
                   if(nodeType == ctwc.PROUTER) {
                       showPRouterTabs(nodeDetails, underlayTabView);
                   } else if (nodeType == ctwc.VROUTER) {
                       showVRouterTabs(nodeDetails, underlayTabView);
                   } else if (nodeType == ctwc.VIRTUALMACHINE) {
                       showVMTabs(nodeDetails, underlayTabView);
                   } else if (nodeType == ctwc.UNDERLAY_LINK) {
                       showLinkTrafficStatistics(nodeDetails, underlayTabView);
                   }
                });
            }
        }
    });

    var getUnderlayTabConfig = function (viewConfig) {
        // Underlay default tab config (Search flows & Trace flow)
        var underlayDefaultTabConfig =
            ctwvc.getUnderlayDefaultTabConfig(viewConfig);
        return {
            elementId: ctwc.UNDERLAY_TAB_ID,
            view: "TabsView",
            viewConfig: {
                theme: 'classic',
                disabled: ifNull(
                    viewConfig['tabsToDisable'], []),
                activate: function (e, ui) {
                    activate(e, ui);
                },
                tabs: underlayDefaultTabConfig
            }
        };
    };

    function activate (e, ui) {<commit_msg>Fixed : Whenever user choose a Virtual Machine or vRouter from Underlay Graph, it will auto select in TraceFlows tab<commit_after>/*
 * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
 */

define([
    'underscore',
    'contrail-view',
    'monitor/infrastructure/underlay/ui/js/underlay.utils'
], function (_, ContrailView, underlayUtils) {
    var UnderlayTabView = ContrailView.extend({
        el: $(contentContainer),

        render: function () {
            var self = this,
                viewConfig = this.attributes.viewConfig,
                callbackExecuted = false;
            this.renderView4Config(self.$el, self.model,
                 getUnderlayTabConfig(viewConfig), null, null, null,
                 function (underlayTabView) {
                    if(!callbackExecuted) {
                        self.listenToGraphModel(underlayTabView, viewConfig);
                        callbackExecuted = true;
                    }
                 }
            );
        },
        listenToGraphModel : function (underlayTabView, viewConfig) {
            var _this = this;
            graphModel = viewConfig.model;
            if(graphModel != null) {
                underlayTabView.listenTo(viewConfig.model.selectedElement().model(),
                    'change:nodeType', function (selectedElement) {
                   var nodeType = selectedElement['attributes']['nodeType'];
                   var nodeDetails = selectedElement['attributes']['nodeDetail'];
                   if(nodeType == ctwc.PROUTER) {
                       showPRouterTabs(nodeDetails, underlayTabView);
                   } else if (nodeType == ctwc.VROUTER) {
                     $("input[name='traceflow_radiobtn_name'][value='vRouter']").prop("checked", true);
                     $("input[name='traceflow_radiobtn_name'][value='vRouter']").trigger('click');
                     $("#vrouter_dropdown_name_dropdown").val(nodeDetails.label).trigger('change');
                       showVRouterTabs(nodeDetails, underlayTabView);
                   } else if (nodeType == ctwc.VIRTUALMACHINE) {
                     $("input[name='traceflow_radiobtn_name'][value='instance']").prop("checked", true);
                     $("input[name='traceflow_radiobtn_name'][value='instance']").trigger('click');
                     $("#instance_dropdown_name_dropdown").val(nodeDetails.name).trigger('change');
                       showVMTabs(nodeDetails, underlayTabView);
                   } else if (nodeType == ctwc.UNDERLAY_LINK) {
                       showLinkTrafficStatistics(nodeDetails, underlayTabView);
                   }
                });
            }
        }
    });

    var getUnderlayTabConfig = function (viewConfig) {
        // Underlay default tab config (Search flows & Trace flow)
        var underlayDefaultTabConfig =
            ctwvc.getUnderlayDefaultTabConfig(viewConfig);
        return {
            elementId: ctwc.UNDERLAY_TAB_ID,
            view: "TabsView",
            viewConfig: {
                theme: 'classic',
                disabled: ifNull(
                    viewConfig['tabsToDisable'], []),
                activate: function (e, ui) {
                    activate(e, ui);
                },
                tabs: underlayDefaultTabConfig
            }
        };
    };

    function activate (e, ui) {
{'fraction_non_alphanumeric': 0.10428736964078796, 'fraction_numerical': 0.0016553550736633008, 'mean_word_length': 1.706989247311828, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7591279', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1499, 'n_words': 276}