Merge remote-tracking branch 'origin/master' into rustedbuilds
Conflicts: test/data/test.db
This commit is contained in:
commit
ed38bcdafc
17 changed files with 1116 additions and 694 deletions
|
@ -774,6 +774,137 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
|
|||
loadViewInfo();
|
||||
}
|
||||
|
||||
function BuildPackageCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $location, $timeout) {
|
||||
var namespace = $routeParams.namespace;
|
||||
var name = $routeParams.name;
|
||||
var buildid = $routeParams.buildid;
|
||||
|
||||
var params = {
|
||||
'repository': namespace + '/' + name,
|
||||
'build_uuid': buildid
|
||||
};
|
||||
|
||||
$scope.initializeTree = function() {
|
||||
if ($scope.drawn) {
|
||||
$scope.tree.notifyResized();
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.drawn = true;
|
||||
$timeout(function() {
|
||||
$scope.tree.draw('file-tree-container');
|
||||
}, 10);
|
||||
};
|
||||
|
||||
$scope.downloadForUser = function() {
|
||||
var blob = $scope.zip.generate({type:"blob"});
|
||||
saveAs(blob, $scope.repobuild['display_name'] + '.zip');
|
||||
};
|
||||
|
||||
var processBuildPack = function(response) {
|
||||
// Try to load as a zip file.
|
||||
var zipFiles = null;
|
||||
var zip = null;
|
||||
try {
|
||||
var zip = new JSZip(response);
|
||||
zipFiles = zip.files;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
// Find the Dockerfile in the zip file. If there isn't any zip file, then the response
|
||||
// itself (should) be the Dockerfile.
|
||||
if (zipFiles && Object.keys(zipFiles).length) {
|
||||
// Load the dockerfile contents.
|
||||
var dockerfile = zip.file('Dockerfile');
|
||||
if (dockerfile) {
|
||||
$scope.dockerFileContents = dockerfile.asText();
|
||||
}
|
||||
|
||||
// Build the zip file tree.
|
||||
$scope.zip = zip;
|
||||
$scope.tree = new FileTree(Object.keys(zipFiles));
|
||||
$($scope.tree).bind('fileClicked', function(e) {
|
||||
var file = zip.file(e.path);
|
||||
if (file) {
|
||||
var blob = new Blob([file.asArrayBuffer()]);
|
||||
saveAs(blob, file.name);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$scope.dockerFileContents = response;
|
||||
}
|
||||
|
||||
$scope.loaded = true;
|
||||
};
|
||||
|
||||
var downloadBuildPack = function() {
|
||||
$scope.downloadProgress = 0;
|
||||
$scope.downloading = true;
|
||||
|
||||
ApiService.getRepoBuildArchiveUrl(null, params).then(function(resp) {
|
||||
startDownload(resp['url']);
|
||||
}, function() {
|
||||
$scope.downloading = false;
|
||||
$scope.downloadError = true;
|
||||
});
|
||||
};
|
||||
|
||||
var startDownload = function(url) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', url, true);
|
||||
if (request.overrideMimeType) {
|
||||
request.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
}
|
||||
request.onprogress = function(e) {
|
||||
$scope.$apply(function() {
|
||||
var percentLoaded;
|
||||
if (e.lengthComputable) {
|
||||
$scope.downloadProgress = (e.loaded / e.total) * 100;
|
||||
}
|
||||
});
|
||||
};
|
||||
request.onerror = function() {
|
||||
$scope.$apply(function() {
|
||||
$scope.downloading = false;
|
||||
$scope.downloadError = true;
|
||||
});
|
||||
};
|
||||
request.onreadystatechange = function() {
|
||||
var state = request.readyState;
|
||||
if (state == 4) {
|
||||
$scope.$apply(function() {
|
||||
$scope.downloading = false;
|
||||
processBuildPack(request.responseText);
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
request.send();
|
||||
};
|
||||
|
||||
var getBuildInfo = function() {
|
||||
$scope.repository_build = ApiService.getRepoBuildStatus(null, params, true).then(function(resp) {
|
||||
if (!resp['is_writer']) {
|
||||
$rootScope.title = 'Unknown build';
|
||||
$scope.accessDenied = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$rootScope.title = 'Repository Build Pack - ' + resp['display_name'];
|
||||
$scope.repobuild = resp;
|
||||
$scope.repo = {
|
||||
'namespace': namespace,
|
||||
'name': name
|
||||
};
|
||||
|
||||
downloadBuildPack();
|
||||
return resp;
|
||||
});
|
||||
};
|
||||
|
||||
getBuildInfo();
|
||||
}
|
||||
|
||||
function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $location, $interval, $sanitize, ansi2html) {
|
||||
var namespace = $routeParams.namespace;
|
||||
var name = $routeParams.name;
|
||||
|
@ -805,7 +936,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
};
|
||||
|
||||
$scope.adjustLogHeight = function() {
|
||||
$('.build-logs').height($(window).height() - 385);
|
||||
$('.build-logs').height($(window).height() - 415);
|
||||
};
|
||||
|
||||
$scope.askRestartBuild = function(build) {
|
||||
|
|
Reference in a new issue