r3941 - in trunk/pollen-ui-angular/src/main/webapp: . js
Author: garandel Date: 2014-05-14 10:53:32 +0200 (Wed, 14 May 2014) New Revision: 3941 Url: http://forge.chorem.org/projects/pollen/repository/revisions/3941 Log: Add global conf in js/conf.js Added: trunk/pollen-ui-angular/src/main/webapp/js/conf.js.exemple Modified: trunk/pollen-ui-angular/src/main/webapp/index.html trunk/pollen-ui-angular/src/main/webapp/js/services.js Modified: trunk/pollen-ui-angular/src/main/webapp/index.html =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-13 22:58:53 UTC (rev 3940) +++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-14 08:53:32 UTC (rev 3941) @@ -25,6 +25,8 @@ <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/> <link rel="stylesheet" href="css/style.css"/> + <script src="js/conf.js"></script> + <script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js"></script> Added: trunk/pollen-ui-angular/src/main/webapp/js/conf.js.exemple =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/js/conf.js.exemple (rev 0) +++ trunk/pollen-ui-angular/src/main/webapp/js/conf.js.exemple 2014-05-14 08:53:32 UTC (rev 3941) @@ -0,0 +1,4 @@ +var conf = { + // Rest-API Base Url + restURL : "http://exemple.com/api" +} \ No newline at end of file Modified: trunk/pollen-ui-angular/src/main/webapp/js/services.js =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/js/services.js 2014-05-13 22:58:53 UTC (rev 3940) +++ trunk/pollen-ui-angular/src/main/webapp/js/services.js 2014-05-14 08:53:32 UTC (rev 3941) @@ -20,14 +20,9 @@ */ angular.module('pollenServices', ['ngResource']) -.factory('BaseUrl', function() { +.factory('Poll', ['$resource', function ($resource) { - return 'http://localhost\\:8080/pollen-rest-api/v1'; -}) - -.factory('Poll', ['$resource', 'BaseUrl', function ($resource, BaseUrl) { - - return $resource(BaseUrl+'/polls/:pollId/:cmd', {pollId:'@topiaId'}, { + return $resource(conf.restURL+'/polls/:pollId/:cmd', {pollId:'@topiaId'}, { 'add' : { method : 'POST', transformRequest : function (data, headersGetter) { @@ -42,17 +37,16 @@ transformRequest : function (data, headersGetter) { return 'poll='+encodeURIComponent(JSON.stringify(data)); } - ,headers : { 'X-HTTP-Method' : 'PUT'} } }); }]) -.factory('PollChoice', ['$resource', 'BaseUrl', function ($resource, BaseUrl) { +.factory('PollChoice', ['$resource', function ($resource) { var transformParam = function (data) { return 'choice='+encodeURIComponent(JSON.stringify(data)); }; - return $resource(BaseUrl+'/polls/:pollId/choices/:choiceId', {choiceId : '@topiaId'}, + return $resource(conf.restURL+'/polls/:pollId/choices/:choiceId', {choiceId : '@topiaId'}, { 'add' : { method:'POST', @@ -71,7 +65,7 @@ ); }]) -.factory('PollVote', ['$resource', 'BaseUrl', function ($resource, BaseUrl) { +.factory('PollVote', ['$resource', function ($resource) { var transformParam = function (data) { var obj = {}; obj.voter = {name : data.name} @@ -80,7 +74,7 @@ return 'vote='+encodeURIComponent(JSON.stringify(obj)); }; - return $resource(BaseUrl+'/polls/:pollId/votes/:voteId', {voteId : '@topiaId'}, + return $resource(conf.restURL+'/polls/:pollId/votes/:voteId', {voteId : '@topiaId'}, { 'add' : { method:'POST',
participants (1)
-
garandelï¼ users.chorem.org