<commit_before>/* New Instance view */
Atmo.Views.NewInstanceScreen = Backbone.View.extend({
	tagName: 'div',
	className: 'screen',
	id: 'imageStore',
	events: {
		'click .clear_search': 'clear_search',
		'change #image_search': 'filter_image_list',
		'keyup #image_search': 'filter_image_list',
		'click .image_list > li': 'img_clicked',
		'click #launchInstance': 'launch_instance',
		'keyup #newinst_name' : 'validate_name',
		//'dblclick .image_list > li' : 'quick_launch',
		'click #help_request_more_resources2' : 'show_request_resources_modal',
	},
	template: _.template(Atmo.Templates.new_instance_screen),
	initialize: function(options) {
		Atmo.images.bind('reset', this.render_image_list, this);
		Atmo.images.bind('fail', this.report_error_image_list, this);
        Atmo.instances.bind('add', this.render_resource_charts, this);
        Atmo.instances.bind('remove', this.render_resource_charts, this);
		Atmo.instances.bind('change:state', this.render_resource_charts, this);
		Atmo.instance_types.bind('change:selected', this.update_resource_charts, this);
        this.launch_lock = false;
		this.under_quota = true;
        this.init_query = options['query'] ? options['query'] : null;
        this.tagger = null;
	},
	render: function() {
		this.$el.html(this.template());

		this.mem_resource_chart = new Atmo.Views.ResourceCharts({
			el: this.$el.find('#memHolder'), 
			quota_type: 'mem',
		}).render();
		this.cpu_resource_chart = new Atmo.Views.ResourceCharts({
			el: this.$el.find('#cpuHolder'), 
			quota_type: 'cpu'
		}).render();
        if (Atmo.profile.attributes.selected_identity.has_allocation()) {
		    this.time_resource_chart = new Atmo.Views.ResourceCharts({
		    	el: this.$el.find('#allocationHolder'), 
		    	quota_type: 'allocation'
		    }).render();
        } else {
            graph_holders = this.$el.find('#resource_usage_holder');
            alloc_graph = this.$el.find("#allocationHolder").parent();
            alloc_graph.remove();
            graph_holders.children().each( function() {
                $(this).removeClass('span4').addClass('span6');
            });
        }

		// Make the dropdown functional
		this.$el.find('a[data-target="advanced_options"]').click(function() {
			$('#advanced_options').collapse('toggle');
		});
		this.$el.find('#advanced_options').on('show', function() {
			$('a[data-target="advanced_options"]').addClass('dropup');
		});
		this.$el.find('#advanced_options').on('hide', function() {
			$('a[data-target="advanced_options"]').removeClass('dropup');
		});

		this.render_image_list();
		this.render_instance_type_list();<commit_msg>New instance screen makes space for third resource chart if it has to<commit_after>/* New Instance view */
Atmo.Views.NewInstanceScreen = Backbone.View.extend({
	tagName: 'div',
	className: 'screen',
	id: 'imageStore',
	events: {
		'click .clear_search': 'clear_search',
		'change #image_search': 'filter_image_list',
		'keyup #image_search': 'filter_image_list',
		'click .image_list > li': 'img_clicked',
		'click #launchInstance': 'launch_instance',
		'keyup #newinst_name' : 'validate_name',
		//'dblclick .image_list > li' : 'quick_launch',
		'click #help_request_more_resources2' : 'show_request_resources_modal',
	},
	template: _.template(Atmo.Templates.new_instance_screen),
	initialize: function(options) {
		Atmo.images.bind('reset', this.render_image_list, this);
		Atmo.images.bind('fail', this.report_error_image_list, this);
        Atmo.instances.bind('add', this.render_resource_charts, this);
        Atmo.instances.bind('remove', this.render_resource_charts, this);
		Atmo.instances.bind('change:state', this.render_resource_charts, this);
		Atmo.instance_types.bind('change:selected', this.update_resource_charts, this);
        this.launch_lock = false;
		this.under_quota = true;
        this.init_query = options['query'] ? options['query'] : null;
        this.tagger = null;
	},
	render: function() {
		this.$el.html(this.template());

		this.mem_resource_chart = new Atmo.Views.ResourceCharts({
			el: this.$el.find('#memHolder'), 
			quota_type: 'mem',
		}).render();
		this.cpu_resource_chart = new Atmo.Views.ResourceCharts({
			el: this.$el.find('#cpuHolder'), 
			quota_type: 'cpu'
		}).render();
        if (Atmo.profile.attributes.selected_identity.has_allocation()) {
		    this.time_resource_chart = new Atmo.Views.ResourceCharts({
		    	el: this.$el.find('#allocationHolder'), 
		    	quota_type: 'allocation'
		    }).render();
        } else {
            graph_holders = this.$el.find('#resource_usage_holder');
            alloc_graph = this.$el.find("#allocationHolder").parent();
            alloc_graph.remove();
            graph_holders.children().each( function() {
                $(this).removeClass('col-md-4').addClass('col-md-6');
            });
        }

		// Make the dropdown functional
		this.$el.find('a[data-target="advanced_options"]').click(function() {
			$('#advanced_options').collapse('toggle');
		});
		this.$el.find('#advanced_options').on('show', function() {
			$('a[data-target="advanced_options"]').addClass('dropup');
		});
		this.$el.find('#advanced_options').on('hide', function() {
			$('a[data-target="advanced_options"]').removeClass('dropup');
		});

		this.render_image_list();
		this.render_instance_type_list();
{'fraction_non_alphanumeric': 0.17173994738819992, 'fraction_numerical': 0.0011273957158962795, 'mean_word_length': 4.193170731707317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '937581', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1710, 'n_words': 257}