<commit_before>'use strict';

/**
 * @ngdoc overview
 * @name dreamfactoryApp
 * @description
 * # dreamfactoryApp
 *
 * Main module of the application.
 */
angular
    .module('dreamfactoryApp', [
        'ngAnimate',
        'ngCookies',
        'ngResource',
        'ngRoute',
        'ngSanitize',
        'ngTouch',
        'dfUtility',
        'dfHome',
        'dfSystemConfig',
        'dfAdmins',
        'dfUsers',
        'dfApps',
        'dfData',
        'dfServices',
        'dfRoles',
        'dfSchema',
        'dfUserManagement',
        'dfScripts',
        'dfProfile',
        'dfApplication',
        'dfHelp',
        'dfLaunchPad',
        'dfApiDocs',
        'dfFileManager',
        'dfPackageManager',
        'dfLimit',
        'dfLicenseExpired',
        'dfLicenseExpiredBanner',
        'dfLimit',
        'dfReports',
        'dfScheduler'
    ])

    // each tab uses this in its resolve function to make sure user is allowed access
    // if access is not allowed the user is sent to launchpad
    .factory('checkUserService', function ($location, $q, SystemConfigDataService) {

        return {

            checkUser: function () {

                var deferred = $q.defer();

                // check if admin app access is allowed
                // it will be allowed for admin users, and non-admin users whose role allows it
                // if no role is assigend for the user for the admin app the default role can also allow access

                var systemConfig = SystemConfigDataService.getSystemConfig();
                var result = false;
                if (systemConfig) {
                    result = (systemConfig.apps && systemConfig.apps.filter(function (item) {
                        return (item.name === 'admin');
                    }).length > 0);
                }
                if (result) {
                    // user has access to admin, proceed to load the requested admin route
                    deferred.resolve();
                } else {
                    // user does not have access to admin, redirect to launchpad
                    $location.url('/launchpad');
                    deferred.reject();
                }
                return deferred.promise;
            }
        };
    })

    // some tabs need to check if user is an admin

    .factory('checkAdminService', function ($q, UserDataService, $location) {

        return {

            checkAdmin: function () {

                var deferred = $q.defer();
                var currentUser = UserDataService.getCurrentUser();

                if (currentUser && currentUser.is_sys_admin) {
                    // admin
                    deferred.resolve();
                } else {
                    // not admin
                    $location.url('/launchpad');
                    deferred.reject();
                }

                return deferred.promise;
            }
        };
    })

    .factory('allowAdminAccess', function (SystemConfigDataService) {

        return {

            get: function () {
                var result = false;
                var systemConfig = SystemConfigDataService.getSystemConfig();
                if (systemConfig) {
                    result = (systemConfig.apps && systemConfig.apps.filter(function (item) {
                        return (item.name === 'admin');
                    }).length > 0);
                }
                return result;
            }
        };
    })

    // Set application version number
    .constant('APP_VERSION', '4.9.0')

    // Set global url for this application
    .constant('INSTANCE_BASE_URL', '')

    // Make prefix configurable
    .constant('INSTANCE_API_PREFIX', '/api/v2')

    // App should use this service when making calls to the API<commit_msg>Release 4.10.0<commit_after>'use strict';

/**
 * @ngdoc overview
 * @name dreamfactoryApp
 * @description
 * # dreamfactoryApp
 *
 * Main module of the application.
 */
angular
    .module('dreamfactoryApp', [
        'ngAnimate',
        'ngCookies',
        'ngResource',
        'ngRoute',
        'ngSanitize',
        'ngTouch',
        'dfUtility',
        'dfHome',
        'dfSystemConfig',
        'dfAdmins',
        'dfUsers',
        'dfApps',
        'dfData',
        'dfServices',
        'dfRoles',
        'dfSchema',
        'dfUserManagement',
        'dfScripts',
        'dfProfile',
        'dfApplication',
        'dfHelp',
        'dfLaunchPad',
        'dfApiDocs',
        'dfFileManager',
        'dfPackageManager',
        'dfLimit',
        'dfLicenseExpired',
        'dfLicenseExpiredBanner',
        'dfLimit',
        'dfReports',
        'dfScheduler'
    ])

    // each tab uses this in its resolve function to make sure user is allowed access
    // if access is not allowed the user is sent to launchpad
    .factory('checkUserService', function ($location, $q, SystemConfigDataService) {

        return {

            checkUser: function () {

                var deferred = $q.defer();

                // check if admin app access is allowed
                // it will be allowed for admin users, and non-admin users whose role allows it
                // if no role is assigend for the user for the admin app the default role can also allow access

                var systemConfig = SystemConfigDataService.getSystemConfig();
                var result = false;
                if (systemConfig) {
                    result = (systemConfig.apps && systemConfig.apps.filter(function (item) {
                        return (item.name === 'admin');
                    }).length > 0);
                }
                if (result) {
                    // user has access to admin, proceed to load the requested admin route
                    deferred.resolve();
                } else {
                    // user does not have access to admin, redirect to launchpad
                    $location.url('/launchpad');
                    deferred.reject();
                }
                return deferred.promise;
            }
        };
    })

    // some tabs need to check if user is an admin

    .factory('checkAdminService', function ($q, UserDataService, $location) {

        return {

            checkAdmin: function () {

                var deferred = $q.defer();
                var currentUser = UserDataService.getCurrentUser();

                if (currentUser && currentUser.is_sys_admin) {
                    // admin
                    deferred.resolve();
                } else {
                    // not admin
                    $location.url('/launchpad');
                    deferred.reject();
                }

                return deferred.promise;
            }
        };
    })

    .factory('allowAdminAccess', function (SystemConfigDataService) {

        return {

            get: function () {
                var result = false;
                var systemConfig = SystemConfigDataService.getSystemConfig();
                if (systemConfig) {
                    result = (systemConfig.apps && systemConfig.apps.filter(function (item) {
                        return (item.name === 'admin');
                    }).length > 0);
                }
                return result;
            }
        };
    })

    // Set application version number
    .constant('APP_VERSION', '4.10.0')

    // Set global url for this application
    .constant('INSTANCE_BASE_URL', '')

    // Make prefix configurable
    .constant('INSTANCE_API_PREFIX', '/api/v2')

    // App should use this service when making calls to the API
{'fraction_non_alphanumeric': 0.10183727034120735, 'fraction_numerical': 0.002230971128608924, 'mean_word_length': 1.4255251432208784, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5786956', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1819, 'n_words': 520}