Add ability to download the build pack

This commit is contained in:
Joseph Schorr 2014-02-17 17:36:58 -05:00
parent bc0d51656a
commit 509ba2f4f7
2 changed files with 11 additions and 0 deletions

View file

@ -793,6 +793,11 @@ function BuildPackageCtrl($scope, Restangular, ApiService, $routeParams, $rootSc
}, 10); }, 10);
}; };
$scope.downloadForUser = function() {
var blob = $scope.zip.generate({type:"blob"});
saveAs(blob, $scope.repobuild['display_name'] + '.zip');
};
var processBuildPack = function(response) { var processBuildPack = function(response) {
// Try to load as a zip file. // Try to load as a zip file.
var zipFiles = null; var zipFiles = null;
@ -813,6 +818,7 @@ function BuildPackageCtrl($scope, Restangular, ApiService, $routeParams, $rootSc
} }
// Build the zip file tree. // Build the zip file tree.
$scope.zip = zip;
$scope.tree = new FileTree(Object.keys(zipFiles)); $scope.tree = new FileTree(Object.keys(zipFiles));
$($scope.tree).bind('fileClicked', function(e) { $($scope.tree).bind('fileClicked', function(e) {
var file = zip.file(e.path); var file = zip.file(e.path);

View file

@ -9,6 +9,11 @@
<span class="repo-circle no-background" repo="repo"></span> <span class="repo-circle no-background" repo="repo"></span>
<span class="repo-breadcrumb" repo="repo" subsection-icon="'fa-tasks'" subsection="repobuild.display_name"></span> <span class="repo-breadcrumb" repo="repo" subsection-icon="'fa-tasks'" subsection="repobuild.display_name"></span>
</h3> </h3>
<div class="repo-controls">
<a href="javascript:void(0)" title="Download Buildpack" bs-tooltip="tooltip.title" ng-show="zip" ng-click="downloadForUser()">
<i class="fa fa-download toggle-icon"></i>
</a>
</div>
</div> </div>
<div class="row" ng-show="downloading"> <div class="row" ng-show="downloading">