/**
* Copyright 2016 [ZTE] and others.
*
* 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 : "tmNodesController",
templateId : "",
$language: {
"sProcessing": "
"
+$.i18n.prop("nfv-nso-iui-table-sProcess")+"",
"sLengthMenu": $.i18n.prop("nfv-nso-iui-table-sLengthMenu"),
"sZeroRecords": $.i18n.prop("nfv-nso-iui-table-sZeroRecords"),
"sInfo": " " + $.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 : "/openoapi/catalog/v1/servicetemplates/{0}/nodetemplates",
queryTemplateInfoUrl : "/openoapi/catalog/v1/servicetemplates"
},
$init : function() {
vm.$initTemplateData();
//vm.$initTopoNodesData();
vm.$initNodesData();
},
$initTemplateData : function() {
$.ajax({
type : "GET",
url : vm.$restUrl.queryTemplateInfoUrl,
success : function(resp) {
if(resp) {
vm.servicesTemplateData = [];
for(var i=0; itbody').on("click", 'td.details-control', function () {
var tr = $(this).closest('tr');
var table = $('#' + vm.$nodesTabId).dataTable();
if (table.fnIsOpen(tr[0])) {
table.fnClose(tr[0]);
tr.removeClass('shown');
}
else {
table.fnOpen(tr[0], vm.nodesList.$format_Detail(), 'details');
tr.addClass('shown');
}
});
},
//nodes list table
nodesList :{
nodesData: [],
$nodesTabDataId : "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" : tmNodesDetailUtil.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}
]
},
$initNodesTable: function () {
var setting = {};
setting.language = vm.$language;
setting.paginate = true;
setting.info = true;
setting.columns = vm.nodesList.$nodesTabFields.table;
setting.restUrl = vm.$restUrl.queryNodeTemplateUrl;
setting.tableId = vm.nodesList.$nodesTabDataId;
serverPageTable.initTableWithoutLib(setting,{},vm.nodesList.$nodesTabDataId + '_div');
},
$format_Detail: function() {
var sOut = ''
vm.$initNodesData();
return sOut;
},
},
//Nodes Details
nodesDetail : {
nodesTemplateDetailData: [],
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.nodesDetail.isShow = isShow;
if (isShow == "block") {
vm.nodesDetail.detailTitle = nodetypename + " " + $.i18n.prop("nfv-templateDetail-nodesTab-iui-title-nodeDetail"),
$('#' + vm.nodesDetail.detailData[0].id).click();
vm.nodesDetail.detailData[0].isActive = true;
vm.nodesDetail.$initNodeDetailTable(nodetypeid);
}
},
detailCondChange : function(index) {
vm.nodesDetail.detailIndex = index;
for(var i=0; i 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();