/* * Copyright 2016-2017 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var vm = avalon .define({ $id: "vnfmController", vnfmInfo: [], //mocSelectItems : [], vimSelectItems: [], server_rtn: { info_block: false, warning_block: false, rtn_info: "", $RTN_SUCCESS: "RTN_SUCCESS", $RTN_FAILED: "RTN_FAILED" }, $Status: { success: "active", failed: "inactive" }, $restUrl: { queryVnfmInfoUrl: '/onapapi/aai/esr/v1/vnfms', addVnfmInfoUrl: '/onapapi/aai/esr/v1/vnfms', updateVnfmInfoUrl: '/onapapi/aai/esr/v1/vnfms/', delVnfmInfoUrl: '/onapapi/aai/esr/v1/vnfms/', queryMocUrl: '', queryVimUrl: '/onapapi/aai/esr/v1/vims' }, $htmlText: { saveSuccess: $.i18n.prop("nfv-vnfm-iui-message-save-success"), saveFail: $.i18n.prop("nfv-vnfm-iui-message-save-fail"), alreadyExist: $.i18n.prop("nfv-vnfm-iui-message-vnfm-already-exists"), updateSuccess: $.i18n.prop("nfv-vnfm-iui-message-update-success"), updateFail: $.i18n.prop("nfv-vnfm-iui-message-update-fail") }, $initTable: function () { $.ajax({ "type": 'GET', "url": vm.$restUrl.queryVnfmInfoUrl, //"dataType": "json", "success": function (resp) { for (var i = 0; i < resp.length; i++) { resp[i].status = vm.$Status.success; } vm.vnfmInfo = resp; }, error: function (XMLHttpRequest, textStatus, errorThrown) { bootbox.alert($.i18n.prop("nfv-vnfm-iui-message-query-fail") + ":" + textStatus + ":" + errorThrown); return; }, complete: function () { vnfmUtil.tooltipVnfmStatus(); } }); }, // $initMoc : function() { // /*var url = vm.$restUrl.queryMocUrl; // commonUtil.get(url, null, function(resp) { // if (resp) { // vm.addVnfm.moc = resp.data; // } // });*/ // var resp = [ // { id : "nfv.vnfm.eco", name : "VNFM(ECO)"}, // { id : "nfv.vnfm.tacker", name : "VNFM(Tacker)"}, // { id : "nfv.vnfm.cmcc", name : "VNFM(CMCC)"}, // { id : "nfv.vnfm.etsi", name : "VNFM(ETSI)"} // ] // vm.mocSelectItems = resp; // }, $initVim: function () { $.ajax({ type: 'get', url: vm.$restUrl.queryVimUrl, dataType: 'json', success: function (resp) { if (resp) { vm.vimSelectItems = resp; } vm.vimSelectItems.push({"vimId": "", "name": ""}); } }); }, addVnfm: { title: $.i18n.prop("nfv-vnfm-iui-text-register"), vnfmId: "", name: "", type: "", //moc : "", nameReadonly : false, vimId: "", //vimVisiable : false, vendor: "", version: "", description: "", certificateUrl: "", url: "", urlTip: $.i18n.prop("nfv-vnfm-iui-text-url-tip"), userName: "", password: "", saveType: "add", status: "" }, $showVnfmTable: function () { vm.addVnfm.title = $.i18n.prop("nfv-vnfm-iui-text-register"), vm.addVnfm.vnfmId = ""; vm.addVnfm.name = ""; vm.addVnfm.type = ""; //vm.addVnfm.moc = ""; vm.addVnfm.nameReadonly = false; vm.addVnfm.vimId = ""; //vm.addVnfm.vimVisiable = false; vm.addVnfm.vendor = ""; vm.addVnfm.version = ""; vm.addVnfm.description = ""; vm.addVnfm.certificateUrl = ""; vm.addVnfm.url = ""; vm.addVnfm.userName = ""; vm.addVnfm.password = ""; vm.addVnfm.saveType = "add"; vm.server_rtn.warning_block = false; vm.server_rtn.info_block = false; //vm.$initMoc(); vm.$initVim(); //vm.$mocChange(); $(".form-group").each(function () { $(this).removeClass('has-success'); $(this).removeClass('has-error'); $(this).find(".help-block[id]").remove(); }); $("#addVnfmDlg").modal("show"); }, // $getMocName : function(mocId) { // var items = vm.mocSelectItems; // for(var i=0;i