This is an automated email from the git hooks/post-receive script. New commit to branch feature/addPollenResourceApi in repository pollen. See http://git.chorem.org/pollen.git commit 3cf3443f15e6def8068ba2a52b9f75e2de42a747 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jul 11 15:08:37 2014 +0200 UI use PollenResourceApi --- .../src/main/webapp/js/controllers/pollCtrl.js | 12 ++++++------ pollen-ui-angular/src/main/webapp/js/directives.js | 12 +++++++++--- pollen-ui-angular/src/main/webapp/js/services.js | 21 +++++++++++++++++++++ .../src/main/webapp/partials/home.html | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index c03f5a6..1230902 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -25,8 +25,8 @@ angular.module('pollControllers', []) }]) .controller('PollCtrl', - ['$scope', '$rootScope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', '$q', 'Poll', 'Page', 'DateFormat', - function ( $scope, $rootScope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route, $q, Poll, Page, DateFormat) { + ['$scope', '$rootScope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', '$q', 'Poll', 'PollenResource', 'Page', 'DateFormat', + function ( $scope, $rootScope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route, $q, Poll, PollenResource, Page, DateFormat) { $scope.setTab = function (defaultValue) { if (angular.isDefined($routeParams.tab)) { return $routeParams.tab; @@ -201,7 +201,7 @@ angular.module('pollControllers', []) choice.choiceValue = choice.choiceValue.getTime(); } else if (choice.choiceType == 'IMAGE') { - choice.choiceValue = choice.choiceValue.meta.name+"####"+choice.choiceValue.data; + choice.choiceValue = choice.choiceValue.meta.id; } return choice; @@ -212,9 +212,9 @@ angular.module('pollControllers', []) choice.choiceValue = new Date(Number(choice.choiceValue)); } else if (choice.choiceType == 'IMAGE') { - var tmp = choice.choiceValue.split("####"); - - choice.choiceValue = {meta:{name:tmp[0]}, data : tmp[1]}; + PollenResource.getMeta({resourceId : choice.choiceValue}, function (data) { + choice.choiceValue = {meta:data, data : conf.restURL+'/resources/'+data.id, id : data.id}; + }); } return choice; diff --git a/pollen-ui-angular/src/main/webapp/js/directives.js b/pollen-ui-angular/src/main/webapp/js/directives.js index 755eb81..b5dd14c 100644 --- a/pollen-ui-angular/src/main/webapp/js/directives.js +++ b/pollen-ui-angular/src/main/webapp/js/directives.js @@ -438,27 +438,33 @@ angular.module('pollenDirective', []) ///// UPLOAD FILE ///// ////////////////////////////////////// -.directive("uploadFile", function () { +.directive("uploadFile", ["PollenResource", function (PollenResource) { return { restrict : "E", scope: { ngModel: "=" }, - template:'<input type="file" />', + template:'<form><input type="file" name="resource" /></form>', link: function (scope, element, attrs) { element.bind("change", function (changeEvent) { var reader = new FileReader(); reader.onload = function (loadEvent) { + var formData = new FormData(element[0].firstChild); scope.$apply(function () { scope.ngModel = { meta: changeEvent.target.files[0], data: loadEvent.target.result}; }); + + PollenResource.upload(formData, function (response) { + scope.ngModel.meta.id = response.id; + }); + } reader.readAsDataURL( changeEvent.target.files[0] ); }); } } -}) +}]) ////////////////////////////////////// ///// ZOOM IMAGE ///// diff --git a/pollen-ui-angular/src/main/webapp/js/services.js b/pollen-ui-angular/src/main/webapp/js/services.js index a1303ab..78b6ffa 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -318,6 +318,27 @@ angular.module('pollenServices', ['ngResource']) }]) ////////////////////////////////////// +///// RESOURCES FILE ///// +////////////////////////////////////// + +.factory('PollenResource', ['$resource', function ($resource) { + return $resource(conf.restURL+'/resources/:resourceId', null, + { + 'getMeta': { + method : 'GET', + url: conf.restURL+'/resources/:resourceId/meta' + }, + 'upload' : { + method: 'POST', + transformRequest: angular.identity, + headers:{ + 'Content-Type':undefined + } + } + }); +}]) + +////////////////////////////////////// ///// SESSION STORAGE RESOURCE ///// ////////////////////////////////////// diff --git a/pollen-ui-angular/src/main/webapp/partials/home.html b/pollen-ui-angular/src/main/webapp/partials/home.html index d5a161f..846d330 100644 --- a/pollen-ui-angular/src/main/webapp/partials/home.html +++ b/pollen-ui-angular/src/main/webapp/partials/home.html @@ -18,6 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -<div class="hero-unit"> +<div> <img src="img/pollen.png"/> </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm