modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 16 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 8 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java | 332 ++++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java | 286 ++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java | 25 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3 6 files changed, 670 insertions(+)
New commits: commit 959f3d0535ccab8cc96c4b842d16fb8a4338f2f1 Author: Simeon Pinder spinder@redhat.com Date: Thu Mar 10 18:12:48 2011 -0500
Event counts portlet for groups.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java index 14f3603..1894c09 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java @@ -405,6 +405,14 @@ public class ImageManager { return "subsystems/event/Events" + icon + "_16.png"; }
+ public static String getEventLargeIcon() { + return "subsystems/event/Events_24.png"; + } + + public static String getEventIcon() { + return "subsystems/event/Events_16.png"; + } + public static String getMonitorIcon() { return "subsystems/monitor/Monitor_16.png"; } @@ -420,5 +428,4 @@ public class ImageManager { public static String getMonitorFailedLargeIcon() { return "subsystems/monitor/Monitor_failed_24.png"; } - } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java index 2c47be3..2375ece 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java @@ -26,6 +26,7 @@ import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet; @@ -98,6 +99,7 @@ public class PortletFactory { registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE); // registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE); registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE); + registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
//register group portlet names registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size()); @@ -105,6 +107,7 @@ public class PortletFactory { registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME); // registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME); registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME); + registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
//############## Resource Activity Dashboard ############################################ //defines mapping for Group Activity Dashboard @@ -120,6 +123,7 @@ public class PortletFactory { registeredPortletIconMap.put(GroupAlertsPortlet2.KEY, ImageManager.getAlertLargeIcon()); registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorLargeIcon()); registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon()); + registeredPortletIconMap.put(GroupEventsPortlet.KEY, ImageManager.getEventLargeIcon()); }
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java new file mode 100644 index 0000000..b8a7949 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java @@ -0,0 +1,332 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.CheckboxItem; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.layout.VLayout; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.core.domain.event.EventSeverity; +import org.rhq.enterprise.gui.coregui.client.ImageManager; +import org.rhq.enterprise.gui.coregui.client.UserSessionManager; +import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; +import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; +import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; +import org.rhq.enterprise.gui.coregui.client.util.GwtTuple; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/**This portlet allows the end user to customize the Events display + * + * @author Simeon Pinder + */ +public class GroupEventsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet { + + private int groupId = -1; + protected LocatableCanvas recentEventsContent = new LocatableCanvas(extendLocatorId("RecentEvents")); + private boolean currentlyLoading = false; + private Configuration portletConfig = null; + private DashboardPortlet storedPortlet; + + public GroupEventsPortlet(String locatorId) { + super(locatorId); + //figure out which page we're loading + String currentPage = History.getToken(); + String[] elements = currentPage.split("/"); + int currentGroupIdentifier = Integer.valueOf(elements[1]); + this.groupId = currentGroupIdentifier; + initializeUi(); + } + + @Override + protected void onInit() { + super.onInit(); + loadData(); + } + + /**Defines layout for the portlet page. + */ + protected void initializeUi() { + setPadding(5); + setMembersMargin(5); + addMember(recentEventsContent); + } + + // A non-displayed, persisted identifier for the portlet + public static final String KEY = "GroupEvents"; + // A default displayed, persisted name for the portlet + public static final String NAME = "Group: Event Counts"; + public static final String ID = "id"; + + // set on initial configuration, the window for this portlet view. + private PortletWindow portletWindow; + //instance ui widgets + + private Timer refreshTimer; + + private static List<String> CONFIG_INCLUDE = new ArrayList<String>(); + static { + CONFIG_INCLUDE.add(Constant.RESULT_COUNT); + CONFIG_INCLUDE.add(Constant.METRIC_RANGE); + CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG); + CONFIG_INCLUDE.add(Constant.METRIC_RANGE_ENABLE); + CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN); + CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT); + } + + /** Responsible for initialization and lazy configuration of the portlet values + */ + public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { + //populate portlet configuration details + if (null == this.portletWindow && null != portletWindow) { + this.portletWindow = portletWindow; + } + + if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { + return; + } + this.storedPortlet = storedPortlet; + portletConfig = storedPortlet.getConfiguration(); + + //lazy init any elements not yet configured. + for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) { + if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) { + portletConfig.put(new PropertySimple(key, + PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key))); + } + } + } + + public Canvas getHelpCanvas() { + return new HTMLFlow(MSG.view_portlet_help_eventcounts()); + } + + public static final class Factory implements PortletViewFactory { + public static PortletViewFactory INSTANCE = new Factory(); + + public final Portlet getInstance(String locatorId) { + return new GroupEventsPortlet(locatorId); + } + } + + protected void loadData() { + currentlyLoading = true; + getRecentEventUpdates(); + } + + @Override + public DynamicForm getCustomSettingsForm() { + final LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings")); + LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page")); + + //add range selector + final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent + .getMeasurementRangeEditor(portletConfig); + + //submit handler + customSettings.addSubmitValuesHandler(new SubmitValuesHandler() { + + @Override + public void onSubmitValues(SubmitValuesEvent event) { + + String selectedValue = null; + //alert time range filter. Check for enabled and then persist property. Dealing with compound widget. + FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM); + CheckboxItem itemC = (CheckboxItem) item; + selectedValue = String.valueOf(itemC.getValueAsBoolean()); + if (!selectedValue.trim().isEmpty()) {//then call + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue)); + } + + //alert time advanced time filter enabled. + selectedValue = String.valueOf(measurementRangeEditor.isAdvanced()); + if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) { + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue)); + } + + //alert time frame + List<Long> begEnd = measurementRangeEditor.getBeginEndTimes(); + if (begEnd.get(0) != 0) {//advanced settings + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1)))); + } + + //persist + storedPortlet.setConfiguration(portletConfig); + configure(portletWindow, storedPortlet); + loadData(); + customSettings.markForRedraw(); + } + + }); + page.addMember(measurementRangeEditor); + customSettings.addChild(page); + return customSettings; + } + + /** Fetches recent events and updates the DynamicForm instance with the latest + * event information over last 24hrs. + */ + private void getRecentEventUpdates() { + final int groupId = this.groupId; + long end = System.currentTimeMillis(); + long start = end - (24 * 60 * 60 * 1000); + + //result timeframe if enabled + PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE); + if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting + property = portletConfig.getSimple(Constant.METRIC_RANGE); + if (property != null) { + String currentSetting = property.getStringValue(); + String[] range = currentSetting.split(","); + start = Long.valueOf(range[0]); + end = Long.valueOf(range[1]); + } + } + + GWTServiceLookup.getEventService().getEventCountsBySeverityForGroup(groupId, start, end, + new AsyncCallback<Map<EventSeverity, Integer>>() { + + @Override + public void onFailure(Throwable caught) { + Log + .debug("Error retrieving recent event counts for group [" + groupId + "]:" + + caught.getMessage()); + } + + @Override + public void onSuccess(Map<EventSeverity, Integer> eventCounts) { + //Now populated Tuples + List<GwtTuple<EventSeverity, Integer>> results = new ArrayList<GwtTuple<EventSeverity, Integer>>(); + for (EventSeverity severity : eventCounts.keySet()) { + int count = eventCounts.get(severity); + if (count > 0) { + results.add(new GwtTuple<EventSeverity, Integer>(severity, count)); + } + } + //build display + VLayout column = new VLayout(); + column.setHeight(10); + + if (!results.isEmpty()) { + int rowNum = 0; + for (GwtTuple<EventSeverity, Integer> tuple : results) { + // event history records do not have a usable locatorId, we'll use rownum, which is unique and + // may be repeatable. + LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent + .extendLocatorId(String.valueOf(rowNum))); + row.setNumCols(2); + row.setWidth(10);//pack. + + //icon + StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(ImageManager + .getEventSeverityIcon(tuple.getLefty()), tuple.getLefty().name()); + //count + StaticTextItem count = AbstractActivityView.newTextItem(String.valueOf(tuple.righty)); + row.setItems(iconItem, count); + + column.addMember(row); + } + //insert see more link + LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String + .valueOf(rowNum))); + AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + + "/Events/History/", column); + } else { + LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentEventsContent + .extendLocatorId("None"), AbstractActivityView.RECENT_CRITERIA_EVENTS_NONE); + column.addMember(row); + } + //cleanup + for (Canvas child : recentEventsContent.getChildren()) { + child.destroy(); + } + recentEventsContent.addChild(column); + recentEventsContent.markForRedraw(); + } + }); + } + + @Override + public void startRefreshCycle() { + //current setting + final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); + + //cancel any existing timer + if (refreshTimer != null) { + refreshTimer.cancel(); + } + + if (refreshInterval >= MeasurementUtility.MINUTES) { + + refreshTimer = new Timer() { + public void run() { + if (!currentlyLoading) { + loadData(); + redraw(); + } + } + }; + + refreshTimer.scheduleRepeating(refreshInterval); + } + } + + @Override + protected void onDestroy() { + if (refreshTimer != null) { + + refreshTimer.cancel(); + } + super.onDestroy(); + } + + @Override + public void redraw() { + super.redraw(); + loadData(); + } + +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java index 9c36bbf..fdeca2c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java @@ -99,6 +99,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R public static String RECENT_BUNDLE_DEPLOY = MSG.common_title_recent_bundle_deployments(); public static String RECENT_BUNDLE_DEPLOY_NONE = MSG.view_resource_inventory_activity_no_recent_bundle_deploy(); public static String SEE_MORE = MSG.common_msg_see_more(); + public static String RECENT_CRITERIA_EVENTS_NONE = MSG.view_resource_inventory_activity_criteria_no_recent_events();
private ResourceGroupComposite groupComposite = null; private ResourceComposite resourceComposite = null; diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index e00893e..b37a23d 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -1445,12 +1445,13 @@ view_portlet_defaultName_recentlyAddedResources = Recently Added Resources view_portlet_defaultName_tagCloud = Tag Count
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored. +view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured. view_portlet_help_favoriteResources = This portlet displays the current user''s favorite resources. view_portlet_help_graph = This portlet displays the resource metric graph. view_portlet_help_inventorySummary = This portlet displays a short summary of the current user''s viewable inventory and metric collection rate. view_portlet_help_mashup = This portlet displays the returned content of a remote HTTP request (via an iframe). view_portlet_help_message = This portlet displays a static HTML message. The <i>message</i> property must be configured. -view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions for the selected resource. +view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions. view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory. view_portlet_help_platformSummary = This portlet displays information about the current user''s platform resources. view_portlet_help_problemResources = This portlet displays the current user''s alerted or unavailable resources. @@ -1557,6 +1558,7 @@ view_inventory_resources_title = Resources view_inventory_resources_title_children = Child Resources view_inventory_resources_title_members = Member Resources view_resource_inventory_activity_changed_by=Changed by +view_resource_inventory_activity_criteria_no_recent_events=No event counts based off display criteria. view_resource_inventory_activity_no_recent_alerts=No recent alerts view_resource_inventory_activity_no_recent_bundle_deploy=No recent bundle deployments view_resource_inventory_activity_no_recent_config_history=No configuration change history
commit 53424e64c94023c0844ddf10e8e071e69ee4fa8a Author: Simeon Pinder spinder@redhat.com Date: Thu Mar 10 17:17:21 2011 -0500
Oob portlet for groups.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java index e8dc553..14f3603 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java @@ -412,4 +412,13 @@ public class ImageManager { public static String getMonitorLargeIcon() { return "subsystems/monitor/Monitor_24.png"; } + + public static String getMonitorFailedIcon() { + return "subsystems/monitor/Monitor_failed_16.png"; + } + + public static String getMonitorFailedLargeIcon() { + return "subsystems/monitor/Monitor_failed_24.png"; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java index 87193f4..2c47be3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java @@ -27,6 +27,7 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.FavoriteResourcesPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet; @@ -96,12 +97,14 @@ public class PortletFactory { registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE); registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE); // registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE); + registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
//register group portlet names registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size()); registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME); registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME); // registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME); + registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
//############## Resource Activity Dashboard ############################################ //defines mapping for Group Activity Dashboard @@ -116,6 +119,7 @@ public class PortletFactory { registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertLargeIcon()); registeredPortletIconMap.put(GroupAlertsPortlet2.KEY, ImageManager.getAlertLargeIcon()); registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorLargeIcon()); + registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon()); }
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java new file mode 100644 index 0000000..9f91b88 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java @@ -0,0 +1,286 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups; + +import java.util.ArrayList; +import java.util.List; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.LinkItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.layout.VLayout; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.UserSessionManager; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; +import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; +import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/**This portlet allows the end user to customize the OOB display + * + * @author Simeon Pinder + */ +public class GroupOobsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet { + + private int groupId = -1; + protected LocatableCanvas recentOobContent = new LocatableCanvas(extendLocatorId("RecentOobs")); + private boolean currentlyLoading = false; + private Configuration portletConfig = null; + private DashboardPortlet storedPortlet; + + public GroupOobsPortlet(String locatorId) { + super(locatorId); + //figure out which page we're loading + String currentPage = History.getToken(); + String[] elements = currentPage.split("/"); + int currentGroupIdentifier = Integer.valueOf(elements[1]); + this.groupId = currentGroupIdentifier; + initializeUi(); + } + + @Override + protected void onInit() { + super.onInit(); + loadData(); + } + + /**Defines layout for the portlet page. + */ + protected void initializeUi() { + setPadding(5); + setMembersMargin(5); + addMember(recentOobContent); + } + + // A non-displayed, persisted identifier for the portlet + public static final String KEY = "GroupOobs"; + // A default displayed, persisted name for the portlet + public static final String NAME = "Group: OOB Metrics"; + public static final String ID = "id"; + + // set on initial configuration, the window for this portlet view. + private PortletWindow portletWindow; + //instance ui widgets + + private Timer refreshTimer; + + private static List<String> CONFIG_INCLUDE = new ArrayList<String>(); + static { + CONFIG_INCLUDE.add(Constant.RESULT_COUNT); + } + + /** Responsible for initialization and lazy configuration of the portlet values + */ + public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { + //populate portlet configuration details + if (null == this.portletWindow && null != portletWindow) { + this.portletWindow = portletWindow; + } + + if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { + return; + } + this.storedPortlet = storedPortlet; + portletConfig = storedPortlet.getConfiguration(); + + //lazy init any elements not yet configured. + for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) { + if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) { + portletConfig.put(new PropertySimple(key, + PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key))); + } + } + } + + public Canvas getHelpCanvas() { + return new HTMLFlow(MSG.view_portlet_help_oobs()); + } + + public static final class Factory implements PortletViewFactory { + public static PortletViewFactory INSTANCE = new Factory(); + + public final Portlet getInstance(String locatorId) { + return new GroupOobsPortlet(locatorId); + } + } + + protected void loadData() { + currentlyLoading = true; + getRecentOobs(); + } + + @Override + public DynamicForm getCustomSettingsForm() { + LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings")); + LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page")); + //build editor form container + final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("alert-filter")); + form.setMargin(5); + //add result count selector + final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig); + form.setItems(resultCountSelector); + + //submit handler + customSettings.addSubmitValuesHandler(new SubmitValuesHandler() { + + @Override + public void onSubmitValues(SubmitValuesEvent event) { + + //results count + portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig); + + //persist + storedPortlet.setConfiguration(portletConfig); + configure(portletWindow, storedPortlet); + loadData(); + } + + }); + page.addMember(form); + customSettings.addChild(page); + return customSettings; + } + + /** Fetches OOB measurements and updates the DynamicForm instance with the latest N + * oob change details. + */ + private void getRecentOobs() { + final int groupId = this.groupId; + int resultCount = 5;//default to + + //result count + PropertySimple property = portletConfig.getSimple(Constant.RESULT_COUNT); + if (property != null) { + String currentSetting = property.getStringValue(); + if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) { + resultCount = 5; + } else { + resultCount = Integer.valueOf(currentSetting); + } + } + + GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForGroup(groupId, resultCount, + new AsyncCallback<PageList<MeasurementOOBComposite>>() { + @Override + public void onFailure(Throwable caught) { + Log.debug("Error retrieving recent out of bound metrics for group [" + groupId + "]:" + + caught.getMessage()); + } + + @Override + public void onSuccess(PageList<MeasurementOOBComposite> result) { + VLayout column = new VLayout(); + column.setHeight(10); + if (!result.isEmpty()) { + for (MeasurementOOBComposite oob : result) { + LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent.extendLocatorId(oob + .getScheduleName())); + row.setNumCols(2); + + String title = oob.getScheduleName() + ":"; + String destination = "/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId() + + "&id=" + groupId + "&mode=chartSingleMetricSingleResource"; + LinkItem link = AbstractActivityView.newLinkItem(title, destination); + StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter + .format(oob.getTimestamp())); + + row.setItems(link, time); + column.addMember(row); + } + //insert see more link spinder(2/24/11): no page that displays all oobs... See More not possible. + } else { + LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentOobContent + .extendLocatorId("None"), AbstractActivityView.RECENT_OOB_NONE); + column.addMember(row); + } + recentOobContent.setContents(""); + for (Canvas child : recentOobContent.getChildren()) { + child.destroy(); + } + recentOobContent.addChild(column); + recentOobContent.markForRedraw(); + } + }); + } + + @Override + public void startRefreshCycle() { + //current setting + final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); + + //cancel any existing timer + if (refreshTimer != null) { + refreshTimer.cancel(); + } + + if (refreshInterval >= MeasurementUtility.MINUTES) { + + refreshTimer = new Timer() { + public void run() { + if (!currentlyLoading) { + loadData(); + redraw(); + } + } + }; + + refreshTimer.scheduleRepeating(refreshInterval); + } + } + + @Override + protected void onDestroy() { + if (refreshTimer != null) { + + refreshTimer.cancel(); + } + super.onDestroy(); + } + + @Override + public void redraw() { + super.redraw(); + loadData(); + } + +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java index b183bf5..9c36bbf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java @@ -29,12 +29,15 @@ import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.fields.FormItemIcon; import com.smartgwt.client.widgets.form.fields.LinkItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.LayoutSpacer; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.resource.Resource; @@ -46,6 +49,7 @@ import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.RefreshableView; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility; import org.rhq.enterprise.gui.coregui.client.util.measurement.GwtMonitorUtils; @@ -455,6 +459,26 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R } }
+ /** Takes the current value of the widget and persists it into the configuration object passed in. + * + * @param resultCountSelector + * @param portletConfig + * returns populated configuration object. + */ + public static Configuration saveResultCounterSettings(final SelectItem resultCountSelector, + final Configuration portletConfig) { + String selectedValue; + if ((resultCountSelector != null) && (portletConfig != null)) { + selectedValue = resultCountSelector.getValue().toString(); + if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(Constant.RESULT_COUNT_DEFAULT))) {//then 5 + portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, Constant.RESULT_COUNT_DEFAULT)); + } else { + portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, selectedValue)); + } + } + return portletConfig; + } + protected boolean displayGroupConfigurationUpdates(GroupCategory groupCategory, Set<ResourceTypeFacet> facets) { if ((groupCategory == null) || facets == null) { return false; diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index dad5c7b..e00893e 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -1450,6 +1450,7 @@ view_portlet_help_graph = This portlet displays the resource metric graph. view_portlet_help_inventorySummary = This portlet displays a short summary of the current user''s viewable inventory and metric collection rate. view_portlet_help_mashup = This portlet displays the returned content of a remote HTTP request (via an iframe). view_portlet_help_message = This portlet displays a static HTML message. The <i>message</i> property must be configured. +view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions for the selected resource. view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory. view_portlet_help_platformSummary = This portlet displays information about the current user''s platform resources. view_portlet_help_problemResources = This portlet displays the current user''s alerted or unavailable resources.