<commit_before>"use strict";
var contentManagementApp = soajsApp.components;
contentManagementApp.controller("ContentManagementCtrl", ['$scope', 'ngDataApi', '$compile', '$timeout', '$modal', 'injectFiles', 'cmService', function ($scope, ngDataApi, $compile, $timeout, $modal, injectFiles, cmService) {
    $scope.$parent.isUserLoggedIn();
    $scope.access = {};
	$scope.selectedEnv = $scope.$parent.currentSelectedEnvironment.toUpperCase();

    $scope.loadUIModule = function (oneService) {
        $scope.hp = false;
        $scope.selectedService = oneService;

        constructModulePermissions($scope, $scope.access, {
            'listEntries': [oneService.name, '/list'],
            'addEntry': [oneService.name, '/add'],
            'updateEntry': [oneService.name, '/update'],
            'getEntry': [oneService.name, '/get'],
            'deleteEntry': [oneService.name, '/delete']
        });

        //get schema from remote service.
        $scope.ui = {
            grid: false,
            add: false,
            left: [],
            top: [],
            links: {}
        };

        getSendDataFromServer($scope, ngDataApi, {
            "method": "get",
            "routeName": "/" + oneService.name + "/schema",
	        "params":{
		        "__env": $scope.selectedEnv.toUpperCase()
	        }
        }, function (error, cbConfig) {
            if (error || !cbConfig) {
                $scope.$parent.displayAlert("danger", error.message);
            }
            else {
                oneService.schema = cbConfig;
                for (var apiRoute in oneService.schema.soajsService.apis) {
                    if (oneService.schema.soajsService.apis.hasOwnProperty(apiRoute)) {
                        var APILabel = oneService.schema.genericService.config.schema[apiRoute]._apiInfo;
	                    switch (oneService.schema.soajsService.apis[apiRoute].type) {
                            case 'add':
                                if ($scope.access.addEntry) {
                                    $scope.ui.add = true;
                                    $scope.ui.links['add'] = {
                                        'l': APILabel.l,
                                        'v': apiRoute
                                    };
                                }
                                break;
                            case 'update':
                                if ($scope.access.updateEntry) {
                                    $scope.ui.left.push({
                                        'label': APILabel.l,
                                        'icon': 'pencil2',
                                        'handler': 'editCMDataEntry'
                                    });
                                    $scope.ui.links['update'] = apiRoute;
                                }
                                break;
                            case 'get':
                                if ($scope.access.getEntry) {
                                    $scope.ui.left.push({
                                        'label': APILabel.l,
                                        'icon': 'search',
                                        'handler': 'viewCMDataEntry'
                                    });
                                    $scope.ui.links['get'] = apiRoute;
                                }
                                break;
                            case 'delete':
                                if ($scope.access.deleteEntry) {
                                    $scope.ui.left.push({
                                        'label': APILabel.l,
                                        'icon': 'cross',
                                        'handler': 'deleteCMDataEntry',
                                        'msg': translation.areYouSureWantDeleteSelectedEntry[LANG]
                                    });
                                    $scope.ui.top.push({
                                        'label': APILabel.l,
                                        'msg': translation.areYouSureWantDeleteSelectedEntryS[LANG],
                                        'handler': 'deleteCMDataEntries'
                                    });
                                    $scope.ui.links['delete'] = apiRoute;
                                }
                                break;
                            case 'list':
                                if ($scope.access.listEntries) {
                                    $scope.ui.grid = true;
                                    $scope.ui.links['list'] = apiRoute;
                                }
                                break;
                        }
                    }
                }
                $timeout(function () {
                    $scope.populateCMUI();
                }, 1000);
            }
        });

    };

    $scope.populateCMUI = function () {
        if ($scope.ui.grid) {
            $scope.listCMDataEntries();
        }
        else {
            var el = angular.element(document.getElementById("contentGridContainer"));
            el.html("<br/><a href=\"\" ng-click=\"goBack()\" class=\"f-right btn btn-primary\">" + translation.goBack[LANG] + "</a><p>" + translation.youDoNotHaveAccessContentModule[LANG] + "</p>");
            $compile(el.contents())($scope);
        }
    };

    $scope.goBack = function () {
        var el = angular.element(document.getElementById("contentGridContainer"));
        el.html("");<commit_msg>SOAJ-199: fixed display bug.<commit_after>"use strict";
var contentManagementApp = soajsApp.components;
contentManagementApp.controller("ContentManagementCtrl", ['$scope', 'ngDataApi', '$compile', '$timeout', '$modal', 'injectFiles', 'cmService', function ($scope, ngDataApi, $compile, $timeout, $modal, injectFiles, cmService) {
    $scope.$parent.isUserLoggedIn();
    $scope.access = {};
	$scope.selectedEnv = $scope.$parent.currentSelectedEnvironment.toUpperCase();

    $scope.loadUIModule = function (oneService) {
        $scope.hp = false;
        $scope.selectedService = oneService;

        constructModulePermissions($scope, $scope.access, {
            'listEntries': [oneService.name, '/list'],
            'addEntry': [oneService.name, '/add'],
            'updateEntry': [oneService.name, '/update'],
            'getEntry': [oneService.name, '/get'],
            'deleteEntry': [oneService.name, '/delete']
        });

        //get schema from remote service.
        $scope.ui = {
            grid: false,
            add: false,
            left: [],
            top: [],
            links: {}
        };

        getSendDataFromServer($scope, ngDataApi, {
            "method": "get",
            "routeName": "/" + oneService.name + "/schema",
	        "params":{
		        "__env": $scope.selectedEnv.toUpperCase()
	        }
        }, function (error, cbConfig) {
            if (error || !cbConfig) {
                $scope.$parent.displayAlert("danger", error.message);
            }
            else {
                oneService.schema = cbConfig;
                for (var apiRoute in oneService.schema.soajsService.apis) {
                    if (oneService.schema.soajsService.apis.hasOwnProperty(apiRoute)) {
                        var APILabel = oneService.schema.genericService.config.schema[apiRoute]._apiInfo;
	                    switch (oneService.schema.soajsService.apis[apiRoute].type) {
                            case 'add':
                                if ($scope.access.addEntry) {
                                    $scope.ui.add = true;
                                    $scope.ui.links['add'] = {
                                        'l': APILabel.l,
                                        'v': apiRoute
                                    };
                                }
                                break;
                            case 'update':
                                if ($scope.access.updateEntry) {
                                    $scope.ui.left.push({
                                        'label': APILabel.l,
                                        'icon': 'pencil2',
                                        'handler': 'editCMDataEntry'
                                    });
                                    $scope.ui.links['update'] = apiRoute;
                                }
                                break;
                            case 'get':
                                if ($scope.access.getEntry) {
                                    $scope.ui.left.push({
                                        'label': APILabel.l,
                                        'icon': 'search',
                                        'handler': 'viewCMDataEntry'
                                    });
                                    $scope.ui.links['get'] = apiRoute;
                                }
                                break;
                            case 'delete':
                                if ($scope.access.deleteEntry) {
                                    $scope.ui.left.push({
                                        'label': APILabel.l,
                                        'icon': 'cross',
                                        'handler': 'deleteCMDataEntry',
                                        'msg': translation.areYouSureWantDeleteSelectedEntry[LANG]
                                    });
                                    $scope.ui.top.push({
                                        'label': APILabel.l,
                                        'msg': translation.areYouSureWantDeleteSelectedEntryS[LANG],
                                        'handler': 'deleteCMDataEntries'
                                    });
                                    $scope.ui.links['delete'] = apiRoute;
                                }
                                break;
                            case 'list':
                                if ($scope.access.listEntries) {
                                    $scope.ui.grid = true;
                                    $scope.ui.links['list'] = apiRoute;
                                }
                                break;
                        }
                    }
                }
                $timeout(function () {
                    $scope.populateCMUI();
                }, 1000);
            }
        });

    };

    $scope.populateCMUI = function () {
        if ($scope.ui.grid) {
            $scope.listCMDataEntries();
        }
        else {
            var el = angular.element(document.getElementById("contentGridContainer"));
            el.html("<br/><p>" + translation.youDoNotHaveAccessContentModule[LANG] + "</p>");
            $compile(el.contents())($scope);
        }
    };

    $scope.goBack = function () {
        var el = angular.element(document.getElementById("contentGridContainer"));
        el.html("");
{'fraction_non_alphanumeric': 0.1145530523255814, 'fraction_numerical': 0.0011809593023255813, 'mean_word_length': 0.9347978910369068, 'pattern_counts': {'":': 8, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 76, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1452320', 'n_tokens_mistral': 2488, 'n_tokens_neox': 2374, 'n_words': 387}