Fin Upload File

This commit is contained in:
Eole 2016-05-10 00:03:41 +02:00
parent f3cbeeb408
commit 28cfcece08
2 changed files with 39 additions and 24 deletions

View file

@ -6,6 +6,8 @@
mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', '$rootScope', function ($scope, Image, Loading, Identity, upload, $rootScope)
{
$scope.$on('editImageEvent', function (eventName, image, axioms) {
var list = $("#upload_button");
$.each(list, function(){$(this).detach();});
$scope.image = image;
$scope.data = {};
$scope.data.id = image.id;
@ -23,29 +25,43 @@ mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', '
'width',
'0%'
);
if(image.status != "queued"){
$("#fileupload").css('display','none');
$("#fileupload").fileupload('destroy');
$("#fileupload").val('');
$("#progress").css('display', 'none');
}else{
$("#fileupload").val('');
$("#fileupload").css('display','block');
$("#progress").css('display', 'block');
$("#fileupload").fileupload({
replaceFileInput: false,
formData: {task: "image", token: Identity.getToken(), action: "uploadImage", id: $scope.data.id},
/* ... */
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress_text').html(progress+'%');
$('#progress .bar').css(
'width',
progress + '%'
);
},
add: function (e, data) {
data.process();
var list = $("#upload_button");
$.each(list, function(){$(this).detach();});
data.context = $('<button id="upload_button"/>').text('Upload')
.click(function () {
$(this).detach();
data.submit();
});
console.log("test");
$("#fileupload").after(data.context);
},
});
}
$('#editImageModal').modal('show');
$("#fileupload").fileupload({
replaceFileInput: false,
formData: {task: "image", token: Identity.getToken(), action: "uploadImage", id: $scope.data.id},
/* ... */
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
},
add: function (e, data) {
data.process();
$.each($("#upload_button"), function(){$(this).detach();});
data.context = $('<button id="upload_button"/>').text('Upload')
.click(function () {
$(this).detach();
data.submit();
});
$("#fileupload").after(data.context);
},
});
});
$scope.applyEdition = function (id) {

View file

@ -34,12 +34,11 @@
</fieldset>
</form>
<div ng-if='image.status == "queued"'>
<input id="fileupload" type="file" name="files" size="0" data-url="../server/index.php">
<div id="progress">
<div style="width: 100%; float: left"><p id="progress_text" style="text-align: center; width: 100%">0 %</p></div>
<div class="bar" style="width: 0%;"></div>
</div>
</div>
<!-- <form action="../server/index.php" enctype="multipart/form-data" method="post" ng-if='image.status == "queued"'>
<input type="hidden" name="task" value="image" />
<input type="hidden" name="token" value="{{ getToken()}}" />