<commit_before>'use strict'

angular.module('app').component('raw', raw())

function raw() {

    return {
        templateUrl: 'app/raw/raw.html',
        controller: RawController,
        controllerAs: 'ctrl'
    }
}

function RawController($scope, operationService, results, query) {
    var vm = this

    // variables
    vm.operationsForEdit = []
    vm.editingOperations = false
    vm.operations = query.getOperations()
    vm.results = results.get()

    // watches

    query.observeOperations().then(null, null, function(operations) {
        vm.operations = operations
    })

    results.observe().then(null, null, function(results) {
        vm.results = results
    })

    // functions

    vm.editOperations = function() {
        vm.operationsForEdit = []

        for(var i in vm.operations) {
            vm.operationsForEdit.push(JSON.stringify(vm.operations[i], null, 2));
        }
        vm.editingOperations = true;
    }

    vm.addOperation = function() {
        vm.operationsForEdit.push("")
    }

    vm.saveOperations = function() {
        query.setOperations([])
        for(var i in vm.operationsForEdit) {
            try {
                if (vm.operationsForEdit[i] !== "") {
                    query.addOperation(JSON.parse(vm.operationsForEdit[i]));
                }
            } catch(e) {
                console.error('Invalid json: ' + vm.operationsForEdit[i]);
            }
        }
        vm.editingOperations = false;
    }
}<commit_msg>gh-200 no longer deletes edited operation if invalid and pops up with message<commit_after>'use strict'

angular.module('app').component('raw', raw())

function raw() {

    return {
        templateUrl: 'app/raw/raw.html',
        controller: RawController,
        controllerAs: 'ctrl'
    }
}

function RawController($scope, operationService, results, query, $mdToast) {
    var vm = this

    // variables
    vm.operationsForEdit = []
    vm.editingOperations = false
    vm.operations = query.getOperations()
    vm.results = results.get()

    // watches

    query.observeOperations().then(null, null, function(operations) {
        vm.operations = operations
    })

    results.observe().then(null, null, function(results) {
        vm.results = results
    })

    // functions

    vm.editOperations = function() {
        vm.operationsForEdit = []

        for(var i in vm.operations) {
            vm.operationsForEdit.push(JSON.stringify(vm.operations[i], null, 2));
        }
        vm.editingOperations = true;
    }

    vm.addOperation = function() {
        vm.operationsForEdit.push("")
    }

    vm.saveOperations = function() {
        query.setOperations([])
        for(var i in vm.operationsForEdit) {
            try {
                if (vm.operationsForEdit[i] !== "") {
                    query.addOperation(JSON.parse(vm.operationsForEdit[i]));
                }
            } catch(e) {
                $mdToast.show($mdToast.simple()
                    .textContent('Invalid json for operation ' + (+i + 1))
                    .position('bottom right'))
                console.log('Invalid json: ' + vm.operationsForEdit[i]);
                return;
            }
        }
        vm.editingOperations = false;
    }
}
{'fraction_non_alphanumeric': 0.12892307692307692, 'fraction_numerical': 0.0018461538461538461, 'mean_word_length': 2.027001862197393, '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': '5618694', 'n_tokens_mistral': 933, 'n_tokens_neox': 909, 'n_words': 169}