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

Commit 1b90a72

Browse files
chrisirhcbekos
authored andcommitted
demo(build): make build modal download consistent
Closes #1579
1 parent 566ae73 commit 1b90a72

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

Diff for: misc/demo/assets/app.js

+11-20
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,21 @@ angular.module('bootstrapDemoApp', ['ui.bootstrap', 'plunker'], function($httpPr
33
delete $httpProvider.defaults.headers.common['X-Requested-With'];
44
});
55

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

12-
var downloadFileFromUrl = function(downloadUrl) {
13-
$iframe.attr('src', '');
14-
$iframe.attr('src', downloadUrl);
15-
};
16-
8+
function MainCtrl($scope, $http, $document, $modal, orderByFilter) {
179
$scope.showBuildModal = function() {
1810
var modalInstance = $modal.open({
1911
templateUrl: 'buildModal.html',
2012
controller: 'SelectModulesCtrl',
2113
resolve: {
2214
modules: function() {
23-
return $http.get(url + "/api/bootstrap").then(function(response) {
15+
return $http.get(builderUrl + "/api/bootstrap").then(function(response) {
2416
return response.data.modules;
2517
});
2618
}
2719
}
2820
});
29-
30-
modalInstance.result.then(function(selectedModules) {
31-
var downloadUrl = url + "/api/bootstrap/download?";
32-
angular.forEach(selectedModules, function(module) {
33-
downloadUrl += "modules=" + module + "&";
34-
});
35-
downloadFileFromUrl(downloadUrl);
36-
});
3721
};
3822

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

4731
var SelectModulesCtrl = function($scope, $modalInstance, modules) {
48-
4932
$scope.selectedModules = [];
5033
$scope.modules = modules;
5134

@@ -64,6 +47,14 @@ var SelectModulesCtrl = function($scope, $modalInstance, modules) {
6447
$scope.cancel = function () {
6548
$modalInstance.dismiss();
6649
};
50+
51+
$scope.download = function (selectedModules) {
52+
var downloadUrl = builderUrl + "/api/bootstrap/download?";
53+
angular.forEach(selectedModules, function(module) {
54+
downloadUrl += "modules=" + module + "&";
55+
});
56+
return downloadUrl;
57+
};
6758
};
6859

6960
var DownloadCtrl = function($scope, $modalInstance) {

Diff for: misc/demo/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ <h4 style="text-align: center;">{{buildErrorText}}</h4>
293293
</div>
294294
</div>
295295
<div class="modal-footer">
296-
<a class="btn btn-primary" ng-disabled="!selectedModules.length" ng-click="selectedModules.length && downloadBuild()">
296+
<a class="btn btn-default" ng-click="cancel()">Close</a>
297+
<a class="btn btn-primary" ng-disabled="!selectedModules.length" ng-href="{{selectedModules.length ? download(selectedModules) : ''}}">
297298
<i class="glyphicon glyphicon-download-alt"></i> Download {{selectedModules.length}} Modules
298299
</a>
299-
<a class="btn" ng-click="cancel()">Cancel</a>
300300
</div>
301301
</script>
302302

0 commit comments

Comments
 (0)