<commit_before>'use strict';

angular.module('hobsonApp').
    controller('SettingsController', ['$scope', '$modal', 'AppData', 'SettingsService', 'DialogContextService', 'toastr',
        function($scope, $modal, AppData, SettingsService, DialogContextService, toastr) {
            $scope.shuttingDown = false;
            $scope.isShutdownCollapsed = true;

            var setConfiguration = function(result) {
                console.debug('configuration = ', result.data);
                $scope.name = result.data.name;
                $scope.address = result.data.location.text;
                $scope.latitude = result.data.location.latitude;
                $scope.longitude = result.data.location.longitude;
                $scope.logLevel = result.data.logLevel;
            };

            $scope.shutdown = function() {
                $scope.shuttingDown = true;
                SettingsService.shutdown().then(function() {
                    $scope.shuttingDown = false;
                    $scope.isCollapsed = true;
                    toastr.success('The hub has begun shutting down.', null, {
                        closeButton: true
                    });
                }, function() {
                    $scope.shuttingDown = false;
                    $scope.isCollapsed = true;
                    toastr.error('An error occurred. Please check the log for details.', null, {
                        closeButton: true
                    });
                });
            };

            $scope.save = function() {
                var config = {
                  name: $scope.name,
                  address: {
                    text: ($scope.address === '') ? null : $scope.address,
                    latitude: ($scope.latitude === '') ? null : parseFloat($scope.latitude),
                    longitude: ($scope.longitude === '') ? null : parseFloat($scope.longitude)
                  },
                  logLevel: $scope.logLevel
                };

                SettingsService.setConfiguration(config).then(function() {
                  toastr.success('The settings have been saved.', null, {
                    closeButton: true
                  });
                });
            };

            $scope.showLocation = function() {
                window.open('https://www.google.com/maps/place/' + encodeURIComponent($scope.address));
            };

            $scope.onLogLevelChange = function(logLevel) {
                console.debug('onLogLevelChange: ', logLevel);
                SettingsService.setLogLevel(logLevel);
                // show the user a non-modal notification
                toastr.success('The log level has been changed.', null, {
                    closeButton: true
                });
            };

            $scope.viewLog = function() {
                var mi = $modal.open({
                    templateUrl: 'views/partials/log_viewer_dialog.html',
                    size: 'lg',
                    backdrop: 'static'
                });
                DialogContextService.pushModalInstance(mi);
            };

            AppData.currentTab = 'settings';

            $scope.loadingPromise = SettingsService.getConfiguration();
            $scope.loadingPromise.then(setConfiguration);
        }]);
<commit_msg>Fixed JSON property name.<commit_after>'use strict';

angular.module('hobsonApp').
    controller('SettingsController', ['$scope', '$modal', 'AppData', 'SettingsService', 'DialogContextService', 'toastr',
        function($scope, $modal, AppData, SettingsService, DialogContextService, toastr) {
            $scope.shuttingDown = false;
            $scope.isShutdownCollapsed = true;

            var setConfiguration = function(result) {
                console.debug('configuration = ', result.data);
                $scope.name = result.data.name;
                $scope.address = result.data.location.text;
                $scope.latitude = result.data.location.latitude;
                $scope.longitude = result.data.location.longitude;
                $scope.logLevel = result.data.logLevel;
            };

            $scope.shutdown = function() {
                $scope.shuttingDown = true;
                SettingsService.shutdown().then(function() {
                    $scope.shuttingDown = false;
                    $scope.isCollapsed = true;
                    toastr.success('The hub has begun shutting down.', null, {
                        closeButton: true
                    });
                }, function() {
                    $scope.shuttingDown = false;
                    $scope.isCollapsed = true;
                    toastr.error('An error occurred. Please check the log for details.', null, {
                        closeButton: true
                    });
                });
            };

            $scope.save = function() {
                var config = {
                  name: $scope.name,
                  location: {
                    text: ($scope.address === '') ? null : $scope.address,
                    latitude: ($scope.latitude === '') ? null : parseFloat($scope.latitude),
                    longitude: ($scope.longitude === '') ? null : parseFloat($scope.longitude)
                  },
                  logLevel: $scope.logLevel
                };

                SettingsService.setConfiguration(config).then(function() {
                  toastr.success('The settings have been saved.', null, {
                    closeButton: true
                  });
                });
            };

            $scope.showLocation = function() {
                window.open('https://www.google.com/maps/place/' + encodeURIComponent($scope.address));
            };

            $scope.onLogLevelChange = function(logLevel) {
                console.debug('onLogLevelChange: ', logLevel);
                SettingsService.setLogLevel(logLevel);
                // show the user a non-modal notification
                toastr.success('The log level has been changed.', null, {
                    closeButton: true
                });
            };

            $scope.viewLog = function() {
                var mi = $modal.open({
                    templateUrl: 'views/partials/log_viewer_dialog.html',
                    size: 'lg',
                    backdrop: 'static'
                });
                DialogContextService.pushModalInstance(mi);
            };

            AppData.currentTab = 'settings';

            $scope.loadingPromise = SettingsService.getConfiguration();
            $scope.loadingPromise.then(setConfiguration);
        }]);

{'fraction_non_alphanumeric': 0.11597044186397225, 'fraction_numerical': 0.0, 'mean_word_length': 1.4160291438979964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5557091', 'n_tokens_mistral': 1622, 'n_tokens_neox': 1513, 'n_words': 285}