<commit_before>Cobler.types.uApp = function(container){
	function get() {
		item.widgetType = 'uApp';
		return item;
	}
	var item = {
		guid: generateUUID()}
	var fields = {
		Title: {},
		'App ID': {type: 'select', choices: '/api/groups/'+group_id+'/appinstances'},
    'User Options':{name:'user_edit',type:'checkbox'},
		// 'Template': {}
	}
	return {
    container:container,
		fields: fields,
		render: function() {
      var temp = get();
      temp.uapp_admin = group_admin;
			return templates['widgets_microapp'].render(temp, templates);
		},
		edit: berryEditor.call(this, container),
		toJSON: get,
		get: get,
		set: function (newItem) {
			$.extend(item, newItem);
		},
		initialize: function(el){
    if(typeof this.get().app_id == 'undefined'){return false;};
      this.fields['App ID'].enabled = false;
      if(this.container.owner.options.disabled && this.get().enable_min){
          var collapsed = (Lockr.get(this.get().guid) || {collapsed:this.get().collapsed}).collapsed;
          this.set({collapsed:collapsed});
          $(el).find('.widget').toggleClass('cob-collapsed',collapsed)
      }

      $.ajax({
          url: '/api/fetch/'+this.get().app_id,
          dataType : 'json',
					type: 'POST',
          data: (Lockr.get('/api/apps/instances/'+this.get().app_id+'/user_options')|| {options:{}}),
					success  : function(data){
            if(typeof data.user.id == 'undefined') {
              var url = '/api/apps/instances/'+this.get().app_id+'/user_options';
              data.user.options = (Lockr.get(url)|| {options:{}}).options;
            }


            var opts = {
              template: this.get().template || 'dashboard',
              $el: $(el).find('.collapsible'),
              crud: function(name, data, callback, verb){
                $.ajax({
                url: '/api/app_data/'+ this.config.app_instance_id + '/' +name+ '?verb='+verb,
                // dataType : 'json',
                type: 'POST',
                data: {request: data, options:this.data.user.options},
                error: function (data) {
                  if(typeof data.responseJSON.error !== 'undefined' && data.responseJSON.error) {
                    toastr.error(data.responseJSON.error.message || data.responseJSON.error,'ERROR')
                  }else{
                    toastr.error(data.statusText, 'ERROR')
                  }
                }.bind(this),
                success  : callback.bind(this)
                });
              }
            }
            opts.data = data;
            opts.config = (_.find(apps, {id: parseInt(this.get().app_id,10)}) || _.find(Berry.collection.get('/api/groups/'+group_id+'/appinstances'), {id: parseInt(this.get().app_id,10)})).app.code || {};
            // opts.config = _.find(Berry.collection.get('/api/appinstances'), {id: parseInt(this.get().app_id,10)}).app.code;
            opts.config.app_instance_id = this.get().app_id;
            opts.config.title = this.get().title;
            $('style[name="'+opts.config.app_instance_id+'"]').remove();
            if(opts.config.css.length){
              $('body').append('<style name="'+opts.config.app_instance_id+'">'+opts.config.css+'</style>');
            }
            opts.onLoad = function(){
              this.bae.app.on('refetch', function(data){
                if(typeof this.bae.data.user.id == 'undefined') {
                  options =  (Lockr.get('/api/apps/instances/'+this.get().app_id+'/user_options')|| {options:{}});
                }else{
                   options = this.bae.data.user.options;
                }

                $.ajax({
                  type: 'POST',
                  url:'/api/fetch/'+this.get().app_id,
                  data:{options:options},
                  success:function(data){
                      if(typeof data.user.id == 'undefined') {
                        var url = '/api/apps/instances/'+this.get().app_id+'/user_options';
                        data.user.options = (Lockr.get(url)|| {options:{}}).options;
                      }
                    this.bae.app.update(data);
                    // toastr.success('', 'Data refetched Successfully');
                  }.bind(this),
                  error:function(data){
                      toastr.error(data.statusText, 'An error occured updating App')
                  }
                })
              }.bind(this));<commit_msg>Only send user options when not logged in<commit_after>Cobler.types.uApp = function(container){
	function get() {
		item.widgetType = 'uApp';
		return item;
	}
	var item = {
		guid: generateUUID()}
	var fields = {
		Title: {},
		'App ID': {type: 'select', choices: '/api/groups/'+group_id+'/appinstances'},
    'User Options':{name:'user_edit',type:'checkbox'},
		// 'Template': {}
	}
	return {
    container:container,
		fields: fields,
		render: function() {
      var temp = get();
      temp.uapp_admin = group_admin;
			return templates['widgets_microapp'].render(temp, templates);
		},
		edit: berryEditor.call(this, container),
		toJSON: get,
		get: get,
		set: function (newItem) {
			$.extend(item, newItem);
		},
		initialize: function(el){
    if(typeof this.get().app_id == 'undefined'){return false;};
      this.fields['App ID'].enabled = false;
      if(this.container.owner.options.disabled && this.get().enable_min){
          var collapsed = (Lockr.get(this.get().guid) || {collapsed:this.get().collapsed}).collapsed;
          this.set({collapsed:collapsed});
          $(el).find('.widget').toggleClass('cob-collapsed',collapsed)
      }

      $.ajax({
          url: '/api/fetch/'+this.get().app_id,
          dataType : 'json',
					type: 'POST',
          data: (Lockr.get('/api/apps/instances/'+this.get().app_id+'/user_options')|| {options:{}}),
					success  : function(data){
            if(typeof data.user.id == 'undefined') {
              var url = '/api/apps/instances/'+this.get().app_id+'/user_options';
              data.user.options = (Lockr.get(url)|| {options:{}}).options;
            }


            var opts = {
              template: this.get().template || 'dashboard',
              $el: $(el).find('.collapsible'),
              crud: function(name, data, callback, verb){
                var send_data = {request: data};
                if(typeof this.data.user.id == 'undefined') {
                  send_data.options = this.data.user.options;
                }
                $.ajax({
                url: '/api/app_data/'+ this.config.app_instance_id + '/' +name+ '?verb='+verb,
                // dataType : 'json',
                type: 'POST',
                data: send_data,
                error: function (data) {
                  if(typeof data.responseJSON.error !== 'undefined' && data.responseJSON.error) {
                    toastr.error(data.responseJSON.error.message || data.responseJSON.error,'ERROR')
                  }else{
                    toastr.error(data.statusText, 'ERROR')
                  }
                }.bind(this),
                success  : callback.bind(this)
                });
              }
            }
            opts.data = data;
            opts.config = (_.find(apps, {id: parseInt(this.get().app_id,10)}) || _.find(Berry.collection.get('/api/groups/'+group_id+'/appinstances'), {id: parseInt(this.get().app_id,10)})).app.code || {};
            // opts.config = _.find(Berry.collection.get('/api/appinstances'), {id: parseInt(this.get().app_id,10)}).app.code;
            opts.config.app_instance_id = this.get().app_id;
            opts.config.title = this.get().title;
            $('style[name="'+opts.config.app_instance_id+'"]').remove();
            if(opts.config.css.length){
              $('body').append('<style name="'+opts.config.app_instance_id+'">'+opts.config.css+'</style>');
            }
            opts.onLoad = function(){
              this.bae.app.on('refetch', function(data){
                var options;
                if(typeof this.bae.data.user.id == 'undefined') {
                  options =  (Lockr.get('/api/apps/instances/'+this.get().app_id+'/user_options')|| {options:{}});
                }

                $.ajax({
                  type: 'POST',
                  url:'/api/fetch/'+this.get().app_id,
                  data:{options:options},
                  success:function(data){
                      if(typeof data.user.id == 'undefined') {
                        var url = '/api/apps/instances/'+this.get().app_id+'/user_options';
                        data.user.options = (Lockr.get(url)|| {options:{}}).options;
                      }
                    this.bae.app.update(data);
                    // toastr.success('', 'Data refetched Successfully');
                  }.bind(this),
                  error:function(data){
                      toastr.error(data.statusText, 'An error occured updating App')
                  }
                })
              }.bind(this));
{'fraction_non_alphanumeric': 0.1745588563770382, 'fraction_numerical': 0.0013401831583649765, 'mean_word_length': 1.854638189352885, 'pattern_counts': {'":': 0, '<': 7, '<?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': '797305', 'n_tokens_mistral': 2753, 'n_tokens_neox': 2613, 'n_words': 396}