<commit_before>angular.module('pullImage', [])
    .controller('PullImageController', ['$scope', '$log', 'Dockerfile', 'Messages', 'Image', 'ViewSpinner',
        function($scope, $log, Dockerfile, Messages, Image, ViewSpinne) {
            $scope.template = 'app/components/pullImage/pullImage.html';

            $scope.config = {
                registry: '',
                repo: '',
                fromImage: '',
                tag: 'latest'
            }

            function failedRequestHandler(e, Messages) {
                Messages.error('Error', errorMsgFilter(e));
            }

            $scope.pull = function() {
                $('#error-message').hide();
                var config = angular.copy($scope.config);
                var imageName = (config.registry ? config.registry + '/' : '' ) +
                    (config.repo ? config.repo + '/' : '') +
                    (config.fromImage) +
                    (config.tag ? ':' + config.tag : '');

                ViewSpinner.spin();
                Image.create(config, function(data) {
                    ViewSpinner.stop();
                    if (data.constructor === Array) {
                        var f = data.length > 0 && data[data.length-1].hasOwnProperty('error');
                        //check for error
                        if (f) {
                            var d = data[data.length - 1];
                            $scope.error = "Cannot pull image " + imageName + " Reason: " + d.error;
                            $('#error-message').show();
                        } else {
                            Messages.send("Image Added", imageName);
                            $('#pull-modal').modal('hide');
                        }
                    } else {
                        Messages.send("Image Added", imageName);
                        $('#pull-modal').modal('hide');
                    }
                }, function(e) {
                    ViewSpinner.stop();
                    $scope.error = "Cannot pull image " + imageName + " Reason: " + e.data;
                    $('#error-message').show();
                });
            }
        }]);<commit_msg>dockerui-118 How to pull images / create container from repo image ? -Fixed ViewSpinner variable. -Hide the modal on submit, show Spinner and show again modal if needed (in case of error) -Clear modal values after successful pull<commit_after>angular.module('pullImage', [])
    .controller('PullImageController', ['$scope', '$log', 'Dockerfile', 'Messages', 'Image', 'ViewSpinner',
        function($scope, $log, Dockerfile, Messages, Image, ViewSpinner) {
            $scope.template = 'app/components/pullImage/pullImage.html';

            $scope.init = function() {
                $scope.config = {
                    registry: '',
                    repo: '',
                    fromImage: '',
                    tag: 'latest'
                }
            }

            $scope.init();

            function failedRequestHandler(e, Messages) {
                Messages.error('Error', errorMsgFilter(e));
            }

            $scope.pull = function() {
                $('#error-message').hide();
                var config = angular.copy($scope.config);
                var imageName = (config.registry ? config.registry + '/' : '' ) +
                    (config.repo ? config.repo + '/' : '') +
                    (config.fromImage) +
                    (config.tag ? ':' + config.tag : '');

                ViewSpinner.spin();
                $('#pull-modal').modal('hide');
                Image.create(config, function(data) {
                    ViewSpinner.stop();
                    if (data.constructor === Array) {
                        var f = data.length > 0 && data[data.length-1].hasOwnProperty('error');
                        //check for error
                        if (f) {
                            var d = data[data.length - 1];
                            $scope.error = "Cannot pull image " + imageName + " Reason: " + d.error;
                            $('#pull-modal').modal('show');
                            $('#error-message').show();
                        } else {
                            Messages.send("Image Added", imageName);
                            $scope.init();
                        }
                    } else {
                        Messages.send("Image Added", imageName);
                        $scope.init();
                    }
                }, function(e) {
                    ViewSpinner.stop();
                    $scope.error = "Cannot pull image " + imageName + " Reason: " + e.data;
                    $('#pull-modal').modal('show');
                    $('#error-message').show();
                });
            }
        }]);
{'fraction_non_alphanumeric': 0.1410469464063149, 'fraction_numerical': 0.0018695471541337765, 'mean_word_length': 1.1728339350180506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7312634', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1109, 'n_words': 227}