<commit_before>Kamato.register.controller('easyDBCtrl', function ($scope, $http, $modal, ngDialog, $rootScope){

	var db_link = "./manage/db/";

	$http.get(db_link).
        success(function(db) {
            $scope.tables = db.data;
            $scope.table_click(db.data[0], 15, 1);
        });

    $scope.t_d_more = [];
    var jsonTemp = {};
    var viewing_table = "";

    $scope.findData = function() {
    	var link = db_link + $scope.default_view_table;
    	var searchQuery;
    	try {
    		searchQuery = {"query": JSON.parse($scope.command_sample)};
    	}
    	catch(e) {
    		searchQuery = {"query": {}};
    	}
    	$http.post(link, searchQuery).success(function(schema) {
        	var t_d_temp = schema.data.list;
        	$scope.t_head = schema.data.list[0];
 			$scope.colspan = Object.keys(schema.data.list[0]).length +1; //+1是del button欄位
        	angular.forEach(t_d_temp, function(list_value, list_key){
        		angular.forEach(t_d_temp[list_key], function(value, key){
        			var value_id = t_d_temp[list_key]._id;
        			if(typeof(value) == "object" && value != null){
        				//存json			
        				jsonTemp[value_id+key] = value;
        				$scope.t_d_more.push(jsonTemp);
        				//json換註解
        				t_d_temp[list_key][key] = "json file"
        			}
        			$scope.t_d = t_d_temp;

        		})
        	});
    	});
    }

    var first_row_id = 0; 

    $scope.option_index = 2;          //page   
    $scope.default_rows = 15;
    $scope.rows_options = [
        {'num': 5},
        {'num': 10},
        {'num': 15},
        {'num': 20}
    ]

    $scope.custom_rows = 15;  //table click

	$scope.table_click =function(name, default_table_rows, page_num){
        pre_id_attr="";    //清除上一次在其他table點擊json的事件
        $scope.warn_hint = false;   //清除在其他table點擊的刪除警告標語
        
        $scope.custom_rows = default_table_rows;
		viewing_table = name;
		$scope.is_show = false;
		//要把顯示json內容方框丟回table最下面,否則會被ng-repeat蓋過 
		var j_text = document.getElementsByClassName("json_text");
		var table = document.getElementsByClassName("db_table");
		table[0].childNodes[1].appendChild(j_text[0]);
		$scope.default_view_table = name;

        //Get table資訊(第一筆資料id, 總筆數)
		$http.get(db_link+name).
        success(function(schema) {
            first_row_id = schema.data.max_serial_num;
            var table_length = schema.data.table_length;
            if( (table_length%default_table_rows) <= 0){
                $scope.total_pages = new Array(table_length/default_table_rows);
            }
            else{ 
                $scope.total_pages = new Array(parseInt(table_length/default_table_rows)+1);
            }
            //顯示table內容(預設15筆資料)
            $scope.show_table(name,default_table_rows, page_num);
        });
	}

    $scope.sch_click = function(name){  
        if($scope.sch_name  == name){
            $scope.sch_name = '';
        }
        else{
            $scope.sch_name = name;
        }
    }

    $scope.sch_menu_click = function(schema_name){
        if($scope.selected_sch_menu == schema_name){
            $scope.selected_sch_menu = '';
        }
        else{ 
            $scope.selected_sch_menu = schema_name;
        }
    }

    $scope.sch_type_click = function(schema_name, type){
        $scope.t_head[schema_name] = type;
        $scope.sch_name = '';
        console.log($scope.t_head); 
        $http.put(db_link+viewing_table, $scope.t_head).
        success(function(page_schema){  
            console.log(page_schema);<commit_msg>[ EasyDB ][  更新 ] id 不能換schema<commit_after>Kamato.register.controller('easyDBCtrl', function ($scope, $http, $modal, ngDialog, $rootScope){

	var db_link = "./manage/db/";

	$http.get(db_link).
        success(function(db) {
            $scope.tables = db.data;
            $scope.table_click(db.data[0], 15, 1);
        });

    $scope.t_d_more = [];
    var jsonTemp = {};
    var viewing_table = "";

    $scope.findData = function() {
    	var link = db_link + $scope.default_view_table;
    	var searchQuery;
    	try {
    		searchQuery = {"query": JSON.parse($scope.command_sample)};
    	}
    	catch(e) {
    		searchQuery = {"query": {}};
    	}
    	$http.post(link, searchQuery).success(function(schema) {
        	var t_d_temp = schema.data.list;
        	$scope.t_head = schema.data.list[0];
 			$scope.colspan = Object.keys(schema.data.list[0]).length +1; //+1是del button欄位
        	angular.forEach(t_d_temp, function(list_value, list_key){
        		angular.forEach(t_d_temp[list_key], function(value, key){
        			var value_id = t_d_temp[list_key]._id;
        			if(typeof(value) == "object" && value != null){
        				//存json			
        				jsonTemp[value_id+key] = value;
        				$scope.t_d_more.push(jsonTemp);
        				//json換註解
        				t_d_temp[list_key][key] = "json file"
        			}
        			$scope.t_d = t_d_temp;

        		})
        	});
    	});
    }

    var first_row_id = 0; 

    $scope.option_index = 2;          //page   
    $scope.default_rows = 15;
    $scope.rows_options = [
        {'num': 5},
        {'num': 10},
        {'num': 15},
        {'num': 20}
    ]

    $scope.custom_rows = 15;  //table click

	$scope.table_click =function(name, default_table_rows, page_num){
        pre_id_attr="";    //清除上一次在其他table點擊json的事件
        $scope.warn_hint = false;   //清除在其他table點擊的刪除警告標語
        
        $scope.custom_rows = default_table_rows;
		viewing_table = name;
		$scope.is_show = false;
		//要把顯示json內容方框丟回table最下面,否則會被ng-repeat蓋過 
		var j_text = document.getElementsByClassName("json_text");
		var table = document.getElementsByClassName("db_table");
		table[0].childNodes[1].appendChild(j_text[0]);
		$scope.default_view_table = name;

        //Get table資訊(第一筆資料id, 總筆數)
		$http.get(db_link+name).
        success(function(schema) {
            first_row_id = schema.data.max_serial_num;
            var table_length = schema.data.table_length;
            if( (table_length%default_table_rows) <= 0){
                $scope.total_pages = new Array(table_length/default_table_rows);
            }
            else{ 
                $scope.total_pages = new Array(parseInt(table_length/default_table_rows)+1);
            }
            //顯示table內容(預設15筆資料)
            $scope.show_table(name,default_table_rows, page_num);
        });
	}

    $scope.sch_click = function(name){  
        if($scope.sch_name  == name){
            $scope.sch_name = '';
        }
        else{
            $scope.sch_name = name;
        }
    }

    $scope.sch_menu_click = function(schema_name){
        if($scope.selected_sch_menu == schema_name){
            $scope.selected_sch_menu = '';
        }
        else{ 
            $scope.selected_sch_menu = schema_name;
        }
    }

    $scope.sch_type_click = function(schema_name, type){
        if(schema_name == '_id'){
            $scope.t_head[schema_name] = 'Number';
        }
        else{
            $scope.t_head[schema_name] = type;    
        }
        $scope.sch_name = '';
        console.log($scope.t_head); 
        $http.put(db_link+viewing_table, $scope.t_head).
        success(function(page_schema){  
            console.log(page_schema);
{'fraction_non_alphanumeric': 0.13829491807831157, 'fraction_numerical': 0.007775617883921133, 'mean_word_length': 2.145414847161572, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, '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': '7145988', 'n_tokens_mistral': 2697, 'n_tokens_neox': 2612, 'n_words': 344}