summaryrefslogtreecommitdiffstats
path: root/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication
diff options
context:
space:
mode:
Diffstat (limited to 'nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication')
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/validate.js64
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppController.js710
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailController.js281
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailUtil.js80
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppUtil.js510
5 files changed, 0 insertions, 1645 deletions
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/validate.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/validate.js
deleted file mode 100644
index 9cf00eb2..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/validate.js
+++ /dev/null
@@ -1,64 +0,0 @@
-$(function(){
- var form = $("#vmAppForm");
- var error = $('.alert-danger', form);
- var success = $('.alert-success', form);
-
- $.extend($.validator.messages, {
- required: $.i18n.prop("nfv-virtualApplication-iui-validate-inputParam")
- });
-
- form.validate({
- doNotHideMessage : true,
- errorElement : 'span',
- errorClass : 'help-block',
- focusInvalid : false,
- rules : {
- instanceName : {
- required : true
- },
- serviceTemplateName : {
- required : true
- },
- vimId : {
- required : true
- },
- vnfmId : {
- required : true
- }
- },
- messages : {
- instanceName : {
- required : $.i18n.prop("nfv-virtualApplication-iui-validate-instanceName")
- },
- serviceTemplateName : {
- required : $.i18n.prop("nfv-virtualApplication-iui-validate-serviceTemplateName")
- },
- vimId : {
- required : $.i18n.prop("nfv-virtualApplication-iui-validate-vimId")
- },
- vnfmId : {
- required : $.i18n.prop("nfv-virtualApplication-iui-validate-vnfmId")
- }
- },
- errorPlacement : function(error, element) {
- error.insertAfter(element);
- },
- invalidHandler : function(event, validator) {
- success.hide();
- error.show();
- },
- highlight : function(element) {
- $(element).closest(".form-group").removeClass("has-success").addClass("has-error");
- },
- unhighlight: function (element) {
- $(element).closest(".form-group").removeClass("has-error");
- },
- success : function(label) {
- label.addClass("valid").closest(".form-group").removeClass("has-error");
- },
- submitHandler: function (form) {
- success.show();
- error.hide();
- }
- });
-}); \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppController.js
deleted file mode 100644
index 74dad401..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppController.js
+++ /dev/null
@@ -1,710 +0,0 @@
-/*
- * Copyright (C) 2015 ZTE, Inc. and others. All rights reserved. (ZTE)
- *
- * 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: "vmAppController",
- $tableId : "ict_virtualApplication_table",
- $virtualAppTableFields : {// table columns
- table: [
- {"mData": "instanceId", name: "ID", "bVisible": false},
- {"mData": "instanceName", name: $.i18n.prop("nfv-virtualApplication-iui-field-name"), "fnRender" : vmAppUtil.nameRender},
- {"mData": "serviceTemplateId", name: $.i18n.prop("nfv-virtualApplication-iui-field-template")},
- {"mData": "createdDate", name: $.i18n.prop("nfv-virtualApplication-iui-field-createDate")},
- {"mData": "instanceStatus", name: $.i18n.prop("nfv-virtualApplication-iui-field-status"), "fnRender" : vmAppUtil.statusRender},
- {"mData": "instanceOperating", name: "instanceOperating", "bVisible": false},
- {"mData": null, name: $.i18n.prop("nfv-virtualApplication-iui-field-action"), "fnRender" : vmAppUtil.operationRender, "sWidth" : "180px"},
- {"mData": "operationInfo", name: "operationinfo", "bVisible": false},
- {"mData": null, name: $.i18n.prop("nfv-virtualApplication-iui-field-operation"), "fnRender" : vmAppUtil.delRender}
- ]
- },
- $language: {
- "sProcessing": "<img src='../component/thirdparty/data-tables/images/loading-spinner-grey.gif'/><span>&nbsp;&nbsp;"
- +$.i18n.prop("nfv-nso-iui-table-sProcess")+"</span>",
- "sLengthMenu": $.i18n.prop("nfv-nso-iui-table-sLengthMenu"),
- "sZeroRecords": $.i18n.prop("nfv-nso-iui-table-sZeroRecords"),
- "sInfo": "<span class='seperator'> </span>" + $.i18n.prop("nfv-nso-iui-table-sInfo"),
- "sInfoEmpty": $.i18n.prop("nfv-nso-iui-table-sInfoEmpty"),
- "sGroupActions": $.i18n.prop("nfv-nso-iui-table-sGroupActions"),
- "sAjaxRequestGeneralError":$.i18n.prop("nfv-nso-iui-table-sAjaxRequestGeneralError"),
- "sEmptyTable": $.i18n.prop("nfv-nso-iui-table-sEmptyTable"),
- "oPaginate": {
- "sPrevious": $.i18n.prop("nfv-nso-iui-table-sPrevious"),
- "sNext": $.i18n.prop("nfv-nso-iui-table-sNext"),
- "sPage": $.i18n.prop("nfv-nso-iui-table-sPage"),
- "sPageOf": $.i18n.prop("nfv-nso-iui-table-sPageOf")
- }
- },
- $restUrl : {
- queryAppinstancesUrl: "/api/nsoc/v1/appinstances",
- queryStatusUrl: "/api/nsoc/v1/appinstances/",
- deleteAppinstancesUrl: "/api/nsoc/v1/appinstances/",
- newAppinstancesUrl: "/api/nsoc/v1/appinstances",
- queryAppinstancesByIdUrl: "/api/nsoc/v1/appinstances/",
- executeOperationUrl: "/api/nsoc/v1/appinstances/",
- queryOperationParamsUrl: "/api/nsoc/v1/servicetemplates/",
- queryServiceTemplate: "/api/nsoc/v1/servicetemplates?deletionPending=false",
- queryVimInfoUrl : "/api/roc/v1/resource/vims",
- queryVnfmInfoUrl : "/api/roc/v1/resource/vnfms",
- delInstanceTemplateUrl: "/api/nsoc/v1/csars/",
- queryFlavorParamUrl: "/api/nsoc/v1/servicetemplates/",
- queryTemplateOptionsUrl: "/api/nsoc/v1/servicetemplates/",
- queryInputParamUrl: "/api/nsoc/v1/servicetemplates/",
- queryVnfInfoUrl : "/api/nsoc/v1/servicetemplates/",
- queryRocInfoBaseUrl : "/api/roc/v1/resource"
- },
- $initTable: function() {
- var setting = {};
- setting.language = vm.$language;
- setting.paginate = true;
- setting.info = true;
- setting.columns = vm.$virtualAppTableFields.table;
- setting.restUrl = vm.$restUrl.queryAppinstancesUrl;
- setting.tableId = vm.$tableId;
- serverPageTable.initDataTable(setting, {}, vm.$tableId + "_div");
- },
- $openDetail : function(instanceId, serviceTemplateId) {
- var url = "./virtualApplicationDetail.html?instanceId=" + instanceId
- + "&templateId=" + serviceTemplateId;
- window.open(url, "_self");
- },
- $initCometd : function() {
- var cometd = new $.Cometd();
- var cometdURL = location.protocol + "//" + location.host + "/api/nsocnotification/v1";
- cometd.configure({
- url : cometdURL,
- logLevel : "info"
- });
- // unregister websocket transport, use long-polling transport
- cometd.unregisterTransport('websocket');
-
- cometd.addListener("/meta/handshake", function(handshake){
- if(handshake.successful === true) {
- cometd.batch(function() {
- //subscribe multiple channels
- cometd.subscribe("/lifecycle/instance/status", function(message){
- //message = JSON.parse(message.data);
- message = message.data;
- var table = $('#' + vm.$tableId).dataTable();
- var tableData = table.fnGetData();
- if(message.instanceStatus) {
- var instance = message.instanceStatus;
- for (var i=0; i<tableData.length; i++) {
- if(tableData[i]["instanceId"] == instance.instanceid) {
- //if(instance.instancestatus == "normal" || instance.instancestatus == "failed") {
- refreshByCond();
- //}
- }
- }
- }
- });
- cometd.subscribe("/servicetemplate/update", function(message){
- //message = JSON.parse(message.data);
- message = message.data;
- var table = $('#' + vm.$tableId).dataTable();
- var tableData = table.fnGetData();
- if(message.oldTemplateid) {
- var oldTemplateid = message.oldTemplateid;
- for (var i=0; i<tableData.length; i++) {
- if(tableData[i]["serviceTemplateId"] == oldTemplateid) {
- table.fnUpdate(message.newTemplateid , i, 2, false, false);
- }
- }
- }
- });
- });
- }
- });
- cometd.handshake();
- },
- //create vmapp
- showCreateApp : function() {
- vm.vmAppDialog.type = "create";
- vm.vmAppDialog.title = $.i18n.prop("nfv-virtualApplication-iui-text-title");
- vm.vmAppDialog.btnTitle = $.i18n.prop("nfv-virtualApplication-iui-text-createBtn");
- vm.vmAppDialog.$initData();
-
- $("a[href='#basicTab']").trigger("click");
- $("#vmAppDialog").modal("show");
- },
- $initWizard : function() {
- $(function(){
- $('#wizard').bootstrapWizard({
- 'nextSelector' : '.button-next',
- 'previousSelector' : '.button-previous',
- 'onTabShow' : function(tab, navigation, index) {
- //remove error message
- $(".form-group").each(function () {
- $(this).removeClass('has-success');
- $(this).removeClass('has-error');
- $(this).find(".help-block").remove();
- });
-
- var $total = navigation.find('li').length;
- var $current = index+1;
- if(($current == 1) || ($current == 2 && vm.vmAppDialog.type == "execute")) {
- $('.button-previous').hide();
- $('.button-next').show();
- $('#createBtn').hide();
- } else if ($current == $total) {
- $('.button-previous').show();
- $('.button-next').hide();
- $('#createBtn').show();
- } else {
- $('.button-previous').show();
- $('.button-next').show();
- $('#createBtn').hide();
- }
- },
- 'onTabClick' : function() {
- var $valid = $("#vmAppForm").valid();
- if(!$valid) {
- return false;
- }
- },
- 'onNext' : function(tab, navigation, index) {
- var $valid = $("#vmAppForm").valid();
- if(!$valid) {
- return false;
- }
- }
- });
- //prevent the validator from validating the next page input elements when click next button
- $(".button-next").click(function(e){
- e.preventDefault();
- });
- });
- },
- vmAppDialog : {
- type : "",
- title : "",
- btnTitle : "",
- name : "",
- currentRow : 0,
- templateId : "",
- operation : "",
- //basic tab
- templateSelectItems : [],
- vimSelectItems : [],
- vnfmSelectItems : [],
- vnfItems : [],
- templateType : "",
- description : "",
- //flavor tab
- flavorVisible : false,
- flavors : [],
- flavorDesc : "",
- flavorParams : [],
- //inputParams tab
- operationParams : [],
- templateInputParams : [],
- inputParamDescVisible : false,
- language : getLanguage(),
- //inputParams tab for scaleOut and scaleIn
- vmAppScaleHtml : "virtualApplicationScale.html",
- $initData : function() {
- $('#wizard ul').show();
- $('#wizard ul li').show();
- vm.vmAppDialog.inputParamDescVisible = false;
- vm.vmAppDialog.flavorParams = [];
- vm.vmAppDialog.flavorDesc = "";
-
- if(vm.vmAppDialog.type == "create") {
- //create new vmapp, show all tabs
- vmAppUtil.queryTemplate();
- vmAppUtil.queryVimInfo();
- vmAppUtil.queryVnfmInfo();
- } else {
- /*if(vmAppUtil.isScaleOperation(vm.vmAppDialog.operation)) {
- vm.vmAppDialog.flavorVisible = true;
- var url = vm.$restUrl.queryServiceTemplate + "&templateid=" + vm.vmAppDialog.templateId;
- commonUtil.get(url, null, function(data) {
- if (data) {
- //default display the first template flavors
- vm.vmAppDialog.flavors = data.flavors || [];
- if(data.flavors.length) {
- //default display the first flavor desc
- vm.vmAppDialog.flavorDesc = data.flavors[0].desc;
- var flavorName = data.flavors[0].name;
- vmAppUtil.queryFlavorParam(vm.vmAppDialog.templateId, flavorName);
- }
- }
- });
- } else {*/
- //execute vmapp operation
- $("a[href='#flavorTab']").trigger("click");
- //hide basic tab
- $('#wizard ul li').eq(0).hide();
-
- $("a[href='#inputParamTab']").trigger("click");
- $('#wizard ul').hide();
- $('.button-previous').hide();
- $("#flavor").val("");
- //}
- }
- },
- $initInputParams : function(templateId) {
- vm.vmAppDialog.operationParams = [];
- vm.vmAppDialog.templateInputParams = [];
- //query sevicetemplate operation list
- $.ajax({
- type : "GET",
- url : vm.$restUrl.queryTemplateOptionsUrl + templateId + "/operations?returnJson=true",
- dataType : "json",
- success : function(data) {
- var options = data || [];
- for(var i=0;i<options.length;i++) {
- if(options[i].name == "init") {
- url = vm.$restUrl.queryOperationParamsUrl + templateId + "/operations/init/parameters";
- //query operation params
- $.ajax({
- type : "GET",
- url : vm.$restUrl.queryInputParamUrl + templateId + "/operations/init/parameters",
- dataType : "json",
- success : function(resp) {
- vm.vmAppDialog.operationParams = resp || [];
- if(vm.vmAppDialog.templateInputParams.length || vm.vmAppDialog.operationParams.length) {
- vm.vmAppDialog.inputParamDescVisible = false;
- } else {
- vm.vmAppDialog.inputParamDescVisible = true;
- }
- }
- });
- break;
- }
- }
- }
- });
- //query template input params
- $.ajax({
- type : "GET",
- url : vm.$restUrl.queryInputParamUrl + templateId + "/parameters",
- dataType : "json",
- success : function(resp) {
- vm.vmAppDialog.templateInputParams = resp || [];
- if(vm.vmAppDialog.templateInputParams.length || vm.vmAppDialog.operationParams.length) {
- vm.vmAppDialog.inputParamDescVisible = false;
- } else {
- vm.vmAppDialog.inputParamDescVisible = true;
- }
- }
- });
- },
- $initVnfInfo : function(templateInfo) {
- vm.vmAppDialog.vnfItems = [];
- vm.vmAppDialog.templateType = templateInfo.nfvtype;
- if(vmAppUtil.isNSTemplate(templateInfo.nfvtype)) {
- vmAppUtil.queryVnfInfo(templateInfo.templateid);
- } else {
- var vnfNode = {
- templateid : templateInfo.templateid,
- name : templateInfo.templatename
- }
- vm.vmAppDialog.vnfItems.push(vnfNode);
- }
- },
- $templateChange : function() {
- var $option = $("#serviceTemplateName option:selected");
- var index = $option.data("index");
- var templateItem = vm.vmAppDialog.templateSelectItems[index];
- vm.vmAppDialog.flavors = templateItem.flavors || [];
- //as template change,flavor change too
- vm.vmAppDialog.$flavorChange();
- if(vm.vmAppDialog.flavors.length) {
- vm.vmAppDialog.flavorDesc = vm.vmAppDialog.flavors[0].desc;
- } else {
- vm.vmAppDialog.flavorDesc = "";
- }
- //as template change,operationParams change too
- vm.vmAppDialog.$initInputParams(templateItem.templateid);
- //if the template is a ns template, query vnf templates
- vm.vmAppDialog.$initVnfInfo(templateItem);
- },
- $flavorChange : function() {
- var templateId = "";
- if(vm.vmAppDialog.type == "create") {
- templateId = $("#serviceTemplateName").val();
- } else {
- templateId = vm.vmAppDialog.templateId;
- }
- var $flavor = $("#flavor option:selected");
- var flavorName = $flavor.val();
- vm.vmAppDialog.flavorParams = [];
- vm.vmAppDialog.flavorDesc = $flavor.data("desc");
- if(templateId && flavorName) {
- vmAppUtil.queryFlavorParam(templateId, flavorName);
- }
- },
- $getFlavorI18nInfo : function(key) {
- return $.i18n.prop("nfv-virtualApplication-iui-text-flavor-" + key);
- },
- $getGoupParamKey : function(groupName, key) {
- //to prevent a duplicate key
- return groupName + key;
- },
- $getVnfmText : function(name) {
- if(vmAppUtil.isNSTemplate(vm.vmAppDialog.templateType)) {
- return name + " " + $.i18n.prop("nfv-virtualApplication-iui-text-vnfm");
- } else {
- return $.i18n.prop("nfv-virtualApplication-iui-text-vnfm");
- }
- },
- $confirmBtnClick : function() {
- //validate rules
- var form = $("#vmAppForm");
- if(!form.valid()) {
- return false;
- }
- //flavor params
- var flavorParams = vmAppUtil.generateGourpParams(vm.vmAppDialog.flavorParams);
- //additional params, include template input params
- var additionalParams = vmAppUtil.generateAdditionalParams(vm.vmAppDialog.templateInputParams);
- //vnfRelationInfos
- var vnfRelationInfos = vmAppUtil.generateVNFRelationInfos(vm.vmAppDialog.vnfItems);
- //operation param
- var inputParams = [];
- var operationParam = {
- groupName : vm.vmAppDialog.operation,
- params : []
- }
- $.each(vm.vmAppDialog.operationParams, function(index, element){
- var value = $("#" + element.paramKey).val();
- if(value) {
- var groupParam = {
- key : element.paramKey,
- value : value
- }
- operationParam.params.push(groupParam);
- }
- });
- operationParam.params = operationParam.params.concat(additionalParams);
- inputParams.push(operationParam);
-
- if(vm.vmAppDialog.type == "create") {
- operationParam.groupName = "init";
- var param = {
- instanceName : $("#instanceName").val(),
- templateId : $("#serviceTemplateName").val(),
- type : vm.vmAppDialog.templateType,
- flavor : $("#flavor").val(),
- flavorParams : flavorParams,
- operationParams : inputParams,
- //vnfRelationInfos : vnfRelationInfos
- vnfmId : $("#vnfmId").val()
- };
- vmAppUtil.newApp(param);
- } else {
- var param = {
- flavor : $("#flavor").val(),
- flavorParams : flavorParams,
- operationParams : inputParams
- }
- vmAppUtil.executeOperation(param, vm.vmAppDialog.currentRow, vm.vmAppDialog.operation);
- }
- }
- },
- vmAppScaleDialog : {
- $tableId : "ict_vdu_table",
- $virtualAppTableFields : {// table columns
- vduTemplateTable: [
- {"mData": "id", name: "ID", "bVisible": false},
- {"mData": "vnfId", name: "VNFID", "bVisible": false},
- {"mData": "type", name: $.i18n.prop("nfv-virtualApplication-iui-scale-field-type")},
- {"mData": "num", name: $.i18n.prop("nfv-virtualApplication-iui-scale-field-num")},
- {"mData": "name", name: $.i18n.prop("nfv-virtualApplication-iui-scale-field-name")},
- {"mData": null, name: $.i18n.prop("nfv-virtualApplication-iui-scale-field-operation"), "fnRender" : vmAppUtil.delVduRender}
- ],
- vduInstanceTable: [
- {"mData": "oid", name: "ID", "bVisible": false},
- {"mData": "type", name: $.i18n.prop("nfv-virtualApplication-iui-scale-field-type")},
- {"mData": "name", name: $.i18n.prop("nfv-virtualApplication-iui-scale-field-name")},
- {"mData": null, name: $.i18n.prop("nfv-virtualApplication-iui-scale-field-operation"),
- "sWidth" : "100px", "sClass" : "icheckbox", "fnRender" : vmAppUtil.checkRender}
- ]
- },
- $initTable: function(operationType, tableData) {
- var setting = {};
- setting.language = vm.$language;
- setting.paginate = true;
- setting.info = false;
- if(operationType == "type") {
- setting.columns = vm.vmAppScaleDialog.$virtualAppTableFields.vduTemplateTable;
- } else {
- setting.columns = vm.vmAppScaleDialog.$virtualAppTableFields.vduInstanceTable;
- }
- setting.tableId = vm.vmAppScaleDialog.$tableId;
- serverPageTable.initTableWithData(setting, setting.tableId + "_div", tableData);
-
- $('input:checkbox').iCheck({
- //initialize icheck style
- checkboxClass: 'icheckbox_square-aero'
- });
- var oTable = $("#" + vm.vmAppScaleDialog.$tableId).dataTable();
- oTable.on("draw", function(){
- //initialize icheck style
- $('input:checkbox').iCheck({
- checkboxClass: 'icheckbox_square-aero'
- });
- });
- },
- currentRow : 0,
- operation : "",
- instanceId : "",
- templateId : "",
- scaleTitle : "",
- title : "",
- saveType : "add",
- instanceType : false,
- typeVisible : true,
- titleVisible : false,
- vnfDatas : [],
- currentVnfData : {},
- vnfSelectItems : [],
- vduSelectItems : [],
- btnTitle : $.i18n.prop("nfv-virtualApplication-iui-text-scale-vduBtn-title"),
- numTip : $.i18n.prop("nfv-virtualApplication-iui-text-scale-vnf-numTip"),
- nameTip : $.i18n.prop("nfv-virtualApplication-iui-text-scale-vnf-nameTip"),
- $initScaleParams : function() {
- //set riadio visible and checked attribution
- if(vm.vmAppScaleDialog.operation == "scaleOut") {
- vm.vmAppScaleDialog.scaleTitle = $.i18n.prop("nfv-virtualApplication-iui-text-scale-out-modal-title");
- vm.vmAppScaleDialog.instanceType = true;
- } else {
- vm.vmAppScaleDialog.scaleTitle = $.i18n.prop("nfv-virtualApplication-iui-text-scale-in-modal-title");
- vm.vmAppScaleDialog.instanceType = false;
- }
- vm.vmAppScaleDialog.vnfSelectItems = [];
- vm.vmAppScaleDialog.vnfDatas = [];
- vm.vmAppScaleDialog.titleVisible = false;
-
- vmAppUtil.queryScalableVnfInfo(vm.vmAppScaleDialog.templateId);
- },
- $addValidatorMethod : function() {
- $.validator.addMethod("vnfRepeat", function(value, element, params){
- var vnfId = $(element).val();
- var vnfDatas = vm.vmAppScaleDialog.vnfDatas;
- for(var i=0;i<vnfDatas.length;i++) {
- if(vnfDatas[i].id == vnfId) {
- return false;
- }
- }
- return true;
- }, $.i18n.prop("nfv-virtualApplication-iui-text-scale-validate-message"));
- },
- $addVnf : function(action, vnf) {
- var vnfData;
- var operationType;
- if(action == "add") {
- var form = $("#vnfForm");
- if(!form.valid()) {
- return false;
- }
-
- vm.vmAppScaleDialog.saveType = "add";
- var index = parseInt($("#vnfType option:selected").attr("data-index"));
- vnfData = vm.vmAppScaleDialog.vnfSelectItems[index];
- vnfData.vduTableData = [];
- operationType = $("input[name='operationType']:checked").val();
- } else {
- vm.vmAppScaleDialog.saveType = "edit";
- vnfData = vnf;
- operationType = vnfData.operationType;
- }
-
- vm.vmAppScaleDialog.currentVnfData = vnfData;
- vm.vmAppScaleDialog.vduSelectItems = vnfData.vduTypeList;
-
- if(operationType == "type") {
- vm.vmAppScaleDialog.typeVisible = true;
- vm.vmAppScaleDialog.title = $.i18n.prop("nfv-virtualApplication-iui-text-scale-type-title");
- vm.vmAppScaleDialog.$initTable(operationType, vnfData.vduTableData);
- } else {
- vm.vmAppScaleDialog.typeVisible = false;
- vm.vmAppScaleDialog.title = $.i18n.prop("nfv-virtualApplication-iui-text-scale-instance-title");
- //initialize table without data, in case of query vdu instances no data
- vm.vmAppScaleDialog.$initTable("instance", []);
- //query scalable vdu instances
- vmAppUtil.queryScalableVduInstance(vm.vmAppScaleDialog.instanceId, vnfData.id, vnfData.vduTypeList);
- }
-
- $("#addVduModal").modal("show");
- },
- $addVduToTable : function() {
- //validate vdu form
- var form = $("#vduForm");
- if(!form.valid()) {
- return false;
- }
-
- var currentVnfData = vm.vmAppScaleDialog.currentVnfData;
- var vduType = {
- id : $("#vduType option:selected").val(),
- vnfId : currentVnfData.id,
- type : $("#vduType option:selected").text(),
- num : $("#vduNum").val(),
- name : $("#vduName").val()
- }
-
- var oTable = $("#" + vm.vmAppScaleDialog.$tableId).dataTable();
- oTable.fnAddData(vduType);
- },
- $deleteVnf : function(vnfId) {
- var vnfDatas = vm.vmAppScaleDialog.vnfDatas;
- for(var i=0;i<vnfDatas.length;i++) {
- if(vnfDatas[i].id == vnfId) {
- vnfDatas.splice(i, 1);
- }
- }
- vm.vmAppScaleDialog.titleVisible = vnfDatas.length;
- },
- $scaleConfirmClick : function() {
- var operationType = $("input[name='operationType']:checked").val();
- var currentVnfData = vm.vmAppScaleDialog.currentVnfData;
- currentVnfData.operationType = operationType;
- currentVnfData.vduTableData = [];
- var vduInstanceNameArray = [];
- var oTable = $("#" + vm.vmAppScaleDialog.$tableId).dataTable();
- var data = oTable.fnGetData();
- if(operationType == "instance") {
- var tr = oTable.fnGetNodes();
- for(var i=0;i<tr.length;i++) {
- var isChecked = $(tr[i]).find("input:checked").length;
- if(isChecked) {
- var currentRowData = data[i];
- currentVnfData.vduTableData.push(currentRowData);
- vduInstanceNameArray.push(currentRowData.name);
- }
- }
- currentVnfData.vduNameStr = vduInstanceNameArray.toString();
- } else {
- currentVnfData.vduTableData = data;
- var vduTypeArray = [];
- var vduNumArray = [];
- for(var i=0;i<currentVnfData.vduTableData.length;i++) {
- vduTypeArray.push(currentVnfData.vduTableData[i].type);
- vduNumArray.push(currentVnfData.vduTableData[i].num);
- }
- currentVnfData.vduTypeStr = vduTypeArray.toString();
- currentVnfData.vduNumStr = vduNumArray.toString();
- }
-
- if(vm.vmAppScaleDialog.saveType == "edit") {
- var vnfDatas = vm.vmAppScaleDialog.vnfDatas;
- for(var i=0;i<vnfDatas.length;i++) {
- if(vnfDatas[i].id == currentVnfData.id) {
- if(currentVnfData.vduTableData.length) {
- vnfDatas[i] = currentVnfData;
- } else {
- //delete the vnf which has no vdu data
- vm.vmAppScaleDialog.vnfDatas.splice(i, 1);
- }
- }
- }
- } else {
- if(currentVnfData.vduTableData.length) {
- vm.vmAppScaleDialog.vnfDatas.push(currentVnfData);
- }
- }
- vm.vmAppScaleDialog.titleVisible = vm.vmAppScaleDialog.vnfDatas.length;
- $("#addVduModal").modal("hide");
- },
- $confirmBtnClick : function() {
- var scaleParams = [];
- var scaleParam = {
- groupName : vm.vmAppScaleDialog.operation,
- params : []
- }
- scaleParam.params = vmAppUtil.generateScaleParams(vm.vmAppScaleDialog.vnfDatas);
- scaleParams.push(scaleParam);
-
- var param = {
- operationParams : scaleParams
- }
- vmAppUtil.executeOperation(param, vm.vmAppScaleDialog.currentRow, vm.vmAppScaleDialog.operation);
- }
- },
- templateRender : function(action) {
- if(action == "add") {
- var data = vm.vmAppDialog.templateSelectItems;
- if(data.length) {
- //default display the first template flavors
- vm.vmAppDialog.flavors = data[0].flavors || [];
- if(vm.vmAppDialog.flavors.length) {
- //default display the first flavor desc
- vm.vmAppDialog.flavorDesc = vm.vmAppDialog.flavors[0].desc;
- }
- //default display the first template input params
- vm.vmAppDialog.$initInputParams(data[0].templateid);
- //if the template is a ns template, query vnf templates
- vm.vmAppDialog.$initVnfInfo(data[0]);
- }
- }
- },
- vnfRender : function(action) {
- if(action == "add") {
- //add vnfm rules
- $(this).find('select').each(function(){
- $(this).rules("add", {required : true});
- });
- }
- },
- flavorRender : function(action) {
- if(action == "add") {
- //default display the first flavor params
- vm.vmAppDialog.$flavorChange();
- }
- },
- paramRender : function(action) {
- if(action == "add") {
- //add dynamic validate rules
- $(this).find('input').each(function(){
- $(this).rules("add", {required : true});
- });
- }
- },
- operationParamRender : function(action) {
- if(action == "add") {
- //add dynamic validate rules
- $(this).find('input').each(function(){
- var required = $(this).attr("data-required");
- if(required == "true") {
- $(this).rules("add", {required : true});
- }
- });
- }
- },
- includeRender : function() {
- //internationalize scale dialog
- var lang = getLanguage();
- loadPropertiesSideMenu(lang, 'nfv-nso-iui-i18n', 'i18n/');
-
- //initialize vnf form validator
- vmAppUtil.initFormValidator("vnfForm");
- //add dynamic validate rule
- vm.vmAppScaleDialog.$addValidatorMethod();
- $("#vnfType").rules("add", {vnfRepeat : true});
- //initialize vdu form validator
- vmAppUtil.initFormValidator("vduForm");
- $("#vduNum").rules("add", {digits : true, required : true});
- }
-});
-avalon.scan();
-vm.$initTable();
-vm.$initWizard();
-vm.$initCometd();
-
-var refreshByCond = function() {
- vm.$initTable();
- vm.$initWizard();
-} \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailController.js
deleted file mode 100644
index dfa09e72..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailController.js
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright (C) 2015 ZTE, Inc. and others. All rights reserved. (ZTE)
- *
- * 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 : "vmAppDetailController",
- templateId : "",
- templateData : [
- {href: "#topology", name: "Topology", value: true},
- {href: "#nodes", name: "Nodes", value: false}
- ],
- $language: {
- "sProcessing": "<img src='../component/thirdparty/data-tables/images/loading-spinner-grey.gif'/><span>&nbsp;&nbsp;"
- +$.i18n.prop("nfv-nso-iui-table-sProcess")+"</span>",
- "sLengthMenu": $.i18n.prop("nfv-nso-iui-table-sLengthMenu"),
- "sZeroRecords": $.i18n.prop("nfv-nso-iui-table-sZeroRecords"),
- "sInfo": "<span class='seperator'> </span>" + $.i18n.prop("nfv-nso-iui-table-sInfo"),
- "sInfoEmpty": $.i18n.prop("nfv-nso-iui-table-sInfoEmpty"),
- "sGroupActions": $.i18n.prop("nfv-nso-iui-table-sGroupActions"),
- "sAjaxRequestGeneralError":$.i18n.prop("nfv-nso-iui-table-sAjaxRequestGeneralError"),
- "sEmptyTable": $.i18n.prop("nfv-nso-iui-table-sEmptyTable"),
- "oPaginate": {
- "sPrevious": $.i18n.prop("nfv-nso-iui-table-sPrevious"),
- "sNext": $.i18n.prop("nfv-nso-iui-table-sNext"),
- "sPage": $.i18n.prop("nfv-nso-iui-table-sPage"),
- "sPageOf": $.i18n.prop("nfv-nso-iui-table-sPageOf")
- }
- },
- tabChange : function(index) {
- refreshByCond(index);
- },
- $restUrl : {
- queryNodeTemplateUrl : "/api/nsoc/v1/servicetemplates/{0}/nodetemplates",
- queryNodesInfoUrl:"/api/nsoc/v1/appinstances/{0}/nodeintsances",
- queryEventsInfoUrl: "/api/nsoc/v1/appinstances/{0}/operateschedules"
- },
- $init : function() {
- $.ajax({
- type : "GET",
- url : vm.$restUrl.queryNodeTemplateUrl,
- success : function(resp) {
- if(resp) {
- var nodeTemplateData = [];
- for(var i=0; i<resp.length; i++) {
- var nodeTemplate = topoUtil.generateNodeTemplate(resp[i]);
- nodeTemplateData.push(nodeTemplate);
- }
- vm.nodesTab.nodesDetail.nodeTemplateDetailData = resp;
- //generate node template table
- vm.topologyTab.topoTemplateData = topoUtil.generateTopoTemplate(nodeTemplateData);
- //initialize topology graph data
- vmAppDetailUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
- }
- },
- error : function() {
- commonUtil.showMessage($.i18n.prop("nfv-topology-iui-message-error"), "danger");
- }
- });
-
- //initialize event table
- vm.executionTab.$initEventsTable();
- },
- $initCometd : function() {
- commonUtil.registerCometdMessage("/api/nsocnotification/v1", "/lifecycle/instance/process", function(message) {
- var table = $('#' + vm.executionTab.$eventsTabId).dataTable();
- var tableData = table.fnGetData();
- if(message.instanceProcess) {
- var instance = message.instanceProcess;
- if(instance.instanceid == vm.executionTab.$instanceId) {
- table.fnAddData(instance.operationSchedule.currentStepInfo, true);
- }
- }
- });
- },
- topologyTab : {
- topology : "topology.html",
- vnfTip : $.i18n.prop("nfv-topology-iui-vnf-tip"),
- btnTip : $.i18n.prop("nfv-topology-iui-btn-return-tip"),
- topoTemplateData:[],
- boxTopoDatas:[],
- networkTopoDatas:[],
- isShowNum: true,
- eventVisible: false,
- returnBtnVisible : false,
- $getColor: function(index) {
- return topoUtil.getColor(index);
- },
- $getCidr: function(properties){
- return topoUtil.getCidr(properties.$model);
- },
- $getCpTop: function(index, parentBoxId){
- return topoUtil.getCpTop(index, parentBoxId);
- },
- $initTopology : function(topoTemplateData) {
- vmAppDetailUtil.initTopoData(topoTemplateData);
- },
- $showTopo:function(id, name){
- vm.nodesTab.nodesDetail.$showDetails("block", id, name);
- },
- $showEvent: function() {
- vm.topologyTab.eventVisible = !vm.topologyTab.eventVisible;
- if(vm.topologyTab.eventVisible) {
- //query event table data
- var oTable = $("#" + vm.executionTab.$eventsTabId).dataTable();
- oTable.fnAdjustColumnSizing();
- } else {
- //refresh topo data
- vm.topologyTab.$initTopology(vm.topologyTab.topoTemplateData.$model);
- }
- },
- $showVnfTopo: function(templateId) {
- vm.topologyTab.returnBtnVisible = true;
- vm.$restUrl.queryNodeTemplateUrl = "/api/nsoc/v1/servicetemplates/" + templateId + "/nodetemplates";
- vm.$init();
- },
- $returnNS: function() {
- vm.topologyTab.returnBtnVisible = false;
- vm.$restUrl.queryNodeTemplateUrl = "/api/nsoc/v1/servicetemplates/" + vm.templateId + "/nodetemplates";
- vm.$init();
- }
- },
- nodesTab : {
- $nodesTabId : "ict_nodes_table",
- $nodesTabFields : {// table columns
- table: [
- {"mData": "nodeId", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-nodeId"), "sClass" : "td_nodeId", "bVisible":false},
- {"mData": "nodeName", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-nodeName"), "bSortable":false, "fnRender" : vmAppDetailUtil.nameRender},
- {"mData": "nodeType", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-nodeType"), "sWidth" : "150px", "bSortable":true},
- {"mData": "nodeTemplateId", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-templateType"),"bSortable":false},
- {"mData": "nodeIp", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-host"), "bSortable":false},
- {"mData": "createTime", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-createTime"), "bSortable":false}
- ]
- },
- $initNodesTab: function() {
- var setting = {};
- setting.language = vm.$language;
- setting.paginate = true;
- setting.info = true;
- setting.sort = true;
- setting.columns = vm.nodesTab.$nodesTabFields.table;
- setting.restUrl = vm.$restUrl.queryNodesInfoUrl;
- setting.tableId = vm.nodesTab.$nodesTabId;
- serverPageTable.initDataTable(setting, {}, vm.nodesTab.$nodesTabId + '_div');
- },
- //Nodes Details
- nodesDetail : {
- nodeTemplateDetailData: [],
- nodeInstanceSelectItems: [],
- detailTitle : "",
- isShow : "none",
- detailIndex : 0,
- detailData : [
- {id: "general", name: $.i18n.prop("nfv-templateDetail-nodesTab-iui-tab-general"), isActive: true},
- {id: "properties", name: $.i18n.prop("nfv-templateDetail-nodesTab-iui-tab-properties"), isActive: false},
- {id: "relationShips", name: $.i18n.prop("nfv-templateDetail-nodesTab-iui-tab-relationShips"), isActive: false}
- ],
- $showDetails : function(isShow, nodetypeid, nodetypename) {
- console.log(isShow);
- vm.nodesTab.nodesDetail.isShow = isShow;
- if (isShow == "block") {
- vm.nodesTab.nodesDetail.detailTitle = nodetypename + " " + $.i18n.prop("nfv-virtualApplicationDetail-iui-text-nodeDetail"),
- $('#' + vm.nodesTab.nodesDetail.detailData[0].id).click();
- vm.nodesTab.nodesDetail.detailData[0].isActive = true;
- vm.nodesTab.nodesDetail.$initNodeDetailTable(nodetypeid);
- }
- },
- detailCondChange : function(index) {
- vm.nodesTab.nodesDetail.detailIndex = index;
- for(var i=0; i<vm.nodesTab.nodesDetail.detailData.length; i++) {
- vm.nodesTab.nodesDetail.detailData[i].isActive = false;
- }
- vm.nodesTab.nodesDetail.detailData[index].isActive = true;
- },
- $tableFields : {// table columns
- general: [
- {"mData": "key", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-key"), "bSortable" : false},
- {"mData": "value", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-value"), "bSortable" : false}
- ],
- properties: [
- {"mData": "key", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-key"), "bSortable" : false},
- {"mData": "value", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-value"), "bSortable" : false}
- ],
- relationShips: [
- {"mData": "sourceNodeName", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-sourceNodeName"), "bSortable" : false},
- {"mData": "targetNodeName", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-targetNodeName"), "bSortable" : false},
- {"mData": "type", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-type"), "bSortable" : false}
- ]
- },
- $initNodeDetailTable: function(nodetemplateid) {
- var data = topoUtil.getCurrentDetailData(vm.nodesTab.nodesDetail.nodeTemplateDetailData.$model, nodetemplateid);
-
- $.each(vm.nodesTab.nodesDetail.$tableFields, function(key, value){
- var setting = {};
- setting.language = vm.$language;
- setting.paginate = false;
- setting.info = false;
- setting.columns = value;
- setting.tableId = "ict_table_" + key;
- serverPageTable.initTableWithData(setting, setting.tableId + '_div', data[key]);
- });
- }
- }
- },
- executionTab : {
- $eventsTabId : "ict_events_table",
- $eventsTabFields : {// table columns
- table: [
- {"mData": "name", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-currentStepName"), "bSortable": false, "sWidth":"15%"},
- {"mData": "status", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-currentStepStatus"), "bSortable": false, "sWidth":"10%"},
- {"mData": "percent", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-percent"), "bSortable": false, "sWidth":"10%"},
- {"mData": "description", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-currentStepDesc"), "bSortable": false, "sWidth":"50%"},
- {"mData": "currentTime", name: $.i18n.prop("nfv-virtualApplicationDetail-iui-field-executionTime"), "bSortable": true, "sWidth":"15%"}
- ]
- },
- $initEventsTable: function() {
- var setting = {};
- setting.language = vm.$language;
- setting.paginate = false;
- setting.info = false;
- setting.sort = true;
- setting.columns = vm.executionTab.$eventsTabFields.table;
- setting.restUrl = vm.$restUrl.queryEventsInfoUrl;
- setting.tableId = vm.executionTab.$eventsTabId;
- serverPageTable.initDataTableForEvent(setting, {},
- vm.executionTab.$eventsTabId + '_div');
-
- var oTable = $("#" + setting.tableId).dataTable();
- oTable.fnSort( [ [4,'asc'] ] );
- },
- $instanceId : "",
- steps : [],
- $init: function() {
- vm.executionTab.$initEventsTable();
- }
- }
-});
-
-var refreshByCond = function (index) {
- switch(index) {
- case 0 :
- vm.topologyTab.$initTopology(vm.topologyTab.topoTemplateData.$model);
- vm.executionTab.$initEventsTable();
- break;
- case 1 :
- vm.nodesTab.$initNodesTab();
- break;
- }
-}
-
-var initParam = function() { //initialize template detail params
- var paramStr = window.location.search.substring(1);
- if(paramStr.length > 0) {
- var params = paramStr.split("&");
- var paramArray = [];
- for(var i=0; i<params.length; i++) {
- paramArray.push(params[i].substring(params[i].indexOf("=") + 1));
- }
-
- avalon.scan();
- vm.executionTab.$instanceId = paramArray[0];
- vm.$restUrl.queryNodesInfoUrl = commonUtil.format(vm.$restUrl.queryNodesInfoUrl, paramArray[0]);
- vm.$restUrl.queryEventsInfoUrl = commonUtil.format(vm.$restUrl.queryEventsInfoUrl, paramArray[0]);
- vm.$restUrl.queryNodeTemplateUrl = commonUtil.format(vm.$restUrl.queryNodeTemplateUrl, paramArray[1]);
- vm.templateId = paramArray[1];
-
- vm.$init();
- vm.$initCometd();
- }
-}
-initParam(); \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailUtil.js
deleted file mode 100644
index 8684cade..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppDetailUtil.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2015 ZTE, Inc. and others. All rights reserved. (ZTE)
- *
- * 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 vmAppDetailUtil = {};
-vmAppDetailUtil.timer = null;
-
-vmAppDetailUtil.nameRender = function(obj) {
- return '<a href="#" onclick="vm.nodesTab.nodesDetail.$showDetails('
- + '\'block\',\'' + obj.aData.nodeTemplateId + '\', \'' + obj.aData.nodeName + '\')">' + obj.aData.nodeName + '</a>';
-}
-
-/**
- * Content is too long, add the tooltip
- * @param {[type]} obj [description]
- * @return {[type]} [description]
- */
-vmAppDetailUtil.keyRender = function(obj) {
- return '<span title="' + obj.aData.key + '">' + obj.aData.key + '</span>';
-}
-
-vmAppDetailUtil.valueRender = function(obj) {
- return '<span title="' + obj.aData.value + '">' + obj.aData.value + '</span>';
-}
-
-vmAppDetailUtil.sourceNodeNameRender = function(obj) {
- return '<span title="' + obj.aData.sourceNodeName + '">' + obj.aData.sourceNodeName + '</span>';
-}
-
-vmAppDetailUtil.targetNodeNameRender = function(obj) {
- return '<span title="' + obj.aData.targetNodeName + '">' + obj.aData.targetNodeName + '</span>';
-}
-
-vmAppDetailUtil.typeRender = function(obj) {
- return '<span title="' + obj.aData.type + '">' + obj.aData.type + '</span>';
-}
-
-vmAppDetailUtil.initSteps = function() {
- $.ajax({
- type : "GET",
- url : vm.$restUrl.queryEventsInfoUrl,
- data : "json",
- success : function(data) {
- console.log("initSteps");
- if (data) {
- var step = $(".step");
- if (step.getStep().length == 0) {
- vm.executionTab.steps = [{title : "start"}, {title : "install VM"}, {title : "execute"}, {title : "complete"}];
- step.loadStep({
- size : "large",
- color : "blue",
- steps : vm.executionTab.steps
- });
- }
- }
- }
- });
-}
-
-vmAppDetailUtil.initTopoData = function(topoTemplateData) {
- $.ajax({
- type : "GET",
- url : vm.$restUrl.queryNodesInfoUrl,
- data : "json",
- success : function(resp){
- topoUtil.initTopoData(topoTemplateData, resp);
- }
- });
-}
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppUtil.js
deleted file mode 100644
index 24e8305e..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/vmAppUtil.js
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * Copyright (C) 2015 ZTE, Inc. and others. All rights reserved. (ZTE)
- *
- * 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 vmAppUtil = {};
-
-vmAppUtil.COLUMN_STATUS_INDEX = 4;
-vmAppUtil.COLUMN_OPERATION_INDEX = 5;
-vmAppUtil.TYPE_SUCCESS = "success";
-vmAppUtil.TYPE_DANGER = "danger";
-
-vmAppUtil.nameRender = function(obj) {
- return '<a href="#" onclick="vm.$openDetail(\'' + obj.aData.instanceId + '\', '
- + '\'' + obj.aData.serviceTemplateId + '\')">' + obj.aData.instanceName + '</a>';
-}
-
-vmAppUtil.operationRender = function(obj) {
- var table = $('#' + vm.$tableId).dataTable();
- var row = obj.iDataRow;
- var operationInfo = table.fnGetData(row)["operationInfo"];
- var instanceOperating = table.fnGetData(row)["instanceOperating"];
- var instanceStatus = table.fnGetData(row)["instanceStatus"];
- var disabled = "";
-
- var statusText = $.i18n.prop("nfv-virtualApplication-iui-status-" + instanceOperating);
- if (status.indexOf("nfv-virtualApplication") > -1) {
- statusText = $.i18n.prop("nfv-virtualApplication-iui-status-execute");
- }
- if($(instanceStatus).text() == statusText) {
- disabled = "disabled";
- }
-
- var optionHtml = "<option></option>";
- if (operationInfo) {
- for(var i=0; i<operationInfo.length; i++) {
- var name = $.i18n.prop("nfv-virtualApplication-iui-operation-" + operationInfo[i].operationname);
- if (name.indexOf("nfv-virtualApplication") > -1) {
- name = operationInfo[i].operationname;
- }
-
- if (operationInfo[i].operationid == instanceOperating) {
- optionHtml += "<option value=" + operationInfo[i].operationid + " selected>" + name + "</option>";
- } else {
- optionHtml += "<option value=" + operationInfo[i].operationid + ">" + name + "</option>";
- }
- }
- }
- return '<span><span class="span-action"><select name="type" ' + disabled + '>' + optionHtml + '</select></span>'
- + '&nbsp&nbsp<button type="button" ' + disabled + ' class="btn blue1 btn-sm btn-operation" '
- + 'onclick="vmAppUtil.execute('+ obj.iDataRow +')"><i class="ict-start"></i></button></span>';
-};
-
-vmAppUtil.statusRender = function(obj) {
- var attr = 'class="label label-success"';
- var status = $.i18n.prop("nfv-virtualApplication-iui-status-" + obj.aData.instanceStatus);
- if (obj.aData.instanceStatus == "failed") {
- attr = 'class="label label-danger"';
- } else if (obj.aData.instanceStatus == "processing") {
- status = $.i18n.prop("nfv-virtualApplication-iui-status-" + obj.aData.instanceOperating);
- if (status.indexOf("nfv-virtualApplication") > -1) {
- status = $.i18n.prop("nfv-virtualApplication-iui-status-execute");
- }
- }
- return '<span ' + attr + '>' + status + '</span>';
-};
-
-vmAppUtil.delRender = function(obj) {
- return '<div><a href="#" class="btn-xs grey btn-editable" onclick="vmAppUtil.deleteVmApp(\''
- + obj.aData.instanceId + '\', \'' + obj.aData.serviceTemplateId + '\')">'
- + '<i class=\"ict-delete\"></i>' + $.i18n.prop('nfv-software-iui-action-delete') + '</a></div>';
-};
-
-vmAppUtil.dateRender = function(obj) {
- var date = new Date(obj.aData[obj.mDataProp]);
- return commonUtil.parseDate(date, "yyyy-MM-dd hh:mm:ss");
-};
-
-vmAppUtil.deleteVmApp = function(instanceId, servicetemplateid) {
- bootbox.confirm($.i18n.prop("nfv-virtualApplication-iui-message-delete-confirm"), function(result){
- if(result) {
- var url = vm.$restUrl.deleteAppinstancesUrl + instanceId;
- $.ajax({
- type : "delete",
- url : url,
- dataType : "json",
- success : function(resp) {
- if(resp.deleteresult == "true"){
- var packageurl = vm.$restUrl.delInstanceTemplateUrl + servicetemplateid;
- commonUtil.delete(packageurl, function(resp) {
- refreshByCond();
- });
- }else{
- commonUtil.showMessage($.i18n.prop("nfv-virtualApplication-iui-message-delete-fail"), vmAppUtil.TYPE_DANGER);
- refreshByCond();
- }
- },
- error : function() {
- commonUtil.showMessage($.i18n.prop("nfv-virtualApplication-iui-message-delete-fail"), vmAppUtil.TYPE_DANGER);
- refreshByCond();
- }
- });
- }
- });
-};
-
-vmAppUtil.execute = function(row) {
- var oSelect = $("tbody tr select").eq(row);
- var operation = oSelect.find("option:selected").val();
- if (operation) {
- var table = $('#' + vm.$tableId).dataTable();
- var templateId = table.fnGetData(row)["serviceTemplateId"];
- var url = vm.$restUrl.queryOperationParamsUrl + templateId + "/operations/" + operation + "/parameters";
- //query operation params
- commonUtil.get(url, null, function(data) {
- //empty operation params
- vm.vmAppDialog.operationParams = [];
- //empty template input params
- vm.vmAppDialog.templateInputParams = [];
- if(vmAppUtil.isScaleOperation(operation)) {
- vm.vmAppScaleDialog.operation = operation;
- vm.vmAppScaleDialog.currentRow = row;
- vm.vmAppScaleDialog.instanceId = table.fnGetData(row)["instanceId"];
- vm.vmAppScaleDialog.templateId = templateId;
- vm.vmAppScaleDialog.$initScaleParams();
- $("#scaleModal").modal("show");
- } else if ((data && data.length > 0)) {
- vm.vmAppDialog.type = "execute";
- vm.vmAppDialog.title = $.i18n.prop("nfv-virtualApplication-iui-text-params");
- vm.vmAppDialog.btnTitle = $.i18n.prop("nfv-virtualApplication-iui-text-confirmBtn");
- vm.vmAppDialog.operation = operation;
- vm.vmAppDialog.currentRow = row;
- vm.vmAppDialog.templateId = templateId;
- vm.vmAppDialog.operationParams = data;
- vm.vmAppDialog.$initData();
- $("#vmAppDialog").modal("show");
- } else {
- var group = {
- flavor : "",
- flavorParams : [],
- operationParams : []
- }
- vmAppUtil.executeOperation(group, row, operation);
- }
- });
- }
-};
-
-vmAppUtil.executeOperation = function(group, row, operation) {
- vmAppUtil.changeBtnStatus("processing", operation, row, true);
- var table = $('#' + vm.$tableId).dataTable();
- var instanceId = table.fnGetData(row)["instanceId"];
- var url = vm.$restUrl.executeOperationUrl + instanceId + "/operations/" + operation;
- $.ajax({
- type : "POST",
- url : url,
- data : JSON.stringify(group),
- contentType : "application/json",
- dataType : "json",
- error : function() {
- vmAppUtil.changeBtnStatus("failed", operation, row, false);
- }
- });
- if(vmAppUtil.isScaleOperation(operation)) {
- $("#scaleModal").modal("hide");
- } else {
- $("#vmAppDialog").modal("hide");
- }
-};
-
-vmAppUtil.changeBtnStatus = function(status, operation, row, disabled) {
- var table = $('#' + vm.$tableId).dataTable();
- var oBtn = $("tbody tr button i.ict-start").eq(row).parent();
- var oSelect = $("tbody tr select").eq(row);
-
- oSelect.attr("disabled", disabled);
- oBtn.attr("disabled", disabled);
- table.fnUpdate(status, row, vmAppUtil.COLUMN_STATUS_INDEX, false, false);
- table.fnUpdate(operation, row, vmAppUtil.COLUMN_OPERATION_INDEX, false, false);
-};
-
-vmAppUtil.queryTemplate = function() {
- var url = vm.$restUrl.queryServiceTemplate + "&status=Enabled";
- commonUtil.get(url, null, function(data) {
- vm.vmAppDialog.templateSelectItems = data || [];
- });
-};
-
-vmAppUtil.queryFlavorParam = function(templateId, flavorName) {
- var url = vm.$restUrl.queryFlavorParamUrl + templateId + "/flavors/" + flavorName + "/parameters";
- commonUtil.get(url, null, function(data) {
- vm.vmAppDialog.flavorParams = data || [];
- });
-};
-
-vmAppUtil.queryVimInfo = function() {
- var url = vm.$restUrl.queryVimInfoUrl;
- commonUtil.get(url, null, function(resp) {
- if (resp) {
- vm.vmAppDialog.vimSelectItems = resp.data;
- }
- });
-};
-
-vmAppUtil.queryVnfmInfo = function() {
- var url = vm.$restUrl.queryVnfmInfoUrl;
- commonUtil.get(url, null, function(resp) {
- if (resp) {
- vm.vmAppDialog.vnfmSelectItems = resp.data;
- }
- });
-};
-
-vmAppUtil.queryVnfInfo = function(templateId) {
- var url = vm.$restUrl.queryVnfInfoUrl + templateId + "/vnftemplates";
- commonUtil.get(url, null, function(resp) {
- if (resp) {
- vm.vmAppDialog.vnfItems = resp;
- }
- });
-};
-
-vmAppUtil.newApp = function(param) {
- $.ajax({
- type : "POST",
- url : vm.$restUrl.newAppinstancesUrl,
- contentType : "application/json",
- data : JSON.stringify(param),
- dataType : "text",
- success : function(data) {
- refreshByCond();
- commonUtil.showMessage($.i18n.prop("nfv-virtualApplication-iui-message-create-success"), vmAppUtil.TYPE_SUCCESS);
- },
- error : function() {
- refreshByCond();
- commonUtil.showMessage($.i18n.prop("nfv-virtualApplication-iui-message-create-fail"), vmAppUtil.TYPE_DANGER);
- }
- });
- $("#vmAppDialog").modal("hide");
-
-};
-
-vmAppUtil.isScaleOperation = function(operation) {
- if(operation == "scaleIn" || operation == "scaleOut") {
- return true;
- } else {
- return false;
- }
-}
-
-vmAppUtil.generateGourpParams = function(data) {
- var groupParams = [];
- $.each(data, function(index, group){
- var groupParam = {
- groupName : group.groupName,
- params : []
- }
- $.each(group.params, function(index, element){
- var id = vm.vmAppDialog.$getGoupParamKey(group.groupName, element.key);
- var value = $("#" + id).val();
- if(value) {
- var param = {
- key : element.key,
- value : value
- }
- groupParam.params.push(param);
- }
- });
- if(groupParam.params.length) {
- groupParams.push(groupParam);
- }
- });
- return groupParams;
-}
-
-vmAppUtil.generateAdditionalParams = function(data) {
- var additionalParams = [];
- $.each(data, function(index, group){
- var param = {
- key : "object_" + group.groupName, //前缀objec_标识为value是一个对象字符串,方便plan解析参数
- value : ""
- }
- var templateParam = {};
- $.each(group.params, function(index, element){
- var id = vm.vmAppDialog.$getGoupParamKey(group.groupName, element.key);
- var value = $("#" + id).val();
- if(value) {
- templateParam[element.key] = value;
- } else {
- templateParam[element.key] = "";
- }
- });
- param.value = JSON.stringify(templateParam);
- additionalParams.push(param);
- });
- return additionalParams;
-}
-
-vmAppUtil.generateVNFRelationInfos = function(data) {
- var vnfRelationInfos = [];
- $.each(data, function(index, element){
- var info = {
- vnfdid : element.templateid,
- vnfmid : $("#" + element.templateid).val()
- }
- vnfRelationInfos.push(info);
- });
- return vnfRelationInfos;
-}
-
-vmAppUtil.delVduRender = function(obj) {
- return '<div><a href="#" class="btn-xs grey btn-editable" onclick="vmAppUtil.deleteVdu(\''
- + obj.aData.id + '\', \'' + obj.aData.vnfId + '\')">'
- + '<i class=\"ict-delete\"></i>' + $.i18n.prop('nfv-software-iui-action-delete') + '</a></div>';
-}
-
-vmAppUtil.deleteVdu = function(vduId, vnfId) {
- var oTable = $("#" + vm.vmAppScaleDialog.$tableId).dataTable();
- var tableData = oTable.fnGetData();
- for(i=0;i<tableData.length;i++) {
- if((tableData[i].id == vduId) && (tableData[i].vnfId == vnfId)) {
- //remove the vdu from vduTableData
- oTable.fnDeleteRow(i);
- break;
- }
- }
-}
-
-vmAppUtil.checkRender = function(obj) {
- var checkHtml = "";
- var oid = obj.aData.oid;
- //get selected vdu node instanceid
- var iCheckData = vm.vmAppScaleDialog.currentVnfData.vduTableData;
- for(var i=0;i<iCheckData.length;i++) {
- if(oid == iCheckData[i].oid) {
- checkHtml = "checked";
- break;
- }
- }
- return '<input type="checkbox" class="form-control" '+checkHtml+'/>';
-}
-
-vmAppUtil.queryScalableVnfInfo = function(templateId) {
- var url = vm.$restUrl.queryVnfInfoUrl + templateId + "/vnftemplates";
- $.ajax({
- type : "GET",
- url : url,
- dataType : "json",
- success : function(resp) {
- resp = resp || [];
- for(var i=0; i<resp.length; i++) {
- var vnfData = {
- id : resp[i].templateid,
- name : resp[i].name,
- operationType : "",
- vduTypeList : [],
- vduTableData : [],
- vduTypeStr : "",
- vduNumStr : "",
- vduNameStr : ""
- }
- var nodetemplates = resp[i].nodetemplates;
- for(var j=0; j<nodetemplates.length; j++) {
- //only display these vdus which have the scalable attribute
- if(nodetemplates[j].scalable && (nodetemplates[j].parentType.indexOf(".VDU") > -1)) {
- vnfData.vduTypeList.push(nodetemplates[j]);
- }
- }
-
- if(vnfData.vduTypeList.length) {
- vm.vmAppScaleDialog.vnfSelectItems.push(vnfData);
- }
- }
- }
- });
-}
-
-vmAppUtil.queryScalableVduInstance = function(instanceId, vnfTemplateId, vduTypeList) {
- //query vnf instances by ns id
- var vnfUrl = vm.$restUrl.queryRocInfoBaseUrl + "/vnfs?nsId=" + instanceId;
- //var vnfUrl = vm.$restUrl.queryRocInfoBaseUrl + "/vnfs/" + instanceId;
- $.ajax({
- type : "GET",
- url : vnfUrl,
- dataType : "json",
- success : function(resp) {
- if(resp.operationResult == "SUCCESS") {
- var data = resp.data;
- for(var i=0; i<data.length; i++) {
- if(data[i].type == vnfTemplateId) {
- //query vdu node instances by vnf id
- var vduUrl = vm.$restUrl.queryRocInfoBaseUrl + "/vdus?vnfId=" + data[i].oid;
- $.ajax({
- type : "GET",
- url : vduUrl,
- dataType : "json",
- success : function(resp) {
- if(resp.operationResult == "SUCCESS") {
- var vduInstanceNodes = resp.data;
- var data = [];
- for(var j=0; j<vduInstanceNodes.length; j++) {
- if($.inArray(vduInstanceNodes[j].type, vduTypeList)) {
- data.push(vduInstanceNodes[j]);
- }
- }
- vm.vmAppScaleDialog.$initTable("instance", data);
- }
- }
- });
- break;
- }
- }
- }
- }
- });
-}
-
-vmAppUtil.generateScaleParams = function(vnfDatas) {
- var scaleParams = [];
- for(var i=0; i<vnfDatas.length; i++) {
- var param = {
- key : "object_VNF_" + vnfDatas[i].id, //前缀object_VNF_标识为value是一个对象字符串,方便plan解析参数
- value : ""
- }
- var aspect = {};
- //get vdu input param
- if(vnfDatas[i].operationType == "type") {
- aspect.scaleBy = "byType";
- aspect.vduTypes = [];
- $.each(vnfDatas[i].vduTableData, function(index, element){
- var vduType = {
- vduType : element.id,
- instancesNum : element.num,
- vduName : element.name
- }
- aspect.vduTypes.push(vduType);
- });
- } else {
- aspect.scaleBy = "byInstance";
- aspect.vduInstances = [];
- $.each(vnfDatas[i].vduTableData, function(index, element){
- var vduInstance = {
- vduId : element.oid
- }
- aspect.vduInstances.push(vduInstance);
- });
- }
- param.value = JSON.stringify(aspect);
- scaleParams.push(param);
- }
- return scaleParams;
-}
-
-vmAppUtil.initFormValidator = function(formId) {
- $(function(){
- var form = $("#" + formId);
- var error = $('.alert-danger', form);
- var success = $('.alert-success', form);
-
- $.extend($.validator.messages, {
- required: $.i18n.prop("nfv-virtualApplication-iui-validate-inputParam"),
- digits: $.i18n.prop("nfv-virtualApplication-iui-validate-digits"),
- range: $.i18n.prop("nfv-virtualApplication-iui-validate-range")
- });
-
- form.validate({
- doNotHideMessage : true,
- errorElement : 'span',
- errorClass : 'help-block',
- focusInvalid : false,
- errorPlacement : function(error, element) {
- error.insertAfter(element);
- },
- invalidHandler : function(event, validator) {
- success.hide();
- error.show();
- },
- highlight : function(element) {
- $(element).closest("div").removeClass("has-success").addClass("has-error");
- },
- unhighlight: function (element) {
- $(element).closest("div").removeClass("has-error");
- },
- success : function(label) {
- label.addClass("valid").closest(".form-group").removeClass("has-error");
- },
- submitHandler: function (form) {
- success.show();
- error.hide();
- }
- });
- });
-}
-
-vmAppUtil.isNSTemplate = function(type) {
- if(type == "NS") {
- return true;
- }
- return false;
-} \ No newline at end of file