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