summaryrefslogtreecommitdiffstats
path: root/lifecyclemgr/src/main/webapp/lifecyclemgr/js/DataService.js
blob: fd3e3d9ae5d6e1a2c07cc7b6eee1d43a722a4894 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
app.factory("DataService", function($http, $log){
    var lcData = null;
    return {
        loadGetServiceData : function() {

            //load main Table
            return $http({
                url: '/openoapi/inventory/v1/services',
                //url: 'http://localhost:5000/api/getLCData',
                method: 'GET',
                headers: {'Content-Type': 'application/json'}

                /*url: '/openoapi/inventory/v1/services',
                method: 'POST',
                headers: {'Content-Type': 'application/json'},
                data: JSON.stringify({'sort': [],
                 'pagination': 0,
                 'pagesize': 10000,
                 'condition': {},
                 'serviceId': ""})*/
            }).then(function(response){
                //$log.info(response);
                lcData = response.data.lcData;
                return response.data;
            });
        },
        getSavedLCData : function(id){
            var returnData = null;
            if(lcData) {
                for (var i = 0; i < lcData.length; i++) {
                    if(lcData[i].id == id) {
                        returnData = lcData[i].inputParameters;
                        break;
                    }
                }
                return returnData;
            }
            else
                return null;
        },
        getOverlayData : function() {
            return $http({
                url: 'http://localhost:5000/api/getOverlayVPNData',
                method: 'GET',
                headers: {'Content-Type': 'application/json'}
            }).then(function(response){
                //$log.info(response);
                return response.data;
            });
        },
        getUnderlayData : function() {
            return $http({
                url: 'http://localhost:5000/api/getUnderlayVPNData',
                method: 'GET',
                headers: {'Content-Type': 'application/json'}
            }).then(function(response){
                //$log.info(response);
                return response.data;
            });
        },
        loadServiceDetails : function(id) {
            return JSON.parse('[{"id":"12345", "name":"sdno"}, {"id":"23456", "name":"gso"},{"id":"12345", "name":"nfvo"}]');
        },

        generateTemplatesComponent : function() {
            //dropdown data
            return $http({
                url: '/openoapi/catalog/v1/servicetemplates',
                //url: 'http://localhost:5000/api/getTemplateData',
                method: 'GET',
                headers: {'Content-Type': 'application/json'}
            }).then(function(response){
                //$log.info(response);
                return response.data.templateData;
            });
        },
	
	fetchCreateParameters : function(templateId) {
            //For Template parameters tab in popup
            return $http({
                url: '/openoapi/catalog/v1/servicetemplates/'+templateId,
               // url: 'http://localhost:5000/api/getTemplateParameter',
                method: 'GET',
                headers: {'Content-Type': 'application/json'}
            }).then(function(response){
                //$log.info(response);
                return response.data;
            });
        },

        createServiceInstance : function(lifecycleData, sengMsgObj) {
            ///For submit of OK button
            var parameter = {
                'service' : {
                    'name' :  lifecycleData.name,
                    'description' : lifecycleData.desc,
                    'serviceDefId' : '', //no need now, reserved
                    'templateId' :  lifecycleData.optSelect,
                    'parameters' : sengMsgObj
                }
            };
            return $http({
                url: '/openoapi/servicegateway/v1/services',
                //url: 'http://localhost:5000/api/getTemplateData',
                method: 'POST',
                headers: {'Content-Type': 'application/json'},
                data : JSON.stringify(parameter)
            }).then(function(response){
                //$log.info(response);
                return response.data.templateData;
            });
        }
    }
});