From aa9c6805e755d9af8a8124df127c14fcce5627c3 Mon Sep 17 00:00:00 2001
From: nancylizi
Date: Thu, 29 Sep 2016 19:49:09 +0800
Subject: Modify the bug which "Different service template shows the same nodes
template table" Issue-id:TOSCA-91
Change-Id: I6f7ee6c11f2926d1a0945f0a52e718e992a129fe
Signed-off-by: nancylizi
---
.../webapp/catalog/js/template/tmController.js | 4 +-
.../catalog/js/template/tmDetailController.js | 104 +++++++++++----------
.../src/main/webapp/catalog/templateDetail.html | 4 +-
3 files changed, 60 insertions(+), 52 deletions(-)
diff --git a/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmController.js b/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmController.js
index 1b1c76d6..4b667a4b 100644
--- a/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmController.js
+++ b/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmController.js
@@ -23,7 +23,7 @@ var vm = avalon.define({
$templateTableFields : {// table columns
table: [
{"mData": "serviceTemplateId", name: "ID", "bVisible": false},
- {"mData": "templateName", name: $.i18n.prop("nfv-template-iui-field-templatename"), "fnRender" : tmUtil.nameRender},
+ {"mData": "templateName",name: $.i18n.prop("nfv-template-iui-field-templatename"),"fnRender": tmUtil.nameRender},
//{"mData": "templateName", name: $.i18n.prop("nfv-template-iui-field-templatename-topo"), "fnRender" : tmUtil.topoRender},
//{"mData": "templateName", name: $.i18n.prop("nfv-template-iui-field-templatename-nodes"), "fnRender" : tmUtil.nodesRender},
{"mData": "vendor", name: $.i18n.prop("nfv-template-iui-field-vendor")},
@@ -33,7 +33,7 @@ var vm = avalon.define({
]
},
$language: {
- "sProcessing": " "
+ "sProcessing": " "
+$.i18n.prop("nfv-nso-iui-table-sProcess")+"",
"sLengthMenu": $.i18n.prop("nfv-nso-iui-table-sLengthMenu"),
"sZeroRecords": $.i18n.prop("nfv-nso-iui-table-sZeroRecords"),
diff --git a/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmDetailController.js b/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmDetailController.js
index 4db377ef..fe1567cf 100644
--- a/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmDetailController.js
+++ b/openo-portal/portal-catalog/src/main/webapp/catalog/js/template/tmDetailController.js
@@ -14,9 +14,10 @@
* limitations under the License.
*/
var vm = avalon.define({
- $id: "tmDetailController",
- templateId: "",
- templateData: [
+ $id : "tmDetailController",
+ templateId : "",
+ globalNodesData: {},
+ templateData : [
{href: "#topology", name: "Topology", value: true},
{href: "#nodes", name: "Nodes", value: false}
],
@@ -71,14 +72,16 @@ var vm = avalon.define({
success: function (resp) {
if (resp) {
vm.nodesTab.nodesDetail.nodesTemplateDetailData = [];
+ var nodesTempData = [];
for (var i = 0; i < resp.length; i++) {
//generate node table display data
var nodeTemplate = topoUtil.generateNodeTemplate(resp[i]);
- vm.nodesTab.nodesList.nodesData.push(nodeTemplate);
+ nodesTempData.push(nodeTemplate);
}
+ vm.globalNodesData[vm.templateId] = nodesTempData;
vm.nodesTab.nodesDetail.nodesTemplateDetailData = resp;
//generate topology graph display data
- vm.topologyTab.topoTemplateData = topoUtil.generateTopoTemplate(vm.nodesTab.nodesList.nodesData.$model);
+ vm.topologyTab.topoTemplateData = topoUtil.generateTopoTemplate(vm.globalNodesData[vm.templateId]);
//initialize topology data
topoUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
//vm.nodesTab.nodesList.$initNodesTable();
@@ -89,31 +92,6 @@ var vm = avalon.define({
}
});
},
- $initNodesData: function () {
- $.ajax({
- type: "GET",
- url: vm.$restUrl.queryNodeTemplateUrl,
- success: function (resp) {
- if (resp) {
- vm.nodesTab.nodesDetail.nodesTemplateDetailData = [];
- for (var i = 0; i < resp.length; i++) {
- //generate node table display data
- var nodeTemplate = topoUtil.generateNodeTemplate(resp[i]);
- vm.nodesTab.nodesList.nodesData.push(nodeTemplate);
- }
- vm.nodesTab.nodesDetail.nodesTemplateDetailData = resp;
- //generate topology graph display data
- //vm.topologyTab.topoTemplateData = topoUtil.generateTopoTemplate(vm.nodesTab.nodesList.nodesData.$model);
- //initialize topology data
- //topoUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
- vm.nodesTab.nodesList.$initNodesTable();
- }
- },
- error: function () {
- commonUtil.showMessage($.i18n.prop("nfv-topology-iui-message-error"), "danger");
- }
- });
- },
topologyTab: {
topology: "topology.html",
vnfTip: $.i18n.prop("nfv-topology-iui-vnf-tip"),
@@ -161,9 +139,6 @@ var vm = avalon.define({
{"mData": "version", name: $.i18n.prop("nfv-template-iui-field-version")},
{"mData": "csarid", name: "packageID", "bVisible": false},
{"mData": "type", name: $.i18n.prop("nfv-template-iui-field-type")},
- //{"mData": "inputs", name: $.i18n.prop("nfv-template-iui-field-inputs"),"fnRender" : tmDetailUtil.inputsRender},
- //{"mData": "outputs", name: $.i18n.prop("nfv-template-iui-field-outputs"),"fnRender" : tmDetailUtil.outputsRender},
- //{"mData": "operations", name: $.i18n.prop("nfv-template-iui-field-operations")}
]
},
$initNfvNodesTab: function () {
@@ -185,15 +160,43 @@ var vm = avalon.define({
tr.removeClass('shown');
}
else {
- table.fnOpen(tr[0], vm.nodesTab.nodesList.$format_Detail(), 'details');
+ table.fnOpen(tr[0], vm.nodesTab.nodesList.$format_Detail(table,tr[0]), 'details');
tr.addClass('shown');
}
});
},
-
+ $initNodesData: function (tempId) {
+ $.ajax({
+ type: "GET",
+ //url: vm.$restUrl.queryNodeTemplateUrl,
+ url: "/openoapi/catalog/v1/servicetemplates/" + tempId + "/nodetemplates",
+ success: function (resp) {
+ if (resp) {
+ vm.nodesTab.nodesDetail.templatesNodesDetailData[tempId] = [];
+ var nodesTempData = [];
+ for (var i = 0; i < resp.length; i++) {
+ //generate node table display data
+ var nodeTemplate = topoUtil.generateNodeTemplate(resp[i]);
+ nodesTempData.push(nodeTemplate);
+ }
+ vm.nodesTab.nodesList.nodesData[tempId] = nodesTempData;
+ vm.nodesTab.nodesDetail.templatesNodesDetailData[tempId] = resp;
+ //generate topology graph display data
+ //vm.topologyTab.topoTemplateData = topoUtil.generateTopoTemplate(vm.nodesTab.nodesList.nodesData.$model);
+ //initialize topology data
+ //topoUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
+ vm.nodesTab.nodesList.$initNodesTable(tempId);
+ }
+ },
+ error: function () {
+ commonUtil.showMessage($.i18n.prop("nfv-topology-iui-message-error"), "danger");
+ }
+ });
+ },
//nodes list table
nodesList: {
- nodesData: [],
+ nodesData: {},
+ tempId:"",
$nodesTabDataId: "ict_nodes_table",
$nodesTabFields: {// table columns
table: [
@@ -227,27 +230,32 @@ var vm = avalon.define({
}
]
},
- $initNodesTable: function () {
+ $initNodesTable: function (tempId) {
var setting = {};
setting.language = vm.$language;
setting.paginate = true;
setting.info = true;
//setting.sort = true;
setting.columns = vm.nodesTab.nodesList.$nodesTabFields.table;
- setting.restUrl = vm.$restUrl.queryNodeTemplateUrl;
- setting.tableId = vm.nodesTab.nodesList.$nodesTabDataId;
+ setting.restUrl = "/openoapi/catalog/v1/servicetemplates/" + tempId + "/nodetemplates";
+ setting.tableId = vm.nodesTab.nodesList.$nodesTabDataId + "_" + tempId;
//serverPageTable.initTableWithData(setting,vm.nodesTab.nodesList.$nodesTabDataId + '_div',vm.nodesTab.nodesList.nodesData.$model);
- serverPageTable.initTableWithoutLib(setting, {}, vm.nodesTab.nodesList.$nodesTabDataId + '_div');
+ serverPageTable.initTableWithoutLib(setting, {}, setting.tableId + '_div');
},
- $format_Detail: function () {
- var sOut = ''
- vm.$initNodesData();
+ $format_Detail: function (oTable, nTr) {
+ var aData = oTable.fnGetData(nTr);
+ var tempId = aData.serviceTemplateId;
+ vm.nodesTab.nodesList.tempId = tempId;
+ var tableId = "ict_nodes_table" + "_" + tempId + "_div";
+ var sOut = ''
+ vm.nodesTab.$initNodesData(tempId);
return sOut;
},
},
//Nodes Details
nodesDetail: {
nodesTemplateDetailData: [],
+ templatesNodesDetailData:[],
detailTitle: "",
isShow: "none",
detailIndex: 0,
@@ -264,13 +272,13 @@ var vm = avalon.define({
isActive: false
}
],
- $showDetails: function (isShow, nodetypeid, nodetypename) {
+ $showDetails: function (isShow, nodetypeid, nodetypename,tempId) {
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);
+ vm.nodesTab.nodesDetail.$initNodeDetailTable(nodetypeid,tempId);
}
},
detailCondChange: function (index) {
@@ -280,7 +288,7 @@ var vm = avalon.define({
}
vm.nodesTab.nodesDetail.detailData[index].isActive = true;
},
- $tableFields: {// table columns
+ $tableFields : {// table columns
general: [
{
"mData": "key",
@@ -323,8 +331,8 @@ var vm = avalon.define({
}
]
},
- $initNodeDetailTable: function (nodetemplateid) {
- var data = topoUtil.getCurrentDetailData(vm.nodesTab.nodesDetail.nodesTemplateDetailData.$model, nodetemplateid);
+ $initNodeDetailTable: function (nodetemplateid,tempId) {
+ var data = topoUtil.getCurrentDetailData(vm.nodesTab.nodesList.nodesData[tempId], nodetemplateid);
//initialize three tables of nodedetail
$.each(vm.nodesTab.nodesDetail.$tableFields, function (key, value) {
var setting = {};
diff --git a/openo-portal/portal-catalog/src/main/webapp/catalog/templateDetail.html b/openo-portal/portal-catalog/src/main/webapp/catalog/templateDetail.html
index f2b88d7f..5582a97f 100644
--- a/openo-portal/portal-catalog/src/main/webapp/catalog/templateDetail.html
+++ b/openo-portal/portal-catalog/src/main/webapp/catalog/templateDetail.html
@@ -106,8 +106,8 @@
-
-
+
+
--
cgit 1.2.3-korg