summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-09-30 18:29:21 +0100
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-10-01 09:51:06 +0100
commitb090c887c3f36c70056326c6ae63321ae4393217 (patch)
tree18645e4f3265be5a95c37ed1452f5eb564a1a277
parent7a0af26c0d5f9b6cb0157378b33ee90b4ba00adc (diff)
downloadciat-ui-b090c887c3f36c70056326c6ae63321ae4393217.tar.gz
Add progress bars to the "Builds" lane
-rw-r--r--js/main.js36
-rw-r--r--partials/visualisation.html4
2 files changed, 34 insertions, 6 deletions
diff --git a/js/main.js b/js/main.js
index 71f7410..b3ee2e1 100644
--- a/js/main.js
+++ b/js/main.js
@@ -44,18 +44,30 @@ app.controller('VisualisationController', function($scope, $http, $q, $interval)
.then(function(builders) {
angular.forEach(builders.data, function(value, key) {
var lastBuildID;
- if (value.state === 'building') {
+ var currentBuildStarted;
+ var state = value.state;
+
+ var latestBuildNumber = value.cachedBuilds.length - 1;
+ var latestBuildsPath = apiBase + '/builders/' + key +
+ '/builds/' + latestBuildNumber;
+ $http.get(latestBuildsPath).then(function(estimationResponse) {
+
+ var currentTime = Math.floor((new Date()).getTime() / 1000)
+ var timeRunning = 0;
+ if (state === 'building') {
lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 2];
+ timeRunning = currentTime - estimationResponse.data.times[0];
} else {
lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 1];
}
var buildsPath = apiBase + '/builders/' + key +
'/builds/' + lastBuildID;
- var currentTime = Math.round(new Date().getTime() / 1000);
+
$http.get(buildsPath).then(function(response) {
- var previousTime = Math.round(response.data.times[0] - response.data.times[1])
+ var progress = 100;
+ var previousTime = response.data.times[1] - response.data.times[0];
var details = {
success: checkInArray(response.data.text, 'successful'),
failed: checkInArray(response.data.text, 'failed'),
@@ -72,10 +84,25 @@ app.controller('VisualisationController', function($scope, $http, $q, $interval)
});
}
else if (key.indexOf("Build") > -1) {
+ var progressStyle = "progress-bar-success progress-bar-striped"
+ if (state === "building" ) {
+ progressStyle = "progress-bar-warning progress-bar-striped active"
+ progress = (timeRunning * 100) / previousTime;
+ //alert (currentTime)
+ //alert (estimationResponse.data.times[0])
+ //alert (timeRunning)
+ //alert (previousTime)
+ if (progress > 100 ) {
+ progress = 90;
+ }
+ }
$scope.builds.push({
name: key,
lastBuild: details,
- data: value
+ data: value,
+ progress: progress,
+ style: progressStyle
+
});
}
else if(key.indexOf("Deploy") > -1) {
@@ -108,6 +135,7 @@ app.controller('VisualisationController', function($scope, $http, $q, $interval)
return left - right;
});
});
+ });
});
});
}
diff --git a/partials/visualisation.html b/partials/visualisation.html
index 1643a3f..4bde367 100644
--- a/partials/visualisation.html
+++ b/partials/visualisation.html
@@ -28,8 +28,8 @@
{{step.name}}
</div>
<div class="progress">
- <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 45%">
- <span class="sr-only">45% Complete</span>
+ <div class="progress-bar {{step.style}}" role="progressbar" aria-valuenow="{{step.progress}}" aria-valuemin="0" aria-valuemax="100" style="width: {{step.progress}}%">
+ <span class="sr-only">{{step.progress}}% Complete</span>
</div>
</div>
</div>