{"size": 3223, "ext": "js", "max_stars_repo_path": "majordodo-web-ui/src/main/webapp/controllers/resources.controller.js", "max_stars_repo_name": "majordodo/majordodo", "max_stars_repo_stars_event_min_datetime": "2016-05-17T10:06:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T11:34:51.000Z", "max_issues_repo_path": "majordodo-web-ui/src/main/webapp/controllers/resources.controller.js", "max_issues_repo_name": "majordodo/majordodo", "max_issues_repo_issues_event_min_datetime": "2017-01-10T11:18:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-11T11:19:21.000Z", "max_forks_repo_path": "majordodo-web-ui/src/main/webapp/controllers/resources.controller.js", "max_forks_repo_name": "majordodo/majordodo", "max_forks_repo_forks_event_min_datetime": "2017-01-10T10:43:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-03T12:50:19.000Z"}
{"max_stars_count": 22, "max_issues_count": 155, "max_forks_count": 10, "avg_line_length": 32.5555555556, "max_line_length": 100, "alphanum_fraction": 0.3797704002}
function resourcesController($scope, $http, $route, $timeout, $location, $state, GlobalFunctions) {
    $scope.brokerUrl = "";
    if (!$state.brokerUrl) {
        $scope.brokerUrl = $location.search().brokerUrl;
        $state.brokerUrl = $scope.brokerUrl;
    } else {
        $scope.brokerUrl = $state.brokerUrl;
    }
    $scope.resources = [];

    $scope.go = function (path) {
        $location.path(path);
    };

    $scope.keyPress = function (event) {
        if (event.keyCode === 13) {
            $scope.reloadData();
        }
    }

    $scope.reloadData = function () {
        if ($scope.brokerUrl.indexOf("?") === -1) {
            $scope.brokerUrl = $scope.brokerUrl + "?";
        }
        $state.brokerUrl = $scope.brokerUrl;
        var theUrl = $scope.brokerUrl + '&view=resources';
        $http.get(theUrl).
                success(function (data, status, headers, config) {
                    $('#warning-alert').hide();
                    if (data.ok) {
                        var res = data.resources;
                        $scope.options = getOptions();
                        var running = [];
                        var max = [];
                        for (var i = 0; i < res.length; i++) {
                            running.push({x: res[i].id, y: res[i].runningTasks});
                            max.push({x: res[i].id, y: res[i].actualLimit});
                        }
                        var d = [{
                                values: running,
                                key: "Running tasks"
                            }, {
                                values: max,
                                key: "Global limit"
                            }];
                        $scope.data = d;
                        $scope.lastupdate = new Date();
                        $scope.resources = data.resources;
                    }
                }).
                error(function (data, status, headers, config) {
                    $scope.badUrl = $scope.brokerUrl || 'URL';
                    $('#warning-alert').fadeIn(500);
                });

    };

    $(document).ready(function () {
        $('#warning-alert').hide();
        $('li').removeClass("active");
        $('#li-resources').addClass("active");
        $scope.reloadData();
    });
}

function getOptions() {
    return {
        chart: {
            type: 'multiBarChart',
            height: 450,
            margin: {
                top: 20,
                right: 20,
                bottom: 45,
                left: 45
            },
            clipEdge: true,
            duration: 500,
            stacked: true,
            showValues: true,
            xAxis: {
                axisLabel: 'Resource',
                showMaxMin: true,
                tickFormat: function (d) {
                    return d;
                }
            },
            yAxis: {
                axisLabel: '',
                axisLabelDistance: -20,
                tickFormat: function (d) {
                    return d3.format(',f')(d);
                }
            }
        }
    };
}

