From eb7d53145631df469c408a1b8c481cc4dc03da41 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 16 Feb 2011 15:35:34 -0800 Subject: [PATCH] bug 8577: Make listAlerts API take in id parameter. --- api/src/com/cloud/api/commands/ListAlertsCmd.java | 8 ++++++++ server/src/com/cloud/server/ManagementServerImpl.java | 7 ++++++- ui/scripts/cloud.core.alert.js | 7 ++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/api/src/com/cloud/api/commands/ListAlertsCmd.java b/api/src/com/cloud/api/commands/ListAlertsCmd.java index 8fba5c4801b..b4bbc24b6dd 100644 --- a/api/src/com/cloud/api/commands/ListAlertsCmd.java +++ b/api/src/com/cloud/api/commands/ListAlertsCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.AlertResponse; import com.cloud.api.response.ListResponse; @@ -41,6 +42,9 @@ public class ListAlertsCmd extends BaseListCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the alert") + private Long id; + @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="list by alert type") private String type; @@ -48,6 +52,10 @@ public class ListAlertsCmd extends BaseListCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + public Long getId() { + return id; + } + public String getType() { return type; } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index a7b2633a038..565881d2545 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -3105,10 +3105,15 @@ public class ManagementServerImpl implements ManagementServer { Filter searchFilter = new Filter(AlertVO.class, "lastSent", false, cmd.getStartIndex(), cmd.getPageSizeVal()); SearchCriteria sc = _alertDao.createSearchCriteria(); - + Object id = cmd.getId(); Object type = cmd.getType(); Object keyword = cmd.getKeyword(); + + if (id != null) { + sc.addAnd("id", SearchCriteria.Op.EQ, id); + } + if (keyword != null) { SearchCriteria ssc = _alertDao.createSearchCriteria(); ssc.addOr("subject", SearchCriteria.Op.LIKE, "%" + keyword + "%"); diff --git a/ui/scripts/cloud.core.alert.js b/ui/scripts/cloud.core.alert.js index 24b1af2561e..c7b9253cdb6 100644 --- a/ui/scripts/cloud.core.alert.js +++ b/ui/scripts/cloud.core.alert.js @@ -67,9 +67,7 @@ function alertJsonToDetailsTab() { var $thisTab = $("#right_panel_content").find("#tab_content_details"); $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - - //uncomment the following section when Bug 8577("listAlerts API, listEvents API doesn't take in id parameter correctly") is fixed - /* + $.ajax({ data: createURL("command=listAlerts&id="+jsonObj.id), dataType: "json", @@ -82,8 +80,7 @@ function alertJsonToDetailsTab() { } } }); - */ - + $thisTab.find("#id").text(fromdb(jsonObj.id)); $thisTab.find("#type").text(toAlertType(jsonObj.type)); $thisTab.find("#typeid").text(fromdb(jsonObj.type));