Work in progress: Add the UI for the build status and start on the file drop stuff

This commit is contained in:
Joseph Schorr 2013-10-26 16:03:11 -04:00
parent dc7a62db67
commit fc6e3258a8
13 changed files with 278 additions and 31 deletions

View file

@ -1,5 +1,5 @@
// Start the application code itself.
quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel'], function($provide) {
quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel', '$strap.directives'], function($provide) {
$provide.factory('UserService', ['Restangular', function(Restangular) {
var userResponse = {
verified: false,
@ -177,7 +177,72 @@ quayApp.directive('repoCircle', function () {
'repo': '=repo'
},
controller: function($scope, $element) {
window.console.log($scope);
}
};
return directiveDefinitionObject;
});
quayApp.directive('buildStatus', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/build-status.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'build': '=build'
},
controller: function($scope, $element) {
$scope.getBuildProgress = function(buildInfo) {
switch (buildInfo.status) {
case 'building':
return (buildInfo.current_command / buildInfo.total_commands) * 100;
break;
case 'pushing':
return (buildInfo.current_image / buildInfo.total_images) * 100;
break;
case 'complete':
return 100;
break;
case 'initializing':
case 'starting':
case 'waiting':
return 0;
break;
}
return -1;
};
$scope.getBuildMessage = function(buildInfo) {
switch (buildInfo.status) {
case 'initializing':
return 'Starting Dockerfile build';
break;
case 'starting':
case 'waiting':
case 'building':
return 'Building image from Dockerfile';
break;
case 'pushing':
return 'Pushing image built from Dockerfile';
break;
case 'complete':
return 'Dockerfile build completed and pushed';
break;
case 'error':
return 'Dockerfile build failed: ' + buildInfo.message;
break;
}
};
}
};
return directiveDefinitionObject;

View file

@ -339,6 +339,19 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim
}
});
var startBuildInfoTimer = function(repo) {
setInterval(function() {
$scope.$apply(function() { getBuildInfo(repo); });
}, 5000);
};
var getBuildInfo = function(repo) {
var buildInfo = Restangular.one('repository/' + repo.namespace + '/' + repo.name + '/build/');
buildInfo.get().then(function(resp) {
$scope.buildsInfo = resp.builds;
});
};
var listImages = function() {
if ($scope.imageHistory) { return; }
@ -443,6 +456,10 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim
$('#copyClipboard').clipboardCopy();
$scope.loading = false;
if (repo.is_building) {
getBuildInfo(repo);
}
}, function() {
$scope.repo = null;
$scope.loading = false;
@ -895,7 +912,7 @@ function V1Ctrl($scope, UserService) {
};
}
function NewRepoCtrl($scope, UserService) {
function NewRepoCtrl($scope, $location, UserService, Restangular) {
$scope.repo = {
'is_public': 1,
'description': '',
@ -906,7 +923,7 @@ function NewRepoCtrl($scope, UserService) {
$scope.user = currentUser;
if ($scope.user.anonymous) {
document.location = '/signin/';
$location.path('/signin/');
}
}, true);
@ -931,4 +948,24 @@ function NewRepoCtrl($scope, UserService) {
$('#editModal').modal('hide');
$scope.repo.description = $('#wmd-input-description')[0].value;
};
$scope.createNewRepo = function() {
$scope.creating = true;
var repo = $scope.repo;
var data = {
'repository': repo.name,
'visibility': repo.is_public == '1' ? 'public' : 'private'
};
var createPost = Restangular.one('repository');
createPost.customPOST(data).then(function(created) {
// Repository created. Start the upload process if applicable.
// Otherwise, redirect to the repo page.
$location.path('/repository/' + created.namespace + '/' + created.name);
}, function() {
$('#cannotcreateModal').modal();
$scope.creating = false;
});
};
}