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

Commit

Permalink
Merge pull request #115 from tsegismont/calltime_daterangeeditor
Browse files Browse the repository at this point in the history
Bug 1032054 - Refresh button on Monitoring/Calltime page does not move '...Looks good to me, addition of the time bar is useful.
  • Loading branch information
mtho11 committed Aug 29, 2014
2 parents 8420862 + f5a0afb commit b08d924
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 80 deletions.
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
* Copyright (C) 2005-2011 Red Hat, Inc.
* Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -13,9 +13,10 @@
* 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.
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/

package org.rhq.coregui.client.inventory.groups.detail;

import java.util.ArrayList;
Expand Down Expand Up @@ -116,7 +117,6 @@ public static class SubTab {

// subtabs
private SubTab summaryActivity;
private SubTab summaryTimeline;
private SubTab monitorGraphs;
private SubTab monitorMetrics;
private SubTab monitorTraits;
Expand All @@ -142,7 +142,6 @@ public ResourceGroupDetailView(String baseViewPath) {

summaryTab = getTabSet().getTabByName(Tab.Summary.NAME);
summaryActivity = summaryTab.getSubTabByName(Tab.Summary.SubTab.ACTIVITY);
summaryTimeline = summaryTab.getSubTabByName(Tab.Summary.SubTab.TIMELINE);

monitoringTab = getTabSet().getTabByName(Tab.Monitoring.NAME);
monitorCallTime = monitoringTab.getSubTabByName(Tab.Monitoring.SubTab.CALL_TIME);
Expand Down Expand Up @@ -278,7 +277,7 @@ private static TwoLevelTab[] createTabs() {
return tabs.toArray(new TwoLevelTab[tabs.size()]);
}

private final static Canvas viewWithoutHeader(Table t) {
private static Canvas viewWithoutHeader(Table t) {
t.setShowHeader(false);
return t;
}
Expand Down Expand Up @@ -377,7 +376,7 @@ public Canvas createView() {
viewFactory = (!visible) ? null : new ViewFactory() {
@Override
public Canvas createView() {
return viewWithoutHeader(new CalltimeView(EntityContext.forGroup(groupComposite.getResourceGroup())));
return new CalltimeView(EntityContext.forGroup(groupComposite.getResourceGroup()));
}
};
updateSubTab(this.monitoringTab, this.monitorCallTime, visible, true, viewFactory);
Expand Down Expand Up @@ -583,6 +582,7 @@ private void loadResourceType(final ResourceGroupComposite groupComposite, final
ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events,
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
new ResourceTypeRepository.TypeLoadedCallback() {
@Override
public void onTypesLoaded(ResourceType type) {
// until we finish the following work we're susceptible to fast-click issues in
// tree navigation. So, wait until after it's done to notify listeners that the view is
Expand Down
@@ -1,3 +1,22 @@
/*
* RHQ Management Platform
* Copyright (C) 2005-2014 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/

package org.rhq.coregui.client.inventory.resource.detail.monitoring;

import java.util.ArrayList;
Expand All @@ -17,12 +36,10 @@
import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits;
import org.rhq.core.domain.util.PageList;
import org.rhq.coregui.client.CoreGUI;
import org.rhq.coregui.client.UserSessionManager;
import org.rhq.coregui.client.gwt.GWTServiceLookup;
import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
import org.rhq.coregui.client.util.MeasurementConverterClient;
import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
import org.rhq.coregui.client.util.preferences.UserPreferences;

/**
* A data source to read in calltime (aka response time) metric data.
Expand Down Expand Up @@ -65,6 +82,7 @@ public ArrayList<ListGridField> getListGridFields() {
ListGridField minField = new ListGridField(FIELD_MIN, MSG.common_title_monitor_minimum());
minField.setWidth("10%");
minField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return record.getAttribute(FIELD_MIN_STRING);
}
Expand All @@ -74,6 +92,7 @@ public String format(Object value, ListGridRecord record, int rowNum, int colNum
ListGridField maxField = new ListGridField(FIELD_MAX, MSG.common_title_monitor_maximum());
maxField.setWidth("10%");
maxField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return record.getAttribute(FIELD_MAX_STRING);
}
Expand All @@ -83,6 +102,7 @@ public String format(Object value, ListGridRecord record, int rowNum, int colNum
ListGridField avgField = new ListGridField(FIELD_AVG, MSG.common_title_monitor_average());
avgField.setWidth("10%");
avgField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return record.getAttribute(FIELD_AVG_STRING);
}
Expand All @@ -92,6 +112,7 @@ public String format(Object value, ListGridRecord record, int rowNum, int colNum
ListGridField totalField = new ListGridField(FIELD_TOTAL, MSG.view_resource_monitor_calltime_total());
totalField.setWidth("10%");
totalField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return record.getAttribute(FIELD_TOTAL_STRING);
}
Expand Down Expand Up @@ -120,7 +141,7 @@ public ListGridRecord copyValues(CallTimeDataComposite from) {
MeasurementNumericValueAndUnits total = MeasurementConverterClient.fit(from.getTotal(),
MeasurementUnits.MILLISECONDS);
String totalString = MeasurementConverterClient.format(from.getTotal(), MeasurementUnits.MILLISECONDS, true);

ListGridRecord record = new ListGridRecord();
record.setAttribute(FIELD_DESTINATION, from.getCallDestination());
record.setAttribute(FIELD_REQUESTCOUNT, from.getCount());
Expand All @@ -137,18 +158,13 @@ public ListGridRecord copyValues(CallTimeDataComposite from) {

@Override
protected CallTimeDataCriteria getFetchCriteria(DSRequest request) {
UserPreferences prefs = UserSessionManager.getUserPreferences();
MeasurementUserPreferences mprefs = new MeasurementUserPreferences(prefs);
ArrayList<Long> range = mprefs.getMetricRangePreferences().getBeginEndTimes();
String destinationFilter = getFilter(request, FILTER_DESTINATION, String.class);

CallTimeDataCriteria criteria = new CallTimeDataCriteria();
criteria.addFilterBeginTime(range.get(0));
criteria.addFilterEndTime(range.get(1));
criteria.addFilterBeginTime(CustomDateRangeState.getInstance().getStartTime());
criteria.addFilterEndTime(CustomDateRangeState.getInstance().getEndTime());
String destinationFilter = getFilter(request, FILTER_DESTINATION, String.class);
if (destinationFilter != null && destinationFilter.length() > 0) {
criteria.addFilterDestination(destinationFilter);
}

return criteria;
}

Expand All @@ -157,10 +173,12 @@ protected void executeFetch(final DSRequest request, final DSResponse response,
GWTServiceLookup.getMeasurementDataService().findCallTimeDataForContext(this.entityContext, criteria,
new AsyncCallback<PageList<CallTimeDataComposite>>() {

@Override
public void onSuccess(PageList<CallTimeDataComposite> result) {
sendSuccessResponse(request, response, result);
}

@Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_calltime_loadFailed(), caught);
}
Expand Down
@@ -0,0 +1,80 @@
/*
* RHQ Management Platform
* Copyright (C) 2005-2014 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/

package org.rhq.coregui.client.inventory.resource.detail.monitoring;

import java.util.ArrayList;

import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridField;

import org.rhq.core.domain.common.EntityContext;
import org.rhq.coregui.client.components.table.Table;
import org.rhq.coregui.client.dashboard.AutoRefreshUtil;
import org.rhq.coregui.client.inventory.AutoRefresh;
import org.rhq.coregui.client.inventory.common.graph.Refreshable;

/**
* @author Thomas Segismont
*/
public class CalltimeTableView extends Table<CalltimeDataSource> implements Refreshable, AutoRefresh {
private final TextItem destinationFilter;
private Timer refreshTimer;

public CalltimeTableView(EntityContext context) {
setDataSource(new CalltimeDataSource(context));
destinationFilter = new TextItem(CalltimeDataSource.FILTER_DESTINATION,
MSG.view_resource_monitor_calltime_destinationFilter());
}

@Override
protected void configureTableFilters() {
setFilterFormItems(this.destinationFilter);
}

@Override
protected void configureTable() {
ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields();
getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
}

@Override
public void refreshData() {
if (isVisible() && !isRefreshing()) {
refresh();
}
}

@Override
public void startRefreshCycle() {
refreshTimer = AutoRefreshUtil.startRefreshCycleWithPageRefreshInterval(this, this, refreshTimer);
}

@Override
public boolean isRefreshing() {
return false;
}

@Override
protected void onDestroy() {
AutoRefreshUtil.onDestroy(refreshTimer);
super.onDestroy();
}
}
@@ -1,8 +1,7 @@
/*
* RHQ Management Platform
* Copyright 2010-2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
* Copyright (C) 2005-2014 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
Expand All @@ -14,74 +13,33 @@
* 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.
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.coregui.client.inventory.resource.detail.monitoring;

import java.util.ArrayList;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridField;
package org.rhq.coregui.client.inventory.resource.detail.monitoring;

import org.rhq.core.domain.common.EntityContext;
import org.rhq.coregui.client.IconEnum;
import org.rhq.coregui.client.components.measurement.UserPreferencesMeasurementRangeEditor;
import org.rhq.coregui.client.components.table.TableSection;
import org.rhq.coregui.client.components.view.HasViewName;
import org.rhq.coregui.client.components.view.ViewName;
import org.rhq.coregui.client.inventory.common.graph.ButtonBarDateTimeRangeEditor;
import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;

/**
* A view that displays a paginated table of calltime (aka response time) data.
*
* @author John Mazzitelli
* @author Thomas Segismont
*/
public class CalltimeView extends TableSection<CalltimeDataSource> implements HasViewName {

public static final ViewName SUBSYSTEM_VIEW_ID = new ViewName("CalltimeData",
MSG.view_resource_monitor_calltime_title(), IconEnum.CALLTIME);

private TextItem destinationFilter;

// for subsystem views
public CalltimeView() {
this(EntityContext.forSubsystemView());
}

public CalltimeView(EntityContext context) {
super(SUBSYSTEM_VIEW_ID.getTitle());
setDataSource(new CalltimeDataSource(context));
destinationFilter = new TextItem(CalltimeDataSource.FILTER_DESTINATION,
MSG.view_resource_monitor_calltime_destinationFilter());
}

@Override
protected void configureTableFilters() {
setFilterFormItems(this.destinationFilter);
}

@Override
protected boolean isDetailsEnabled() {
return false; // we don't have more details other than what the main table shows
}

@Override
public Canvas getDetailsView(Integer id) {
return null; // we do not support detail views
}

@Override
protected void configureTable() {
ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields();
getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
addExtraWidget(new UserPreferencesMeasurementRangeEditor(), true);
public class CalltimeView extends EnhancedVLayout {
private final CalltimeTableView calltimeTableaView;
private final ButtonBarDateTimeRangeEditor timeRangeEditor;

super.configureTable();
public CalltimeView(EntityContext entityContext) {
calltimeTableaView = new CalltimeTableView(entityContext);
timeRangeEditor = new ButtonBarDateTimeRangeEditor(calltimeTableaView);
}

@Override
public ViewName getViewName() {
return SUBSYSTEM_VIEW_ID;
protected void onDraw() {
super.onDraw();
removeMembers(getMembers());
addMember(timeRangeEditor);
addMember(calltimeTableaView);
}
}

0 comments on commit b08d924

Please sign in to comment.