aboutsummaryrefslogtreecommitdiffstats
path: root/nsoc-iui/src/main/resources/webroot/nsoc/js
diff options
context:
space:
mode:
Diffstat (limited to 'nsoc-iui/src/main/resources/webroot/nsoc/js')
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/component/commonUtil.js128
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/component/loadi18n_nsoc.js23
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/component/serverPageTable.js407
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmController.js254
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmUtil.js59
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/host-validate.js56
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/package/pmController.js223
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/package/pmUtil.js137
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smController.js147
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smUtil.js33
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmController.js83
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailController.js241
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailUtil.js44
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmUtil.js46
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/template/topoUtil.js617
-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
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfm-validate.js66
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmController.js275
-rw-r--r--nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmUtil.js73
23 files changed, 0 insertions, 4557 deletions
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/component/commonUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/component/commonUtil.js
deleted file mode 100644
index abc4cd63..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/component/commonUtil.js
+++ /dev/null
@@ -1,128 +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 commonUtil = {};
-commonUtil.arrayRemove = function( aryInstance , index ){
- if(aryInstance == undefined || aryInstance == null){
- return;
- }
- for(var i=0,n=0;i<aryInstance.length;i++) {
- if(aryInstance[i]!=aryInstance[dx]) {
- aryInstance[n++]=aryInstance[i];
- }
- }
- aryInstance.length-=1;
-};
-
-//For the expansion of the Date, convert the Date to specify the format String
-// examples:
-// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
-// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
-commonUtil.parseDate = function( dateObj , format){
- var o = {
- "M+" : dateObj.getMonth()+1, //month
- "d+" : dateObj.getDate(), //day
- "h+" : dateObj.getHours(), //hour
- "m+" : dateObj.getMinutes(), //minute
- "s+" : dateObj.getSeconds(), //second
- "q+" : Math.floor((dateObj.getMonth()+3)/3), //quarter
- "S" : dateObj.getMilliseconds() //millisecond
- }
- if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
- (dateObj.getFullYear()+"").substr(4 - RegExp.$1.length));
- for(var k in o)
- if(new RegExp("("+ k +")").test(format))
- format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] :
- ("00"+ o[k]).substr((""+ o[k]).length));
- return format;
-};
-
-//tooltip
-commonUtil.showMessage = function(message, type) {
- $.growl({
- icon: "fa fa-envelope-o fa-lg",
- title: "&nbsp;&nbsp;" + $.i18n.prop("nfv-nso-iui-common-tip"),
- message: message
- },{
- type: type
- });
-};
-
-commonUtil.registerCometdMessage = function(url, channel, callback) {
- var cometd = new $.Cometd();
- var cometdURL = location.protocol + "//" + location.host + url;
- cometd.configure({
- url : cometdURL,
- logLevel : "info"
- });
- // unregister websocket transport, use long-polling transport
- cometd.unregisterTransport('websocket');
- // store channel object parameters(this object include channel and callback function), start from arguments[1]
- var _args = arguments;
-
- cometd.addListener("/meta/handshake", function(handshake){
- if(handshake.successful === true) {
- cometd.batch(function() {
- //subscribe channel
- cometd.subscribe(channel, function(message){
- callback.call(this, message.data);
- });
- });
- }
- });
- cometd.handshake();
-}
-
-commonUtil.format = function() {
- if(arguments.length == 0) {
- return null;
- }
- var str = arguments[0];
- for(var i=0; i<arguments.length; i++) {
- var reg = new RegExp("\\{" + (i - 1) + "\\}" , "gm");
- str = str.replace(reg, arguments[i]);
- }
- return str;
-}
-
-commonUtil.get = function(url, params, callback) {
- $.ajax({
- type : "GET",
- url : url,
- //contentType : contentType || "application/x-www-form-urlencoded; charset=UTF-8",
- dataType : "json",
- data : params || {},
- success : callback
- });
-}
-
-commonUtil.post = function(url, params, callback, contentType) {
- $.ajax({
- type : "POST",
- url : url,
- contentType : contentType || "application/x-www-form-urlencoded; charset=UTF-8",
- data : params || {},
- success : callback
- });
-}
-
-commonUtil.delete = function(url, callback, contentType) {
- $.ajax({
- type : "DELETE",
- url : url,
- contentType : contentType || "application/x-www-form-urlencoded; charset=UTF-8",
- success : callback
- });
-} \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/component/loadi18n_nsoc.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/component/loadi18n_nsoc.js
deleted file mode 100644
index c809aa26..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/component/loadi18n_nsoc.js
+++ /dev/null
@@ -1,23 +0,0 @@
-function loadPropertiesSideMenu(lang, fileNamePrefix, filePath){
- jQuery.i18n.properties({
- language:lang,
- name:fileNamePrefix,
- path:filePath,
- mode:'map',
- callback: function() {
- var i18nItems = $("[name_i18n=com_zte_nfv_nsoc_i18n]");
- for(var i=0;i<i18nItems.length;i++) {
- var $item = $(i18nItems.eq(i));
- var itemId = $item.attr("id");
- var itemTitle = $item.attr("title");
- if(typeof(itemTitle) != "undefined") {
- $item.attr("title", $.i18n.prop(itemId));
- } else {
- $item.text($.i18n.prop(itemId));
- }
- }
- }
- });
-}
-var lang = getLanguage();
-loadPropertiesSideMenu(lang, 'nfv-nso-iui-i18n', 'i18n/'); \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/component/serverPageTable.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/component/serverPageTable.js
deleted file mode 100644
index f0cda72e..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/component/serverPageTable.js
+++ /dev/null
@@ -1,407 +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 serverPageTable = {};
-/* Bootstrap style full number pagination control */
-$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
-{
- return {
- "iStart": oSettings._iDisplayStart,
- "iEnd": oSettings.fnDisplayEnd(),
- "iLength": oSettings._iDisplayLength,
- "iTotal": oSettings.fnRecordsTotal(),
- "iFilteredTotal": oSettings.fnRecordsDisplay(),
- "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
- "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
- };
-};
-
-$.extend( $.fn.dataTableExt.oPagination, {
- "bootstrap_extended": {
- "fnInit": function( oSettings, nPaging, fnDraw ) {
- var oLang = oSettings.oLanguage.oPaginate;
- var oPaging = oSettings.oInstance.fnPagingInfo();
-
- var fnClickHandler = function ( e ) {
- e.preventDefault();
- if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
- fnDraw( oSettings );
- }
- };
-
- $(nPaging).append(
- '<div class="pagination-panel"> ' + oLang.sPage + ' ' +
- '<a href="#" class="btn btn-sm default prev disabled" title="' + oLang.sPrevious + '"><i class="fa fa-angle-left"></i></a>' +
- '<input type="text" class="pagination-panel-input input-mini input-inline input-sm" maxlenght="5" style="text-align:center; margin: 0 4px; border: 1px solid rgb(169, 169, 169);height: 28px;">' +
- '<a href="#" class="btn btn-sm default next disabled" title="' + oLang.sNext + '"><i class="fa fa-angle-right"></i></a> ' +
- oLang.sPageOf + ' <span class="pagination-panel-total"></span>' +
- '</div>'
- );
-
- var els = $('a', nPaging);
-
- $(els[0]).bind('click.DT', { action: "previous" }, fnClickHandler );
- $(els[1]).bind('click.DT', { action: "next" }, fnClickHandler);
-
- $('.pagination-panel-input', nPaging).bind('change.DT', function(e) {
- var oPaging = oSettings.oInstance.fnPagingInfo();
- e.preventDefault();
- var page = parseInt($(this).val());
- if (page > 0 && page < oPaging.iTotalPages) {
- if ( oSettings.oApi._fnPageChange(oSettings, page-1) ) {
- fnDraw( oSettings );
- }
- } else {
- $(this).val(oPaging.iPage + 1);
- }
- });
-
- $('.pagination-panel-input', nPaging).bind('keypress.DT', function(e) {
- var oPaging = oSettings.oInstance.fnPagingInfo();
- if (e.which == 13) {
- var page = parseInt($(this).val());
- if (page > 0 && page < oSettings.oInstance.fnPagingInfo().iTotalPages) {
- if ( oSettings.oApi._fnPageChange(oSettings, page-1) ) {
- fnDraw( oSettings );
- }
- } else {
- $(this).val(oPaging.iPage + 1);
- }
- e.preventDefault();
- }
- });
- },
-
- "fnUpdate": function ( oSettings, fnDraw ) {
- var iListLength = 5;
- var oPaging = oSettings.oInstance.fnPagingInfo();
- var an = oSettings.aanFeatures.p;
- var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
-
- if ( oPaging.iTotalPages < iListLength) {
- iStart = 1;
- iEnd = oPaging.iTotalPages;
- }
- else if ( oPaging.iPage <= iHalf ) {
- iStart = 1;
- iEnd = iListLength;
- } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
- iStart = oPaging.iTotalPages - iListLength + 1;
- iEnd = oPaging.iTotalPages;
- } else {
- iStart = oPaging.iPage - iHalf + 1;
- iEnd = iStart + iListLength - 1;
- }
-
-
- for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
- var wrapper = $(an[i]).parents(".dataTables_wrapper");
-
- if (oPaging.iTotalPages <= 0) {
- $('.pagination-panel, .dataTables_length', wrapper).hide();
- } else {
- $('.pagination-panel, .dataTables_length', wrapper).show();
- }
-
- $('.pagination-panel-total', an[i]).html(oPaging.iTotalPages);
- $('.pagination-panel-input', an[i]).val(oPaging.iPage + 1);
-
- // Remove the middle elements
- $('li:gt(1)', an[i]).filter(':not(.next)').remove();
-
- // Add the new list items and their event handlers
- for ( j=iStart ; j<=iEnd ; j++ ) {
- sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
- $('<li '+sClass+'><a href="#">'+j+'</a></li>')
- .insertBefore( $('li.next:first', an[i])[0] )
- .bind('click', function (e) {
- e.preventDefault();
- oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
- fnDraw( oSettings );
- } );
- }
-
- // Add / remove disabled classes from the static elements
- if ( oPaging.iPage === 0 ) {
- $('a.prev', an[i]).addClass('disabled');
- } else {
- $('a.prev', an[i]).removeClass('disabled');
- }
-
- if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
- $('a.next', an[i]).addClass('disabled');
- } else {
- $('a.next', an[i]).removeClass('disabled');
- }
- }
- }
- }
-} );
-
-serverPageTable.getRestPara = function( cond , tableSetting ){
- var pageNo=tableSetting._iDisplayStart/tableSetting._iDisplayLength+1;
- var pageSize = tableSetting._iDisplayLength;
- var queryParameter={"pageNo":pageNo,"pageSize":tableSetting._iDisplayLength,groupId:["it.group.database=02","it.group.server=01"]},
- newData={"data":JSON.stringify(queryParameter)};
- //put the pageinfo in cond if there is a pageinfo
- var pageInfo = vm.logInfo[vm.logType].pageInfo;
- if(pageInfo != null && serverPageTable.perpagenumber == pageSize){
- cond.idEnd = pageInfo.pageStart[pageNo - 1];
- cond.idStart = pageInfo.pageStart[pageNo];
- if(!cond.idStart){ //the last page
- cond.idStart = 0;
- }
-
- }else{
- delete cond.idStart;
- delete cond.idEnd;
- vm.logInfo[vm.logType].pageInfo = null;
- pageNo = 1;
- tableSetting._iDisplayStart = 0;
- }
- var data = {
- cond:JSON.stringify(cond),
- perpagenumber:pageSize,
- pageNo:pageNo,
- needPageInfo:vm.logInfo[vm.logType].pageInfo == null
- };
- serverPageTable.perpagenumber = pageSize;
- return data;
-};
-
-
-
-serverPageTable.initDataTable = function( setting ,cond , divId) {
- //transform colomn
- var column = setting.columns;
- //empty table
- $('#'+ divId).children().remove();
- var tableId = setting.tableId;
- var tableEleStr = '<table class="table table-striped table-bordered table-hover" id= '+ tableId + '>'
- + '<thead>'
- +'<tr role="row" class="heading" >'
- + '</tr>'
- + '</thead>'
- +'<tbody>'
- +'</tbody>'
- +'</table>';
- $('#'+ divId).append(tableEleStr);
- //$('#'+ tableId).append(' <thead><tr role="row" class="heading" ></tr></thead><tbody></tbody>');
- var trEle = $('#'+ tableId + ' > thead >tr');
- //var dataTableColumn = [];
- for ( var one in column){
- var th = '<th>' + column[one].name + '</th>';
- trEle.append(th);
- }
- var table = $("#" + tableId).dataTable({
- //"sDom" : "tr<'row'<'col-md-6 col-sm-12'><'col-md-6 col-sm-12'pli>>", // datatable layout
- //"sDom" : "<'row'<'col-md-12 col-sm-12'lip>r><'table-scrollable't>>",
- "sDom": '<"top"rt><"bottom"lip>',
- "oLanguage": setting.language,//language
- //"bJQueryUI": true,
- "bPaginate": setting.paginate,// page button
- "bFilter": false,// search bar
- "bAutoWidth":true,//automatically set colum width
- "bLengthChange": true,// record number in each row
- "iDisplayLength": 10,// row number in each page
- "bSort": setting.sort ? true : false,// sort
- "bInfo": setting.info,// Showing 1 to 10 of 23 entries
- "bWidth": true,
- "bScrollCollapse": true,
- "sPaginationType": "bootstrap_extended", // page, a total of two kinds of style, another one is two_button
- "bProcessing": true,
- "bServerSide": false,
- "bDestroy": true,
- "bSortCellsTop": true,
- "sAjaxSource": setting.restUrl,
- "aoColumns": setting.columns,
- "aoColumnDefs": [
- {
- sDefaultContent: '',
- aTargets: [ '_all' ]
- }
- ],
- "fnServerData": function (sSource, aoData, fnCallback, oSettings) {
- oSettings.jqXHR = $.ajax({
- "type": 'get',
- "url": sSource,
- "dataType": "json",
- //"data":serverPageTable.getRestPara(cond,oSettings),
- "success": function (resp) {
- oSettings.iDraw = oSettings.iDraw + 1;
-
- resp = resp || [];
- var data = {};
- data.aaData = resp;
- var totalCounts = resp.length;
-
- data.iTotalRecords = totalCounts;
- data.iTotalDisplayRecords = totalCounts;
- data.sEcho = oSettings;
- fnCallback(data);
- },
- "error": function(resp) {
- var data = {};
- data.aaData = [];
- var totalCounts = 0;
-
- data.iTotalRecords = totalCounts;
- data.iTotalDisplayRecords = totalCounts;
- data.sEcho = oSettings;
- fnCallback(data);
- }
- });
- }
- });
-};
-
-serverPageTable.initTableWithData = function( setting , divId , tableData) {
- //transform colomn
- var column = setting.columns;
- //empty table
- $('#'+ divId).children().remove();
- var tableId = setting.tableId;
- var tableEleStr = '<table class="table table-striped table-bordered table-hover" id= '+ tableId + '>'
- + '<thead>'
- +'<tr role="row" class="heading" >'
- + '</tr>'
- + '</thead>'
- +'<tbody>'
- +'</tbody>'
- +'</table>';
- $('#'+ divId).append(tableEleStr);
- var trEle = $('#'+ tableId + ' > thead >tr');
- for ( var one in column){
- var th = '<th>' + column[one].name + '</th>';
- trEle.append(th);
- }
- var table = $("#" + tableId).dataTable({
- "sDom" : "<'row'<'col-md-12 col-sm-12'lip>r>>",
- "oLanguage": setting.language,//language
- //"bJQueryUI": true,
- "bPaginate": setting.paginate,// page button
- "bFilter": false,// search bar
- "bAutoWidth":true,//automatically set the column width
- "bLengthChange": true,// record number in each row
- "iDisplayLength": 10,// row number in each page
- "bSort": setting.sort ? true : false,// sort
- "bInfo": setting.info,// Showing 1 to 10 of 23 entries
- "bWidth": true,
- "bScrollCollapse": true,
- "sPaginationType": "bootstrap_extended", // page, a total of two kinds of style, another one is two_button
- "bProcessing": false,
- "bServerSide": false,
- "bDestroy": true,
- "bSortCellsTop": true,
- "sAjaxSource": tableData,
- "aoColumns": setting.columns,
- "fnServerData": function (sSource, aoData, fnCallback, oSettings) {
- oSettings.iDraw = oSettings.iDraw + 1;
- var resp = tableData || [];
- var data = {};
- data.aaData = resp;
- var totalCounts = resp.length;
-
- data.iTotalRecords = totalCounts;
- data.iTotalDisplayRecords = totalCounts;
- data.sEcho = oSettings;
- fnCallback(data);
- }
- });
-};
-
-
-serverPageTable.initDataTableForEvent = function( setting ,cond , divId) {
- //transform colomn
- var column = setting.columns;
- //empty table
- $('#'+ divId).children().remove();
- var tableId = setting.tableId;
- var tableEleStr = '<table class="table table-striped table-bordered table-hover" id= '+ tableId + '>'
- + '<thead>'
- +'<tr role="row" class="heading" >'
- + '</tr>'
- + '</thead>'
- +'<tbody>'
- +'</tbody>'
- +'</table>';
- $('#'+ divId).append(tableEleStr);
- var trEle = $('#'+ tableId + ' > thead >tr');
- for ( var one in column){
- var th = '<th>' + column[one].name + '</th>';
- trEle.append(th);
- }
- var table = $("#" + tableId).dataTable({
- "sDom": '<"top"rt><"bottom"lip>',
- "oLanguage": setting.language,//language
- //"bJQueryUI": true,
- "bPaginate": setting.paginate,// page button
- "bFilter": false,// search bar
- "bAutoWidth":true,//automatically set the column width
- "bLengthChange": true,// record number in each row
- "iDisplayLength": 10,// row number in each page
- "bSort": setting.sort ? true : false,// 排序
- "bInfo": setting.info,// Showing 1 to 10 of 23 entries
- "bWidth": true,
- "bScrollCollapse": true,
- "sPaginationType": "bootstrap_extended", // page, a total of two kinds of style, another one is two_button
- "bProcessing": true,
- "bServerSide": false,
- "bDestroy": true,
- "bSortCellsTop": true,
- "sAjaxSource": setting.restUrl,
- "aoColumns": setting.columns,
- "aoColumnDefs": [
- {
- sDefaultContent: '',
- aTargets: [ '_all' ]
- }
- ],
- "fnServerData": function (sSource, aoData, fnCallback, oSettings) {
- oSettings.jqXHR = $.ajax({
- "type": 'get',
- "url": sSource,
- "dataType": "json",
- //"data":serverPageTable.getRestPara(cond,oSettings),
- "success": function (resp) {
- oSettings.iDraw = oSettings.iDraw + 1;
-
- var result = [];
- for(var i=0;i<resp.length;i++) {
- result.push(resp[i].currentStepInfo);
- }
- var data = {};
- data.aaData = result;
- var totalCounts = result.length;
-
- data.iTotalRecords = totalCounts;
- data.iTotalDisplayRecords = totalCounts;
- data.sEcho = oSettings;
- fnCallback(data);
- },
- "error": function(resp) {
- var data = {};
- data.aaData = [];
- var totalCounts = 0;
-
- data.iTotalRecords = totalCounts;
- data.iTotalDisplayRecords = totalCounts;
- data.sEcho = oSettings;
- fnCallback(data);
- }
- });
- }
- });
-}; \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmController.js
deleted file mode 100644
index 1c1e39d9..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmController.js
+++ /dev/null
@@ -1,254 +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: "hmController",
- $tableId : "ict_host_table",
- $hostTableFields : {// table columns
- table: [
- {"mData": "id", "name": "ID", "bVisible": false},
- {"mData": "name", "name": $.i18n.prop("nfv-host-iui-field-name")},
- {"mData": "size", "name": $.i18n.prop("nfv-host-iui-field-size")},
- {"mData": "vimId", "name": "VIMID", "bVisible": false},
- {"mData": "vimName", "name": "VIM"},
- {"mData": "vimUser", "name": $.i18n.prop("nfv-host-iui-field-vimUser")},
- {"mData": "createTime", "name": $.i18n.prop("nfv-host-iui-field-createTime")},
- {"mData": "progress", "name": $.i18n.prop("nfv-host-iui-field-progress"), "fnRender" : hmUtil.progressRender},
- {"mData": "status", "name": $.i18n.prop("nfv-host-iui-field-status")},
- {"mData": null, "name": $.i18n.prop("nfv-host-iui-field-operation"), "fnRender" : hmUtil.actionRender}
- ]
- },
- $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 : {
- uploadHostImage: '/api/nsoc/v1/hostimages',
- queryHostInfoUrl: "/api/nsoc/v1/hostimages",
- delHostUrl: "/api/nsoc/v1/hostimages/",
- updateHostUrl: "/api/nsoc/v1/hostimages/",
- queryVimInfoUrl : "/api/roc/v1/resource/vims"
- },
- $initTable: function() {
- var setting = {
- language : vm.$language,
- paginate : true,
- info : true,
- columns : vm.$hostTableFields.table,
- restUrl : vm.$restUrl.queryHostInfoUrl,
- tableId : vm.$tableId
- };
- serverPageTable.initDataTable(setting, {}, vm.$tableId + '_div');
- },
- uploadHostImage : {
- vimSelectItems : [],
- tenant : "",
- localVisible : true,
- /*$initUpload : function() {
- var fileLanguage = getLanguage();
- if (lang == "zh-CN") {
- fileLanguage = "zh";
- } else {
- fileLanguage = "en";
- }
- $("#hostfile").fileinput({
- language: fileLanguage,
- showPreview : false,
- showUpload : false,
- uploadExtraData : function(){
- var index = $("#vim").val();
- var selectVim = vm.uploadHostImage.vimSelectItems[index];
- var vimid = selectVim.oid;
- var extraData = {
- url : $("#hosturl").val(),
- name : $("#hostName").val(),
- vimid : vimid
- }
- return extraData;
- },
- uploadUrl : vm.$restUrl.uploadHostImage,
- layoutTemplates : {progress : ''}, //hide progress
- ajaxSettings : {
- success : function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-host-iui-message-upload-success"), "success");
- refreshByCond();
- },
- error : function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-host-iui-message-upload-failed"), "warning");
- }
- }
- });
- },*/
- $initUpload : function() {
- var maxChunkSize = 20000000; //20M
- $("#hostForm").fileupload({
- url : vm.$restUrl.uploadHostImage,
- maxNumberOfFiles : 1,
- maxChunkSize : maxChunkSize,
- autoUpload : false,
- add : function(e, data) {
- $("#fileName").text(data.files[0].name);
- $("#fileremove").attr("disabled", false);
-
- $("#uploadBtn").remove();
- $('<button id="uploadBtn" class="btn blue1" type="button"/>')
- .text($.i18n.prop("nfv-software-iui-btn-upload"))
- .appendTo($(".modal-footer")[0])
- .click(function () {
- var index = $("#vim").val();
- var selectVim = vm.uploadHostImage.vimSelectItems[index];
- var vimid = selectVim.oid;
- var extData = {
- url : $("#hosturl").val(),
- name : $("#hostName").val(),
- vimid : vimid,
- imageId : ""
- };
- vm.uploadHostImage.$uploadFile(data, extData);
- });
- $("#fileremove").click(function(){
- $("#fileName").text("");
- $("#uploadBtn").attr("disabled", true);
- $("#fileremove").attr("disabled", true);
- });
- },
- done : function(e, data) {
- refreshByCond();
- },
- fail : function(e, data) {
- commonUtil.showMessage($.i18n.prop("nfv-host-iui-message-upload-failed"), "danger");
- },
- chunkdone : function(e, data) {
- //get imageid from server and send it to server
- var imageId = data.jqXHR.responseText;
- data.formData.imageId = imageId;
- //the first chunk file is uploaded, refresh table
- if(data.loaded <= maxChunkSize) {
- refreshByCond();
- }
- },
- chunkfail : function(e, data) {
- var imageId = data.formData.imageId;
- if(imageId) {
- $.ajax({
- type : "PUT",
- async : false, //to prevent the ajax request has been cancelled
- url : vm.$restUrl.updateHostUrl + imageId + "?progress=fail",
- success : function() {
- //refreshByCond();
- }
- });
- }
- }
- });
- },
- $showUploadImage: function() {
- hmUtil.queryVimInfo();
- $("#fileName").text("");
- $("#hosturl").val("");
- $("#hostName").val("");
-
- $("#uploadImage").modal("show");
- $('.btn-file').removeClass("btn-primary").addClass("blue1");
- $(".form-group").each(function () {
- $(this).removeClass('has-success')
- .removeClass('has-error')
- .find(".help-block").remove();
- });
- },
- $uploadFile : function(data, extData) {
- var form = $("#hostForm");
- if(!form.valid()) {
- return false;
- }
-
- if(vm.uploadHostImage.localVisible) {
- $("#hostForm").fileupload({ formData : extData });
- data.submit();
- } else {
- $.ajax({
- type : "POST",
- contentType : "application/x-www-form-urlencoded; charset=UTF-8",
- url : vm.$restUrl.uploadHostImage + "?url=" + extData.url
- + "&name=" + extData.name + "&vimid=" + extData.vimid,
- success : function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-host-iui-message-upload-success"), "success");
- refreshByCond();
- },
- error : function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-host-iui-message-upload-failed"), "warning");
- }
- });
- }
- $("#uploadImage").modal("hide");
- },
- $changeEvent : function() {
- var index = $("#vim").val();
- var selectVim = vm.uploadHostImage.vimSelectItems[index];
- if (selectVim) {
- $("#tenant").val(selectVim.user);
- }
- },
- $showLocalOrUrl : function(type) {
- $(".form-group").each(function () {
- $(this).removeClass('has-success')
- .removeClass('has-error')
- .find(".help-block").remove();
- });
- type == "local" ? vm.uploadHostImage.localVisible = true : vm.uploadHostImage.localVisible = false;
- }
- },
- initTenant : function(action) { //init tenant value
- if (action === "add") {
- vm.uploadHostImage.$changeEvent();
- }
- },
- $initCometd : function() {
- commonUtil.registerCometdMessage("/api/nsocnotification/v1", "/hostimages/update", function(message) {
- var table = $('#' + vm.$tableId).dataTable();
- var tableData = table.fnGetData();
- var image = message.image;
- if(image) {
- for (var i=0; i<tableData.length; i++) {
- if(tableData[i]["id"] == image.id) {
- table.fnUpdate(image.size, i, 2, false, false);
- table.fnUpdate(image.status, i, 8, false, false);
- }
- }
- }
- });
- }
-});
-avalon.scan();
-vm.$initTable();
-vm.uploadHostImage.$initUpload();
-vm.$initCometd();
-
-var refreshByCond = function() {
- vm.$initTable();
-}; \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmUtil.js
deleted file mode 100644
index aa0ec468..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/hmUtil.js
+++ /dev/null
@@ -1,59 +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 hmUtil = {};
-
-hmUtil.actionRender = function(obj) {
- return '<a href="#" class="btn-xs grey btn-editable" onclick="hmUtil.delHost(\''
- + obj.aData.id + '\', \'' + obj.aData.vimId + '\')"><i class="ict-delete"></i>'
- + $.i18n.prop('nfv-host-iui-operation-delete') + '</a>';
-}
-
-hmUtil.progressRender = function(obj) {
- return $.i18n.prop("nfv-host-iui-progress-" + obj.aData.progress);
-}
-
-hmUtil.delHost = function(id, vimId) {
- bootbox.confirm($.i18n.prop("nfv-host-iui-message-delete-confirm"), function(result){
- if(result) {
- $.ajax({
- type : "DELETE",
- url : vm.$restUrl.delHostUrl + id + "?vimid=" + vimId,
- dataType : "json",
- success : function(resp) {
- if (resp) {
- commonUtil.showMessage($.i18n.prop("nfv-host-iui-message-delete-success"), "success");
- refreshByCond();
- }
- },
- error : function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-host-iui-message-delete-failed"), "warning");
- }
- });
- }
- });
-}
-
-hmUtil.queryVimInfo = function() {
- $.get(
- vm.$restUrl.queryVimInfoUrl,
- function(resp) {
- if (resp) {
- vm.uploadHostImage.vimSelectItems = resp.data;
- }
- },
- "json"
- );
-} \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/host-validate.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/host-validate.js
deleted file mode 100644
index f6000dd0..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/hostMirror/host-validate.js
+++ /dev/null
@@ -1,56 +0,0 @@
-$(function(){
- var form = $("#hostForm");
- var error = $('.alert-danger', form);
- var success = $('.alert-success', form);
-
- form.validate({
- doNotHideMessage : true,
- errorElement : 'span',
- errorClass : 'help-block',
- focusInvalid : false,
- rules : {
- hosturl : {
- required : true,
- url : true
- },
- hostName : {
- required : true
- },
- vim : {
- required : true
- }
- },
- messages : {
- hosturl : {
- required : $.i18n.prop('nfv-host-iui-validate-hosturl-required'),
- url : $.i18n.prop('nfv-host-iui-validate-hosturl-url')
- },
- hostName : {
- required : $.i18n.prop('nfv-host-iui-validate-hostName')
- },
- vim : {
- required : $.i18n.prop('nfv-host-iui-validate-vim')
- }
- },
- 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/package/pmController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/package/pmController.js
deleted file mode 100644
index cb7e59f9..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/package/pmController.js
+++ /dev/null
@@ -1,223 +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.
- */
-avalon.config({
- interpolate: ["<!--", "-->"]
-});
-
-var vm = avalon.define({
- $id: "pmController",
- $tableId : "ict_package_table",
- $packageTableFields : {// table columns
- table: [
- {"mData": "name", name: $.i18n.prop("nfv-package-iui-field-name")},
- {"mData": "type", name: $.i18n.prop("nfv-package-iui-field-type")},
- {"mData": "size", name: $.i18n.prop("nfv-package-iui-field-size")},
- {"mData": "createTime", name: $.i18n.prop("nfv-package-iui-field-createTime")},
- {"mData": "status", name: $.i18n.prop("nfv-package-iui-field-status"), "fnRender" : pmUtil.statusRender},
- {"mData": null, name: $.i18n.prop("nfv-package-iui-field-operation"), "fnRender" : pmUtil.actionRender}
- ]
- },
- $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 : {
- queryPackageInfoUrl: "/api/nsoc/v1/csars",
- uploadPackageUrl: "/api/nsoc/v1/csars",
- delPackageUrl: "/api/nsoc/v1/csars",
- changePackageStatusUrl : "/api/nsoc/v1/csars"
- },
- $getPackageCond: function() {
- var cond = {};
- return cond;
- },
- $initTable: function() {
- var setting = {
- language : vm.$language,
- paginate : true,
- info : true,
- columns : vm.$packageTableFields.table,
- restUrl : vm.$restUrl.queryPackageInfoUrl + "?deletionPending=false",
- tableId : vm.$tableId
- };
- serverPageTable.initDataTable(setting, vm.$getPackageCond(),
- vm.$tableId + '_div');
- },
- /*$initUpload : function() {
- var fileLanguage = getLanguage();
- if (lang == "zh-CN") {
- fileLanguage = "zh";
- } else {
- fileLanguage = "en";
- }
- $("#csarFile").fileinput({
- language: fileLanguage,
- showPreview : true,
- uploadUrl : vm.$restUrl.uploadPackageUrl,
- uploadAsync : true,
- layoutTemplates : {
- actions : '' //hide the delete button and upload button
- },
- allowedFileExtensions : ['zip','csar'],
- allowedPreviewTypes : ['image'],
- previewSettings : {
- other: {width: '160px', height: '20px'}
- },
- dropZoneTitleClass : 'package-drop-zone-title',
- ajaxSettings : {
- success : function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-upload-success"), 'success');
- refreshByCond();
- }
- },
- elErrorContainer : '#fileError',
- showAjaxErrorDetails : false
- });
- $('#csarFile').on('fileuploaderror', function(event, data, previewId, index) {
- $('#fileError').hide();
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-upload-fail"), 'danger');
- });
-
- $('#csarFile').on('fileloaded', function(event, file, previewId, index, reader) {
- //hide original upload button
- $('a.fileinput-upload-button').hide();
- $('#confirm').show();
- });
-
- $('.btn-file').removeClass("btn-primary").addClass("blue1");
-
- //replace upload button for confirm
- var css = $('a.fileinput-upload-button').attr("class");
- var children = $('a.fileinput-upload-button').eq(0).html();
- $('<button id="confirm" class="'+css+'">'+children+'</button>').insertAfter('.fileinput-upload-button');
- $('#confirm').on('click', function(e){
- e.preventDefault();
-
- var fileName = $('.file-caption-name').eq(0).text();
- var existPackage = pmUtil.getExistPackageByName(fileName);
- if(existPackage == 0){//0:package is not exist
- $('a.fileinput-upload-button').trigger('click');
- return;
- }
- var msg = "";
- if(existPackage == 1){//1:package not exist, instance reference this csar
- msg = $.i18n.prop("nfv-package-iui-message-upload-csar-deletionpending");
- }
- if(existPackage == 2){//2:package exist
- msg = $.i18n.prop("nfv-package-iui-message-upload-csar-exist");
- }
-
- bootbox.confirm(msg, function(result){
- if(result) {
- $('a.fileinput-upload-button').trigger('click');
- }
- });
- });
- },*/
- $initUpload : function() {
- $("#fileupload").fileupload({
- url : vm.$restUrl.uploadPackageUrl,
- dropZone: $('#dropzone'),
- maxNumberOfFiles : 1,
- maxChunkSize : 20000000, //20M
- autoUpload : false,
- add : function(e, data) {
- $("#bar").css('width', '0%');
- $("#persent").text('0%');
- $("#fileName").text(data.files[0].name);
- $("#fileremove").attr("disabled", false);
- $("#filesubmit").attr("disabled", false);
-
- $("#filesubmit").remove();
- $('<button id="filesubmit" class="btn btn-default" type="button"/>').text("上传")
- .appendTo($(".input-group-btn")[0])
- .click(function () {
- var fileName = data.files[0].name;
- var existPackage = pmUtil.getExistPackageByName(fileName);
- if(existPackage == 0){//0:package is not exist
- $(".progress").addClass("active");
- data.submit();
- } else {
- var msg = "";
- if(existPackage == 1){//1:package not exist, instance reference this csar
- msg = $.i18n.prop("nfv-package-iui-message-upload-csar-deletionpending");
- }
- if(existPackage == 2){//2:package exist
- msg = $.i18n.prop("nfv-package-iui-message-upload-csar-exist");
- }
-
- bootbox.confirm(msg, function(result){
- if(result) {
- $(".progress").addClass("active");
- data.submit();
- }
- });
- }
- });
- $("#fileremove").click(function(){
- $("#bar").css('width', '0%');
- $("#persent").text("");
- $("#fileName").text("");
- $("#filesubmit").attr("disabled", true);
- $("#fileremove").attr("disabled", true);
- });
- },
- done : function(e, data) {
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-upload-success"), 'success');
- },
- fail : function(e, data) {
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-upload-fail"), 'danger');
- },
- always : function(e, data) {
- refreshByCond();
- $(".progress").removeClass("active");
- $("#bar").css('width', '100%');
- $("#persent").text('100%');
- },
- progressall : function(e ,data) {
- var progress = parseInt(data.loaded / data.total * 80, 10);
- $("#bar").css('width', progress + '%');
- $("#persent").text(progress + '%');
- }
- });
- },
- $initCometd : function() {
- commonUtil.registerCometdMessage("/api/nsocnotification/v1", "/package/delete", function(message) {
- pmUtil.updateDeletedPackageStatus(message);
- });
- }
-});
-avalon.scan();
-vm.$initUpload();
-vm.$initTable();
-vm.$initCometd();
-
-var refreshByCond = function() {
- vm.$initTable();
-}; \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/package/pmUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/package/pmUtil.js
deleted file mode 100644
index 6a7f0fc4..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/package/pmUtil.js
+++ /dev/null
@@ -1,137 +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 pmUtil = {};
-
-pmUtil.actionRender = function(obj) {
- return '<a href="#" class="btn-xs grey btn-editable" onclick="pmUtil.delPackage(\'' + obj.aData.name + '\')">'
- + '<i class=\"ict-delete\"></i>' + $.i18n.prop('nfv-software-iui-action-delete') + '</a>';
-}
-
-pmUtil.statusRender = function(obj) {
- var status;
- var attr;
- switch(obj.aData.status) {
- case "Enabled" :
- attr = 'class="label label-success"';
- status = $.i18n.prop("nfv-package-iui-status-active");
- break;
- case "activating" :
- attr = 'class="label label-info"';
- status = $.i18n.prop("nfv-package-iui-status-activating");
- break;
- case "deleting" :
- attr = 'class="label label-warning"';
- status = $.i18n.prop("nfv-package-iui-status-deleting");
- break;
- case "deletefail" :
- attr = 'class="label label-danger"';
- status = $.i18n.prop("nfv-package-iui-status-deletefail");
- break;
- default :
- attr = 'class="label label-info status" data-toggle="tooltip" title="' + $.i18n.prop("nfv-package-iui-status-tip") + '"'
- + 'onclick="pmUtil.changeStatus(\'' + obj.aData.name + '\',\'Enabled\')"';
- status = $.i18n.prop("nfv-package-iui-status-inactive");
- }
- return '<span ' + attr + '>' + status + '</span>';
-}
-
-pmUtil.changeStatus = function(name, status) {
- pmUtil.changeTableStatus(name, "activating");
- $.ajax({
- type : "PUT",
- url : vm.$restUrl.changePackageStatusUrl + "?csarName=" + name + "&status=" + status,
- success : function() {
- refreshByCond();
- },
- error : function() {
- refreshByCond();
- }
- });
-}
-
-pmUtil.changeTableStatus = function(name, status) {
- var table = $("#" + vm.$tableId).dataTable();
- var tableData = table.fnGetData();
- for (var i=0; i<tableData.length; i++) {
- if(tableData[i]["name"] == name) {
- table.fnUpdate(status, i, 4, false, false);
- break;
- }
- }
-}
-
-pmUtil.isRowDeletingStatus = function(name) {
- var table = $("#" + vm.$tableId).dataTable();
- var tableData = table.fnGetData();
- for (var i=0; i<tableData.length; i++) {
- if(tableData[i]["name"] == name &&
- tableData[i]["status"].indexOf($.i18n.prop("nfv-package-iui-status-deleting")) > -1) {
- return true;
- }
- }
- return false;
-}
-
-pmUtil.delPackage = function(name) {
- if(pmUtil.isRowDeletingStatus(name)){
- return;
- }
-
- bootbox.confirm($.i18n.prop("nfv-package-iui-message-delete-confirm"), function(result){
- if(result) {
- pmUtil.changeTableStatus(name, "deleting");
- var url = vm.$restUrl.delPackageUrl + "?csarName=" + name;
- commonUtil.delete(url, function(resp) {
-
- });
- }
- });
-}
-
-//query packages exist
-//0: the package does not exist
-//1: the package does not exist, but the instance cite this package
-//2: the package exists
-pmUtil.getExistPackageByName = function(name) {
- var index = name.indexOf(".csar") || name.indexOf(".zip");
- if(index > 0){
- name = name.substring(0, index);
- }
- var result = $.ajax({
- type : "GET",
- url : vm.$restUrl.queryPackageInfoUrl + "?csarName=" + name,
- async: false
- });
- var data = result.responseJSON;
- if(data != undefined && data.length == 0){
- return 0;
- }
- var result = data[0];
- if(result.deletionPending != undefined && result.deletionPending == "true"){
- return 1;
- }
-
- return 2;
-}
-
-pmUtil.updateDeletedPackageStatus = function(message) {
- if(message.status == "true" || message.status == "deletionPending") {
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-delete-success"), "success");
- refreshByCond();
- } else {
- pmUtil.changeTableStatus(message.csarid, "deletefail");
- }
-}
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smController.js
deleted file mode 100644
index ea03c96d..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smController.js
+++ /dev/null
@@ -1,147 +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: "smController",
- $tableId : "ict_software_table",
- $softwareTableFields : {// table columns
- table: [
- {"mData": "imageName", name: $.i18n.prop("nfv-software-iui-field-name")},
- {"mData": "size", name: $.i18n.prop("nfv-software-iui-field-size")},
- {"mData": "type", name: $.i18n.prop("nfv-software-iui-field-type")},
- {"mData": "version", name: $.i18n.prop("nfv-software-iui-field-version")},
- {"mData": "createTime", name: $.i18n.prop("nfv-software-iui-field-createTime")},
- {"mData": "location", name: $.i18n.prop("nfv-software-iui-field-location")},
- {"mData": null, name: $.i18n.prop("nfv-software-iui-field-operation"), "fnRender" : smUtil.actionRender}
- ]
- },
- $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 : {
- uploadSoftwareImageUrl: "/api/nsoc/v1/softwareimages",
- querySoftwareImageUrl: "/api/nsoc/v1/softwareimages",
- delSoftwareImageUrl: "/api/nsoc/v1/softwareimages"
- },
- $getSoftwareCond: function() {
- return {};
- },
- $initTable: function() {
- var setting = {
- language : vm.$language,
- paginate : true,
- info : true,
- columns : vm.$softwareTableFields.table,
- restUrl : vm.$restUrl.querySoftwareImageUrl,
- tableId : vm.$tableId
- };
- serverPageTable.initDataTable(setting, vm.$getSoftwareCond(),
- vm.$tableId + '_div');
- },
- $initCometd : function() {
- commonUtil.registerCometdMessage("/api/nsocnotification/v1", "/softwareimages/uploadProcess", function(message){
- var table = $('#' + vm.$tableId).dataTable();
- var tableData = table.fnGetData();
- //var message = JSON.parse(jsonMessage);
- if(message.softwareImage) {
- var imageArray = JSON.parse(message.softwareImage);
- table.fnAddData(imageArray[0], true);
- } else {
- for (var i=0; i<tableData.length; i++) {
- if(tableData[i]["imageName"] == message.imageName) {
- table.fnUpdate(message.progress , i, 2, false, false);
- }
- }
- }
- });
- },
- uploadSoftwareImage : {
- $initUpload : function() {
- $("#softwareFile").fileupload({
- url : vm.$restUrl.uploadSoftwareImageUrl,
- //dropZone: $('#dropzone'),
- maxNumberOfFiles : 1,
- maxChunkSize : 20000000,
- autoUpload : false,
- add : function(e, data) {
- $("#bar").css('width', '0%');
- $("#persent").text('0%');
- $("#fileName").text(data.files[0].name);
- $("#fileremove").attr("disabled", false);
-
- $("#uploadBtn").remove();
- $('<button id="uploadBtn" class="btn blue1" type="button"/>')
- .text($.i18n.prop("nfv-software-iui-btn-upload"))
- .appendTo($(".modal-footer")[0])
- .click(function () {
- var extData = {
- type : $("#type").val(),
- version : $("#version").val()
- };
- $("#softwareFile").fileupload({ formData : extData });
- data.submit();
- $("#uploadImage").modal("hide");
- });
- $("#fileremove").click(function(){
- //$("#bar").css('width', '0%');
- //$("#persent").text("");
- $("#fileName").text("");
- $("#uploadBtn").attr("disabled", true);
- $("#fileremove").attr("disabled", true);
- });
- },
- chunkalways : function(e, data) {
- //refreshByCond();
- console.log("success");
- $("#bar").css('width', '100%');
- $("#persent").text('100%');
- },
- progressall : function(e ,data) {
- var progress = parseInt(data.loaded / data.total * 80, 10);
- $("#bar").css('width', progress + '%');
- $("#persent").text(progress + '%');
- }
- });
- },
- $showUploadImage: function() {
- $("#type").val("");
- $("#version").val("");
- $("#fileName").text("");
- $("#uploadImage").modal("show");
- }
- }
-});
-avalon.scan();
-vm.uploadSoftwareImage.$initUpload();
-vm.$initTable();
-vm.$initCometd();
-
-var refreshByCond = function() {
- vm.$initTable();
-}; \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smUtil.js
deleted file mode 100644
index 6381c15b..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/softwareMirror/smUtil.js
+++ /dev/null
@@ -1,33 +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 smUtil = {};
-
-smUtil.actionRender = function(obj) {
- return '<a href="#" class="btn-xs grey btn-editable" onclick="smUtil.delSoftWare(\'' + obj.aData.imageName + '\')">'
- + '<i class=\"ict-delete\"></i>' + $.i18n.prop('nfv-software-iui-action-delete') + '</a>';
-}
-
-smUtil.delSoftWare = function(imageName) {
- bootbox.confirm($.i18n.prop("nfv-software-iui-message-delete-confirm"), function(result){
- if(result) {
- var url = vm.$restUrl.delSoftwareImageUrl + "?imageName=" + imageName;
- commonUtil.delete(url, function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-software-iui-message-delete-success"), "success");
- refreshByCond();
- });
- }
- });
-} \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmController.js
deleted file mode 100644
index 196ed50f..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmController.js
+++ /dev/null
@@ -1,83 +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.
- */
-avalon.config({
- interpolate: ["<!--", "-->"]
-});
-
-var vm = avalon.define({
- $id: "tmController",
- $tableId : "ict_template_table",
- $templateTableFields : {// table columns
- table: [
- {"mData": "templateid", name: "ID", "bVisible": false},
- {"mData": "templatename", name: $.i18n.prop("nfv-template-iui-field-templatename"), "fnRender" : tmUtil.nameRender},
- {"mData": "producttype", name: $.i18n.prop("nfv-template-iui-field-producttype")},
- {"mData": "vendor", name: $.i18n.prop("nfv-template-iui-field-vendor")},
- {"mData": "version", name: $.i18n.prop("nfv-template-iui-field-version")},
- {"mData": "flavors", name: $.i18n.prop("nfv-template-iui-field-flavor"), "fnRender" : tmUtil.flavorRender},
- {"mData": "nfvtype", name: "NFVTYPE", "bVisible": 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")
- }
- },
- $restUrl : {
- queryTemplateInfoUrl : "/api/nsoc/v1/servicetemplates?deletionPending=false"
- },
- $getTemplateCond: function() {
- var cond = {};
- return cond;
- },
- $initTable: function() {
- var setting = {};
- setting.language = vm.$language;
- setting.paginate = true;
- setting.info = true;
- setting.columns = vm.$templateTableFields.table;
- setting.restUrl = vm.$restUrl.queryTemplateInfoUrl;
- setting.tableId = vm.$tableId;
- serverPageTable.initDataTable(setting, vm.$getTemplateCond(),
- vm.$tableId + '_div');
- },
- $openDetail : function(templateId, rowId) {
- var oSelect = $("tbody tr select").eq(rowId);
- var flavor = "";
- if(oSelect.length) {
- oSelect.find("option:selected").val();
- }
- window.open("./templateDetail.html?templateId="+templateId+"&flavor="+flavor,"_self");
- },
-});
-avalon.scan();
-vm.$initTable();
-
-var refreshByCond = function() {
- vm.$initTable();
-}; \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailController.js
deleted file mode 100644
index f4207630..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailController.js
+++ /dev/null
@@ -1,241 +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 : "tmDetailController",
- 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")
- }
- },
- $restUrl : {
- queryNodeTemplateUrl : "/api/nsoc/v1/servicetemplates/{0}/nodetemplates"
- },
- $init : function() {
- $.ajax({
- type : "GET",
- url : vm.$restUrl.queryNodeTemplateUrl,
- success : function(resp) {
- if(resp) {
- vm.nodesTab.nodeTemplateData = [];
- for(var i=0; i<resp.length; i++) {
- //generate node table display data
- var nodeTemplate = topoUtil.generateNodeTemplate(resp[i]);
- vm.nodesTab.nodeTemplateData.push(nodeTemplate);
- }
- vm.nodesTab.nodesDetail.nodeTemplateDetailData = resp;
- //generate topology graph display data
- vm.topologyTab.topoTemplateData = topoUtil.generateTopoTemplate(vm.nodesTab.nodeTemplateData.$model);
- //initialize topology data
- topoUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
- vm.nodesTab.$initNodesTab();
- }
- },
- error : function() {
- commonUtil.showMessage($.i18n.prop("nfv-topology-iui-message-error"), "danger");
- }
- });
- },
- 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: false,
- returnBtnVisible : false,
- $getColor: function(index) {
- return topoUtil.getColor(index);
- },
- $getCidr: function(properties){
- return topoUtil.getCidr(properties);
- },
- $getCpTop: function(index, parentBoxId){
- return topoUtil.getCpTop(index, parentBoxId);
- },
- $initTopology : function() {
- topoUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
- },
- $showTopo:function(id, name){
- vm.nodesTab.nodesDetail.$showDetails("block", id, name);
- },
- $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 : {
- nodeTemplateData: [],
- $nodesTabId : "ict_nodes_table",
- $nodesTabFields : {// table columns
- table: [
- {"mData": "id", name: "ID", "bVisible": false},
- {"mData": "name", name: $.i18n.prop("nfv-templateDetail-iui-field-nodetypename"), "bSortable": true, "fnRender" : tmDetailUtil.nameRender},
- {"mData": "type", name: $.i18n.prop("nfv-templateDetail-iui-field-type"), "bSortable": false},
- {"mData": "containedin", name: $.i18n.prop("nfv-templateDetail-iui-field-containedin"), "bSortable": false},
- {"mData": "deployedon", name: $.i18n.prop("nfv-templateDetail-iui-field-deployedon"), "bSortable": false},
- {"mData": "connectedto", name: $.i18n.prop("nfv-templateDetail-iui-field-connectedto"), "bSortable": false},
- {"mData": "virtuallinksto", name: $.i18n.prop("nfv-templateDetail-iui-field-virtuallinksto"), "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.tableId = vm.nodesTab.$nodesTabId;
- serverPageTable.initTableWithData(setting, vm.nodesTab.$nodesTabId + '_div', vm.nodesTab.nodeTemplateData.$model);
- },
- //Nodes Details
- nodesDetail : {
- nodeTemplateDetailData: [],
- 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) {
- vm.nodesTab.nodesDetail.isShow = isShow;
- if (isShow == "block") {
- vm.nodesTab.nodesDetail.detailTitle = nodetypename + " " + $.i18n.prop("nfv-templateDetail-nodesTab-iui-title-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);
- //initialize three tables of nodedetail
- $.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": "currentStepId", name: "ID", "bVisible": false},
- {"mData": "currentStepName", name: $.i18n.prop("nfv-templateDetail-executionTab-iui-field-currentStepName")},
- {"mData": "currentStepStatus", name: $.i18n.prop("nfv-templateDetail-executionTab-iui-field-currentStepStatus")},
- {"mData": "currentStepDesc", name: $.i18n.prop("nfv-templateDetail-executionTab-iui-field-currentStepDesc")},
- {"mData": "currentTime", name: $.i18n.prop("nfv-templateDetail-executionTab-iui-field-executionTime")},
- {"mData": "allSteps", name: "allSteps", "bVisible": false}
- ]
- },
- $queryEventsInfoUrl: "/api/nsoc/appinstance/operateschedule?instanceId=",
- $queryStepUrl: "",
- $getEventsCond: function() {
- var cond = {};
- return cond;
- },
- $initEventsTable: function() {
- console.log("initEventsTable ");
- var setting = {};
- setting.language = vm.$language;
- setting.paginate = false;
- setting.info = false;
- setting.columns = vm.executionTab.$eventsTabFields.table;
- setting.restUrl = vm.executionTab.$queryEventsInfoUrl;
- setting.tableId = vm.executionTab.$eventsTabId;
- serverPageTable.initDataTable(setting, vm.executionTab.$getEventsCond(),
- vm.executionTab.$eventsTabId + '_div');
- },
- $operation : "",
- steps : [],
- $init: function() {
- vm.executionTab.$initEventsTable();
- }
- }
-});
-
-var initParam = function() { //initialize template detail params
- var paramStr = window.location.search.substring(1);
- if(paramStr.length > 0) {
- var params = paramStr.split("&");
- var templateId = params[0].substring(params[0].indexOf('=') + 1);
- var flavor = params[1].substring(params[1].indexOf('=') + 1);
- avalon.scan();
-
- vm.templateId = templateId;
- vm.$restUrl.queryNodeTemplateUrl = commonUtil.format(vm.$restUrl.queryNodeTemplateUrl, templateId);
-
- if(flavor) {
- vm.$restUrl.queryNodeTemplateUrl += "?flavor=" + flavor;
- }
-
- vm.$init();
- }
-};
-initParam(); \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailUtil.js
deleted file mode 100644
index 2edc9c37..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmDetailUtil.js
+++ /dev/null
@@ -1,44 +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 tmDetailUtil = {};
-tmDetailUtil.timer = null;
-
-tmDetailUtil.nameRender = function(obj) {
- return '<a href="#" onclick="vm.nodesTab.nodesDetail.$showDetails('
- + '\'block\',\'' + obj.aData.id + '\', \'' + obj.aData.name + '\')">' + obj.aData.name + '</a>';
-}
-
-tmDetailUtil.initSteps = function() {
- $.ajax({
- type : "GET",
- url : vm.executionTab.$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
- });
- }
- }
- }
- });
-} \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmUtil.js
deleted file mode 100644
index 9077baa5..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/tmUtil.js
+++ /dev/null
@@ -1,46 +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 tmUtil = {};
-
-tmUtil.nameRender = function(obj) {
- return '<a href="#" onclick="vm.$openDetail(\'' + obj.aData.templateid
- + '\',' + obj.iDataRow + ')">' + obj.aData.templatename + '</a>';
-}
-
-tmUtil.flavorRender = function(obj) {
- var flavors = obj.aData.flavors;
- var result = "";
- if(flavors && flavors.length) {
- var optionHtml = "";
- for(var i=0;i<flavors.length;i++) {
- optionHtml += '<option>' + flavors[i].name + '</option>';
- }
- result = '<select>' + optionHtml + '</select>';
- }
- return result;
-}
-
-/*tmUtil.openDetail = function(obj) {
- if (obj) {
- var framework;
- if(window.parent.ZteFrameWork){
- framework = window.parent.ZteFrameWork;
- }else{
- return;
- }
- framework.goToURLByIDAndNewAction('eco-nsoc-templateDetail', 'initParam("' + obj.templateid + '")');
- }
-}*/ \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/topoUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/template/topoUtil.js
deleted file mode 100644
index bcb7e732..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/template/topoUtil.js
+++ /dev/null
@@ -1,617 +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 topoUtil = {};
-topoUtil.topoDatas=[];
-topoUtil.svgOffsetWidth = 0;
-
-/**
- * recursive generate tree structure of the topology graph data
- * @param {[type]} rootName [description]
- * @param {[type]} rootNode [description]
- * @return {[type]} [description]
- */
-topoUtil.generateSortData = function(rootName,rootNode) {
- for(var i=0;i<topoUtil.topoDatas.length;i++) {
- if(topoUtil.topoDatas[i].containIn == rootName){
- rootNode["children"].push(topoUtil.topoDatas[i]);
- var currentNum = rootNode["children"].length-1;
- topoUtil.generateSortData(topoUtil.topoDatas[i].id, rootNode["children"][currentNum])
- }
- }
-}
-
-/**
- * generate CP data, CP is inserted into the VDU or VNF child nodes
- * @param {[type]} cpNode [description]
- * @param {[type]} rootNode [description]
- * @return {[type]} [description]
- */
-topoUtil.generateCpData = function(cpNode, rootNode) {
- for(var i=0;i<cpNode.length;i++){
- for(var j=0;j<rootNode.length;j++) {
- var node = rootNode[j];
- if(cpNode[i].virtualbindsto == node.id) {
- rootNode[j].cp.push(cpNode[i]);
- break;
- }
- }
- }
-}
-
-/**
- * generate NETWORK and VL data, VL is inserted into the NETWORK child nodes
- * @param {[type]} rootNode [description]
- * @return {[type]} [description]
- */
-topoUtil.generateNetworkData = function(vlanNode, networkNode) {
- if(networkNode.length == 0) {
- //no NETWORK, just VL
- var network = {
- subnets : vlanNode
- }
- networkNode.push(network);
- } else {
- //NETWORK and VL
- for(var i=0;i<networkNode.length;i++) {
- networkNode[i].subnets = [];
- for(var j=0;j<vlanNode.length;j++){
- var network = vlanNode[j].virtuallinksto;
- if(network == networkNode[i].id) {
- networkNode[i].subnets.push(vlanNode[j]);
- }
- }
- }
- }
-}
-
-/**
- * initialize topology graph data
- * @param {[type]} resp [description]
- * @param {[type]} nodeInstanceData [description]
- * @return {[type]} [description]
- */
-topoUtil.initTopoData = function(resp, nodeInstanceData) {
- if(resp && resp.length > 0) {
- var datas = resp;
- var boxData = [];
- var networks = [];
- var vlanData = [];
- var cpData = [];
- for(var i=0;i<datas.length;i++){
- if (datas[i]["containIn"] == "") {
- datas[i]["containIn"] = "--";
- }
- //add the property of children for all nodes
- datas[i]["children"] = [];
- datas[i]["cp"] = [];
- //count instances number
- if (nodeInstanceData) {
- datas[i]["num"] = topoUtil.getInstanceNum(datas[i], nodeInstanceData);
- }
- //empty currentLinkNum
- datas[i]["currentLinkNum"] = 0;
- //distinguish VL, CP, NETWORK, VNF, VDU, VNFC from nodes to display topology graph
- var type = datas[i]["parentType"];
- if (type.toUpperCase().indexOf(".VL") > -1) {
- vlanData.push(datas[i]);
- } else if (type.toUpperCase().indexOf(".CP") > -1) {
- cpData.push(datas[i]);
- } else if(type.toUpperCase().indexOf(".NETWORK") > -1) {
- networks.push(datas[i]);
- } else if ((type.toUpperCase().indexOf(".VNF") > -1) || (type.toUpperCase().indexOf(".VDU") > -1)
- || (type.toUpperCase().indexOf(".VNFC") > -1)) {
- boxData.push(datas[i]);
- }
- }
-
- //generate CP nodes
- topoUtil.generateCpData(cpData, boxData);
- //generate VNF/NS tree data
- var rootNode = {"children":[]};
- topoUtil.topoDatas = boxData;
- topoUtil.generateSortData("--", rootNode);
- vm.topologyTab.boxTopoDatas = rootNode.children;
- //generate NETWORK and VL nodes
- topoUtil.generateNetworkData(vlanData, networks);
- vm.topologyTab.networkTopoDatas = networks;
-
- //draw topology graph
- topoUtil.topoDatas = datas;
- setTimeout("topoUtil.generateLine()", 100);
- //bind window object events
- topoUtil.initWindowEvent();
- }
-}
-
-/**
- * get node instances number
- * @param {[type]} nodeTemplate [description]
- * @param {[type]} nodeInstanceData [description]
- * @return {[type]} [description]
- */
-topoUtil.getInstanceNum = function(nodeTemplate, nodeInstanceData) {
- var num = 0;
- var id;
- if(nodeTemplate.properties && nodeTemplate.properties.vnfdid) {
- //ns嵌套vnf,ns中vnf的nodetemplate的属性vnfdid才是嵌套vnf的真实id
- id = nodeTemplate.properties.vnfdid;
- } else {
- id = nodeTemplate.id;
- }
-
- if(nodeInstanceData && nodeInstanceData.length > 0) {
- for (var j=0;j<nodeInstanceData.length;j++) {
- if(nodeInstanceData[j].nodeTemplateId == id) {
- num++;
- }
- }
- }
- return num;
-}
-
-topoUtil.getLineOffset = function(index) {
- return index*15;
-}
-/**
- * get node y coordinate offset, it is based on the total number of connections and the number of connections to
- * calculate the Y coordinate offset current connection
- * here's the connection refers connectsto relationship between VNC and VNC
- * @param {[type]} node current node object
- * @param {[type]} height current DOM object cliengtHeight
- * @return {[type]} Y coordinate offset
- */
-topoUtil.getNodeOffset = function(node, height) {
- var toNodeLinkNum = ++node.currentLinkNum;
- var totalLinkNum = node.inLinks.length + node.outLinks.length;
- totalLinkNum++;
- return (height/totalLinkNum)*toNodeLinkNum;
-}
-/**
- * get node object by name
- * @param {[type]} name node name
- * @return {[type]} node object data
- */
-topoUtil.getTopoDataById = function(id) {
- var node;
- for(var i=0;i<topoUtil.topoDatas.length;i++) {
- if(id == topoUtil.topoDatas[i].id) {
- node = topoUtil.topoDatas[i];
- }
- }
- return node;
-}
-
-topoUtil.pageX = function(elem) {
- return elem.offsetParent ? (elem.offsetLeft + topoUtil.pageX(elem.offsetParent)) : elem.offsetLeft;
-}
-
-topoUtil.pageY = function(elem) {
- return elem.offsetParent ? (elem.offsetTop + topoUtil.pageY(elem.offsetParent)) : elem.offsetTop;
-}
-
-topoUtil.getHorizontalOffset = function(elem, elemArray) {
- var horizontalOffset = 0;
- for(var i=0;i<elemArray.length;i++) {
- var nodeTop = topoUtil.pageY(elemArray[i]);
- var fromTop = topoUtil.pageY(elem);
- if(fromTop == nodeTop) {
- horizontalOffset = topoUtil.getLineOffset(++horizontalIndex);
- }
- }
- return horizontalOffset;
-}
-
-topoUtil.getParentNode = function(elem) {
- return elem.className == "app" ? topoUtil.getParentNode(elem.offsetParent) : elem.offsetParent;
-}
-
-topoUtil.initElementSize = function() {
- var height=$(".bpContainer").height();
- $(".vlan").height() < height ? $(".vlan").height(height) : height;
-
- var networkWidth = $("#networks").width();
- var topoWidth = $("#topo").width();
- var bodyWidth = $("body").width();
- (networkWidth+topoWidth+50) > bodyWidth ? $("body").width(networkWidth+topoWidth+topoUtil.svgOffsetWidth+10) : $("body").width($("html").width());
-
- var containerHeight=$(".container-fluid").height();
- $(".coordinates").height(containerHeight).width($("body").width());
-}
-
-/**
- * get the widest VDU or VNF node to generate connect lines
- * @return {[type]} [description]
- */
-topoUtil.getMaxNodeRight = function() {
- var maxNode = {offsetWidth : 0};
- for(var i=0;i<topoUtil.topoDatas.length;i++) {
- var node = document.getElementById(topoUtil.topoDatas[i].id);
- if(node && (maxNode.offsetWidth < node.offsetWidth)) {
- maxNode = node;
- }
- }
- return topoUtil.pageX(maxNode) + maxNode.offsetWidth;
-}
-
-topoUtil.initWindowEvent = function() {
- $(window.frameElement).attr('scrolling', 'auto');
- $('body').css('overflow', 'scroll');
- $(window).scroll(function(){
- $("#right-menu").css("top",$(window).scrollTop()); //vertical scroll
- $("#right-menu").css("right",-1*$(window).scrollLeft()); //horizontal scroll
- }).unload(function(){
- $(window.frameElement).attr('scrolling', 'no');
- });
- //$(window).resize(topoUtil.generateLine);
-}
-
-/**
- * generate topology attachment
- * connectedto represent the connection between the VNFC and VNFC, virtuallinksto represent the connection between the VLAN and VDU
- * @return {[type]} [description]
- */
-topoUtil.generateLine = function() {
- topoUtil.initElementSize();
- var vduPath='';
- var vlPath='';
- var vduIndex=0;
- var vlIndex=0;
- var fromNodeArray = [];
- var horizontalIndex = 0;
- var maxNodeParentRight = topoUtil.getMaxNodeRight();
- for(var i=0;i<topoUtil.topoDatas.length;i++) {
- //connectedto
- if(topoUtil.topoDatas[i].connectedto !=""){
- var fromNode = document.getElementById(topoUtil.topoDatas[i].id);
- var horizontalOffset = 0;
- for(var k=0;k<fromNodeArray.length;k++) {
- //VNFC node in the same VDU, coordinate offset
- var nodeTop = topoUtil.pageY(fromNodeArray[k]);
- var fromTop = topoUtil.pageY(fromNode);
- if(fromTop == nodeTop) {
- horizontalOffset = topoUtil.getLineOffset(++horizontalIndex);
- }
- }
- fromNodeArray.push(fromNode);
- var fromNodeParent = topoUtil.getParentNode(fromNode);
- var toArray = topoUtil.topoDatas[i].connectedto.split(",");
- for (var j=0;j<toArray.length;j++) {
- var toNode = document.getElementById(toArray[j]);
- var toNodeParent = topoUtil.getParentNode(toNode);
- //Computing connection point and the connection point Y coordinate offset
- var fromNodeOffset = topoUtil.getNodeOffset(topoUtil.topoDatas[i], fromNode.clientHeight);
- var toNodeTopoData = topoUtil.getTopoDataById(toArray[j]);
- var toNodeOffset = topoUtil.getNodeOffset(toNodeTopoData, toNode.clientHeight);
- //X coordinate offset calculation link
- var xLineOffset = topoUtil.getLineOffset(++vduIndex);
- //Get the largest X coordinate offset is used to set the width of the body
- topoUtil.svgOffsetWidth = Math.max(xLineOffset, topoUtil.svgOffsetWidth);
-
- var fromNodeLeft = topoUtil.pageX(fromNode);
- var fromNodeRight = topoUtil.pageX(fromNode) + fromNode.offsetWidth;
- var fromNodeTop = topoUtil.pageY(fromNode);
-
- var toNodeLeft = topoUtil.pageX(toNode);
- var toNodeRight = topoUtil.pageX(toNode) + toNode.offsetWidth;
- var toNodeTop = topoUtil.pageY(toNode);
-
- var coord = '';
- if(fromNodeTop == toNodeTop) {
- if(fromNodeLeft < toNodeLeft) {
- coord = "M"+fromNodeRight+","+(fromNodeTop+horizontalOffset+fromNodeOffset)
- +" L"+toNodeLeft+","+(fromNodeTop+horizontalOffset+fromNodeOffset)
- } else {
- coord = "M"+fromNodeLeft+","+(fromNodeTop+horizontalOffset+fromNodeOffset)
- +" L"+toNodeRight+","+(fromNodeTop+horizontalOffset+fromNodeOffset);
- }
- } else {
- var nodeRight = maxNodeParentRight + xLineOffset;
- coord = "M"+fromNodeRight+","+(fromNodeTop+horizontalOffset+fromNodeOffset)
- +" L"+nodeRight+","+(fromNodeTop+horizontalOffset+fromNodeOffset)
- +" L"+nodeRight+","+(toNodeTop+toNodeOffset)
- +" L"+toNodeRight+","+(toNodeTop+toNodeOffset);
- }
- vduPath +='<path d="'+coord+'" marker-end="url(#arrowhead)" fill="none" stroke-dasharray="5,5" stroke="#7A7A7A" stroke-width="3px" shape-rendering="geometricPrecision"></path>';
- }
- }
-
- //virtuallinksto
- if(topoUtil.topoDatas[i].virtuallinksto !=""){
- var fromNode = document.getElementById(topoUtil.topoDatas[i].id);
- var toArray = topoUtil.topoDatas[i].virtuallinksto.split(",");
- for (var j=0;j<toArray.length;j++) {
- var toNode = document.getElementById(toArray[j]);
- if(toNode) {
- var yLineOffset = topoUtil.getLineOffset(j);
- var xLineOffset = topoUtil.getLineOffset(++vlIndex);
-
- var fromNodeLeft = topoUtil.pageX(fromNode);
- var fromNodeTop = topoUtil.pageY(fromNode);
-
- var toNodeRight = topoUtil.pageX(toNode) + toNode.offsetWidth;
- var toNodeTop = topoUtil.pageY(toNode);
-
- var coord = "";
- if(fromNodeTop == toNodeTop) {
- coord = "M"+fromNodeLeft+","+(fromNodeTop+fromNode.clientHeight/2+xLineOffset)
- +" L"+toNodeRight+","+(fromNodeTop+fromNode.clientHeight/2+xLineOffset);
- } else {
- coord = "M"+fromNodeLeft+","+(fromNodeTop+fromNode.clientHeight/2+yLineOffset)
- +" L"+toNodeRight+","+(fromNodeTop+fromNode.clientHeight/2+yLineOffset);
- }
- vlPath +='<path d="'+coord+'" fill="none" stroke="'+toNode.style.backgroundColor+'" stroke-width="4px"></path>';
- }
- }
- }
- }
-
- $("#svg_vdu g").html(vduPath);
- $("#svg_vl g").html(vlPath);
-}
-
-/**
- * generate node table data
- * @param {[type]} data [description]
- * @return {[type]} [description]
- */
-topoUtil.generateNodeTemplate = function(data) {
- var nodeTemplate = {};
- nodeTemplate.id = data.id;
- nodeTemplate.name = data.name;
- nodeTemplate.type = data.type;
- nodeTemplate.parentType = data.parentType;
- nodeTemplate.vnfdid = ""; //only nested VNF node has value
- nodeTemplate.properties = data.properties;
- nodeTemplate.flavors = data.flavors;
- nodeTemplate.containIn = ""; //containIn relation which the front-end custom is used to display the topo relations of the graph
- nodeTemplate.containedin = ""; //the relation between VNF and VNFC
- nodeTemplate.deployedon = ""; //the relation between VDU and VNFC
- nodeTemplate.connectedto = ""; //the relation between VNFC and VNFC
- nodeTemplate.virtuallinksto = ""; //the relation between VL and CP or between VL and VDU
- nodeTemplate.virtualbindsto = ""; //the relation between CP and VDU
- nodeTemplate.outLinks = []; //a collection of connected nodes connectedto
- nodeTemplate.inLinks = []; //nodes are connected connectedto relationship collection
- nodeTemplate.currentLinkNum = 0;
- var relationShips = data.relationShips || []; //some nodes may not have relationships
- $.each(relationShips, function(index, obj){
- if (obj.sourceNodeId == data.id) {
- switch(obj.type) {
- case "containedIn" :
- case "tosca.relationships.nfv.ContainedIn" :
- case "tosca.relationships.nfv.BelongTo" :
- nodeTemplate.containedin = obj.targetNodeId;
- break;
- case "deployedOn" :
- case "tosca.relationships.nfv.DeployedOn" :
- nodeTemplate.deployedon = obj.targetNodeId;
- break;
- case "connectedTo" :
- case "tosca.relationships.nfv.ConnectsTo" :
- nodeTemplate.connectedto += "," + obj.targetNodeId;
- nodeTemplate.outLinks.push(obj.targetNodeId);
- break;
- case "virtualLinksTo" :
- case "tosca.relationships.nfv.VirtualLinksTo" :
- nodeTemplate.virtuallinksto += "," + obj.targetNodeId;
- break;
- case "virtualBindsTo" :
- case "tosca.relationships.nfv.VirtualBindsTo" :
- nodeTemplate.virtualbindsto += "," + obj.targetNodeId;
- break;
- }
- }
- if (obj.targetNodeId == data.id) {
- switch(obj.type) {
- case "connectedTo" :
- case "tosca.relationships.nfv.ConnectsTo" :
- nodeTemplate.inLinks.push(obj.sourceNodeId);
- break;
- }
- }
- });
- nodeTemplate.connectedto = nodeTemplate.connectedto.substring(1);
- nodeTemplate.virtuallinksto = nodeTemplate.virtuallinksto.substring(1);
- nodeTemplate.virtualbindsto = nodeTemplate.virtualbindsto.substring(1);
-
- if(topoUtil.isVNFType(data.type)) {
- $.each(data.properties, function(key, value) {
- if(key == "vnfdid" && value) {
- nodeTemplate.vnfdid = value;
- }
- });
- }
- return nodeTemplate;
-}
-
-/**
- * generate topology data
- * deployedon is used to display the relation between VNFC and VDU
- * containedin is used to display the relation between VNFC and VNF
- * transform relations between VDU and VNF, containIn is used to display the relation between VDU and VNF
- * @param {[type]} data [description]
- * @return {[type]} [description]
- */
-topoUtil.generateTopoTemplate = function(data) {
- for(var i=0;i<data.length;i++) {
- if(data[i].containedin){
- //assignment is designed to compatible with no VDU, only VNF and VNFC situations
- data[i].containIn = data[i].containedin;
- for(var j=0;j<data.length;j++) {
- if(data[i].deployedon == data[j].id) {
- data[j].containIn = data[i].containedin;
- break;
- }
- }
- }
- //the relationship between VNFC and VDU deployedon replace with containIn
- if(data[i].deployedon){
- data[i].containIn = data[i].deployedon;
- }
- }
- return data;
-}
-
-/**
- * generate nodetemplate detail
- * @param {[type]} data [description]
- * @return {[type]} [description]
- */
-topoUtil.generateNodeTemplateDetail = function(data) {
- var nodeTemplateDetail = {};
- nodeTemplateDetail.properties = [];
- var properties = data.properties;
- for(var key in properties) {
- var property = {};
- property.key = key;
- property.value = properties[key];
- nodeTemplateDetail.properties.push(property);
- }
- //add flavor to nodetempalte properties
- var flavors = data.flavors;
- if(flavors && flavors.length) {
- var flavor = flavors[0];
- for(var key in flavor) {
- var property = {};
- property.key = key;
- property.value = flavor[key];
- nodeTemplateDetail.properties.push(property);
- }
- }
-
- nodeTemplateDetail.relationShips = data.relationShips;
-
- nodeTemplateDetail.general = [];
- var general = {};
- general.key = "name";
- general.value = data.name;
- nodeTemplateDetail.general.push(general);
- var general = {};
- general.key = "type";
- general.value = data.type;
- nodeTemplateDetail.general.push(general);
-
- return nodeTemplateDetail;
-}
-
-topoUtil.getCurrentDetailData = function(detailDatas, nodetemplateid) {
- var data;
- for(var i=0; i<detailDatas.length; i++) {
- if (detailDatas[i].id == nodetemplateid) {
- data = topoUtil.generateNodeTemplateDetail(detailDatas[i]);
- break;
- }
- }
- return data;
-}
-
-/**
- * generate node instance detail
- * a node template may correspond to multiple node instances, their properties are not the same
- * @param {[type]} data [description]
- * @return {[type]} [description]
- */
-topoUtil.generateNodeInstanceDetail = function(data) {
- var nodeInstanceDetail = [];
- nodeInstanceDetail.properties = [];
- nodeInstanceDetail.general = [];
-
- var properties = data.properties;
- for(var i=0;i<properties.length;i++) {
- var nodeDetail = {};
- var name = data.name;
- for(var key in properties[i]) {
- var property = {};
- property.key = key;
- property.value = properties[i][key];
- nodeDetail.properties.push(property);
-
- if(key == "name") {
- name = properties[i][key];
- }
- }
- var general = {};
- general.key = "name";
- general.value = name;
- nodeDetail.general.push(general);
- var general = {};
- general.key = "type";
- general.value = data.type;
- nodeDetail.general.push(general);
-
- nodeDetail.relationShips = data.relationShips;
- nodeInstanceDetail.push(nodeDetail);
- }
- return nodeInstanceDetail;
-}
-
-topoUtil.getCurrentNodeInstanceDetail = function(detailDatas, nodetemplateid) {
- var data;
- for(var i=0; i<detailDatas.length; i++) {
- if (detailDatas[i].id == nodetemplateid) {
- data = topoUtil.generateNodeInstanceDetail(detailDatas[i]);
- break;
- }
- }
- return data;
-}
-
-topoUtil.getCidr = function(properties) {
- for(var key in properties) {
- if(key == "cidr") {
- return properties[key];
- }
- }
-}
-
-topoUtil.getColor = function(index) {
- var colors = ['#1F77B4','#FF7F0E','#2CA02C','#D62728','#9467BD','#8C564B','#4b6c8b','#550000','#dc322f','#FF6600'];
- return colors[index%10];
-}
-
-topoUtil.getCpTop = function(index, parentBoxId) {
- var newTop = "";
- var height = 0;
- if(index == 0) {
- var circle_top = $(".circle").css("top");
- var circle_height = $(".circle").css("height");
- var top = circle_top.substring(0, circle_top.length-2) - 0;
- height = circle_height.substring(0, circle_height.length-2) - 0;
- newTop = (top+height+10);
- } else {
- var circle_top = $(".smallCircle").css("top");
- var circle_height = $(".smallCircle").css("height");
- var top = circle_top.substring(0, circle_top.length-2) - 0;
- height = circle_height.substring(0, circle_height.length-2) - 0;
- newTop = (top+height*(index));
- }
- //if the length of cp over the box which cp is virtualbindsto, set the box min-heght attribute
- var $box = $("#" + parentBoxId);
- var min_height = $box.css("min-height");
- var box_min_height = min_height.substring(0, min_height.length-2) - 0;
- var cp_height = newTop + height;
- if(cp_height > box_min_height) {
- $box.css("min-height", cp_height);
- }
-
- return newTop + "px";
-}
-
-topoUtil.isVNFType = function(type) {
- if((type.toUpperCase().indexOf(".VNF") > -1) && (type.toUpperCase().indexOf(".VNFC") < 0)) {
- return true;
- }
- return false;
-} \ No newline at end of file
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
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfm-validate.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfm-validate.js
deleted file mode 100644
index a257dd63..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfm-validate.js
+++ /dev/null
@@ -1,66 +0,0 @@
-$(function(){
- var form = $('#vnfm_form');
- var error = $('.alert-danger', form);
- var success = $('.alert-success', form);
-
- form.validate({
- doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
- errorElement: 'span', //default input error message container
- errorClass: 'help-block', // default input error message class
- focusInvalid: false, // do not focus the last invalid input
- rules: {
- name:{
- required: true,
- maxlength:20
- },
- moc:{
- required: true,
- maxlength:20
- },
- vimId:{
- required: true,
- },
- url:{
- required: true,
- url: true
- }
- },
- messages: {
- name:{
- required: $.i18n.prop("nfv-vnfm-iui-validate-name")
- },
- moc:{
- required: $.i18n.prop("nfv-vnfm-iui-validate-moc")
- },
- vimId:{
- required: $.i18n.prop("nfv-vnfm-iui-validate-vim")
- },
- url:{
- required: $.i18n.prop("nfv-vnfm-iui-validate-url-required"),
- url: $.i18n.prop("nfv-vnfm-iui-validate-url")
- }
- },
- errorPlacement: function (error, element) { // render error placement for each input type
- error.insertAfter(element); // for other inputs, just perform default behavior
- },
- invalidHandler: function (event, validator) { //display error alert on form submit
- success.hide();
- error.show();
- },
- highlight: function (element) { // hightlight error inputs
- $(element).closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
- },
- unhighlight: function (element) { // revert the change done by hightlight
- $(element).closest('.form-group').removeClass('has-error'); // set error class to the control group
- },
- success: function (label) {
- label.addClass('valid') // mark the current input as valid and display OK icon
- .closest('.form-group').removeClass('has-error'); // set success class to the control group
- },
- submitHandler: function (form) {
- success.show();
- error.hide();
- //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
- }
- });
-}); \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmController.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmController.js
deleted file mode 100644
index 48368cd8..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmController.js
+++ /dev/null
@@ -1,275 +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 : "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 : '/api/nsoc/v1/vnfms',
- addVnfmInfoUrl : '/api/nsoc/v1/vnfms',
- updateVnfmInfoUrl : '/api/nsoc/v1/vnfms/',
- delVnfmInfoUrl : '/api/nsoc/v1/vnfms/',
- queryMocUrl : '',
- queryVimUrl : '/api/roc/v1/resource/vims'
- },
- $htmlText:{
- saveSuccess:$.i18n.prop("nfv-vnfm-iui-message-save-success"),
- saveFail:$.i18n.prop("nfv-vnfm-iui-message-save-fail"),
- 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) {
- 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 && resp.data) {
- vm.vimSelectItems = resp.data;
- }
- }
- });
- },
- addVnfm : {
- title : $.i18n.prop("nfv-vnfm-iui-text-register"),
- vnfmId : "",
- name : "",
- moc : "",
- mocDisabled : false,
- vimId : "",
- vimVisiable : false,
- vendor : "",
- 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.moc = "";
- vm.addVnfm.mocDisabled = false;
- vm.addVnfm.vimId = "";
- vm.addVnfm.vimVisiable = false;
- vm.addVnfm.vendor = "";
- 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<items.length;i++) {
- if(items[i].id == mocId) {
- return items[i].name;
- }
- }
- return "";
- },
- $saveVnfm : function() {
- var form = $('#vnfm_form');
- if (form.valid() == false) {
- return false;
- }
- vm.server_rtn.info_block=true;
- vm.server_rtn.warning_block=false;
- vm.addVnfm.status=vm.$Status.success;
-
- var param = {
- name : vm.addVnfm.name,
- status : vm.addVnfm.status,
- moc : $("#moc").val(),
- vimId : vm.$getVimId($("#moc").val()),
- vendor : vm.addVnfm.vendor,
- url : vm.addVnfm.url,
- userName : vm.addVnfm.userName,
- password : vm.addVnfm.password
- }
- //save VIM info
- if(vm.addVnfm.saveType == "add") {
- $.ajax({
- type : "POST",
- url : vm.$restUrl.addVnfmInfoUrl,
- data : JSON.stringify(param),
- dataType : "json",
- contentType : "application/json",
- success : function(data) {
- vm.server_rtn.info_block=false;
- vm.server_rtn.warning_block=false;
- if (data) {
- vm.vnfmInfo = [];
- vm.$initTable();
-
- $('#addVnfmDlg').modal('hide');
- commonUtil.showMessage(vm.$htmlText.saveSuccess, "success");
- } else {
- vm.server_rtn.warning_block=true;
- vm.server_rtn.rtn_info=vm.$htmlText.saveFail;
- commonUtil.showMessage(vm.$htmlText.saveFail, "failed");
- }
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- vm.server_rtn.warning_block=true;
- vm.server_rtn.rtn_info=textStatus+":"+errorThrown;
- vm.server_rtn.info_block=false;
- }
- });
- } else {
- $.ajax({
- type : "PUT",
- url : vm.$restUrl.updateVnfmInfoUrl+vm.addVnfm.vnfmId,
- data : JSON.stringify(param),
- dataType : "json",
- contentType : "application/json",
- success : function(data) {
- vm.server_rtn.info_block=false;
- vm.server_rtn.warning_block=false;
- if (data) {
- for(var i=0;i<vm.vnfmInfo.length;i++){
- if(vm.vnfmInfo[i].vnfmId == vm.addVnfm.vnfmId) {
- vm.vnfmInfo[i].name = vm.addVnfm.name;
- vm.vnfmInfo[i].moc = $("#moc").val();
- vm.vnfmInfo[i].vimId = vm.$getVimId($("#moc").val());
- vm.vnfmInfo[i].vendor = vm.addVnfm.vendor;
- vm.vnfmInfo[i].url = vm.addVnfm.url;
- vm.vnfmInfo[i].userName = vm.addVnfm.userName;
- vm.vnfmInfo[i].password = vm.addVnfm.password;
- vm.vnfmInfo[i].status = vm.addVnfm.status;
- }
- }
- $('#addVnfmDlg').modal('hide');
- commonUtil.showMessage(vm.$htmlText.updateSuccess,"success");
- } else {
- vm.server_rtn.warning_block=true;
- vm.server_rtn.rtn_info=vm.$htmlText.updateFail;
- commonUtil.showMessage(vm.$htmlText.updateFail, "failed");
- }
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- vm.server_rtn.warning_block=true;
- vm.server_rtn.rtn_info=textStatus+":"+errorThrown;
- vm.server_rtn.info_block=false;
- }
- });
- }
- },
- mocRendered : function(action) {
- if(vm.addVnfm.saveType === "update" && vm.addVnfm.moc) {
- var items = vm.mocSelectItems;
- for(var i=0;i<items.length;i++) {
- if(items[i].id == vm.addVnfm.moc) {
- $("#moc")[0].selectedIndex = i;
- vm.$mocChange();
- break;
- }
- }
- } else {
- $("#moc")[0].selectedIndex = 0;
- }
- },
- vimRendered : function(action) {
- if(vm.addVnfm.saveType === "update") {
- var items = vm.vimSelectItems;
- for(var i=0;i<items.length;i++) {
- if(items[i].oid == vm.addVnfm.vimId) {
- $("#vimId")[0].selectedIndex = i;
- break;
- }
- }
- } else {
- $("#vimId")[0].selectedIndex = 0;
- }
- },
- $mocChange : function() {
- var mocId = $('#moc').val();
- if(mocId == "nfv.vnfm.tacker") {
- vm.addVnfm.vimVisiable = true;
- } else {
- vm.addVnfm.vimVisiable = false;
- }
- },
- $getVimId : function(mocId) {
- if(vm.addVnfm.vimVisiable) {
- return $("#vimId").val();
- } else {
- return "";
- }
- }
- });
-avalon.scan();
-vm.$initTable();
-vm.$initMoc(); \ No newline at end of file
diff --git a/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmUtil.js b/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmUtil.js
deleted file mode 100644
index f466fe69..00000000
--- a/nsoc-iui/src/main/resources/webroot/nsoc/js/vnfm/vnfmUtil.js
+++ /dev/null
@@ -1,73 +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 vnfmUtil = {};
-
-vnfmUtil.delVnfm = function(vnfmId) {
- bootbox.confirm($.i18n.prop("nfv-vnfm-iui-message-delete-confirm"), function(result){
- if(result){
- $.ajax({
- type : "DELETE",
- url : vm.$restUrl.delVnfmInfoUrl + vnfmId,
- dataType : "json",
- success : function(data) {
- if(data) {
- for(var i=0;i<vm.vnfmInfo.length;i++){
- if(vnfmId == vm.vnfmInfo[i].vnfmId){
- //delete the vnfm object from vnfm array
- vm.vnfmInfo.splice(i, 1);
- break;
- }
- }
- commonUtil.showMessage($.i18n.prop("nfv-vnfm-iui-message-delete-success"), "success");
- } else {
- commonUtil.showMessage($.i18n.prop("nfv-vnfm-iui-message-delete-fail"), "warning");
- }
- },
- error : function() {
- commonUtil.showMessage($.i18n.prop("nfv-vnfm-iui-message-delete-fail"), "warning");
- }
- });
- }
- });
-}
-
-vnfmUtil.updateVnfm = function(data) {
- vm.addVnfm.vnfmId = data.vnfmId;
- vm.addVnfm.name = data.name;
- vm.addVnfm.moc = data.moc;
- vm.addVnfm.mocDisabled = true;
- vm.addVnfm.vendor = data.vendor;
- vm.addVnfm.url = data.url;
- vm.addVnfm.userName = data.userName;
- vm.addVnfm.password = data.password;
- vm.addVnfm.saveType = "update";
- vm.addVnfm.title = $.i18n.prop("nfv-vnfm-iui-test-update");
- vm.server_rtn.info_block=false;
- vm.server_rtn.warning_block=false;
- vm.$initMoc();
- vm.$initVim();
-
- $(".form-group").each(function () {
- $(this).removeClass('has-success');
- $(this).removeClass('has-error');
- $(this).find(".help-block[id]").remove();
- });
- $("#addVnfmDlg").modal("show");
-}
-
-vnfmUtil.tooltipVnfmStatus = function() {
- $("[data-toggle='tooltip']").tooltip();
-} \ No newline at end of file