Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
demo(build): make build modal download consistent
Browse files Browse the repository at this point in the history
Closes #1579
  • Loading branch information
chrisirhc authored and bekos committed Jan 17, 2014
1 parent 566ae73 commit 1b90a72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
31 changes: 11 additions & 20 deletions misc/demo/assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,21 @@ angular.module('bootstrapDemoApp', ['ui.bootstrap', 'plunker'], function($httpPr
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});

function MainCtrl($scope, $http, $document, $modal, orderByFilter) {
var url = "http://50.116.42.77:3001";
//iFrame for downloading
var $iframe = angular.element('<iframe>').css('display','none');
$document.find('body').append($iframe);
var builderUrl = "http://50.116.42.77:3001";

var downloadFileFromUrl = function(downloadUrl) {
$iframe.attr('src', '');
$iframe.attr('src', downloadUrl);
};

function MainCtrl($scope, $http, $document, $modal, orderByFilter) {
$scope.showBuildModal = function() {
var modalInstance = $modal.open({
templateUrl: 'buildModal.html',
controller: 'SelectModulesCtrl',
resolve: {
modules: function() {
return $http.get(url + "/api/bootstrap").then(function(response) {
return $http.get(builderUrl + "/api/bootstrap").then(function(response) {
return response.data.modules;
});
}
}
});

modalInstance.result.then(function(selectedModules) {
var downloadUrl = url + "/api/bootstrap/download?";
angular.forEach(selectedModules, function(module) {
downloadUrl += "modules=" + module + "&";
});
downloadFileFromUrl(downloadUrl);
});
};

$scope.showDownloadModal = function() {
Expand All @@ -45,7 +29,6 @@ function MainCtrl($scope, $http, $document, $modal, orderByFilter) {
}

var SelectModulesCtrl = function($scope, $modalInstance, modules) {

$scope.selectedModules = [];
$scope.modules = modules;

Expand All @@ -64,6 +47,14 @@ var SelectModulesCtrl = function($scope, $modalInstance, modules) {
$scope.cancel = function () {
$modalInstance.dismiss();
};

$scope.download = function (selectedModules) {
var downloadUrl = builderUrl + "/api/bootstrap/download?";
angular.forEach(selectedModules, function(module) {
downloadUrl += "modules=" + module + "&";
});
return downloadUrl;
};
};

var DownloadCtrl = function($scope, $modalInstance) {
Expand Down
4 changes: 2 additions & 2 deletions misc/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ <h4 style="text-align: center;">{{buildErrorText}}</h4>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary" ng-disabled="!selectedModules.length" ng-click="selectedModules.length && downloadBuild()">
<a class="btn btn-default" ng-click="cancel()">Close</a>
<a class="btn btn-primary" ng-disabled="!selectedModules.length" ng-href="{{selectedModules.length ? download(selectedModules) : ''}}">
<i class="glyphicon glyphicon-download-alt"></i> Download {{selectedModules.length}} Modules
</a>
<a class="btn" ng-click="cancel()">Cancel</a>
</div>
</script>

Expand Down

0 comments on commit 1b90a72

Please sign in to comment.