blob: 74f0cf25180011e2ee588edf75633d291a98d2b1 (
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
34
35
36
37
38
39
40
41
42
43
44
|
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 = -1;
if (value.state === 'building') {
lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 2];
} else {
lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 1];
}
var previous = null;
if (lastBuildID != -1) {
var buildsPath = 'http://ciat.baserock.org:8010/json/builders/' +
key + '/builds/' + lastBuildID;
previous = $http.get(buildsPath).then(formatBuild);
}
var step = {
name: key,
lastBuild: previous,
data: value
}
$scope.steps.push(step);
});
});
}
]);
|