summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam@sotk.co.uk>2015-09-26 15:12:48 +0100
committerAdam Coldrick <adam@sotk.co.uk>2015-09-28 20:20:09 +0100
commitc2ba11775773c73aa028686acd91a03b8af2c82f (patch)
treefaacf1681a96571bfa5ad14ed797f830f0053f0e
parentc7321b8ba975fcb6a49773197f1305dd0ddd1be9 (diff)
downloadciat-ui-c2ba11775773c73aa028686acd91a03b8af2c82f.tar.gz
Handle in-progress build
-rw-r--r--js/main.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/js/main.js b/js/main.js
index 6854273..74f0cf2 100644
--- a/js/main.js
+++ b/js/main.js
@@ -18,12 +18,23 @@ app.controller('VisualisationController', ['$scope', '$http',
$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 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: $http.get(buildsPath).then(formatBuild),
+ lastBuild: previous,
data: value
}
$scope.steps.push(step);