From 7876e614898a26ebeb899e893e1dcc64430e4cb2 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Sat, 3 Oct 2015 15:16:01 +0100 Subject: Show real data on the builder detail page Get data for the recent builds on a specific builder, and display it in the table in a nice way. --- js/main.js | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'js/main.js') diff --git a/js/main.js b/js/main.js index 77d5c86..8afcf2a 100644 --- a/js/main.js +++ b/js/main.js @@ -1,6 +1,16 @@ var apiBase = 'http://ciat.baserock.org:8010/json'; var app = angular.module('ciat', ['ngRoute']); +function checkInArray(array, key) { + if (array) { + if (array.indexOf(key) > -1) { + return true; + } + } + return false; +} + + app.config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.useXDomain = true; delete $httpProvider.defaults.headers.common['X-Requested-With']; @@ -20,15 +30,6 @@ app.config(['$routeProvider', function($routeProvider) { }]); app.controller('VisualisationController', function($scope, $http, $q, $interval) { - function checkInArray(array, key) { - if (array) { - if (array.indexOf(key) > -1) { - return true; - } - } - return false; - } - function load() { $scope.steps = []; $scope.integrations = []; @@ -183,11 +184,29 @@ app.controller('VisualisationController', function($scope, $http, $q, $interval) app.controller('BuilderDetailController', function($scope, $http, $routeParams) { - $http.get(apiBase + '/builders/' + $routeParams.name).then(function(builder) { + var builderUrl = apiBase + '/builders/' + $routeParams.name; + + // GET details of the builder + $http.get(builderUrl).then(function(builder) { $scope.builder = { name: $routeParams.name, data: builder.data }; }); + + $scope.builds = []; + // GET list of all builds from this builder + $http.get(builderUrl + '/builds/_all').then(function(response) { + for (var n in response.data) { + var build_data = response.data[n]; + $scope.builds.push({ + success: checkInArray(build_data.text, 'successful'), + number: n, + startTime: build_data.times[0], + finishTime: build_data.times[1], + data: build_data + }); + } + }); } ); -- cgit v1.2.1