{"size": 1707, "ext": "js", "max_stars_repo_path": "resources/assets/js/controllers/galleryController.js", "max_stars_repo_name": "rash7/larang", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "resources/assets/js/controllers/galleryController.js", "max_issues_repo_name": "rash7/larang", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "resources/assets/js/controllers/galleryController.js", "max_forks_repo_name": "rash7/larang", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.1029411765, "max_line_length": 106, "alphanum_fraction": 0.6233157586}
myApp.controller('galleryController', ['$scope', '$location', 'galleryModel', '$timeout', '$routeParams', 
	function($scope, $location, galleryModel, $timeout, $routeParams){
/* Get all galleries */
galleryModel.getAllGalleries().then( function onSuc(response){
	 
	$timeout( function(){
	$scope.galleries = response.data;
	$scope.showGalleries = true;
	}, 500);
	
});
/* if the param is present, load the single gallery data */
if($routeParams.id) {
	
	galleryModel.getGalleryById($routeParams.id).then( function onSu(response){
     $scope.singleGallery = response.data;
     
	});
}

/*Variables*/
  angular.extend($scope, {
  	newGallery: {


  	},
  	errorDiv: false,
  	errorMessages: [],
  	singleGallery: {},
  	dropzoneConfig: {
  		'options': { // passed into the Dropzone constructor
            'url': baseUrl + 'upload-file'
                  },
    'eventHandlers': {
      'sending': function (file, xhr, formData) { 
      	console.log('sending');
       formData.append('_token', csrfToken);
       formData.append('galleryId', $routeParams.id);
        },
      'success': function (file, response) {
       console.log('success');
       console.log(response); 
        }
    }
  	}
  });
 /*Functions*/

 angular.extend($scope, {
 	saveNewGallery: function(addGalleryForm){
 		console.log(addGalleryForm);
 		if(addGalleryForm.$valid) {
 			$scope.formSubmitted = false;
 			galleryModel.saveGallery($scope.newGallery).then(function onSucc(response) {
    // Handle success
   $location.path('/gallery/view');
  }); 
    
 		} else {
 			$scope.formSubmitted = true;
 			console.log('Error');
 		}
 	},
 	viewGallery: function(id) {
 		$location.path('gallery/view/' + id);
 	}
 });
}]);