<commit_before>/**
 * Created by Ahmet on 08.06.2016.
 */

var mainAppCtrls = angular.module("mainAppCtrls");
/**
 * @ngdoc controller
 * @name mainAppCtrls.controller:adminWorkshopDetailsCtrl
 * @requires restSvcs.Workshops
 * @description Controller for showing administrator functions in a workshop.
 */
mainAppCtrls.controller('adminWorkshopDetailsCtrl',['$scope','Workshops', '$stateParams', "$alert",'printer','$translate',
    function($scope,Workshops,$stateParams, $alert,printer,$translate) {
        //Get translations for errors and store in array
        var _translations = {};
        //Pass all required translation IDs to translate service
        $translate(['ALERT_NO_PARTICIPANTS']).
        then(function(translations){
            _translations = translations;
        });
        
        //TODO : replace with workshop details
        var workshopid;
        workshopid = $stateParams.id;
        $scope.loading = true;
        Workshops.get({id: workshopid}).$promise.then(function(value,httpResponse){
            $scope.workshop = value;

            var _ea = Date.parse($scope.workshop.end_at);
            var _sa = Date.parse($scope.workshop.start_at);
            $scope.workshop.duration = new Date(_ea - _sa);
            
            $scope.loading = false;
        },function(httpResponse) {
            $alert({
                title: '',
                type: 'danger',
                content: httpReponse.status,
                container: '#alert',
                dismissable: false,
                show: true
            });
            $scope.loading = false;
        });
        $scope.loading = true;
        Workshops.getParticipants({id: workshopid}).$promise.then(function(value,httpResponse){
            $scope.participants = value;

            $scope.loading = false;
        },function(httpResponse) {
            switch(httpResponse.status){
                case 404:
                    $alert({
                        title: '',
                        type: 'info',
                        content: _translations.ALERT_NO_PARTICIPANTS,
                        container: '#alertParticipant',
                        dismissable: false,
                        show: true,
                        animation: 'am-fade-and-slide-top'
                    });
            }
            $scope.loading = false;
        });
        $scope.loading = true;
        Workshops.getWaitinglist({id: workshopid}).$promise.then(function(response){
            $scope.waitingList = response;
            $scope.loading = false;
        },function(response){
            $scope.loading = false;
        });
        /**
         * @ngdoc function
         * @name mainAppCtrls.controller:adminWorkshopDetailsCtrl#printList
         * @methodOf mainAppCtrls.controller:adminWorkshopDetailsCtrl
         * @description Prints the participants list
         */
        $scope.printList = function() {
            printer.print('resources/views/participantList.tpl.html',{});
        }
        /**
         * @ngdoc function
         * @name mainAppCtrls.controller:adminWorkshopDetailsCtrl#delete
         * @methodOf mainAppCtrls.controller:adminWorkshopDetailsCtrl
         * @param {number} _id id of the partcipant, which should be deleted
         * @description Deletes the participant with the passed id
         */
        $scope.delete = function (_id) {
            Workshops.delete({id:_id}).$promise.then(function(httpresponse){
                    $alert({
                        title:'',
                        type: 'success',
                        container:'#alert',
                        show: true,
                        dismissable: false,
                        content: _translations.ALERT_WORKSHOP_DELETE_PARTICIPANT,
                        duration: 20
                    });
                    loadTemplates();
                }
                , function (httpResponse) {
                    $alert({
                        title: '',
                        type: 'danger',
                        content: _translations.ALERT_WORKSHOP_DELETE_PARTICIPANT_FAIL + ' (' + httpReponse.status +')',
                        container: '#alert',
                        dismissable: false,
                        show: true
                    });
                }
            )

        }
        
        
        
        
    }
])<commit_msg>Updated adminWorkshopDetailsCtrl.js<commit_after>/**
 * Created by Ahmet on 08.06.2016.
 */

var mainAppCtrls = angular.module("mainAppCtrls");
/**
 * @ngdoc controller
 * @name mainAppCtrls.controller:adminWorkshopDetailsCtrl
 * @requires restSvcs.Workshops
 * @description Controller for showing administrator functions in a workshop.
 */
