{"size": 1854, "ext": "js", "max_stars_repo_path": "src/Rinsen.Logging/ng-app/Controllers/LoggerController.js", "max_stars_repo_name": "Rinsen/Logging", "max_stars_repo_stars_event_min_datetime": "2016-06-18T20:03:36.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-02T02:17:08.000Z", "max_issues_repo_path": "src/Rinsen.Logging/ng-app/Controllers/LoggerController.js", "max_issues_repo_name": "Rinsen/Logging", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Rinsen.Logging/ng-app/Controllers/LoggerController.js", "max_forks_repo_name": "Rinsen/Logging", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.96875, "max_line_length": 86, "alphanum_fraction": 0.5005393743}
﻿(function () {
    'use strict';

    angular
        .module('app')
        .controller('LoggerController', LoggerController);

    LoggerController.$inject = ['$location', 'LogSelectionOptionsService'];

    function LoggerController($location, logSelectionOptionsService) {
        /* jshint validthis:true */
        var vm = this;
        vm.show = show;
        vm.dataLoading = false;
        vm.logs = [];

        function show() {
            vm.dataLoading = true;
            vm.logs.length = 0;

            var searchModel = {
                from: vm.options.from,
                to: vm.options.to,
                logLevels: [],
                logEnvironments: [],
                logApplications: []
            };

            vm.options.logLevels.forEach(function (logLevel) {
                if (logLevel.selected) {
                    searchModel.logLevels.push(logLevel.level)
                }
            });

            vm.options.logEnvironments.forEach(function (logEnvironment) {
                if (logEnvironment.selected) {
                    searchModel.logEnvironments.push(logEnvironment.id)
                }
            });

            vm.options.logApplications.forEach(function (logApplication) {
                if (logApplication.selected) {
                    searchModel.logApplications.push(logApplication.id)
                }
            });

            logSelectionOptionsService.getLogs(searchModel).then(function (response) {
                response.data.forEach(function (log) {
                    log.expanded = false;
                    vm.logs.push(log);
                });
                vm.dataLoading = false;
            });
        }
        

        activate();

        function activate() {
            vm.options = logSelectionOptionsService.getOptions();
        }
    }
})();
