- New UI for the repo view, which shows the build status and admin button on the top bar, and allows for creation of new builds as well as linking to build history

- Add a new build button to the build history page
-
This commit is contained in:
Joseph Schorr 2014-02-14 22:59:44 -05:00
parent 0ceeb6f8e7
commit 7bf6936154
8 changed files with 439 additions and 204 deletions

View file

@ -341,8 +341,17 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
// Start scope methods //////////////////////////////////////////
$scope.buildDialogShowCounter = 0;
$scope.getFormattedCommand = ImageMetadataService.getFormattedCommand;
$scope.showNewBuildDialog = function() {
$scope.buildDialogShowCounter++;
};
$scope.handleBuildStarted = function(build) {
startBuildInfoTimer($scope.repo);
};
$scope.showBuild = function(buildInfo) {
$location.path('/repository/' + namespace + '/' + name + '/build');
$location.search('current', buildInfo.id);
@ -784,6 +793,17 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
$scope.builds = [];
$scope.polling = false;
$scope.buildDialogShowCounter = 0;
$scope.showNewBuildDialog = function() {
$scope.buildDialogShowCounter++;
};
$scope.handleBuildStarted = function(newBuild) {
$scope.builds.push(newBuild);
$scope.setCurrentBuild(newBuild['id'], true);
};
$scope.adjustLogHeight = function() {
$('.build-logs').height($(window).height() - 385);
};
@ -1548,12 +1568,6 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
'initialize': false
};
$('#couldnotbuildModal').on('hidden.bs.modal', function() {
$scope.$apply(function() {
$location.path('/repository/' + $scope.created.namespace + '/' + $scope.created.name);
});
});
// Watch the namespace on the repo. If it changes, we update the plan and the public/private
// accordingly.
$scope.isUserNamespace = true;
@ -1600,15 +1614,36 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
$scope.repo.namespace = namespace;
};
$scope.handleBuildStarted = function() {
var repo = $scope.repo;
$location.path('/repository/' + repo.namespace + '/' + repo.name);
};
$scope.handleBuildFailed = function(message) {
var repo = $scope.repo;
bootbox.dialog({
"message": message,
"title": "Could not start Dockerfile build",
"buttons": {
"close": {
"label": "Close",
"className": "btn-primary",
"callback": function() {
$scope.$apply(function() {
$location.path('/repository/' + repo.namespace + '/' + repo.name);
});
}
}
}
});
return true;
};
$scope.createNewRepo = function() {
$('#repoName').popover('hide');
var uploader = $('#file-drop')[0];
if ($scope.repo.initialize && uploader.files.length < 1) {
$('#missingfileModal').modal();
return;
}
$scope.creating = true;
var repo = $scope.repo;
var data = {
@ -1624,7 +1659,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
// Repository created. Start the upload process if applicable.
if ($scope.repo.initialize) {
startFileUpload(created);
$scope.createdForBuild = created;
return;
}
@ -1653,74 +1688,6 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
PlanService.changePlan($scope, null, $scope.planRequired.stripeId, callbacks);
};
var startBuild = function(repo, fileId) {
$scope.building = true;
var data = {
'file_id': fileId
};
var params = {
'repository': repo.namespace + '/' + repo.name
};
ApiService.requestRepoBuild(data, params).then(function(resp) {
$location.path('/repository/' + params.repository);
}, function() {
$('#couldnotbuildModal').modal();
});
};
var conductUpload = function(repo, file, url, fileId, mimeType) {
var request = new XMLHttpRequest();
request.open('PUT', url, true);
request.setRequestHeader('Content-Type', mimeType);
request.onprogress = function(e) {
$scope.$apply(function() {
var percentLoaded;
if (e.lengthComputable) {
$scope.upload_progress = (e.loaded / e.total) * 100;
}
});
};
request.onerror = function() {
$scope.$apply(function() {
$('#couldnotbuildModal').modal();
});
};
request.onreadystatechange = function() {
var state = request.readyState;
if (state == 4) {
$scope.$apply(function() {
$scope.uploading = false;
startBuild(repo, fileId);
});
return;
}
};
request.send(file);
};
var startFileUpload = function(repo) {
$scope.uploading = true;
$scope.uploading_progress = 0;
var uploader = $('#file-drop')[0];
var file = uploader.files[0];
$scope.upload_file = file.name;
var mimeType = file.type || 'application/octet-stream';
var data = {
'mimeType': mimeType
};
var getUploadUrl = ApiService.getFiledropUrl(data).then(function(resp) {
conductUpload(repo, file, resp.url, resp.file_id, mimeType);
}, function() {
$('#couldnotbuildModal').modal();
});
};
var subscribedToPlan = function(sub) {
$scope.planChanging = false;