<commit_before>;(function() {
  "use strict";
  angular
    .module('RDash')
    .controller('goodsShowExtraController', ['$scope', '$stateParams', 'providersHTTP', 'goodsProvidersHTTP', 'goodsPhotosHTTP', 'Upload', function($scope, $stateParams, providersHTTP, goodsProvidersHTTP, goodsPhotosHTTP, Upload) {

      $scope.currencyTypes = [{ type: 'RUB', text: 'руб' },{ type: 'EUR', text: '€' },{ type: 'USD', text: '$' }];
      $scope.entry = {};
      $scope.refreshProviders = function(provider) {
        var criteria;
        if (provider) {
          criteria = {
            search: provider,
            type:'providers'
          };
        }
        providersHTTP.read(criteria).success(function(response) {
          $scope.providers = response;
        });
      };
      $scope.progressPercentage = 0;
      $scope.uploadingFile = false;

      $scope.comments = '';
      $scope.currency = 'RUB';
      $scope.price = 0;
      $scope.providerId = 0;
      $scope.goodId = parseInt($stateParams.id, 10);
      goodsProvidersHTTP.setGoodId($scope.goodId);
      goodsPhotosHTTP.setGoodId($scope.goodId);

      $scope.entriesGoodsProviders = [];
      $scope.entriesGoodsPhotos = [];

      goodsProvidersHTTP.read().success(function(response) {
        $scope.entriesGoodsProviders = response;
      });

      goodsPhotosHTTP.read().success(function(response) {
        $scope.entriesGoodsPhotos = response;
      });

      $scope.$watch('photo', function(photo) {
        if (photo) {
          $scope.onAddGoodsPhotos(photo);
        }
      });

      $scope.progressPercentage = 0;
      $scope.uploadingFile = false;
      $scope.onAddGoodsPhotos = function(file) {
        $scope.uploadingFile = true;
        Upload.upload({
          url: '/api/goods/' + $scope.goodId + '/photos/upload',
          fields: { 'goodId': $scope.goodId },
          file: file
        }).progress(function (evt) {
          var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
          $scope.progressPercentage = progressPercentage;
        }).success(function (data, status, headers, config) {
          $scope.uploadingFile = false;
          $scope.entriesGoodsPhotos.push(data);
        });
      };


      $scope.onRemoveGoodsPhotos = function(entry) {
        goodsPhotosHTTP.remove(entry).success(function(response) {
          var l = $scope.entriesGoodsPhotos.length, i, found = false;
          for (i = 0; i < l; i++) {
            if ($scope.entriesGoodsPhotos[i].id === entry.id) {
              found = true;
              break;
            }
          };
          if (found)
            $scope.entriesGoodsPhotos.splice(i, 1);
        });<commit_msg>fixed the problem with photo-uploading<commit_after>;(function() {
  "use strict";
  angular
    .module('RDash')
    .controller('goodsShowExtraController', ['$scope', '$stateParams', 'providersHTTP', 'goodsProvidersHTTP', 'goodsPhotosHTTP', 'Upload', function($scope, $stateParams, providersHTTP, goodsProvidersHTTP, goodsPhotosHTTP, Upload) {

      $scope.currencyTypes = [{ type: 'RUB', text: 'руб' },{ type: 'EUR', text: '€' },{ type: 'USD', text: '$' }];
      $scope.entry = {};
      $scope.refreshProviders = function(provider) {
        var criteria;
        if (provider) {
          criteria = {
            search: provider,
            type:'providers'
          };
        }
        providersHTTP.read(criteria).success(function(response) {
          $scope.providers = response;
        });
      };
      $scope.progressPercentage = 0;
      $scope.uploadingFile = false;

      $scope.comments = '';
      $scope.currency = 'RUB';
      $scope.price = 0;
      $scope.providerId = 0;
      $scope.goodId = parseInt($stateParams.id, 10);
      goodsProvidersHTTP.setGoodId($scope.goodId);
      goodsPhotosHTTP.setGoodId($scope.goodId);

      $scope.entriesGoodsProviders = [];
      $scope.entriesGoodsPhotos = [];

      goodsProvidersHTTP.read().success(function(response) {
        $scope.entriesGoodsProviders = response;
      });

      goodsPhotosHTTP.read().success(function(response) {
        $scope.entriesGoodsPhotos = response;
      });

      $scope.$watch('photo', function(photo) {
        if (photo) {
          $scope.onAddGoodsPhotos(photo);
        }
      });

      $scope.progressPercentage = 0;
      $scope.uploadingFile = false;
      $scope.onAddGoodsPhotos = function(file) {
        $scope.uploadingFile = true;
        Upload.upload({
          url: '/api/goods/' + $scope.goodId + '/photos/upload',
          fields: { 'goodId': $scope.goodId },
          file: file
        }).progress(function (evt) {
          var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
          $scope.progressPercentage = progressPercentage;
        }).success(function (data, status, headers, config) {
          $scope.uploadingFile = false;
          console.log('status', status);
          $scope.entriesGoodsPhotos.push(data);
        }).error(function(response) {
          $scope.uploadingFile = false;
          alert('Фотографию не удалось загрузить');
        });
      };


      $scope.onRemoveGoodsPhotos = function(entry) {
        goodsPhotosHTTP.remove(entry).success(function(response) {
          var l = $scope.entriesGoodsPhotos.length, i, found = false;
          for (i = 0; i < l; i++) {
            if ($scope.entriesGoodsPhotos[i].id === entry.id) {
              found = true;
              break;
            }
          };
          if (found)
            $scope.entriesGoodsPhotos.splice(i, 1);
        });
{'fraction_non_alphanumeric': 0.14675278076785073, 'fraction_numerical': 0.004305705059203444, 'mean_word_length': 2.3145065398335314, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5391361', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1652, 'n_words': 279}