diff options
Diffstat (limited to 'demo-ui/app/services/cosServices.js')
-rw-r--r-- | demo-ui/app/services/cosServices.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/demo-ui/app/services/cosServices.js b/demo-ui/app/services/cosServices.js new file mode 100644 index 0000000..c650b6d --- /dev/null +++ b/demo-ui/app/services/cosServices.js @@ -0,0 +1,64 @@ +(function(){ + + var cosServices = function ($http, dbg) { + + var _cosBasePath = "/cosmgr/webapi/cos" + var _cosUrl = "unset"; + + var setCosUrl = function (cosMgrCfg) { + dbg.p("in setCosUrl"); + _cosUrl = "http://"+cosMgrCfg.ip+":"+cosMgrCfg.port+_cosBasePath; + dbg.p(_cosUrl); + } + + var getCosUrl = function () { + dbg.p("in getCosUrl"); + return _cosUrl; + } + + var getCosList = function() { + dbg.p("in cosServices.getCosList()",2); + var url = _cosUrl+ "/list;" + dbg.p("GET: " + url , 2); + return $http.get(url) + .then(function(response){ return response.data; }); + }; + var createCos = function(cos) { + dbg.p("in cosServices.createCos()",2) + var url = _cosUrl; + dbg.p("POST: " + url, 2); + dbg.pj(cos); + return $http.post(url, cos) + .then(function(response){ return response.data; }); + }; + var updateCos = function(cos) { + dbg.p("in cosServices.updateCos()",2) + var url = _cosUrl + "/" + cos.id; + dbg.p("PUT: " + url, 2); + dbg.pj(cos); + return $http.put(url, cos) + .then(function(response){ return response.data; }); + }; + var deleteCos = function(cos) { + dbg.p("in cosServices.deleteCos()",2) + var url = _cosUrl + "/" + cos.id; + dbg.p("DELELE: " + url, 2); + dbg.pj(cos); + return $http.delete(url) + .then(function(response){ return response.data; }); + }; + + return { // public API + setCosUrl : setCosUrl, + getCosUrl : getCosUrl, + createCos : createCos, + getCosList : getCosList, + deleteCos : deleteCos, + updateCos : updateCos + }; + }; + + var module = angular.module("vcpe"); + module.factory("cosServices", cosServices); + +}());
\ No newline at end of file |