<commit_before>'use strict';

angular.module('GeoHashingApp')
    .controller('EditUserCtrl', ['$scope', '$rootScope', '$stateParams', '$http', '$upload',
        function ($scope, $rootScope, $stateParams, $http, $upload) {

            $rootScope.textAngularOpts = {
                toolbar: [
                    ['h1', 'h2', 'h3', 'p', 'pre', 'bold', 'italics', 'ul', 'ol', 'redo', 'undo', 'clear'],
                    ['html', 'insertImage', 'insertLink']
                ],
                classes: {
                    toolbar: "btn-toolbar",
                    toolbarGroup: "btn-group",
                    toolbarButton: "btn btn-default",
                    toolbarButtonActive: "active",
                    textEditor: 'form-control',
                    htmlEditor: 'form-control'
                }
            };

            $scope.id = $stateParams.id;
            $scope.login = '';
            $scope.friendlyName = '';
            $scope.email = '';


            var getUser = function (userId) {
                $http({method: 'GET', url: '/user/get/' + userId}).
                    success(function (data, status, headers, config) {
                        if (data && data.id) {
                            showUser(data);
                        }
                    }).
                    error(function (data, status, headers, config) {
                        // called asynchronously if an error occurs
                        // or server returns response with an error status.
                    });
            };

            if ($scope.id) {
                getUser($scope.id);
            }

            $scope.submit = function () {
                var userJson = {
                    'id': $scope.id,
                    'user': $scope.user,
                    'latitude': $scope.latitude,
                    'longitude': $scope.longitude,
                    'description': $scope.description
                };

                $http({method: 'POST', url: '/users/edit/json', data: userJson }).
                    success(function (data, status, headers, config) {
                        if (data && data.id) {
                            showUser(data);
                        }
                    }).
                    error(function (data, status, headers, config) {
                        // called asynchronously if an error occurs
                        // or server returns response with an error status.
                    });
            };


            var showUser = function (userJson) {
                $scope.id = userJson.id;
                $scope.user = userJson.user;
                $scope.latitude = userJson.latitude;
                $scope.longitude = userJson.longitude;
                $scope.description = userJson.description;
                $scope.images = userJson.images;
            };


            $scope.onFileSelect = function ($files) {
                //$files: an array of files selected, each file has name, size, and type.
                for (var i = 0; i < $files.length; i++) {
                    var file = $files[i];
                    $scope.upload = $upload.upload({
                        url: '/user/upload/images',<commit_msg>master Show user obtained from the server<commit_after>'use strict';

angular.module('GeoHashingApp')
    .controller('EditUserCtrl', ['$scope', '$rootScope', '$stateParams', '$http', '$upload',
        function ($scope, $rootScope, $stateParams, $http, $upload) {

            $rootScope.textAngularOpts = {
                toolbar: [
                    ['h1', 'h2', 'h3', 'p', 'pre', 'bold', 'italics', 'ul', 'ol', 'redo', 'undo', 'clear'],
                    ['html', 'insertImage', 'insertLink']
                ],
                classes: {
                    toolbar: "btn-toolbar",
                    toolbarGroup: "btn-group",
                    toolbarButton: "btn btn-default",
                    toolbarButtonActive: "active",
                    textEditor: 'form-control',
                    htmlEditor: 'form-control'
                }
            };

            $scope.id = $stateParams.id;
            $scope.login = '';
            $scope.friendlyName = '';
            $scope.email = '';


            var getUser = function (userId) {
                $http({method: 'GET', url: '/user/get/' + userId}).
                    success(function (data, status, headers, config) {
                        if (data && data.id) {
                            showUser(data);
                        }
                    }).
                    error(function (data, status, headers, config) {
                        // called asynchronously if an error occurs
                        // or server returns response with an error status.
                    });
            };

            if ($scope.id) {
                getUser($scope.id);
            }

            $scope.submit = function () {
                var userJson = {
                    'id': $scope.id,
                    'user': $scope.user,
                    'latitude': $scope.latitude,
                    'longitude': $scope.longitude,
                    'description': $scope.description
                };

                $http({method: 'POST', url: '/users/edit/json', data: userJson }).
                    success(function (data, status, headers, config) {
                        if (data && data.id) {
                            showUser(data);
                        }
                    }).
                    error(function (data, status, headers, config) {
                        // called asynchronously if an error occurs
                        // or server returns response with an error status.
                    });
            };


            var showUser = function (userJson) {
                $scope.id = userJson.id;
                $scope.login = userJson.login;
                $scope.email = userJson.email;
                $scope.friendlyName = userJson.friendly_name;
                $scope.provider = userJson.provider;
                $scope.avatar = userJson.avatar;
            };


            $scope.onFileSelect = function ($files) {
                //$files: an array of files selected, each file has name, size, and type.
                for (var i = 0; i < $files.length; i++) {
                    var file = $files[i];
                    $scope.upload = $upload.upload({
                        url: '/user/upload/images',
{'fraction_non_alphanumeric': 0.12486544671689989, 'fraction_numerical': 0.0012302014454866985, 'mean_word_length': 1.134558582212012, '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': '5146852', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1513, 'n_words': 375}