<commit_before>'use strict';


angular.module('backAnd.controllers')
    .controller('tableController', ['$scope', 'Global', 'tableService', 'configService', '$http',
        function($scope, Global, tableService, configService, $http) {
            $scope.global = Global;
            $scope.global.currentTable = 'test2';


            $scope.filterOptions = {
                filterText: "",
                useExternalFilter: true
            };
            $scope.totalServerItems = 0;
            $scope.pagingOptions = {
                pageSizes: [2, 50, 100, 500],
                pageSize: 20,
                currentPage: 1
            };
            $scope.myOptions = {
                columnDefs: 'columns',
                data: 'myData',
                enablePaging: true,
           
                showFooter: true,
                totalServerItems: 'totalServerItems',
                pagingOptions: $scope.pagingOptions,
                filterOptions: $scope.filterOptions
            };
            $scope.setPagingData = function(data, page, pageSize) {
                var pagedData = data.slice((page - 1) * pageSize, page * pageSize);
                $scope.myData = pagedData;
                $scope.totalServerItems = data.length;
                if (!$scope.$$phase) {
                    $scope.$apply();
                }
            };

            $scope.getPagedDataAsync = function(pageSize, page, searchText) {
                setTimeout(function() {
                    var data;
                    if (searchText) {
                        var ft = searchText.toLowerCase();
                        configService.queryjsonp({
                            table: $scope.global.currentTable
                        }, function(data) {
                            console.log(data);
                            $scope.config = data.fields;
                            $scope.columns = [];
                            angular.forEach($scope.config, function(con) {
                                $scope.columns.push({
                                    field: con.type,
                                    displayName: con.displayName,
                                    cellTemplate: '<div class="ngCellText" ><span ng-cell-text >{{row.entity[col.displayName]}}</span></div>'
                                });
                            });
                            tableService.queryjsonp({
                                table: $scope.global.currentTable
                            }, function(largeLoad) {
                                console.log(largeLoad.data.length);
                                $scope.myData = largeLoad.data;
                                debugger
                                data1 = largeLoad.data.filter(function(item) {
                                    return JSON.stringify(item).toLowerCase().indexOf(ft) != -1;
                                });
                                $scope.setPagingData(data1, page, pageSize);
                            });
                        });
                    } else {
                        configService.queryjsonp({
                            table: $scope.global.currentTable
                        }, function(data) {
                            console.log(data);
                            $scope.config = data.fields;
                            $scope.columns = [];
                            angular.forEach($scope.config, function(con) {
                                $scope.columns.push({
                                    field: con.type,
                                    displayName: con.displayName,
                                    cellTemplate: '<div class="ngCellText" ><span ng-cell-text >{{row.entity[col.displayName]}}</span></div>'
                                });
                            });
                            tableService.queryjsonp({
                                table: $scope.global.currentTable,
                                query: '495'
                            }, function(largeLoad) {
                                console.log(largeLoad);
                                $scope.myData = largeLoad.data;
                                $scope.setPagingData(largeLoad.data, page, pageSize);
                            });
                        });
                    }
                }, 100);
            };

            $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);
            $scope.$watch('pagingOptions', function(newVal, oldVal) {
                console.log(newVal)
                console.log(oldVal)
                if (newVal !== oldVal /*&& newVal.currentPage !== oldVal.currentPage*/ ) {<commit_msg>pagination<commit_after>'use strict';


angular.module('backAnd.controllers')
    .controller('tableController', ['$scope', 'Global', 'tableService', 'configService', '$http',
        function($scope, Global, tableService, configService, $http) {
            $scope.global = Global;
            $scope.global.currentTable = 'test2';


            $scope.filterOptions = {
                filterText: "",
                useExternalFilter: true
            };
            $scope.totalServerItems = 0;
            $scope.pagingOptions = {
                pageSizes: [20, 50, 100, 500],
                pageSize: 20,
                currentPage: 1
            };
            $scope.myOptions = {
                columnDefs: 'columns',
                data: 'myData',
                enablePaging: true,

                showFooter: true,
                totalServerItems: 'totalServerItems',
                pagingOptions: $scope.pagingOptions,
                filterOptions: $scope.filterOptions
            };



            $scope.setPagingData = function(data, page, pageSize) {
                var pagedData = data.data.slice((page - 1) * pageSize, page * pageSize);
                $scope.myData = pagedData;
                $scope.totalServerItems = data.totalRows;
                console.log($scope.totalServerItems)
                if (!$scope.$$phase) {
                    $scope.$apply();
                }
            };


            $scope.getPagedDataAsync = function(pageSize, page, searchText) {

                setTimeout(function() {
                    var data;
                    if (searchText) {
                        var ft = searchText.toLowerCase();
                        configService.queryjsonp({
                            table: $scope.global.currentTable
                        }, function(data) {
                            console.log(data);
                            $scope.config = data.fields;
                            $scope.columns = [];
                            angular.forEach($scope.config, function(con) {
                                $scope.columns.push({
                                    field: con.type,
                                    displayName: con.displayName,
                                    cellTemplate: '<div class="ngCellText" ><span ng-cell-text >{{row.entity[col.displayName]}}</span></div>'
                                });
                            });
                            tableService.queryjsonp({
                                table: $scope.global.currentTable,
                                query: $scope.pagingOptions.pageSize
                            }, function(largeLoad) {
                                console.log(largeLoad.data.length);
                                $scope.myData = largeLoad.data;

                                data1 = largeLoad.data.filter(function(item) {
                                    return JSON.stringify(item).toLowerCase().indexOf(ft) != -1;
                                });
                                $scope.setPagingData(data1, page, pageSize);
                            });
                        });
                    } else {
                        configService.queryjsonp({
                            table: $scope.global.currentTable
                        }, function(data) {
                            console.log(data);
                            $scope.config = data.fields;
                            $scope.columns = [];
                            angular.forEach($scope.config, function(con) {
                                $scope.columns.push({
                                    field: con.type,
                                    displayName: con.displayName,
                                    cellTemplate: '<div class="ngCellText" ><span ng-cell-text >{{row.entity[col.displayName]}}</span></div>'
                                });
                            });
                            debugger
                            console.log($scope.columns)
                            tableService.queryjsonp({
                                table: $scope.global.currentTable,
                                query: $scope.pagingOptions.pageSize

                            }, function(largeLoad) {
                                console.log(largeLoad);
                                $scope.myData = largeLoad.data;
                                $scope.setPagingData(largeLoad, page, pageSize);
                            });
                        });
                    }
                }, 100);
            };





            $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);
            $scope.$watch('pagingOptions', function(newVal, oldVal) {
                console.log(newVal)
                console.log(oldVal)
                if (newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) {
{'fraction_non_alphanumeric': 0.10190035952747817, 'fraction_numerical': 0.004725218284540318, 'mean_word_length': 0.9732468585326307, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5295002', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2111, 'n_words': 330}