|
|
@@ -12,20 +12,23 @@ define([ 'angular', 'toaster' ], function(angular) {
|
|
|
return sessionStorage.removeItem(key);
|
|
|
}
|
|
|
};
|
|
|
- }).factory('AuthenticationService', function($http, SessionService, SerializerUtil) {
|
|
|
+ }).factory('BaseService', function() {
|
|
|
+ return {
|
|
|
+ getRootPath : function() {
|
|
|
+ var fullPath = window.document.location.href;
|
|
|
+ var path = window.document.location.pathname;
|
|
|
+ var pos = fullPath.indexOf(path);
|
|
|
+ return fullPath.substring(0, pos) + path.substring(0, path.substr(1).indexOf('/') + 1);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }).factory('AuthenticationService', function($http, SessionService, BaseService, SerializerUtil) {
|
|
|
var cacheSession = function() {
|
|
|
SessionService.set('authenticated', true);
|
|
|
};
|
|
|
var uncacheSession = function() {
|
|
|
SessionService.unset('authenticated');
|
|
|
};
|
|
|
- var getRootPath = function() {
|
|
|
- var fullPath = window.document.location.href;
|
|
|
- var path = window.document.location.pathname;
|
|
|
- var pos = fullPath.indexOf(path);
|
|
|
- return fullPath.substring(0, pos) + path.substring(0, path.substr(1).indexOf('/') + 1);
|
|
|
- };
|
|
|
- var rootPath = getRootPath();
|
|
|
+ var rootPath = BaseService.getRootPath();
|
|
|
return {
|
|
|
root : function() {
|
|
|
return rootPath;
|
|
|
@@ -61,6 +64,16 @@ define([ 'angular', 'toaster' ], function(angular) {
|
|
|
return request;
|
|
|
}
|
|
|
};
|
|
|
+ }).factory('MessageService', function($http, BaseService) {
|
|
|
+ var rootPath = BaseService.getRootPath();
|
|
|
+ return {
|
|
|
+ getOnhand : function(success) {
|
|
|
+ var request = $http.get(rootPath + '/message/onhand');
|
|
|
+ request.success(function(data){
|
|
|
+ success.call(null, data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
}).factory('SerializerUtil', function() {
|
|
|
return {
|
|
|
/**
|