<commit_before>/**
 * This file is part of DreamFactory (tm)
 *
 * http://github.com/dreamfactorysoftware/dreamfactory
 * Copyright 2012-2014 DreamFactory Software, Inc. <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
'use strict';


angular.module('dfHome', ['ngRoute', 'dfUtility', 'dfApplication', 'dfHelp'])
    .constant('MOD_HOME_ROUTER_PATH', '/home')
    .constant('MOD_HOME_ASSET_PATH', 'admin_components/adf-home/')
    .config(['$routeProvider', 'MOD_HOME_ROUTER_PATH', 'MOD_HOME_ASSET_PATH',
        function ($routeProvider, MOD_HOME_ROUTER_PATH, MOD_HOME_ASSET_PATH) {
            $routeProvider
                .when(MOD_HOME_ROUTER_PATH, {
                    templateUrl: MOD_HOME_ASSET_PATH + 'views/main.html',
                    controller: 'HomeCtrl',
                    resolve: {
                        checkAppObj:['dfApplicationData', function (dfApplicationData) {

                            if (dfApplicationData.initInProgress) {

                                return dfApplicationData.initDeferred.promise;
                            }
                        }],
                        checkCurrentUser: ['UserDataService', '$location', '$q', function (UserDataService, $location, $q) {

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

                            // If there is no currentUser and we don't allow guest users
                            if (!currentUser) {

                                $location.url('/login');

                                // This will stop the route from loading anything
                                // it's caught by the global error handler in
                                // app.js
                                throw {
                                    routing: true
                                }
                            }

                            // There is a currentUser but they are not an admin
                            else if (currentUser && !currentUser.is_sys_admin) {

                                $location.url('/launchpad');

                                // This will stop the route from loading anything
                                // it's caught by the global error handler in
                                // app.js
                                throw {
                                    routing: true
                                }
                            }

                            defer.resolve();
                            return defer.promise;
                        }]
                    }
                });
        }])
    .run(['INSTANCE_URL', '$templateCache', function (INSTANCE_URL, $templateCache) {



    }])

    .controller('HomeCtrl', ['$scope', '$sce', 'dfApplicationData', 'SystemConfigDataService',
        function($scope, $sce, dfApplicationData, SystemConfigDataService){

            $scope.trustUrl = function (url) {
                return $sce.trustAsResourceUrl(url);
            }

            $scope.$parent.title = 'Home';

            $scope.apps = dfApplicationData.getApiData('app');

            var statsQueryParams = [
                'total_users=' + dfApplicationData.getApiData('user').length,
                'total_admins=' + dfApplicationData.getApiData('admin').length,
                'total_services=' +  dfApplicationData.getApiData('service').length,
                'total_apps=' + dfApplicationData.getApiData('app').length
            ].join('&');

            // Set module links
            $scope.links = angular.copy(SystemConfigDataService.getSystemConfig().home_links) || [
                {
                    name: 'welcome-home',
                    label: 'Welcome',
                    href: "//www.dreamfactory.com/in_product_v2/welcome.html?" + statsQueryParams,
                    attributes: []
                },
                {
                    name: 'quickstart-home',
                    label: 'Quickstart',
                    href: "//www.dreamfactory.com/in_product_v2/quickstart.html",
                    attributes: []
                },
                {
                    name: 'resource-home',<commit_msg>update to get total count<commit_after>/**
 * This file is part of DreamFactory (tm)
 *
 * http://github.com/dreamfactorysoftware/dreamfactory
 * Copyright 2012-2014 DreamFactory Software, Inc. <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
'use strict';


angular.module('dfHome', ['ngRoute', 'dfUtility', 'dfApplication', 'dfHelp'])
    .constant('MOD_HOME_ROUTER_PATH', '/home')
    .constant('MOD_HOME_ASSET_PATH', 'admin_components/adf-home/')
    .config(['$routeProvider', 'MOD_HOME_ROUTER_PATH', 'MOD_HOME_ASSET_PATH',
        function ($routeProvider, MOD_HOME_ROUTER_PATH, MOD_HOME_ASSET_PATH) {
            $routeProvider
                .when(MOD_HOME_ROUTER_PATH, {
                    templateUrl: MOD_HOME_ASSET_PATH + 'views/main.html',
                    controller: 'HomeCtrl',
                    resolve: {
                        checkAppObj:['dfApplicationData', function (dfApplicationData) {

                            if (dfApplicationData.initInProgress) {

                                return dfApplicationData.initDeferred.promise;
                            }
                        }],
                        checkCurrentUser: ['UserDataService', '$location', '$q', function (UserDataService, $location, $q) {

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

                            // If there is no currentUser and we don't allow guest users
                            if (!currentUser) {

                                $location.url('/login');

                                // This will stop the route from loading anything
                                // it's caught by the global error handler in
                                // app.js
                                throw {
                                    routing: true
                                }
                            }

                            // There is a currentUser but they are not an admin
                            else if (currentUser && !currentUser.is_sys_admin) {

                                $location.url('/launchpad');

                                // This will stop the route from loading anything
                                // it's caught by the global error handler in
                                // app.js
                                throw {
                                    routing: true
                                }
                            }

                            defer.resolve();
                            return defer.promise;
                        }]
                    }
                });
        }])
    .run(['INSTANCE_URL', '$templateCache', function (INSTANCE_URL, $templateCache) {



    }])

    .controller('HomeCtrl', ['$scope', '$sce', 'dfApplicationData', 'SystemConfigDataService',
        function($scope, $sce, dfApplicationData, SystemConfigDataService){

            $scope.trustUrl = function (url) {
                return $sce.trustAsResourceUrl(url);
            }

            $scope.$parent.title = 'Home';

            $scope.apps = dfApplicationData.getApiData('app');

            var statsQueryParams = [
                'total_users=' + dfApplicationData.getApiData('user', 'meta').count,
                'total_admins=' + dfApplicationData.getApiData('admin', 'meta').count,
                'total_services=' +  dfApplicationData.getApiData('service', 'meta').count,
                'total_apps=' + dfApplicationData.getApiData('app', 'meta').count
            ].join('&');

            // Set module links
            $scope.links = angular.copy(SystemConfigDataService.getSystemConfig().home_links) || [
                {
                    name: 'welcome-home',
                    label: 'Welcome',
                    href: "//www.dreamfactory.com/in_product_v2/welcome.html?" + statsQueryParams,
                    attributes: []
                },
                {
                    name: 'quickstart-home',
                    label: 'Quickstart',
                    href: "//www.dreamfactory.com/in_product_v2/quickstart.html",
                    attributes: []
                },
                {
                    name: 'resource-home',
{'fraction_non_alphanumeric': 0.0987861029719548, 'fraction_numerical': 0.0029300962745918793, 'mean_word_length': 1.3685254027261462, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6607687', 'n_tokens_mistral': 2355, 'n_tokens_neox': 2180, 'n_words': 541}