2015-04-08 22:43:59 +00:00
|
|
|
(function () {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BuildsCtrl responsible for rendering the repo's
|
|
|
|
* recent build history.
|
2015-04-16 21:45:05 +00:00
|
|
|
*/
|
2015-04-08 22:43:59 +00:00
|
|
|
function BuildsCtrl($scope, $routeParams, builds, repos, users) {
|
|
|
|
|
|
|
|
var owner = $routeParams.owner;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
var fullName = owner+'/'+name;
|
|
|
|
|
2015-04-16 21:45:05 +00:00
|
|
|
// Gets the currently authenticated user
|
2015-04-08 22:43:59 +00:00
|
|
|
users.getCached().then(function(payload){
|
|
|
|
$scope.user = payload.data;
|
|
|
|
});
|
2015-04-16 21:45:05 +00:00
|
|
|
|
2015-04-08 22:43:59 +00:00
|
|
|
// Gets a repository
|
|
|
|
repos.get(fullName).then(function(payload){
|
|
|
|
$scope.repo = payload.data;
|
|
|
|
}).catch(function(err){
|
|
|
|
$scope.error = err;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Gets a list of builds
|
|
|
|
builds.list(fullName).then(function(payload){
|
|
|
|
$scope.builds = angular.isArray(payload.data) ? payload.data : [];
|
|
|
|
}).catch(function(err){
|
|
|
|
$scope.error = err;
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.watch = function(repo) {
|
|
|
|
repos.watch(repo.full_name).then(function(payload) {
|
|
|
|
$scope.repo.subscription = payload.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.unwatch = function(repo) {
|
|
|
|
repos.unwatch(repo.full_name).then(function() {
|
|
|
|
delete $scope.repo.subscription;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BuildCtrl responsible for rendering a build.
|
2015-04-16 21:45:05 +00:00
|
|
|
*/
|
|
|
|
function BuildCtrl($scope, $routeParams, logs, builds, repos, users) {
|
2015-04-08 22:43:59 +00:00
|
|
|
|
|
|
|
var step = parseInt($routeParams.step) || 1;
|
|
|
|
var number = $routeParams.number;
|
|
|
|
var owner = $routeParams.owner;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
var fullName = owner+'/'+name;
|
|
|
|
|
2015-04-16 21:45:05 +00:00
|
|
|
// Gets the currently authenticated user
|
2015-04-08 22:43:59 +00:00
|
|
|
users.getCached().then(function(payload){
|
|
|
|
$scope.user = payload.data;
|
|
|
|
});
|
2015-04-16 21:45:05 +00:00
|
|
|
|
2015-04-08 22:43:59 +00:00
|
|
|
// Gets a repository
|
|
|
|
repos.get(fullName).then(function(payload){
|
|
|
|
$scope.repo = payload.data;
|
|
|
|
}).catch(function(err){
|
|
|
|
$scope.error = err;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Gets the build
|
|
|
|
builds.get(fullName, number).then(function(payload){
|
|
|
|
$scope.build = payload.data;
|
2015-04-16 21:45:05 +00:00
|
|
|
$scope.task = payload.data.tasks[step];
|
2015-04-08 22:43:59 +00:00
|
|
|
}).catch(function(err){
|
|
|
|
$scope.error = err;
|
|
|
|
});
|
|
|
|
|
2015-04-16 21:45:05 +00:00
|
|
|
if (step) { // TODO only if build is step.state == 'running'
|
2015-04-08 22:43:59 +00:00
|
|
|
// Gets a list of build steps
|
|
|
|
logs.get(fullName, number, step).then(function(payload){
|
|
|
|
$scope.logs = payload.data;
|
|
|
|
}).catch(function(err){
|
|
|
|
$scope.error = err;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('drone')
|
|
|
|
.controller('BuildCtrl', BuildCtrl)
|
|
|
|
.controller('BuildsCtrl', BuildsCtrl);
|
2015-04-16 21:45:05 +00:00
|
|
|
})();
|