<commit_before>$('#viz_config select').select2();

function updateVariables(element) {
    $('#addVizModal .variable-select').find('option').remove().end();
    $('#addVizModal .variable-select').append($("<option disabled selected>-- select variable --</option>"));
    var new_query_id = $('#selected_query').val();
    var new_query_doc = {};
    $.ajax({
        url: '/queries/get_query_variables/',
        data: {
            id: new_query_id,
            document: new_query_doc
            },
        type: 'GET',
        success: function(result){
            var variables = result['variables'];
            var dimensions = result['dimensions'];
            $.each(variables, function(k, v) {
                $('.variable-select').append($("<option></option>")
                    .attr("value", v)
                    .text(k));
            });

            $.each(dimensions, function(k, v) {
                $('.variable-select').append($("<option></option>")
                    .attr("value", v)
                    .text(k));
            });
        }
    });
}


    $('#addVizModal .select2').on("click", function() {
        $('.popover').popover('hide');
    });

    $('#addVizModal select').on('change', function() {
        $('#addVizModal #viz_config').show();
        var new_query_id = $(this).children(":selected").attr("data-query-id");
        $('#addVizModal #selected_query').val(new_query_id);
        $('.popover').popover('hide');
          // updateVariables(this);
    });



    $(".viz_item").click(function (element) {
      var component_id = $(this).attr('data-viz-id');
      var component_selector = 'li[data-viz-id="'+component_id+'"]';
      $.ajax({
            url: '/dashboards/get_visualization_form_fields',
            data: {
                id: parseInt(component_id),
                order: 1
                },
            type: 'GET',
            success: function(form_fields){
                $("#conf-container").html(form_fields);
                $("#conf-container").append('<button type="button" id="select_conf_ok" class="btn btn-sm btn-success" data-toggle="popover">OK</button>');

                $(component_selector).popover({
                    html: true,
                    title: 'Configure visualisation',
                    trigger: 'manual',
                    content: function() {
                        return $('#conf-container').html();
                    }
                });
                updateVariables($('#load-viz-query-select'));
                $('.viz_item').not(component_selector).popover('hide');
                $(component_selector).popover('toggle');
                var popver_id = '#' + $(component_selector).attr('aria-describedby');
                $(popver_id+' #select_conf_ok').click(function(e){
                    $(".outputLoadImg").show();
                    submit_conf(component_selector);
                    $(component_selector).popover("hide");
                });
            }
        });
});


var viz_request = "";
function submit_conf(component_selector) {
    viz_request = "http://localhost:8000/visualizations/";
    var conf_popover_id = '#' + $(component_selector).attr('aria-describedby');
    viz_request += $('#action').val();

    var submitted_args = $(conf_popover_id).find('.popover-content').clone();
    var selects = $(conf_popover_id).find('.popover-content').find("select");
    $(selects).each(function(i) {
        var select = this;<commit_msg>popover cancel button<commit_after>$('#viz_config select').select2();

function updateVariables(element) {
    $('#addVizModal .variable-select').find('option').remove().end();
    $('#addVizModal .variable-select').append($("<option disabled selected>-- select variable --</option>"));
    var new_query_id = $('#selected_query').val();
    var new_query_doc = {};
    $.ajax({
        url: '/queries/get_query_variables/',
        data: {
            id: new_query_id,
            document: new_query_doc
            },
        type: 'GET',
        success: function(result){
            var variables = result['variables'];
            var dimensions = result['dimensions'];
            $.each(variables, function(k, v) {
                $('.variable-select').append($("<option></option>")
                    .attr("value", v)
                    .text(k));
            });

            $.each(dimensions, function(k, v) {
                $('.variable-select').append($("<option></option>")
                    .attr("value", v)
                    .text(k));
            });
        }
    });
}


    $('#addVizModal .select2').on("click", function() {
        $('.popover').popover('hide');
    });

    $('#addVizModal select').on('change', function() {
        $('#addVizModal #viz_config').show();
        var new_query_id = $(this).children(":selected").attr("data-query-id");
        $('#addVizModal #selected_query').val(new_query_id);
        $('.popover').popover('hide');
          // updateVariables(this);
    });



    $(".viz_item").click(function (element) {
      var component_id = $(this).attr('data-viz-id');
      var component_selector = 'li[data-viz-id="'+component_id+'"]';
      $.ajax({
            url: '/dashboards/get_visualization_form_fields',
            data: {
                id: parseInt(component_id),
                order: 1
                },
            type: 'GET',
            success: function(form_fields){
                $("#conf-container").html(form_fields);
                $("#conf-container").append('<button type="button" id="select_conf_ok" class="btn btn-sm btn-success" data-toggle="popover">OK</button>');
                $("#conf-container").append('<button type="button" id="select_conf_cancel" class="btn btn-sm " data-toggle="popover">Cancel</button>');
                $(component_selector).popover({
                    html: true,
                    title: 'Configure visualisation',
                    trigger: 'manual',
                    content: function() {
                        return $('#conf-container').html();
                    }
                });
                updateVariables($('#load-viz-query-select'));
                $('.viz_item').not(component_selector).popover('hide');
                $(component_selector).popover('toggle');
                var popver_id = '#' + $(component_selector).attr('aria-describedby');
                $(popver_id+' #select_conf_ok').click(function(e){
                    $(".outputLoadImg").show();
                    submit_conf(component_selector);
                    $(component_selector).popover("hide");
                });
                $(popver_id+' #select_conf_cancel').click(function(e){
                    $(component_selector).popover("hide");
                });
            }
        });
});


var viz_request = "";
function submit_conf(component_selector) {
    viz_request = "http://localhost:8000/visualizations/";
    var conf_popover_id = '#' + $(component_selector).attr('aria-describedby');
    viz_request += $('#action').val();

    var submitted_args = $(conf_popover_id).find('.popover-content').clone();
    var selects = $(conf_popover_id).find('.popover-content').find("select");
    $(selects).each(function(i) {
        var select = this;
{'fraction_non_alphanumeric': 0.18062217349595724, 'fraction_numerical': 0.0019185966835685898, 'mean_word_length': 2.033250207813799, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 21, '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': '3140297', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1963, 'n_words': 286}