1 /* Copyright 2016-2017, Huawei Technologies Co., Ltd.
\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
7 * http://www.apache.org/licenses/LICENSE-2.0
\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
19 $.getJSON("./conf/dataconfig.json", function (jsonData){
\r
20 url = jsonData.url +":"+ jsonData.port;
\r
21 console.log("URL = " + url);
\r
24 $('.creat-btn').click(function () {
\r
25 /*$('#vmAppDialog').addClass('in').css({'display': 'block'});*/
\r
26 $('#vmAppDialog').modal();
\r
29 $('.close,.button-previous').click(function () {
\r
30 $('#vmAppDialog').removeClass('in').css('display', 'none');
\r
32 $('.detail-top ul li').click(function () {
\r
33 $(this).addClass('current').siblings().removeClass('current');
\r
35 $('.para').click(function () {
\r
36 if ($('#serviceTemplateName').val() == '') {
\r
37 alert('Please choose the service templateļ¼');
\r
38 $('#flavorTab').css('display', 'none');
\r
40 $('#flavorTab').css('display', 'block');
\r
42 $('#basicTab').css('display', 'block');
\r
44 $('.basic').click(function () {
\r
45 $('#flavorTab').css('display', 'none');
\r
48 $('.table tbody tr').click(function(){
\r
49 $(this).addClass('openoTable_row_selected').siblings().removeClass('openoTable_row_selected');
\r
51 $('.table tr:odd').addClass('active');
\r
52 $('#false').click(function () {
\r
53 /*$('#vmAppDialog').addClass('in').css({'display': 'block'});*/
\r
54 $('#vmAppDialog').modal();
\r
56 $('.close,.button-previous').click(function () {
\r
57 $('#vmAppDialog').removeClass('in').css('display', 'none');
\r
59 $('#filterTpLogicalType').click(function () {
\r
60 $('#filterTpLogicalType_select_popupcontainer').toggleClass('openo-hide');
\r
61 $('#filterTpLogicalType').toggleClass('openo-focus');
\r
62 var oLeft = $('#open_base_tpL_td6').offset().left;
\r
63 var oTop = $('#open_base_tpL_td6').offset().top;
\r
64 var oHeight = $('#open_base_tpL_td6').height();
\r
65 $('#filterTpLogicalType_select_popupcontainer').css({'left': oLeft, 'top': oTop + oHeight + 10});
\r
67 $('div.openo-select-popup-container>div.openo-select-item>label').click(function () {
\r
68 var Lvalue = $(this).html();
\r
69 $('#filterTpLogicalType_select_input').attr('value', Lvalue);
\r
70 $('#filterTpLogicalType_select_popupcontainer').addClass('openo-hide');
\r
71 $('#filterTpLogicalType').removeClass('openo-focus');
\r
73 $.fn.serializeObject = function () {
\r
75 var a = this.serializeArray();
\r
76 $.each(a, function () {
\r
77 if (o[this.name] !== undefined) {
\r
78 if (!o[this.name].push) {
\r
79 o[this.name] = [o[this.name]];
\r
81 o[this.name].push(this.value || '');
\r
83 o[this.name] = this.value || '';
\r
89 $('#createNS').click(function(){
\r
90 var formData = JSON.stringify($("#neForm").serializeObject());
\r
91 var jsonobj = JSON.parse(formData);
\r
92 var newJson = {"managedElement": jsonobj};
\r
93 formData = JSON.stringify(newJson);
\r
94 var requestUrl = url + "/openoapi/sdnobrs/v1/managed-elements";
\r
99 contentType : "application/json",
\r
102 success : function(jsonResp) {
\r
103 alert("NS saved successfully!!!");
\r
104 jsonobj["id"]= jsonResp.managedElement.id;
\r
105 $('#ne').bootstrapTable("append", jsonobj);
\r
106 $('#vmAppDialog').removeClass('in').css('display','none');
\r
109 error : function(xhr, ajaxOptions, thrownError) {
\r
110 alert("Error on page : " + xhr.responseText);
\r
114 //init the templates combo
\r
116 generateTemplatesComponent()
\r
118 function (templates) {
\r
119 document.getElementById("svcTempl").innerHTML = templates;
\r
125 * generate the templates Component
\r
128 function generateTemplatesComponent(){
\r
129 var defer = $.Deferred();
\r
133 function (tmplatesResponse) {
\r
134 var templatesInfo = translateToTemplatesInfo(tmplatesResponse);
\r
135 defer.resolve(templatesInfo);
\r
145 function queryTemplates() {
\r
146 var queryTemplatesUrl = '/openoapi/catalog/v1/servicetemplates';
\r
149 url : queryTemplatesUrl
\r
154 * generate templates html string
\r
158 function translateToTemplatesInfo(templates) {
\r
159 var options = '<option value="select">--select--</option>';
\r
161 for (i = 0; i < templates.length; i += 1) {
\r
162 var option = '<option value="' + templates[i].serviceTemplateId + '">' + templates[i].templateName
\r
164 options = options + option;
\r
169 /*******************************************Get Service**********************************************/
\r
170 function loadGetServiceData(){
\r
173 var requestUrl = "/openoapi/inventory/v1/services";
\r
186 contentType : "application/json",
\r
188 data: JSON.stringify(parameter),
\r
189 success : function(jsonobj) {
\r
190 // TODO return according to the json data received.
\r
191 returnVal = jsonobj;
\r
193 error : function(xhr, ajaxOptions, thrownError) {
\r
194 alert("Error on getting link data : " + xhr.responseText);
\r
200 /*********************************************Get Service Details********************************************/
\r
201 function loadServiceDetails(serviceId){
\r
203 // TODO re-confirm the latest url.
\r
204 var requestUrl ="/openoapi/gso/v1/services/toposequence/" + serviceId;
\r
211 contentType : "application/json",
\r
212 success : function(jsonobj) {
\r
213 // TODO return according to the json data received.
\r
214 returnObj = jsonobj;
\r
216 error : function(xhr, ajaxOptions, thrownError) {
\r
217 alert("Error on getting link data : " + xhr.responseText);
\r
223 //get the vim name by id.
\r
224 function getVimNameById(vimId){
\r
226 // TODO re-confirm the latest url.
\r
227 var requestUrl ="/openoapi/extsys/v1/vims/" + vimId;
\r
234 contentType : "application/json",
\r
235 success : function(jsonobj) {
\r
236 // TODO return according to the json data received.
\r
237 returnObj = jsonobj;
\r
239 error : function(xhr, ajaxOptions, thrownError) {
\r
240 alert("Error on getting link data : " + xhr.responseText);
\r
246 // get the sdn controller name by id.
\r
247 function getSdnControllerNameById(sdnControllerId){
\r
249 // TODO re-confirm the latest url.
\r
250 var requestUrl ="/openoapi/extsys/v1/sdncontrollers/" + sdnControllerId;
\r
257 contentType : "application/json",
\r
258 success : function(jsonobj) {
\r
259 // TODO return according to the json data received.
\r
260 returnObj = jsonobj;
\r
262 error : function(xhr, ajaxOptions, thrownError) {
\r
263 alert("Error on getting link data : " + xhr.responseText);
\r
271 function anchorClick(serviceId){
\r
272 var jsonData = loadServiceDetails(serviceId);
\r
273 //TODO populate the modal according to json response
\r