Remove hardcoded /app/data and fix submit for file downloads

This commit is contained in:
Johannes Zellner
2017-08-20 18:09:43 +02:00
parent 979c4e77e3
commit 82380b6b7c
2 changed files with 22 additions and 19 deletions

View File

@@ -1,23 +1,22 @@
<!-- Modal download file -->
<div class="modal fade" id="downloadFileModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Download a file from {{ selected.name }}</h4>
</div>
<div class="modal-body">
<div class="input-group">
<span class="input-group-addon">/app/data/</span>
<input type="text" class="form-control" ng-model="downloadFile.filePath" required autofocus>
</div>
<input class="ng-hide" type="submit" ng-disabled="!downloadFile.filePath"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a class="btn btn-success" ng-href="{{ downloadFile.downloadUrl() }}" ng-disabled="!downloadFile.filePath" target="_blank">Download</a>
</div>
</div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Download a file from {{ selected.name }}</h4>
</div>
<div class="modal-body">
<form ng-submit="downloadFile.submit()">
<input type="text" class="form-control" ng-model="downloadFile.filePath" required autofocus>
<input class="ng-hide" type="submit" ng-disabled="!downloadFile.filePath"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a id="fileDownloadLink" class="btn btn-success" ng-href="{{ downloadFile.downloadUrl() }}" ng-disabled="!downloadFile.filePath" target="_blank">Download</a>
</div>
</div>
</div>
</div>
<div class="logs-controls">

View File

@@ -27,8 +27,7 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
filePath: '',
downloadUrl: function () {
var filePath = '/app/data/' + $scope.downloadFile.filePath;
filePath = filePath.replace(/\/*\//g, '/');
var filePath = $scope.downloadFile.filePath.replace(/\/*\//g, '/');
return Client.apiOrigin + '/api/v1/apps/' + $scope.selected.value + '/download?file=' + filePath + '&access_token=' + Client.getToken();
},
@@ -36,6 +35,11 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
show: function () {
$scope.downloadFile.filePath = '';
$('#downloadFileModal').modal('show');
},
submit: function () {
// we have to click the link to make the browser do the download
$('#fileDownloadLink')[0].click();
}
};