<commit_before>/*************************************************
 * Copyright (c) 2016 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/
/**
 * For setting the values and choices for notification lists
 *
 * NotificationsListInit({
 *     scope:       scope,
 *     id:          notification.id to update
 *     url:         notifier url off of related object
 * });
 *
 */

export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest',
    function(Wait, GetBasePath, ProcessErrors, Rest) {
    return function(params) {
        var scope = params.scope,
            url = params.url,
            id = params.id;

        if (scope.relatednotificationsRemove) {
            scope.relatednotificationsRemove();
        }
        scope.relatednotificationsRemove = scope.$on('relatednotifications', function () {
                var columns = ['/notification_templates_success/', '/notification_templates_error/'];

                _.map(columns, function(column){
                    var notifier_url = url + id + column;
                    Rest.setUrl(notifier_url);
                    Rest.get()
                        .success( function(data, i, j, obj) {
                            var type = (obj.url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error";
                            if (data.results) {
                                    _.forEach(data.results, function(result){
                                        _.forEach(scope.notifications, function(notification){
                                            if(notification.id === result.id){
                                                notification[type] = true;
                                            }
                                        });
                                    });
                            }
                            else {
                                Wait('stop');
                            }
                        })
                        .error( function(data, status) {
                            ProcessErrors(scope, data, status, null, { hdr: 'Error!',
                                msg: 'Failed to update notification ' + data.id + ' PUT returned: ' + status });
                        });
                });

        });
    };
}];
<commit_msg>Adding labels for notifications on related tabs<commit_after>/*************************************************
 * Copyright (c) 2016 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/
/**
 * For setting the values and choices for notification lists
 *
 * NotificationsListInit({
 *     scope:       scope,
 *     id:          notification.id to update
 *     url:         notifier url off of related object
 * });
 *
 */

export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
    function(Wait, GetBasePath, ProcessErrors, Rest, GetChoices) {
    return function(params) {
        var scope = params.scope,
            url = params.url,
            id = params.id;

        if (scope.relatednotificationsRemove) {
            scope.relatednotificationsRemove();
        }
        scope.relatednotificationsRemove = scope.$on('relatednotifications', function () {
                var columns = ['/notification_templates_success/', '/notification_templates_error/'];

                GetChoices({
                    scope: scope,
                    url: GetBasePath('notifications'),
                    field: 'notification_type',
                    variable: 'notification_type_options',
                    callback: 'choicesReadyNotifierList'
                });

                _.map(columns, function(column){
                    var notifier_url = url + id + column;
                    Rest.setUrl(notifier_url);
                    Rest.get()
                        .success( function(data, i, j, obj) {
                            var type = (obj.url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error";
                            if (data.results) {
                                    _.forEach(data.results, function(result){
                                        _.forEach(scope.notifications, function(notification){
                                            if(notification.id === result.id){
                                                notification[type] = true;
                                            }
                                        });
                                    });
                            }
                            else {
                                Wait('stop');
                            }
                        })
                        .error( function(data, status) {
                            ProcessErrors(scope, data, status, null, { hdr: 'Error!',
                                msg: 'Failed to update notification ' + data.id + ' PUT returned: ' + status });
                        });
                });

                if (scope.removeChoicesHere) {
                    scope.removeChoicesHere();
                }
                scope.removeChoicesHere = scope.$on('choicesReadyNotifierList', function () {
                    if (scope.notifications) {
                        scope.notifications.forEach(function(notification, i) {
                            scope.notification_type_options.forEach(function(type) {
                                if (type.value === notification.notification_type) {
                                    scope.notifications[i].notification_type = type.label;
                                }
                            });
                        });
                    }
                });

        });
    };
}];

{'fraction_non_alphanumeric': 0.12921541637990364, 'fraction_numerical': 0.0017205781142463868, 'mean_word_length': 1.1894538606403013, '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': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5397626', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1185, 'n_words': 255}