<commit_before>'use strict';
angular.module('myApp')
.controller('AttachmentsCtrl', function ($scope, $state, $rootScope, DataService, $stateParams) {
    // $scope.files = [];
    $scope.error = false;

    if(!$stateParams.appId) {
      $state.go('applicationInformation', {});
    } else if(!$rootScope.application || $rootScope.application._id != $stateParams.appId) {
      DataService.getApplicationById($stateParams.appId).then(function (result) {
        if(result) {
          $rootScope.application = result;
        } else {
          //TODO: handle error
        }
      });
  }

    $scope.saveLaterBtn = function() {
        $state.go('home');
    };

    $scope.$watch('files', function(newValue) {
        if(newValue && newValue.length > 0) {
            if($rootScope.application) {
                DataService.updateAttachments(newValue[newValue.length - 1], $rootScope.application._id).then(function(result) {
                    if(result) {
                        angular.forEach(result, function (doc) {
                            $rootScope.application.documentation.push(doc);
                        });
                      $scope.error = false;
                    } else {
                        console.log('error');
                      $scope.error = true;
                    }
                });
            }
        } else {
            //TODO:: handle nothing array (i.e. just deleted last item)
        }
    }, true);

    $scope.deleteAttachment = function(index) {
        $rootScope.application.documentation.splice(index, 1);
    };

    $scope.addURL = function(newValue) {
        console.log('link');
        $rootScope.application.documentation.push({fileName:$scope.urlLink, description: "", base64String: "" });
    };

    $scope.atMax = function() {
        angular.element(document).ready(function () {
            if ($rootScope.application.documentation.length > 20)
                return true;
        });
    };
});<commit_msg>removed console.log stmt from review<commit_after>'use strict';
angular.module('myApp')
.controller('AttachmentsCtrl', function ($scope, $state, $rootScope, DataService, $stateParams) {
    // $scope.files = [];
    $scope.error = false;

    if(!$stateParams.appId) {
      $state.go('applicationInformation', {});
    } else if(!$rootScope.application || $rootScope.application._id != $stateParams.appId) {
      DataService.getApplicationById($stateParams.appId).then(function (result) {
        if(result) {
          $rootScope.application = result;
        } else {
          //TODO: handle error
        }
      });
  }

    $scope.saveLaterBtn = function() {
        $state.go('home');
    };

    $scope.$watch('files', function(newValue) {
        if(newValue && newValue.length > 0) {
            if($rootScope.application) {
                DataService.updateAttachments(newValue[newValue.length - 1], $rootScope.application._id).then(function(result) {
                    if(result) {
                        angular.forEach(result, function (doc) {
                            $rootScope.application.documentation.push(doc);
                        });
                      $scope.error = false;
                    } else {
                        console.log('error');
                      $scope.error = true;
                    }
                });
            }
        } else {
            //TODO:: handle nothing array (i.e. just deleted last item)
        }
    }, true);

    $scope.deleteAttachment = function(index) {
        $rootScope.application.documentation.splice(index, 1);
    };

    $scope.addURL = function(newValue) {
        $rootScope.application.documentation.push({fileName:$scope.urlLink, description: "", base64String: "" });
    };

    $scope.atMax = function() {
        angular.element(document).ready(function () {
            if ($rootScope.application.documentation.length > 20)
                return true;
        });
    };
});
{'fraction_non_alphanumeric': 0.1426056338028169, 'fraction_numerical': 0.0035211267605633804, 'mean_word_length': 1.877713458755427, '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': '5615508', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1054, 'n_words': 163}