rebuild GUI structure(only changed modules' name)
[vnfsdk/refrepo.git] / extsys / src / main / webapp / extsys / vnfm / js / vnfmUtil.js
1 /*
2  * Copyright 2016-2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 var vnfmUtil = {};
17
18 vnfmUtil.delVnfm = function (vnfmId) {
19     bootbox.confirm($.i18n.prop("nfv-vnfm-iui-message-delete-confirm"), function (result) {
20         if (result) {
21             $.ajax({
22                 type: "DELETE",
23                 url: vm.$restUrl.delVnfmInfoUrl + vnfmId,
24                 dataType: "json",
25                 success: function (data, statusText, jqXHR) {
26                     if (jqXHR.status == "204") {
27                         for (var i = 0; i < vm.vnfmInfo.length; i++) {
28                             if (vnfmId == vm.vnfmInfo[i].vnfmId) {
29                                 //delete the vnfm object from vnfm array
30                                 vm.vnfmInfo.splice(i, 1);
31                                 break;
32                             }
33                         }
34                         commonUtil.showMessage($.i18n.prop("nfv-vnfm-iui-message-delete-success"), "success");
35                     } else {
36                         commonUtil.showMessage($.i18n.prop("nfv-vnfm-iui-message-delete-fail"), "warning");
37                     }
38                 },
39                 error: function () {
40                     commonUtil.showMessage($.i18n.prop("nfv-vnfm-iui-message-delete-fail"), "warning");
41                 }
42             });
43         }
44     });
45 }
46
47 vnfmUtil.updateVnfm = function (data) {
48     vm.addVnfm.vnfmId = data.vnfmId;
49     vm.addVnfm.name = data.name;
50     //vm.addVnfm.moc = data.moc;
51     //vm.addVnfm.mocDisabled = true;
52     vm.addVnfm.vendor = data.vendor;
53     vm.addVnfm.version = data.version;
54     vm.addVnfm.description = data.description;
55     vm.addVnfm.type = data.type;
56     vm.addVnfm.vimId = data.vimId;
57     vm.addVnfm.url = data.url;
58     vm.addVnfm.nameReadonly=true;
59     vm.addVnfm.userName = data.userName;
60     vm.addVnfm.password = data.password;
61     vm.addVnfm.saveType = "update";
62     vm.addVnfm.title = $.i18n.prop("nfv-vnfm-iui-test-update");
63     vm.server_rtn.info_block = false;
64     vm.server_rtn.warning_block = false;
65     //vm.$initMoc();
66     vm.$initVim();
67
68     $(".form-group").each(function () {
69         $(this).removeClass('has-success');
70         $(this).removeClass('has-error');
71         $(this).find(".help-block[id]").remove();
72     });
73     $("#addVnfmDlg").modal("show");
74 }
75
76 vnfmUtil.tooltipVnfmStatus = function () {
77     $("[data-toggle='tooltip']").tooltip();
78 }