Merge "Add resmgr and extsys to parent pom"
[vnfsdk/refrepo.git] / openo-portal / portal-lifecyclemgr / src / main / webapp / lifecyclemgr / js / underlay.js
1 /* Copyright 2016, Huawei Technologies Co., Ltd.\r
2  *\r
3  * Licensed under the Apache License, Version 2.0 (the "License");\r
4  * you may not use this file except in compliance with the License.\r
5  * You may obtain a copy of the License at\r
6  *\r
7  *    http://www.apache.org/licenses/LICENSE-2.0\r
8  *\r
9  * Unless required by applicable law or agreed to in writing, software\r
10  * distributed under the License is distributed on an "AS IS" BASIS,\r
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12  * See the License for the specific language governing permissions and\r
13  * limitations under the License.\r
14  */\r
15 \r
16  \r
17 function loadUnderlayData(){\r
18         var requestUrl = "http://localhost:8080/org.openo.sdno.l3vpnservice/openoapi/sdnol3vpn/v1/l3vpns";\r
19                         $\r
20                                 .ajax({\r
21                                         type : "GET",\r
22                                         url : requestUrl,\r
23                                         contentType : "application/json",\r
24                                         success : function(jsonobj) {\r
25                                                 alert("loading underlay data");\r
26                                                 //TODO: Update the table\r
27                                         },\r
28                                         error : function(xhr, ajaxOptions, thrownError) {\r
29                                                 alert("Error on getting underlay data : " + xhr.responseText);  \r
30                                         }\r
31                                 });\r
32 }\r
33 function deleteUnderlayData(objectId){\r
34         var requestUrl = "http://localhost:8080/org.openo.sdno.l3vpnservice/openoapi/sdnol3vpn/v1/l3vpns/"+objectId;\r
35                         $\r
36                                 .ajax({\r
37                                         type : "DELETE",\r
38                                         url : requestUrl,\r
39                                         contentType : "application/json",\r
40                                         success : function(jsonobj) {\r
41                                                 alert("deleting underlay data");\r
42                                                 //TODO: Update the table\r
43                                         },\r
44                                         error : function(xhr, ajaxOptions, thrownError) {\r
45                                                 alert("Error on deleting underlay data : " + xhr.responseText);         \r
46                                         }\r
47                                 });\r
48 }\r
49 function loadOverlayData(){\r
50         var requestUrl = "http://localhost:8080/org.openo.sdno.overlayvpnservice/openoapi/sdnooverlayvpn/v1/site2dc-vpn";\r
51                         $\r
52                                 .ajax({\r
53                                         type : "GET",\r
54                                         url : requestUrl,\r
55                                         contentType : "application/json",\r
56                                         success : function(jsonobj) {\r
57                                                 alert("loading Overlay data...");\r
58                                                 //TODO: Update the table\r
59                                         },\r
60                                         error : function(xhr, ajaxOptions, thrownError) {\r
61                                                 alert("Error on getting Overlayvpn data : " + xhr.responseText);        \r
62                                         }\r
63                                 });\r
64 }\r
65 function refressTpDataTable(overlayTable,TpTable){\r
66         alert("refesssing Tp data table");\r
67 }\r
68 $(function(){\r
69         $.fn.serializeObject = function() {\r
70                                 var o = {};\r
71                                 var a = this.serializeArray();\r
72                                 $.each(a, function() {\r
73                                         if (o[this.name] !== undefined) {\r
74                                                 if (!o[this.name].push) {\r
75                                                         o[this.name] = [ o[this.name] ];\r
76                                                 }\r
77                                         o[this.name].push(this.value || '');\r
78                                         } else {\r
79                                                 o[this.name] = this.value || '';\r
80                                         }\r
81                                 });\r
82                         return o;\r
83                         };\r
84         $('#createUnderlay').click(function(){\r
85                                 var formData = JSON.stringify($("#underlayForm").serializeObject());\r
86                                 alert(formData);\r
87                         var jsonobj = JSON.parse(formData);\r
88                         var requestUrl = "http://localhost:8080/org.openo.sdno.l3vpnservice/openoapi/sdnol3vpn/v1/l3vpns";\r
89                         $\r
90                                 .ajax({\r
91                                         type : "POST",\r
92                                         url : requestUrl,\r
93                                         contentType : "application/json",\r
94                                         dataType : "json",\r
95                                         data : formData,\r
96                                         success : function(jsonobj) {\r
97                                                 alert("Details saved successfully!!!");\r
98                                                 //var data = [jsonobj.name,jsonobj.hostName,jsonobj.productName,jsonobj.vendor,jsonobj.description];\r
99                                                 //TODO: update the table\r
100                                         },\r
101                                         error : function(xhr, ajaxOptions, thrownError) {\r
102                                                 alert("Error on page : " + xhr.responseText);   \r
103                                         }\r
104                                 });\r
105                         });\r
106         $('.underlayNameLink').click(function(){\r
107                 alert("coming here");\r
108                 var data = $(this).parent().parent().parent().find('td:last').find('div:last').html();\r
109                 alert(data);\r
110                 var jsonObj = JSON.parse(data);\r
111                 for(var i = 0; i < jsonObj.length; i++) {\r
112                     var obj = jsonObj[i];\r
113                         var rowData = [obj.tpName,obj.peName,obj.vlanId,obj.siteCidr,obj.ip];\r
114                         $('#underlayTpDataTable').DataTable();\r
115                         $('#underlayTpDataTable').dataTable().fnAddData(rowData);\r
116                 }\r
117 \r
118         });\r
119         \r
120 })