blob: e975f6c634e562d3bdfbed1b87360f28e50a70bd [file] [log] [blame]
Seshu-Kumar-Mf7800f42016-09-16 18:35:58 +08001/* Copyright 2016, Huawei Technologies Co., Ltd.
Seshu-Kumar-M72f32522016-09-14 18:06:11 +08002 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
Seshu-Kumar-M72508a12016-09-16 22:33:16 +08007 * http://www.apache.org/licenses/LICENSE-2.0
Seshu-Kumar-M72f32522016-09-14 18:06:11 +08008 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
Seshu-Kumar-M72508a12016-09-16 22:33:16 +080015
Seshu-Kumar-M72f32522016-09-14 18:06:11 +080016
17$('.siteDeleteImg').click(function(){
18 var data = $(this).parent().parent().parent().find('td:last').find('div:last').html();
19 alert(data);
20 var jsonObj = JSON.parse(data);
21 for(var i = 0; i < jsonObj.length; i++) {
22 var obj = jsonObj[i];
23 var rowData = [obj.tpName,obj.peName,obj.vlanId,obj.siteCidr,obj.ip];
24 $('#underlayTpDataTable').DataTable();
25 $('#underlayTpDataTable').dataTable().fnAddData(rowData);
26 }
27});
28
29
30function deleteSite(objectId){
31 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/sites/"+objectId;
32 $
33 .ajax({
34 type : "DELETE",
35 url : requestUrl,
36 contentType : "application/json",
37 success : function(jsonobj) {
38 $('#site').bootstrapTable('remove', {
39 field: 'id',
40 values: [objectId]
41 });
42 alert("Delete Site successfull !!!");
43 },
44 error : function(xhr, ajaxOptions, thrownError) {
45 alert("Error on deleting site: " + xhr.responseText);
46 }
47 });
48}
49function deleteLink(objectId){
50 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/topological-links/"+objectId;
51 $
52 .ajax({
53 type : "DELETE",
54 url : requestUrl,
55 contentType : "application/json",
56 success : function(jsonobj) {
57 $('#link').bootstrapTable('remove', {
58 field: 'id',
59 values: [objectId]
60 });
61 alert("Delete Link successfull !!!");
62 },
63 error : function(xhr, ajaxOptions, thrownError) {
64 alert("Error on deleting link : " + xhr.responseText);
65 }
66 });
67}
68
69function deleteNe(objectId){
70 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/managed-elements/"+objectId;
71 $
72 .ajax({
73 type : "DELETE",
74 url : requestUrl,
75 contentType : "application/json",
76 success : function(jsonobj) {
77 $('#ne').bootstrapTable('remove', {
78 field: 'id',
79 values: [objectId]
80 });
81 alert("Delete NE successfull !!!");
82 },
83 error : function(xhr, ajaxOptions, thrownError) {
84 alert("Error on deleting ne : " + xhr.responseText);
85 }
86 });
87}
88
89function deletePort(objectId){
90 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/logical-termination-points/"+objectId;
91 $
92 .ajax({
93 type : "DELETE",
94 url : requestUrl,
95 contentType : "application/json",
96 success : function(jsonobj) {
97 $('#port').bootstrapTable('remove', {
98 field: 'id',
99 values: [objectId]
100 });
101 alert("Delete Port successfull !!!");
102 },
103 error : function(xhr, ajaxOptions, thrownError) {
104 alert("Error on deleting port : " + xhr.responseText);
105 }
106 });
107}
108function loadSiteData(){
109 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/sites";
110 $
111 .ajax({
112 type : "GET",
113 url : requestUrl,
114 contentType : "application/json",
115 success : function(jsonobj) {
116 $('#site').bootstrapTable({
117 data: jsonobj.sites
118 });
119 },
120 error : function(xhr, ajaxOptions, thrownError) {
121 alert("Error on getting site data : " + xhr.responseText);
122 }
123 });
124}
125function loadLinkData(){
126 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/topological-links";
127 $
128 .ajax({
129 type : "GET",
130 url : requestUrl,
131 contentType : "application/json",
132 success : function(jsonobj) {
133 $('#link').bootstrapTable({
134 data: jsonobj.topologicalLinks
135 });
136 },
137 error : function(xhr, ajaxOptions, thrownError) {
138 alert("Error on getting link data : " + xhr.responseText);
139 }
140 });
141}
142function loadNeData(){
143 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/managed-elements";
144 $
145 .ajax({
146 type : "GET",
147 url : requestUrl,
148 contentType : "application/json",
149 success : function(jsonobj) {
150 $('#ne').bootstrapTable({
151 data: jsonobj.managedElements
152 });
153 },
154 error : function(xhr, ajaxOptions, thrownError) {
155 alert("Error on getting ne data : " + xhr.responseText);
156 }
157 });
158}
159function loadPortData(){
160 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/logical-termination-points";
161 $
162 .ajax({
163 type : "GET",
164 url : requestUrl,
165 contentType : "application/json",
166 success : function(jsonobj) {
167 $('#port').bootstrapTable({
168 data: jsonobj.logicalTerminationPoints
169 });
170 },
171 error : function(xhr, ajaxOptions, thrownError) {
172 alert("Error on getting port data : " + xhr.responseText);
173 }
174 });
175}
176$(function(){
177 $('.creat-btn').click(function(){
178 $('#vmAppDialog').addClass('in').css({'display':'block'});
179
180 });
181 $('.close,.button-previous').click(function(){
182 $('#vmAppDialog').removeClass('in').css('display','none');
183 });
184 $('.detail-top ul li').click(function(){
185 $(this).addClass('current').siblings().removeClass('current');
186 });
187 $('.para').click(function(){
188 if($('#serviceTemplateName').val() == ''){
189 alert('Please choose the service templet!');
190 $('#flavorTab').css('display','none');
191 }else{
192 $('#flavorTab').css('display','block');
193 }
194 $('#basicTab').css('display','block');
195 });
196 $('.basic').click(function(){
197 $('#flavorTab').css('display','none');
198 });
199
200 $('.table tbody tr').click(function(){
201 $(this).addClass('openoTable_row_selected').siblings().removeClass('openoTable_row_selected');
202 });
203 $('.table tr:odd').addClass('active');
204 $('#false').click(function(){
205 $('#vmAppDialog').addClass('in').css({'display':'block'});
206 });
207 $('.close,.button-previous').click(function(){
208 $('#vmAppDialog').removeClass('in').css('display','none');
209 });
210 $('#filterTpLogicalType').click(function(){
211 $('#filterTpLogicalType_select_popupcontainer').toggleClass('openo-hide');
212 $('#filterTpLogicalType').toggleClass('openo-focus');
213 var oLeft = $('#open_base_tpL_td6').offset().left;
214 var oTop = $('#open_base_tpL_td6').offset().top;
215 var oHeight = $('#open_base_tpL_td6').height();
216 $('#filterTpLogicalType_select_popupcontainer').css({'left':oLeft,'top':oTop + oHeight + 10});
217 });
218 $('div.openo-select-popup-container>div.openo-select-item>label').click(function(){
219 var Lvalue = $(this).html();
220 $('#filterTpLogicalType_select_input').attr('value',Lvalue);
221 $('#filterTpLogicalType_select_popupcontainer').addClass('openo-hide');
222 $('#filterTpLogicalType').removeClass('openo-focus');
223 });
224 $.fn.serializeObject = function() {
225 var o = {};
226 var a = this.serializeArray();
227 $.each(a, function() {
228 if (o[this.name] !== undefined) {
229 if (!o[this.name].push) {
230 o[this.name] = [ o[this.name] ];
231 }
232 o[this.name].push(this.value || '');
233 } else {
234 o[this.name] = this.value || '';
235 }
236 });
237 return o;
238 };
239 $('#createSite').click(function(){
240 var formData = JSON.stringify($("#vmAppForm").serializeObject());
241 var jsonobj = JSON.parse(formData);
242 var newJson = {"site": jsonobj};
243 formData = JSON.stringify(newJson);
244 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/sites";
245 $
246 .ajax({
247 type : "POST",
248 url : requestUrl,
249 contentType : "application/json",
250 dataType : "json",
251 data : formData,
252 success : function(jsonResp) {
253 alert("Site saved successfully!!!");
254 jsonobj["id"]= jsonResp.site.id;
255 $('#site').bootstrapTable("append", jsonobj);
256 $('#vmAppDialog').removeClass('in').css('display','none');
257 },
258 error : function(xhr, ajaxOptions, thrownError) {
259 alert("Error on page : " + xhr.responseText);
260 }
261 });
262 });
263
264 $('#createNe').click(function(){
265 var formData = JSON.stringify($("#neForm").serializeObject());
266 var jsonobj = JSON.parse(formData);
267 var newJson = {"managedElement": jsonobj};
268 formData = JSON.stringify(newJson);
269 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/managed-elements";
270 $
271 .ajax({
272 type : "POST",
273 url : requestUrl,
274 contentType : "application/json",
275 dataType : "json",
276 data : formData,
277 success : function(jsonResp) {
278 alert("NE saved successfully!!!");
279 jsonobj["id"]= jsonResp.managedElement.id;
280 $('#ne').bootstrapTable("append", jsonobj);
281 $('#vmAppDialog').removeClass('in').css('display','none');
282
283 },
284 error : function(xhr, ajaxOptions, thrownError) {
285 alert("Error on page : " + xhr.responseText);
286 }
287 });
288 });
289
290 $('#createPort').click(function(){
291 var formData = JSON.stringify($("#portForm").serializeObject());
292 var jsonobj = JSON.parse(formData);
293 var newJson = {"logicalTerminationPoint": jsonobj};
294 formData = JSON.stringify(newJson);
295 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/logical-termination-points";
296 $
297 .ajax({
298 type : "POST",
299 url : requestUrl,
300 contentType : "application/json",
301 dataType : "json",
302 data : formData,
303 success : function(jsonResp) {
304 alert("Port saved successfully!!!");
305 //TODO : hide model data window.
306 jsonobj["id"]= jsonResp.logicalTerminationPoint.id;
307 $('#port').bootstrapTable("append", jsonobj);
308 $('#vmAppDialog').removeClass('in').css('display','none');
309
310 },
311 error : function(xhr, ajaxOptions, thrownError) {
312 alert("Error on page : " + xhr.responseText);
313 }
314 });
315 });
316
317 $('#createLink').click(function(){
318 var formData = JSON.stringify($("#linkForm").serializeObject());
319 var jsonobj = JSON.parse(formData);
320 var newJson = {"topologicalLink": jsonobj};
321 formData = JSON.stringify(newJson);
322 var requestUrl = "http://localhost:8080/org.openo.sdno.brs/openoapi/sdnobrs/v1/topological-links";
323 $
324 .ajax({
325 type : "POST",
326 url : requestUrl,
327 contentType : "application/json",
328 dataType : "json",
329 data : formData,
330 success : function(jsonResp) {
331 alert("Link saved successfully!!!");
332 jsonobj["id"]= jsonResp.topologicalLink.id;
333 $('#link').bootstrapTable("append", jsonobj);
334 $('#vmAppDialog').removeClass('in').css('display','none');
335
336 },
337 error : function(xhr, ajaxOptions, thrownError) {
338 alert("Error on page : " + xhr.responseText);
339 }
340 });
341 });
342
343 })