<commit_before>/**
 * This file is part of the DreamFactory Services Platform(tm) (DSP)
 *
 * DreamFactory Services Platform(tm) <http://github.com/dreamfactorysoftware/dsp-core>
 * 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('dfScripting', ['ngRoute', 'dfUtility'])
    .constant('MODSCRIPTING_ROUTER_PATH', '/scripts')
    .constant('MODSCRIPTING_ASSET_PATH', 'admin_components/dreamfactory_components/adf-scripting/')
    .config(['$routeProvider', 'MODSCRIPTING_ROUTER_PATH', 'MODSCRIPTING_ASSET_PATH',
        function ($routeProvider, MODSCRIPTING_ROUTER_PATH, MODSCRIPTING_ASSET_PATH) {
            $routeProvider
                .when(MODSCRIPTING_ROUTER_PATH, {
                    templateUrl: MODSCRIPTING_ASSET_PATH + 'views/main.html',
                    controller: 'ScriptingCtrl',
                    resolve: {
                        startLoadingScreen: ['dfLoadingScreen', function (dfLoadingScreen) {

                            // start the loading screen
                            dfLoadingScreen.start();
                        }],

                        getEventList: ['DSP_URL', '$http', function(DSP_URL, $http) {

                            return $http({
                                method: 'GET',
                                url: DSP_URL + '/rest/system/event',
                                params: {
                                    all_events: true
                                }
                            });
                        }],

                        getRecentScripts: ['DSP_URL', '$http', function(DSP_URL, $http) {

                            return $http({
                                method: 'GET',
                                url: DSP_URL + '/rest/system/script'
                            });
                        }],

                        getSampleScripts: ['DSP_URL', '$http', function(DSP_URL, $http) {

                            return $http({
                                method: 'GET',
                                url: 'js/example.scripts.js',
                                dataType: "text"
                            });
                        }]

                    }
                });
        }])
    .run(['DSP_URL', '$http', function (DSP_URL, $http) {

    }])
    .controller('ScriptingCtrl', ['DSP_URL', '$scope', '$http', 'getEventList', 'getRecentScripts', 'getSampleScripts', 'dfLoadingScreen', 'SystemConfigDataService', function (DSP_URL, $scope, $http, getEventList, getRecentScripts, getSampleScripts, dfLoadingScreen, SystemConfigDataService) {


        $scope.isHostedSystem = SystemConfigDataService.getSystemConfig().is_hosted;

        $scope.__getDataFromHttpResponse = function (httpResponseObj) {

            if (httpResponseObj.hasOwnProperty('data')) {

                if (httpResponseObj.data.hasOwnProperty('record')) {

                    return httpResponseObj.data.record;

                }else if (httpResponseObj.data.hasOwnProperty('resource')) {

                    return httpResponseObj.data.resource;

                }else {

                    //console.log("Take a look at the response.  Can't parse.")
                    //console.log(httpResponseObj);
                }
            }else {

                //console.log("No data prop in response");
            }
        };

        dfLoadingScreen.stop();

        // @TODO: Problem with parsing email.  Nothing returned at the momment.  Need to fix httpresp func to deal with that scenario.


        // PUBLIC VARS
        $scope.events = $scope.__getDataFromHttpResponse(getEventList);

        $scope.recentScripts = $scope.__getDataFromHttpResponse(getRecentScripts);

        $scope.sampleScripts = getSampleScripts.data;

        $scope.serviceName = '/system/script';

        $scope.currentEvent = '';

        $scope.currentScript = '';
        $scope.currentScriptPath = '';

        $scope.eventList = [];

        $scope.staticEventName = 'static';<commit_msg>Update Scripting.  Change resolve func name Recent scripts -> All scripts<commit_after>/**
 * This file is part of the DreamFactory Services Platform(tm) (DSP)
 *
 * DreamFactory Services Platform(tm) <http://github.com/dreamfactorysoftware/dsp-core>
 * 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('dfScripting', ['ngRoute', 'dfUtility'])
    .constant('MODSCRIPTING_ROUTER_PATH', '/scripts')
    .constant('MODSCRIPTING_ASSET_PATH', 'admin_components/dreamfactory_components/adf-scripting/')
    .config(['$routeProvider', 'MODSCRIPTING_ROUTER_PATH', 'MODSCRIPTING_ASSET_PATH',
        function ($routeProvider, MODSCRIPTING_ROUTER_PATH, MODSCRIPTING_ASSET_PATH) {
            $routeProvider
                .when(MODSCRIPTING_ROUTER_PATH, {
                    templateUrl: MODSCRIPTING_ASSET_PATH + 'views/main.html',
                    controller: 'ScriptingCtrl',
                    resolve: {
                        startLoadingScreen: ['dfLoadingScreen', function (dfLoadingScreen) {

                            // start the loading screen
                            dfLoadingScreen.start();
                        }],

                        getEventList: ['DSP_URL', '$http', function(DSP_URL, $http) {

                            return $http({
                                method: 'GET',
                                url: DSP_URL + '/rest/system/event',
                                params: {
                                    all_events: true
                                }
                            });
                        }],

                        getAllScripts: ['DSP_URL', '$http', function(DSP_URL, $http) {

                            return $http({
                                method: 'GET',
                                url: DSP_URL + '/rest/system/script'
                            });
                        }],

                        getSampleScripts: ['DSP_URL', '$http', function(DSP_URL, $http) {

                            return $http({
                                method: 'GET',
                                url: 'js/example.scripts.js',
                                dataType: "text"
                            });
                        }]
                    }
                });
        }])
    .run(['DSP_URL', '$http', function (DSP_URL, $http) {

    }])
    .controller('ScriptingCtrl', ['DSP_URL', '$scope', '$http', 'getEventList', 'getAllScripts', 'getSampleScripts', 'dfLoadingScreen', 'SystemConfigDataService', function (DSP_URL, $scope, $http, getEventList, getAllScripts, getSampleScripts, dfLoadingScreen, SystemConfigDataService) {


        $scope.isHostedSystem = SystemConfigDataService.getSystemConfig().is_hosted;

        $scope.__getDataFromHttpResponse = function (httpResponseObj) {

            if (httpResponseObj.hasOwnProperty('data')) {

                if (httpResponseObj.data.hasOwnProperty('record')) {

                    return httpResponseObj.data.record;

                }else if (httpResponseObj.data.hasOwnProperty('resource')) {

                    return httpResponseObj.data.resource;

                }else {

                    //console.log("Take a look at the response.  Can't parse.")
                    //console.log(httpResponseObj);
                }
            }else {

                //console.log("No data prop in response");
            }
        };

        dfLoadingScreen.stop();

        // @TODO: Problem with parsing email.  Nothing returned at the momment.  Need to fix httpresp func to deal with that scenario.


        // PUBLIC VARS
        $scope.events = $scope.__getDataFromHttpResponse(getEventList);

        $scope.allScripts = $scope.__getDataFromHttpResponse(getAllScripts);

        $scope.sampleScripts = getSampleScripts.data;

        $scope.serviceName = '/system/script';

        $scope.currentEvent = '';

        $scope.currentScript = '';
        $scope.currentScriptPath = '';

        $scope.eventList = [];

        $scope.staticEventName = 'static';
{'fraction_non_alphanumeric': 0.10654671580316497, 'fraction_numerical': 0.00260134402774767, 'mean_word_length': 1.7066588442358464, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6350717', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2269, 'n_words': 536}