<commit_before>var {ipcRenderer} = require('electron');
var kongConfig = ipcRenderer.sendSync('get-kong-config');

var app = angular.module('KongDashApp', ['ngRoute', 'ngAnimate', 'kongdash']);

app.config(['$routeProvider', 'kdAjaxProvider' , function ($routeProvider, kdAjaxProvider) {

    kdAjaxProvider.setHost(kongConfig.host);

    /* Add a basic authorization header
    if username and password are provided in the settings */
    if (typeof kongConfig.username === 'string' && kongConfig.username) {
        kdAjaxProvider.basicAuth(kongConfig.username, kongConfig.password || '');
    }

    /* Configure routeProvider */
    $routeProvider
        .when('/', {
            templateUrl: 'views/dashboard.html',
            controller: 'DashboardController'
        })
        .when('/api', {
            templateUrl: 'views/api-list.html',
            controller: 'ApiListController'
        })
        .when('/api/:apiId', {
            templateUrl: 'views/api-edit.html',
            controller: 'ApiEditController'
        })
        .when('/api/:apiId/plugins', {
            templateUrl: 'views/plugin-edit.html',
            controller: 'PluginEditController'
        })
        .when('/plugins', {
            templateUrl: 'views/plugin-list.html',
            controller: 'PluginListController'
        })
        .when('/plugins/:pluginId', {
            templateUrl: 'views/plugin-edit.html',
            controller: 'PluginEditController'
        })
        .when('/consumers', {
            templateUrl: 'views/consumer-list.html',
            controller: 'ConsumerListController'
        })
        .when('/consumers/:consumerId', {
            templateUrl: 'views/consumer-edit.html',
            controller: 'ConsumerEditController'
        })
        .when('/consumers/:consumerId/plugins', {
            templateUrl: 'views/plugin-list.html',
            controller: 'PluginListController'
        })
        .when('/settings', {
            templateUrl: 'views/settings.html',
            controller: 'SettingsController'
        })
}]);

/**
 * Converts first letter of a string to uppercase and
 * replaces underscores with whitespaces.
 */
app.filter('pgname', function () {
    return function (input) {
        if (typeof input != 'string' || input == null) {
            return '';
        }

        return (input.charAt(0).toUpperCase() + input.substr(1).toLowerCase()).split('_').join(' ');
    }
});

/**
 * Strips protocol (http:// or https://) from URL.
 */
app.filter('stripProtocol', function () {
    return function (input) {
        if (!input) return '';

        if (input.indexOf('s://') > 1) return input.split('https://')[1];

        return (input.split('http://')[1]) || '';
    }
});

/**
 * Joins a string array with commas.
 */
app.filter('splice', function () {
    return function (input) {
        if (typeof input != 'object') {
            return '';
        }

        return input.join(', ');
    };
});

/**
 * Holds current page title, current host URL and
 * URL of the previous page.
 */
app.factory('viewFactory', function () {
    return { title: '', prevUrl: '', host: kongConfig.host }
});

/**
 * Detects and highlights the correct
 * sidebar link upon location change.
 */
app.run(['$rootScope', 'viewFactory', function ($rootScope, viewFactory) {
    var appConfig = ipcRenderer.sendSync('get-app-config');

    $rootScope.ngViewAnimation = appConfig.enableAnimation ? 'slide-right' : '';

    $rootScope.$on('$locationChangeStart', function (event, next, current) {
        viewFactory.deleteAction = null;
        viewFactory.prevUrl = current;

        if (next.indexOf('#') > 1) {
            var refArray = next.split('#/')[1].split('/');

            var href = '#/' + refArray[0], nav = angular.element('nav.navigation');

            nav.find('a.navigation__link').removeClass('active');
            nav.find('.navigation__link[data-ng-href="' + href + '"]').addClass('active')
        }
    })
}]);<commit_msg>[BUGFIX] ndDependency modified<commit_after>var app = angular.module('KongDash', ['ngAnimate', 'base64'].concat(typeof ngDependency === 'undefined' ? [] : ngDependency));

