aboutsummaryrefslogtreecommitdiffstats
path: root/demo-ui/app/services/eplServices.js
blob: 20fb7af1faa6902e9deb728c60fba2bd8b8e0ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(function(){
  
   var eplServices = function ($http, dbg) {

       var _eplBasePath = "/svcmgr/webapi/svc/epl"
       var _eplUrl      = "unset";

       var setEplUrl = function (eplMgrCfg) {
         dbg.p("in setEplUrl");
         _eplUrl = "http://"+eplMgrCfg.ip+":"+eplMgrCfg.port+_eplBasePath;
         dbg.p(_eplUrl);
       }

       var getEplUrl = function () {
         dbg.p("in setEplUrl");
          return _eplUrl;
       }

      var getEplList = function() {
         dbg.p("in eplServices.getEplList()",2);
         var url = _eplUrl+ "/list;"
         dbg.p("GET: " + url , 2);
         return $http.get(url)
                     .then(function(response){ return response.data; });
      };
      var createEpl = function(epl) {
         dbg.p("in eplServices.createEpl()",2)
         var url = _eplUrl;
         dbg.p("POST: " + url, 2);
         dbg.pj(epl);
         return $http.post(url, epl)
                     .then(function(response){ return response.data; });
      };
      var updateEpl = function(epl) {
         dbg.p("in eplServices.updateEpl()",2)
         var url = _eplUrl + "/" + epl.id;
         dbg.p("PUT: " + url, 2);
         dbg.pj(epl);
         return $http.put(url, epl)
                     .then(function(response){ return response.data; });
      };
      var deleteEpl = function(epl) {
         dbg.p("in eplServices.deleteEpl()",2)
         var url = _eplUrl + "/" + epl.id;
         dbg.p("DELELE: " + url, 2);
         dbg.pj(epl);
         return $http.delete(url)
                     .then(function(response){ return response.data; });
      };

      return { // public API
               setEplUrl  : setEplUrl,
               getEplUrl  : getEplUrl,
               createEpl  : createEpl,
               getEplList : getEplList,
               deleteEpl  : deleteEpl,
               updateEpl  : updateEpl
      };
   };
  
   var module = angular.module("vcpe");
   module.factory("eplServices", eplServices);

}());