Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 1069688] - (JON3-24) Add alert name filter to "Recent Alerts" das…
Browse files Browse the repository at this point in the history
…hboard portlet - Filtering now works for dashboard portlet (called "Recent Alerts") as well as for the "Summary/Activity" subtab portlet (called "Resource: Alerts" and "Group: Alerts")
  • Loading branch information
jkremser committed Mar 21, 2014
1 parent 9e1b17f commit eca4d47
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.smartgwt.client.types.MultipleAppearance;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;

import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.configuration.Configuration;
Expand All @@ -48,6 +49,7 @@ public class PortletConfigurationEditorComponent {
public interface Constant {
String ALERT_PRIORITY = "ALERT_PRIORITY";
String ALERT_PRIORITY_DEFAULT = ""; // no filtering
String ALERT_NAME = "ALERT_NAME";
String METRIC_RANGE_ENABLE = "METRIC_RANGE_ENABLE";
String METRIC_RANGE_ENABLE_DEFAULT = String.valueOf(false); //disabled
String METRIC_RANGE_BEGIN_END_FLAG = "METRIC_RANGE_BEGIN_END_FLAG";
Expand All @@ -74,6 +76,7 @@ public interface Constant {
public static Map<String, String> CONFIG_PROPERTY_INITIALIZATION = new HashMap<String, String>();
static {// Key, Default value
CONFIG_PROPERTY_INITIALIZATION.put(Constant.ALERT_PRIORITY, Constant.ALERT_PRIORITY_DEFAULT);
CONFIG_PROPERTY_INITIALIZATION.put(Constant.ALERT_NAME, "");
//result sort order, if empty initialize to "DESC"
CONFIG_PROPERTY_INITIALIZATION.put(Constant.RESULT_SORT_ORDER, Constant.RESULT_SORT_ORDER_DEFAULT);
//result count, if empty initialize to 5
Expand Down Expand Up @@ -128,6 +131,16 @@ public static SelectItem getResultCountEditor(Configuration portletConfig) {
return maximumResultsComboBox;
}

public static TextItem getAlertNameEditor(Configuration portletConfig) {
final TextItem alertNameEditor = new TextItem(Constant.ALERT_NAME);
alertNameEditor.setTitle(MSG.common_title_name());
alertNameEditor.setWrapTitle(false);
alertNameEditor.setWidth(100);
String currentValue = portletConfig.getSimpleValue(Constant.ALERT_NAME, "");
alertNameEditor.setValue(currentValue);
return alertNameEditor;
}

/* Multiple select combobox for alert priorities to display on dashboard
*
* @return Populated selectItem instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridRecord;

Expand Down Expand Up @@ -169,6 +170,9 @@ public DynamicForm getCustomSettingsForm() {
final DashboardPortlet storedPortlet = this.portletWindow.getStoredPortlet();
final Configuration portletConfig = storedPortlet.getConfiguration();

// alert priority selector
final TextItem alertNameFilter = PortletConfigurationEditorComponent.getAlertNameEditor(portletConfig);

// alert priority selector
final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent
.getAlertPriorityEditor(portletConfig);
Expand All @@ -180,15 +184,20 @@ public DynamicForm getCustomSettingsForm() {
final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);

filterForm.setItems(alertPrioritySelector, resultCountSelector);
filterForm.setItems(alertNameFilter, alertPrioritySelector, resultCountSelector);

//submit handler
customSettingsForm.addSubmitValuesHandler(new SubmitValuesHandler() {

@Override
public void onSubmitValues(SubmitValuesEvent event) {
// alert name
String selectedValue = (null == alertNameFilter.getValue()) ? "" : alertNameFilter.getValue()
.toString();
portletConfig.put(new PropertySimple(Constant.ALERT_NAME, selectedValue));

// alert severity
String selectedValue = (null == alertPrioritySelector.getValue()) ? "" : alertPrioritySelector
selectedValue = (null == alertPrioritySelector.getValue()) ? "" : alertPrioritySelector
.getValue().toString();
if ((selectedValue.trim().isEmpty())
|| (selectedValue.split(",").length == AlertPriority.values().length)) {
Expand Down Expand Up @@ -351,9 +360,13 @@ protected int getTotalRows(final PageList<Alert> result, final DSResponse respon
@Override
protected AlertCriteria getFetchCriteria(DSRequest request) {
AlertCriteria criteria = new AlertCriteria();

// name filter
String currentSetting = this.configuration.getSimpleValue(Constant.ALERT_NAME, "");
criteria.addFilterName(currentSetting);

// result count
String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
Constant.RESULT_COUNT_DEFAULT);

// We have to set a PageControl override here, or RPCDataSource will apply default paging based on the
Expand Down

0 comments on commit eca4d47

Please sign in to comment.