summaryrefslogtreecommitdiff
path: root/js/main.js
blob: 6854273335592efdab9274925f107bf8b3e120e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var app = angular.module('ciat', []);

app.config(['$httpProvider', function($httpProvider) {
        $httpProvider.defaults.useXDomain = true;
        delete $httpProvider.defaults.headers.common['X-Requested-With'];
    }
]);

app.controller('VisualisationController', ['$scope', '$http',
    function($scope, $http) {
        function formatBuild(response) {
            return {
                success: response.data.text[response.data.text.length - 1] === 'successful',
            };
        }

        $scope.steps = [];
        $http.get('http://ciat.baserock.org:8010/json/builders')
            .then(function(builders) {
                angular.forEach(builders.data, function(value, key) {
                    var lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 1];
                    var buildsPath = 'http://ciat.baserock.org:8010/json/builders/' +
                                     key + '/builds/' + lastBuildID;
                    var step = {
                        name: key,
                        lastBuild: $http.get(buildsPath).then(formatBuild),
                        data: value
                    }
                    $scope.steps.push(step);
                });
            });
    }
]);