<commit_before>var app = angular.module('app');
app.controller('keyPairsCtrl', function ($scope, serviceAPI, $routeParams, http, $cookieStore, AuthService, $window) {

    var url = $cookieStore.get('URL') + "/api/v1/keys/";
    var urlprojects = $cookieStore.get('URL') + "/api/v1/projects/";
    $scope.keyName = "";
    $scope.pubKey = "";
    $scope.keypairs = "";
    $scope.newKey = {name:"", publicKey:""};
    $scope.alerts = [];
    loadTable();
    function loadTable() {

        //console.log($routeParams.userId);
            http.get(url)
                .success(function (response) {
                    $scope.keypairs = response;
                    //console.log($scope.users.length);

                    console.log($scope.keypairs);
                })
                .error(function (data, status) {
                    showError(data, status);
                });


        }
        $scope.closeAlert = function (index) {
            $scope.alerts.splice(index, 1);
        };

        $scope.save = function () {
            //console.log($scope.projectObj);

            $scope.newKey.name = $scope.keyName;
            $scope.newKey.publicKey = $scope.pubKey;
            console.log($scope.newKey);
            http.post(url, $scope.newKey)
                .success(function (response) {
                    showOk('Key pair: ' + $scope.keyName + ' saved.');
                    setTimeout(loadTable(),250);
                    $scope.keyName = "";
                    $scope.pubKey = "";
                    //location.reload();
                })
                .error(function (response, status) {
                    showError(response, status);
                });
        };
        $scope.delete = function (data) {
            http.delete(url + data.id)
                .success(function (response) {
                    showOk('Key with name: ' + data.name + ' deleted.');
                    setTimeout(loadTable(), 250);

                })
                .error(function (response, status) {
                    showError(response, status);
                });
        };
        $scope.createKeyName = "";
        $scope.createKey = function () {
            //console.log($scope.projectObj);



            http.postPlain(url + 'generate', $scope.createKeyName)
                .success(function (response) {
                    showOk('Key: ' + $scope.createKeyName + ' generated.');
                    setTimeout(loadTable(),250);
                    console.log(response);
                    document.location = 'data:Application/octet-stream,' +
                        encodeURIComponent(response);
                    //location.reload();
                })
                .error(function (response, status) {<commit_msg>imp: changed save file to .pem<commit_after>var app = angular.module('app');
app.controller('keyPairsCtrl', function ($scope, serviceAPI, $routeParams, http, $cookieStore, AuthService, $window) {

    var url = $cookieStore.get('URL') + "/api/v1/keys/";
    var urlprojects = $cookieStore.get('URL') + "/api/v1/projects/";
    $scope.keyName = "";
    $scope.pubKey = "";
    $scope.keypairs = "";
    $scope.newKey = {name:"", publicKey:""};
    $scope.alerts = [];
    loadTable();
    function loadTable() {

        //console.log($routeParams.userId);
            http.get(url)
                .success(function (response) {
                    $scope.keypairs = response;
                    //console.log($scope.users.length);

                    console.log($scope.keypairs);
                })
                .error(function (data, status) {
                    showError(data, status);
                });


        }
        $scope.closeAlert = function (index) {
            $scope.alerts.splice(index, 1);
        };

        $scope.save = function () {
            //console.log($scope.projectObj);

            $scope.newKey.name = $scope.keyName;
            $scope.newKey.publicKey = $scope.pubKey;
            console.log($scope.newKey);
            http.post(url, $scope.newKey)
                .success(function (response) {
                    showOk('Key pair: ' + $scope.keyName + ' saved.');
                    setTimeout(loadTable(),250);
                    $scope.keyName = "";
                    $scope.pubKey = "";
                    //location.reload();
                })
                .error(function (response, status) {
                    showError(response, status);
                });
        };
        $scope.delete = function (data) {
            http.delete(url + data.id)
                .success(function (response) {
                    showOk('Key with name: ' + data.name + ' deleted.');
                    setTimeout(loadTable(), 250);

                })
                .error(function (response, status) {
                    showError(response, status);
                });
        };
        $scope.createKeyName = "";
        $scope.createKey = function () {
            //console.log($scope.projectObj);



            http.postPlain(url + 'generate', $scope.createKeyName)
                .success(function (response) {
                    showOk('Key: ' + $scope.createKeyName + ' generated.');
                    setTimeout(loadTable(),250);
                    //console.log(response);
                    document.location = 'data:application/x-pem-file,' +
                        encodeURIComponent(response);
                    //location.reload();
                })
                .error(function (response, status) {
{'fraction_non_alphanumeric': 0.14460211963355488, 'fraction_numerical': 0.00431111909466499, 'mean_word_length': 1.4356955380577427, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1087016', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1429, 'n_words': 231}