Fix the bug "delete package, package table would not be refreshed".
Change-Id: Ia2311b7e5e0ecc0f072ab03d064a55764a60d886
Issue-id:GSO-50
Signed-off-by: nancylizi <li.zi30@zte.com.cn>
diff --git a/openo-portal/portal-catalog/src/main/webapp/catalog/csarPackage.html b/openo-portal/portal-catalog/src/main/webapp/catalog/csarPackage.html
index fc42739..6c547ce 100644
--- a/openo-portal/portal-catalog/src/main/webapp/catalog/csarPackage.html
+++ b/openo-portal/portal-catalog/src/main/webapp/catalog/csarPackage.html
@@ -226,6 +226,7 @@
<script type="text/javascript" src="../common/thirdparty/jquery.i18n/jquery.i18n.properties-1.0.9.js"></script>
<script type="text/javascript" src="../common/thirdparty/cometd/cometd.js"></script>
+ <script type="text/javascript" src="../common/thirdparty/cometd/jquery/jquery.cometd.js"></script>
<script type="text/javascript" src="../common/thirdparty/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../common/thirdparty/jQuery-File-Upload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="../common/thirdparty/jQuery-File-Upload/js/jquery.fileupload.js"></script>
diff --git a/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmController.js b/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmController.js
index 9129b9d..3b19d23 100644
--- a/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmController.js
+++ b/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmController.js
@@ -326,6 +326,11 @@
}
});
},
+ $initCometd : function() {
+ commonUtil.registerCometdMessage("/openoapi/catalog/v1/catalognotification", "/package/delete", function(message) {
+ pmUtil.updateDeletedPackageStatus(message);
+ });
+ },
gotoPackageListPage:function(){
window.location.href="./csarPackage.html";
refreshByCond();
@@ -333,7 +338,7 @@
});
avalon.scan();
vm.$initUpload();
-
+vm.$initCometd();
$(function(){
vm.$initTable();
});
diff --git a/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmUtil.js b/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmUtil.js
index 79dd813..ccd0f11 100644
--- a/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmUtil.js
+++ b/openo-portal/portal-catalog/src/main/webapp/catalog/js/package/pmUtil.js
@@ -29,11 +29,11 @@
});
}
-pmUtil.changeTableStatus = function(name, status) {
+pmUtil.changeTableStatus = function(csarId, status) {
var table = $("#" + vm.$tableId).dataTable();
var tableData = table.fnGetData();
for (var i=0; i<tableData.length; i++) {
- if(tableData[i]["name"] == name) {
+ if(tableData[i]["csarId"] == csarId) {
table.fnUpdate(status, i, 4, false, false);
break;
}
@@ -67,11 +67,12 @@
}
pmUtil.updateDeletedPackageStatus = function(message) {
- if(message.status == "true" || message.status == "deletionPending") {
+ var messageobj = JSON.parse(message);
+ if(messageobj.status == "true" || messageobj.status == "deletionPending") {
commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-delete-success"), "success");
refreshByCond();
} else {
- pmUtil.changeTableStatus(message.csarid, "deletefail");
+ pmUtil.changeTableStatus(messageobj.csarid, "deletefail");
}
}
@@ -103,7 +104,9 @@
dataType : "json",
success : function(resp) {
if(resp.data.status == "failed") {
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-onBoarded"), "failed");
+ commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-onBoard-error"), "failed");
+ } else {
+ commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-onBoarded"), "success");
}
refreshByCond();
},
@@ -122,6 +125,11 @@
contentType : "application/json",
dataType : "json",
success : function(resp) {
+ if(resp.data.status == "failed") {
+ commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-onBoard-error"), "failed");
+ } else {
+ commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-onBoarded"), "success");
+ }
refreshByCond();
},
error : function() {
@@ -136,6 +144,11 @@
url : url,
contentType : "application/json",
success : function(resp) {
+ if(resp.data.status == "failed") {
+ commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-onBoard-error"), "failed");
+ } else {
+ commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-onBoarded"), "success");
+ }
refreshByCond();
},
error : function() {
@@ -150,24 +163,18 @@
url : url,
contentType : "application/json",
success : function(resp) {
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-delete-success"), "success");
- setTimeout( function(){
- refreshByCond();
- }, 1 * 1000 );
+ //commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-delete-success"), "success");
+ //setTimeout( function(){
+ // refreshByCond();
+ //}, 1 * 1000 );
},
error : function(resp) {
if(resp.status == 202 || resp.responseText == "success") {
- commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-delete-success"), "success");
- setTimeout( function(){
- refreshByCond();
- }, 1 * 1000 );
+ //commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-delete-success"), "success");
//refreshByCond();
} else {
commonUtil.showMessage($.i18n.prop("nfv-package-iui-message-delete-error"), "failed");
- setTimeout( function(){
- refreshByCond();
- }, 1 * 1000 );
- //refreshByCond();
+ refreshByCond();
}
}
});