From 8ad216dedf017f3d6de047a25d08db3b98e16361 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 9 Mar 2016 15:33:52 +0100 Subject: [PATCH] test --- client/index.html | 2 +- client/js/controllers/image/image.js | 6 +++++- client/js/services/Image.js | 20 +++++++++++++++++++- client/partials/image/image.html | 7 +++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/client/index.html b/client/index.html index a06994c..7ff859d 100644 --- a/client/index.html +++ b/client/index.html @@ -66,7 +66,7 @@ - + diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index e298fcc..d499acb 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,7 +3,7 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, Image, Loading) +mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading',function ($scope, Image, Loading) { var callbackTest=function(){ $scope.images=Image.getData().images; @@ -17,5 +17,9 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, else{ callbackTest(); } + + $scope.doUpload = function () { + Image.uploadImage($scope.myFile,function(){}); + }; }]); diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 2e8c56f..decb5b2 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -44,6 +44,23 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ }; + var uploadImage=function(fileToUpload, callback) { + + + var result=$http.post('../server/index.php', + $.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'filename':fileToUpload, 'id':'6564'})); + + // Wait and handle the response + result.then(function (response){ + callback(parseUploadImageAnswer(response, false)); + },function(response){ + callback(parseUploadImageAnswer(response, true)); + }); + + + + } + var getData=function(response){ return data; @@ -52,7 +69,8 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ // Return services objects return { getImages:getImages, - getData:getData + getData:getData, + uploadImage:uploadImage }; diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 8af8af5..3f597fb 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -6,5 +6,12 @@
{{image.name}}
+
+ + +
+ + +