app.provider('ajax', ['$base64',  function ($base64) {
    var httpConfig = {};

    var httpRequest = function (config) {
        var request = {
            method: config.method,
            url: config.url || (httpConfig.host + config.resource),
            headers: {},
            withCredentials: false
        };

        if (typeof config.data === 'object')
            request.data = config.data;

        if (typeof httpConfig.authorization === 'string') {
            request.withCredentials = true;
            request.headers['Authorization'] = httpConfig.authorization;
        }

        if (typeof httpConfig.accept === 'string')
            request.headers['Accept'] = httpConfig.accept;

        if (typeof httpConfig.contentType === 'string')
            request.headers['Content-Type'] = httpConfig.contentType;

        if (typeof config.headers === 'object') {
            Object.keys(config.headers).forEach(function (item) {
                request.headers[item] = config.headers[item];
            });
        }

        if (Object.keys(request.headers).length <= 0)
            delete request.headers;

        return request;
    };

    this.setHost = function (host) {
        httpConfig.host = host;
    };

    this.basicAuth = function (username, password) {
        httpConfig.authorization = 'Basic ' + $base64.encode(username + ':' + (password || ''));
    };

    this.accept = function (type) {
        httpConfig.accept = 'Accept: ' + type;
    };

    this.contentType = function (type) {
        httpConfig.contentType = 'Content-Type: ' + type;
    };

    this.$get = ['$http', function ($http) {
        return {
            request: function (config) {
                return $http(httpRequest(config))
            },
            get: function (config) {
                config.method = 'GET';
                return $http(httpRequest(config));
            },
            post: function (config) {
                config.method = 'POST';
                return $http(httpRequest(config));
            },
            put: function (config) {
                config.method = 'PUT';
                return $http(httpRequest(config));
            },
            patch: function (config) {
                config.method = 'PATCH';
                return $http(httpRequest(config));
            },
            delete: function (config) {
                config.method = 'DELETE';
                return $http(httpRequest(config));
            }
        };
    }];
}]);

app.factory('toast', function () {
    return {
        displayMessage: function (message) {
            var body = angular.element('body'), status;

            if (body.children('.notification').length > 0)
                body.children('.notification').remove();

            var text = '';

            try {
                if (typeof message.text === 'object') {
                    if (Object.keys(message.text).length > 0) {
                        var firstKey = Object.keys(message.text)[0];

                        if ((firstKey === 'error' || firstKey === 'message') && typeof message.text[firstKey] === 'string') {
                            text = message.text[firstKey];
                        } else {
                            text = firstKey + ' ' + message.text[firstKey];
                        }
                    } else {
                        text = 'No details available!';
                    }
                } else {
                    text = message.text
                }
            } catch (e) {
                text = 'No details available!'
            }

            switch (message.type) {
                case 'danger':
                    status = 'Error!';
                    break;

                case 'success':
                    status = 'Success!';
                    break;

                case 'warning':
                    status = 'Warning!';
                    break;

                default:
                    status = 'Message:';
                    break
            }

            var div = angular.element('<div></div>', {class: 'notification ' + message.type})
                .html('<b>' + status + '</b> ' + text + '.')
                .on('click', function () {
                    div.fadeOut(200);
                });

            body.append(div);
            var interval = setInterval(function () {
                div.fadeOut({
                    duration: 1000, complete: function () {
                        clearInterval(interval);
                    }
                })
            }, 4000);
        },
        error: function (message) {
            this.displayMessage({type: 'danger', text: message})
        },
        warning: function (message) {
            this.displayMessage({type: 'warning', text: message})
        },
        info: function (message) {
            this.displayMessage({type: 'info', text: message})
        },
        success: function (message) {
            this.displayMessage({type: 'success', text: message})
        }
    };
});

/**
 * Converts first letter of a string to uppercase and
 * replaces underscores with whitespaces.
 */
app.filter('pgname', function () {
    return function (input) {
        if (typeof input != 'string' || input == null) {
            return '';
        }

        return (input.charAt(0).toUpperCase() + input.substr(1).toLowerCase()).split('_').join(' ');
    }
});

/**
 * Strips protocol (http:// or https://) from URL.
 */
app.filter('stripProtocol', function () {
    return function (input) {
        if (!input) return '';

        if (input.indexOf('s://') > 1) return input.split('https://')[1];

        return (input.split('http://')[1]) || '';
    }
});

/**
 * Joins a string array with commas.
 */
app.filter('splice', function () {
    return function (input) {
        if (typeof input != 'object') {
            return '';
        }

        return input.join(', ');
    };
});
{'fraction_non_alphanumeric': 0.15131773763695588, 'fraction_numerical': 0.0035534498075214687, 'mean_word_length': 1.7758904109589042, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, 'https://': 4, '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': '599968', 'n_tokens_mistral': 2747, 'n_tokens_neox': 2639, 'n_words': 563}