<commit_before>var am = angular.module('am', ['ui.bootstrap']);
am.controller('amCtl', function ($scope, $http, $uibModal, $log, $q) {
    var AM_FORM_DATA = "amFormData";
    $scope.title = "AM REST DB Client";
    $scope.formData = {
        server: "192.168.3.11:8081",
        context: "/AssetManagerWebService/rs/",
        "ref-link": "",     // "db/amLocation/126874",
        collection: "",     // "EmplDepts",
        param: {
            limit: "100",
            offset: "0",
            filter: "",
            orderby: "",
            fields: []
        },

        user: "admin",
        password: ""
    };
    $scope.pageSize = 10;
    $scope.fields = [];
    $scope.breadcrumb = [];
    $scope.toggleFilter = function toggleSelection(field) {
        var idx = $scope.fields.indexOf(field);
        if (idx > -1) {
            $scope.fields.splice(idx, 1);
        }
        else {
            $scope.fields.push(field);
        }
//        $scope.addFields();
    };
    $scope.addFields = function () {
        $scope.formData.param.fields = $scope.fields;
        $scope.query();
    };

    if (localStorage && localStorage[AM_FORM_DATA]) {
        $scope.formData = JSON.parse(localStorage.getItem(AM_FORM_DATA));
        $scope.formData.collection = "";
        $scope.formData.param.filter = "";
        $scope.formData.param.offset = 0;
        $scope.formData.param.orderby = "";
        $scope.formData.param.fields = [];
    }

    $scope.query = function (form) {
        $scope.loading = true;
        $scope.tableData = {};

        // if param is query form, use it
        var form = form ? form : clone($scope.formData);
        $scope.tableName = form["ref-link"].split("/")[1];

        form.method = "get";
        $http.post('/am/rest', form).success(function (data) {
//            console.log("rest data: " + JSON.stringify(data));
            $scope.loading = false;
            if (data instanceof Object) {
//                console.log("query data:" + JSON.stringify(data));
                if (data.entities instanceof Array)
                    $scope.tableData = data;
            } else {
                $scope.message = data;
            }
        });
        $scope.store();
    };

    $scope.load = function (data) {
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'am_modal.html',
            controller: 'amModalCtrl',
            size: "modal-lg",
            resolve: {
                data: function () {
                    return data;
                },
                form: function () {<commit_msg>fix query return 1 bug<commit_after>var am = angular.module('am', ['ui.bootstrap']);
am.controller('amCtl', function ($scope, $http, $uibModal, $log, $q) {
    var AM_FORM_DATA = "amFormData";
    $scope.title = "AM REST DB Client";
    $scope.formData = {
        server: "192.168.3.11:8081",
        context: "/AssetManagerWebService/rs/",
        "ref-link": "",     // "db/amLocation/126874",
        collection: "",     // "EmplDepts",
        param: {
            limit: "100",
            offset: "0",
            filter: "",
            orderby: "",
            fields: []
        },

        user: "admin",
        password: ""
    };
    $scope.pageSize = 10;
    $scope.fields = [];
    $scope.breadcrumb = [];
    $scope.toggleFilter = function toggleSelection(field) {
        var idx = $scope.fields.indexOf(field);
        if (idx > -1) {
            $scope.fields.splice(idx, 1);
        }
        else {
            $scope.fields.push(field);
        }
//        $scope.addFields();
    };
    $scope.addFields = function () {
        $scope.formData.param.fields = $scope.fields;
        $scope.query();
    };

    if (localStorage && localStorage[AM_FORM_DATA]) {
        $scope.formData = JSON.parse(localStorage.getItem(AM_FORM_DATA));
        $scope.formData.collection = "";
        $scope.formData.param.filter = "";
        $scope.formData.param.offset = 0;
        $scope.formData.param.orderby = "";
        $scope.formData.param.fields = [];
    }

    $scope.query = function (form) {
        $scope.loading = true;
        $scope.tableData = {};

        // if param is query form, use it
        var form = form ? form : clone($scope.formData);
        $scope.tableName = form["ref-link"].split("/")[1];

        form.method = "get";
        $http.post('/am/rest', form).success(function (data) {
//            console.log("rest data: " + JSON.stringify(data));
            $scope.loading = false;
            if (data instanceof Object) {
                console.log("query data:" + JSON.stringify(data));
                if (data.entities instanceof Array)
                    $scope.tableData = data;
                else if (data.type == 'Buffer') {
                    $scope.tableData.count = 0;
                } else {
                    $scope.tableData.count = 1;
                    $scope.tableData.entities = [];
                    $scope.tableData.entities.push(data);
                }
            } else {
                $scope.message = data;
            }
        });
        $scope.store();
    };

    $scope.load = function (data) {
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'am_modal.html',
            controller: 'amModalCtrl',
            size: "modal-lg",
            resolve: {
                data: function () {
                    return data;
                },
                form: function () {
{'fraction_non_alphanumeric': 0.15486086013733286, 'fraction_numerical': 0.011022768341163716, 'mean_word_length': 1.6022566995768688, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2945422', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1595, 'n_words': 297}