From 2856a776dbedfdef2ace3cd4b4c06d1e8ebe6151 Mon Sep 17 00:00:00 2001 From: Loic GUEGAN Date: Fri, 6 May 2016 14:24:15 +0200 Subject: Add image creation and suppression --- client/js/controllers/image/create.js | 80 +++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 client/js/controllers/image/create.js (limited to 'client/js/controllers/image/create.js') diff --git a/client/js/controllers/image/create.js b/client/js/controllers/image/create.js new file mode 100644 index 0000000..cd761fd --- /dev/null +++ b/client/js/controllers/image/create.js @@ -0,0 +1,80 @@ +/** + * The image controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('createImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload','$rootScope', function ($scope, Image, Loading, Identity, upload, $rootScope) + { + /*$scope.uploader = new FileUploader({ + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564' + }); + $scope.uploader.url='../server/index.php' + $scope.uploader.alias='file_name' + $scope.uploader.formData={ + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564' + } + */ + + $scope.doUpload = function () { + /* console.log($('#imageToUpload').prop('files')[0]); + Image.uploadImage($('#imageToUpload').prop('files')[0], function () { + alert("done"); + });*/ + Image.uploadImage("loic", function () {}) + /*$("#drop-area-div").dmUploader({ + extraData: { + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564'}, + url:"../server/index.php" + }); + */ + + /*upload({ + url: '../server/index.php', + method: 'POST', + data: { + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564', + "file_name": $scope.myFile, // a jqLite type="file" element, upload() will extract all the files from the input and put them into the FormData object before sending. + } + }).then( + function (response) { + console.log(response.data); // will output whatever you choose to return from the server on a successful upload + }, + function (response) { + console.error(response); // Will return if status code is above 200 and lower than 300, same as $http + } + );*/ + + + }; + // Manager logout event + $scope.$on('showCreateImageModalEvent', function () { + $scope.token = Identity.getToken(); + + $('#createImageModal').modal("show"); + }); + + var callMeAfterImageCreate = function (response) { + $rootScope.$broadcast("updateImageEvent"); + Loading.stop(); + + } + + $scope.doCreation = function () { + $('#createImageModal').modal("hide"); + Loading.start(); + Image.createImage($scope.name, callMeAfterImageCreate) + }; + + }]); -- cgit v1.2.3