mainAppCtrls.controller('adminWorkshopDetailsCtrl',['$scope','Workshops','Participants', '$stateParams', "$alert",'printer','$translate',
    function($scope,Workshops,Participants, $stateParams, $alert,printer,$translate) {
        //Get translations for errors and store in array
        var _translations = {};
        //Pass all required translation IDs to translate service
        $translate(['ALERT_NO_PARTICIPANTS']).
        then(function(translations){
            _translations = translations;
        });
        
        var workshopid;
        workshopid = $stateParams.id;
        $scope.loading = true;
        Workshops.get({id: workshopid}).$promise.then(function(value,httpResponse){
            $scope.workshop = value;

            var _ea = Date.parse($scope.workshop.end_at);
            var _sa = Date.parse($scope.workshop.start_at);
            $scope.workshop.duration = new Date(_ea - _sa);
            
            $scope.loading = false;
        },function(httpResponse) {
            $alert({
                title: '',
                type: 'danger',
                content: httpReponse.status,
                container: '#alert',
                dismissable: false,
                show: true
            });
            $scope.loading = false;
        });
        $scope.loading = true;
        Workshops.getParticipants({id: workshopid}).$promise.then(function(value,httpResponse){
            $scope.participants = value;

            $scope.loading = false;
        },function(httpResponse) {
            switch(httpResponse.status){
                case 404:
                    $alert({
                        title: '',
                        type: 'info',
                        content: _translations.ALERT_NO_PARTICIPANTS,
                        container: '#alertParticipant',
                        dismissable: false,
                        show: true,
                        animation: 'am-fade-and-slide-top'
                    });
            }
            $scope.loading = false;
        });
        $scope.loading = true;
        Workshops.getWaitinglist({id: workshopid}).$promise.then(function(response){
            $scope.waitingList = response;
            $scope.loading = false;
        },function(response){
            $scope.loading = false;
        });

        /**
         * @ngdoc function
         * @name mainAppCtrls.controller:adminWorkshopDetailsCtrl#loadList
         * @methodOf mainAppCtrls.controller:adminWorkshopDetailsCtrl
         * @description Function to load a list of remaining Participants
         */
        var loadList = function (){
            $scope.loading = true;
            Participants.getParticipants()
            ({id: workshopid}).$promise.then(function(value,httpResponse){
                $scope.participants = value;
            }, function (httpResponse) {
                $scope.loading = false;
            });
        };
        
        /**
         * @ngdoc function
         * @name mainAppCtrls.controller:adminWorkshopDetailsCtrl#printList
         * @methodOf mainAppCtrls.controller:adminWorkshopDetailsCtrl
         * @description Prints the participants list
         */
        $scope.printList = function() {
            printer.print('resources/views/participantList.tpl.html',{});
        }
        /**
         * @ngdoc function
         * @name mainAppCtrls.controller:adminWorkshopDetailsCtrl#delete
         * @methodOf mainAppCtrls.controller:adminWorkshopDetailsCtrl
         * @param {number} _id id of the participant, which should be deleted
         * @description Deletes the participant with the passed id
         */
        $scope.delete = function (_id) {
            Workshops.delete({id:_id}).$promise.then(function(httpresponse){
                    $alert({
                        title:'',
                        type: 'success',
                        container:'#alert',
                        show: true,
                        dismissable: false,
                        content: _translations.ALERT_WORKSHOP_DELETE_PARTICIPANT,
                        duration: 20
                    });
                    loadList();
                }
                , function (httpResponse) {
                    $alert({
                        title: '',
                        type: 'danger',
                        content: _translations.ALERT_WORKSHOP_DELETE_PARTICIPANT_FAIL + ' (' + httpReponse.status +')',
                        container: '#alert',
                        dismissable: false,
                        show: true
                    });
                }
            )

        }
        
        
        
        
    }
])
{'fraction_non_alphanumeric': 0.10502958579881656, 'fraction_numerical': 0.0027472527472527475, 'mean_word_length': 1.523327112769928, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7387746', 'n_tokens_mistral': 2426, 'n_tokens_neox': 2287, 'n_words': 434}