diff options
author | Adam Coldrick <adam@sotk.co.uk> | 2015-09-26 16:27:32 +0100 |
---|---|---|
committer | Adam Coldrick <adam@sotk.co.uk> | 2015-09-28 20:23:46 +0100 |
commit | 6b72d2c28155544ce14bd7232eea199a5141c949 (patch) | |
tree | e4bc96fcecccf81a6228b1eb19e29613aead9b8a | |
parent | a13c5ded91bc2344237911a15b8e962b7ddc37d1 (diff) | |
download | ciat-ui-6b72d2c28155544ce14bd7232eea199a5141c949.tar.gz |
Move $scope.steps.push into $http success callback
Also make the callback useful
-rw-r--r-- | js/main.js | 51 |
1 files changed, 25 insertions, 26 deletions
@@ -17,32 +17,31 @@ app.controller('VisualisationController', function($scope, $http, $q) { } function load() { - $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); - }); - }); + $scope.steps = []; + $http.get('http://ciat.baserock.org:8010/json/builders') + .then(function(builders) { + angular.forEach(builders.data, function(value, key) { + var lastBuildID; + if (value.state === 'building') { + lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 2]; + } else { + lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 1]; + } + + var buildsPath = 'http://ciat.baserock.org:8010/json/builders/' + + key + '/builds/' + lastBuildID; + $http.get(buildsPath).then(function(response) { + var details = { + success: checkInArray(response.data.text, 'successful'), + failed: checkInArray(response.data.text, 'failed') + }; + $scope.steps.push({ + name: key, + lastBuild: details, + data: value + }); + }); + }); } function cancelRefresh() { |