modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java | 311 ------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java | 158 --- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java | 401 ---------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java | 238 ----- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java | 29 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java | 6 modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js | 4 11 files changed, 36 insertions(+), 1134 deletions(-)
New commits: commit 6c46aa725f0a5c81df92250b4b587aa855997fa0 Author: Mike Thompson mithomps@redhat.com Date: Thu Jul 18 20:27:10 2013 -0700
Consolidated Metrics - Dont show graph legend on treegrid charts but show them elsewhere. Removal of old code.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java index e75b65a..ace6154 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java @@ -202,6 +202,10 @@ public abstract class AbstractMetricGraph extends VLayout implements HasD3Metric return metricGraphData.getPortalId(); }
+ public boolean isHideLegend(){ + return metricGraphData.isHideLegend(); + } + public void setGraphListView(AbstractD3GraphListView graphListView) { this.graphListView = graphListView; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java index ecd3b46..dc054fc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java @@ -73,6 +73,7 @@ public class MetricGraphData implements JsonMetricProducer { private MeasurementOOBComposite lastOOB; private Integer chartHeight; private boolean isPortalGraph; + private boolean hideLegend;
private MetricGraphData(int portalId) { @@ -249,6 +250,14 @@ public class MetricGraphData implements JsonMetricProducer { return isPortalGraph; }
+ public boolean isHideLegend() { + return hideLegend; + } + + public void setHideLegend(boolean hideLegend) { + this.hideLegend = hideLegend; + } + public String getChartTitle() {
if(definition != null){ diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java index 9058ea5..eeb97cf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java @@ -73,7 +73,8 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph { global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getButtonBarDateTimeFormat()(), global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getChartSingleValueLabel()(), global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHours()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHoursMinutes()() + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHoursMinutes()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::isHideLegend()() );
@@ -217,8 +218,8 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph { .attr("transform", "translate(" + margin.left + "," + (+titleHeight + titleSpace + margin.top) + ")");
legendUnDefined = (typeof min === 'undefined') || (typeof avg === 'undefined') || (typeof peak === 'undefined'); - if (!useSmallCharts() && !legendUnDefined) { - createMinAvgPeakSidePanel(chartContext.minChartTitle, min, chartContext.avgChartTitle, avg, chartContext.peakChartTitle, peak, chartContext.yAxisUnits); + if (!(chartContext.hideLegend && !useSmallCharts())) { + createMinAvgPeakSidePanel(chartContext.minChartTitle, min, chartContext.avgChartTitle, avg, chartContext.peakChartTitle, peak, chartContext.yAxisUnits); } }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java deleted file mode 100644 index 3d1c881..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * RHQ Management Platform - * Copyright 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. - * - * 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.inventory.resource.detail.monitoring.avail; - -import java.util.ArrayList; -import java.util.Date; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DSResponse; -import com.smartgwt.client.data.Record; -import com.smartgwt.client.data.SortSpecifier; -import com.smartgwt.client.rpc.RPCResponse; -import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.types.ListGridFieldType; -import com.smartgwt.client.types.SortDirection; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.FormItem; -import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.layout.Layout; - -import org.rhq.core.domain.criteria.AvailabilityCriteria; -import org.rhq.core.domain.measurement.Availability; -import org.rhq.core.domain.measurement.MeasurementUnits; -import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary; -import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.core.domain.util.PageControl; -import org.rhq.core.domain.util.PageList; -import org.rhq.core.domain.util.PageOrdering; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.ImageManager; -import org.rhq.enterprise.gui.coregui.client.components.table.Table; -import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; -import org.rhq.enterprise.gui.coregui.client.gwt.AvailabilityGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient; -import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; -import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout; - -/** - * This shows the availability history for a resource. - * - * @author Jay Shaughnessy - * @author John Mazzitelli - * @see org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table.ResourceMetricAvailabilityView - */ -@Deprecated -public class ResourceAvailabilityView extends EnhancedVLayout { - - private ResourceComposite resourceComposite; - private StaticTextItem currentField; - private StaticTextItem availField; - private StaticTextItem availTimeField; - private StaticTextItem downField; - private StaticTextItem downTimeField; - private StaticTextItem disabledField; - private StaticTextItem disabledTimeField; - private StaticTextItem failureCountField; - private StaticTextItem disabledCountField; - private StaticTextItem mtbfField; - private StaticTextItem mttrField; - private StaticTextItem unknownField; - private StaticTextItem currentTimeField; - - public ResourceAvailabilityView(ResourceComposite resourceComposite) { - super(); - - this.resourceComposite = resourceComposite; - - setWidth100(); - setHeight100(); - } - - @Override - protected void onInit() { - super.onInit(); - - addMember(createSummaryForm()); - addMember(createListView()); - } - - private DynamicForm createSummaryForm() { - DynamicForm form = new DynamicForm(); - form.setWidth100(); - form.setAutoHeight(); - form.setMargin(10); - form.setNumCols(4); - - // row 1 - currentField = new StaticTextItem("current", MSG.view_resource_monitor_availability_currentStatus()); - currentField.setWrapTitle(false); - currentField.setColSpan(4); - - // row 2 - availField = new StaticTextItem("avail", MSG.view_resource_monitor_availability_availability()); - availField.setWrapTitle(false); - prepareTooltip(availField, MSG.view_resource_monitor_availability_availability_tooltip()); - - availTimeField = new StaticTextItem("availTime", MSG.view_resource_monitor_availability_uptime()); - availTimeField.setWrapTitle(false); - prepareTooltip(availTimeField, MSG.view_resource_monitor_availability_uptime_tooltip()); - - // row 3 - downField = new StaticTextItem("down", MSG.view_resource_monitor_availability_down()); - downField.setWrapTitle(false); - prepareTooltip(downField, MSG.view_resource_monitor_availability_down_tooltip()); - - downTimeField = new StaticTextItem("downTime", MSG.view_resource_monitor_availability_downtime()); - downTimeField.setWrapTitle(false); - prepareTooltip(downTimeField, MSG.view_resource_monitor_availability_downtime_tooltip()); - - // row 4 - disabledField = new StaticTextItem("disabled", MSG.view_resource_monitor_availability_disabled()); - disabledField.setWrapTitle(false); - prepareTooltip(disabledField, MSG.view_resource_monitor_availability_disabled_tooltip()); - - disabledTimeField = new StaticTextItem("disabledTime", MSG.view_resource_monitor_availability_disabledTime()); - disabledTimeField.setWrapTitle(false); - prepareTooltip(disabledTimeField, MSG.view_resource_monitor_availability_disabledTime_tooltip()); - - // row 5 - failureCountField = new StaticTextItem("failureCount", MSG.view_resource_monitor_availability_numFailures()); - failureCountField.setWrapTitle(false); - prepareTooltip(failureCountField, MSG.view_resource_monitor_availability_numFailures_tooltip()); - - disabledCountField = new StaticTextItem("disabledCount", MSG.view_resource_monitor_availability_numDisabled()); - disabledCountField.setWrapTitle(false); - prepareTooltip(disabledCountField, MSG.view_resource_monitor_availability_numDisabled_tooltip()); - - // row 6 - mtbfField = new StaticTextItem("mtbf", MSG.view_resource_monitor_availability_mtbf()); - mtbfField.setWrapTitle(false); - prepareTooltip(mtbfField, MSG.view_resource_monitor_availability_mtbf_tooltip()); - - mttrField = new StaticTextItem("mttr", MSG.view_resource_monitor_availability_mttr()); - mttrField.setWrapTitle(false); - prepareTooltip(mttrField, MSG.view_resource_monitor_availability_mttr_tooltip()); - - // row 7 - unknownField = new StaticTextItem("unknown"); - unknownField.setWrapTitle(false); - unknownField.setColSpan(4); - unknownField.setShowTitle(false); - - // row 8 - currentTimeField = new StaticTextItem("currentTime"); - currentTimeField.setWrapTitle(false); - currentTimeField.setColSpan(4); - currentTimeField.setShowTitle(false); - - form.setItems(currentField, availField, availTimeField, downField, downTimeField, disabledField, - disabledTimeField, failureCountField, disabledCountField, mtbfField, mttrField, unknownField, - currentTimeField); - - reloadSummaryData(); - - return form; - } - - private void reloadSummaryData() { - GWTServiceLookup.getResourceService().getResourceAvailabilitySummary(resourceComposite.getResource().getId(), - new AsyncCallback<ResourceAvailabilitySummary>() { - - @Override - public void onSuccess(ResourceAvailabilitySummary result) { - - currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(result - .getCurrent().getName(), TimestampCellFormatter.format(result.getLastChange().getTime()))); - availField.setValue(MeasurementConverterClient.format(result.getUpPercentage(), - MeasurementUnits.PERCENTAGE, true)); - availTimeField.setValue(MeasurementConverterClient.format((double) result.getUpTime(), - MeasurementUnits.MILLISECONDS, true)); - downField.setValue(MeasurementConverterClient.format(result.getDownPercentage(), - MeasurementUnits.PERCENTAGE, true)); - downTimeField.setValue(MeasurementConverterClient.format((double) result.getDownTime(), - MeasurementUnits.MILLISECONDS, true)); - disabledField.setValue(MeasurementConverterClient.format(result.getDisabledPercentage(), - MeasurementUnits.PERCENTAGE, true)); - disabledTimeField.setValue(MeasurementConverterClient.format((double) result.getDisabledTime(), - MeasurementUnits.MILLISECONDS, true)); - failureCountField.setValue(result.getFailures()); - disabledCountField.setValue(result.getDisabled()); - mtbfField.setValue(MeasurementConverterClient.format((double) result.getMTBF(), - MeasurementUnits.MILLISECONDS, true)); - mttrField.setValue(MeasurementConverterClient.format((double) result.getMTTR(), - MeasurementUnits.MILLISECONDS, true)); - - if (result.getUnknownTime() > 0L) { - unknownField.setValue(MSG.view_resource_monitor_availability_unknown(MeasurementConverterClient - .format((double) result.getUnknownTime(), MeasurementUnits.MILLISECONDS, true))); - } else { - unknownField.setValue(""); - } - - currentTimeField.setValue(MSG.view_resource_monitor_availability_currentAsOf(TimestampCellFormatter - .format(result.getCurrentTime()))); - } - - @Override - public void onFailure(Throwable caught) { - currentField.setValue(MSG.common_label_error()); - CoreGUI.getErrorHandler() - .handleError(MSG.view_resource_monitor_availability_summaryError(), caught); - } - }); - } - - private void prepareTooltip(FormItem item, String tooltip) { - item.setHoverWidth(400); - item.setPrompt(tooltip); - } - - private Table<ListView.DS> createListView() { - ListView listView = new ListView(resourceComposite.getResource().getId()); - return listView; - } - - private class ListView extends Table<ListView.DS> { - - private DS dataSource; - private int resourceId; - - public ListView(int resourceId) { - super(null, new SortSpecifier[] { new SortSpecifier("startTime", SortDirection.DESCENDING) }); - - this.resourceId = resourceId; - - setDataSource(getDataSource()); - } - - @Override - public DS getDataSource() { - if (null == this.dataSource) { - this.dataSource = new DS(resourceId); - } - return this.dataSource; - } - - @Override - public void refresh() { - super.refresh(); - reloadSummaryData(); - } - - @Override - protected void configureTableContents(Layout contents) { - super.configureTableContents(contents); - setAutoHeight(); - } - - @Override - protected void configureTable() { - ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields(); - getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()])); - - super.configureTable(); - } - - private class DS extends RPCDataSource<Availability, AvailabilityCriteria> { - - public static final String ATTR_ID = "id"; - public static final String ATTR_AVAILABILITY = "availabilityType"; - public static final String ATTR_START_TIME = "startTime"; - public static final String ATTR_END_TIME = "endTime"; - - public static final String ATTR_DURATION = "duration"; - - private AvailabilityGWTServiceAsync availService = GWTServiceLookup.getAvailabilityService(); - private int resourceId; - - public DS(int resourceId) { - super(); - this.resourceId = resourceId; - addDataSourceFields(); - } - - /** - * The view that contains the list grid which will display this datasource's data will call this - * method to get the field information which is used to control the display of the data. - * - * @return list grid fields used to display the datasource data - */ - public ArrayList<ListGridField> getListGridFields() { - ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6); - - ListGridField startTimeField = new ListGridField(ATTR_START_TIME, MSG.common_title_start()); - startTimeField.setCellFormatter(new TimestampCellFormatter()); - startTimeField.setShowHover(true); - startTimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(ATTR_START_TIME)); - startTimeField.setCanSortClientOnly(true); - fields.add(startTimeField); - - ListGridField endTimeField = new ListGridField(ATTR_END_TIME, MSG.common_title_end()); - endTimeField.setCellFormatter(new TimestampCellFormatter()); - endTimeField.setShowHover(true); - endTimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(ATTR_END_TIME)); - endTimeField.setCanSortClientOnly(true); - fields.add(endTimeField); - - ListGridField durationField = new ListGridField(ATTR_DURATION, MSG.common_title_duration()); - durationField.setAlign(Alignment.RIGHT); - fields.add(durationField); - - ListGridField availabilityField = new ListGridField(ATTR_AVAILABILITY, MSG.common_title_availability()); - availabilityField.setType(ListGridFieldType.IMAGE); - availabilityField.setAlign(Alignment.CENTER); - fields.add(availabilityField); - - return fields; - } - - @Override - protected AvailabilityCriteria getFetchCriteria(DSRequest request) { - AvailabilityCriteria c = new AvailabilityCriteria(); - c.addFilterResourceId(resourceId); - c.addFilterInitialAvailability(false); - - // This code is unlikely to be necessary as the encompassing view should be using an initial - // sort specifier. But just in case, make sure we set the initial sort. Note that we have to - // manipulate the PageControl directly as per the restrictions on getFetchCriteria() (see jdoc). - PageControl pageControl = getPageControl(request); - if (pageControl.getOrderingFields().isEmpty()) { - pageControl.initDefaultOrderingField("startTime", PageOrdering.DESC); - } - - return c; - } - - @Override - protected void executeFetch(final DSRequest request, final DSResponse response, - AvailabilityCriteria criteria) { - - this.availService.findAvailabilityByCriteria(criteria, new AsyncCallback<PageList<Availability>>() { - public void onFailure(Throwable caught) { - // TODO fix message - CoreGUI.getErrorHandler().handleError(MSG.common_label_error(), caught); - response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(request.getRequestId(), response); - } - - public void onSuccess(final PageList<Availability> result) { - response.setData(buildRecords(result)); - response.setTotalRows(result.size()); - processResponse(request.getRequestId(), response); - } - }); - } - - @Override - public Availability copyValues(Record from) { - return null; - } - - @Override - public ListGridRecord copyValues(Availability from) { - ListGridRecord record = new ListGridRecord(); - - record.setAttribute(ATTR_ID, from.getId()); - record.setAttribute(ATTR_AVAILABILITY, - ImageManager.getAvailabilityIconFromAvailType(from.getAvailabilityType())); - record.setAttribute(ATTR_START_TIME, new Date(from.getStartTime())); - if (null != from.getEndTime()) { - record.setAttribute(ATTR_END_TIME, new Date(from.getEndTime())); - long duration = from.getEndTime() - from.getStartTime(); - record.setAttribute(ATTR_DURATION, - MeasurementConverterClient.format((double) duration, MeasurementUnits.MILLISECONDS, true)); - - } else { - record.setAttribute(ATTR_END_TIME, MSG.common_label_none2()); - long duration = System.currentTimeMillis() - from.getStartTime(); - record.setAttribute(ATTR_DURATION, - MeasurementConverterClient.format((double) duration, MeasurementUnits.MILLISECONDS, true)); - - } - - return record; - } - } - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java deleted file mode 100644 index dd70b93..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.inventory.resource.detail.monitoring.table; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.TreeSet; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.types.SelectionStyle; -import com.smartgwt.client.widgets.Window; -import com.smartgwt.client.widgets.events.CloseClickEvent; -import com.smartgwt.client.widgets.events.CloseClickHandler; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.criteria.ResourceCriteria; -import org.rhq.core.domain.measurement.MeasurementData; -import org.rhq.core.domain.measurement.MeasurementUnits; -import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.components.measurement.UserPreferencesMeasurementRangeEditor; -import org.rhq.enterprise.gui.coregui.client.components.table.Table; -import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView; -import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.D3GraphListView; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -/** - * Views a resource's measurements in a tabular view. - * - * @author John Mazzitelli - */ -@Deprecated -public class MeasurementTableView extends Table<MetricsTableDataSource> { - - private final int resourceId; - - public MeasurementTableView(int resourceId) { - super(); - this.resourceId = resourceId; - setDataSource(new MetricsTableDataSource(resourceId)); - } - - protected void configureTable() { - ArrayList<ListGridField> fields = getDataSource().getListGridFields(); - setListGridFields(fields.toArray(new ListGridField[0])); - addExtraWidget(new UserPreferencesMeasurementRangeEditor(), true); - addTableAction(MSG.view_measureTable_getLive(), new TableAction() { - @Override - public boolean isEnabled(ListGridRecord[] selection) { - return selection != null && selection.length > 0; - } - - @Override - public void executeAction(ListGridRecord[] selection, Object actionValue) { - if (selection == null || selection.length == 0) { - return; - } - // keyed on metric name - string[0] is the metric label, [1] is the units - final HashMap<String, String[]> scheduleNamesAndUnits = new HashMap<String, String[]>(); - int[] definitionIds = new int[selection.length]; - int i = 0; - for (ListGridRecord record : selection) { - Integer defId = record.getAttributeAsInt(MetricsTableDataSource.FIELD_METRIC_DEF_ID); - definitionIds[i++] = defId.intValue(); - - String name = record.getAttribute(MetricsTableDataSource.FIELD_METRIC_NAME); - String label = record.getAttribute(MetricsTableDataSource.FIELD_METRIC_LABEL); - String units = record.getAttribute(MetricsTableDataSource.FIELD_METRIC_UNITS); - if (units == null || units.length() < 1) { - units = MeasurementUnits.NONE.name(); - } - - scheduleNamesAndUnits.put(name, new String[] { label, units }); - } - - // actually go out and ask the agents for the data - GWTServiceLookup.getMeasurementDataService(60000).findLiveData(resourceId, definitionIds, - new AsyncCallback<Set<MeasurementData>>() { - @Override - public void onSuccess(Set<MeasurementData> result) { - if (result == null) { - result = new HashSet<MeasurementData>(0); - } - ArrayList<ListGridRecord> records = new ArrayList<ListGridRecord>(result.size()); - for (MeasurementData data : result) { - String[] nameAndUnits = scheduleNamesAndUnits.get(data.getName()); - if (nameAndUnits != null) { - double doubleValue; - if (data.getValue() instanceof Number) { - doubleValue = ((Number) data.getValue()).doubleValue(); - } else { - doubleValue = Double.parseDouble(data.getValue().toString()); - } - String value = MeasurementConverterClient.formatToSignificantPrecision( - new double[] { doubleValue }, MeasurementUnits.valueOf(nameAndUnits[1]), true)[0]; - - ListGridRecord record = new ListGridRecord(); - record.setAttribute("name", nameAndUnits[0]); - record.setAttribute("value", value); - records.add(record); - } - } - Collections.sort(records, new Comparator<ListGridRecord>() { - public int compare(ListGridRecord o1, ListGridRecord o2) { - return o1.getAttribute("name").compareTo(o2.getAttribute("name")); - } - }); - showLiveData(records); - } - - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError(MSG.view_measureTable_getLive_failure(), caught); - } - }); - } - }); - - - addTableAction(MSG.view_measureTable_chartMetricValues(), new TableAction() { - @Override - public boolean isEnabled(ListGridRecord[] selection) { - return selection != null && selection.length > 0; - } - - @Override - public void executeAction(ListGridRecord[] selection, Object actionValue) { - if (selection == null || selection.length == 0) { - return; - } - final TreeSet<Integer> definitionIds = new TreeSet<Integer>(); - for (ListGridRecord record : selection) { - Integer defId = record.getAttributeAsInt(MetricsTableDataSource.FIELD_METRIC_DEF_ID); - definitionIds.add(defId); - } - - ResourceCriteria criteria = new ResourceCriteria(); - criteria.addFilterId(resourceId); - criteria.fetchSchedules(true); - GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria, - new AsyncCallback<PageList<ResourceComposite>>() { - - @Override - public void onFailure(Throwable caught) { - CoreGUI.getMessageCenter().notify( - new Message(MSG.view_inventory_resource_loadFailed(String.valueOf(resourceId)), - Message.Severity.Warning)); - - CoreGUI.goToView(InventoryView.VIEW_ID.getName()); - } - - @Override - public void onSuccess(PageList<ResourceComposite> result) { - if (result.isEmpty()) { - onFailure(new Exception(MSG.view_inventory_resource_loadFailed(String - .valueOf(resourceId)))); - } else { - final ResourceComposite resourceComposite = result.get(0); - - ChartViewWindow window = new ChartViewWindow(""); - final D3GraphListView graphListView = D3GraphListView.createMultipleGraphs( - resourceComposite.getResource(), definitionIds, true); - - window.addItem(graphListView); - window.show(); - refreshTableInfo(); - - } - } - }); - - } - }); - } - - private void showLiveData(ArrayList<ListGridRecord> records) { - final Window liveDataWindow = new Window(); - liveDataWindow.setTitle(MSG.view_measureTable_live_title()); - liveDataWindow.setShowModalMask(true); - liveDataWindow.setShowMinimizeButton(false); - liveDataWindow.setShowMaximizeButton(true); - liveDataWindow.setShowCloseButton(true); - liveDataWindow.setShowResizer(true); - liveDataWindow.setCanDragResize(true); - liveDataWindow.setDismissOnEscape(true); - liveDataWindow.setIsModal(true); - liveDataWindow.setWidth(700); - liveDataWindow.setHeight(425); - liveDataWindow.setAutoCenter(true); - liveDataWindow.centerInPage(); - liveDataWindow.addCloseClickHandler(new CloseClickHandler() { - @Override - public void onCloseClick(CloseClickEvent event) { - liveDataWindow.destroy(); - refreshTableInfo(); - } - }); - - ListGrid liveDataGrid = new ListGrid(); - liveDataGrid.setShowAllRecords(true); - liveDataGrid.setData(records.toArray(new ListGridRecord[records.size()])); - liveDataGrid.setSelectionType(SelectionStyle.NONE); - ListGridField name = new ListGridField("name", MSG.common_title_metric()); - ListGridField value = new ListGridField("value", MSG.common_title_value()); - liveDataGrid.setFields(name, value); - - liveDataWindow.addItem(liveDataGrid); - liveDataWindow.show(); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java index 5784ed4..bcea825 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java @@ -27,7 +27,6 @@ import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.Availability; @@ -53,14 +52,16 @@ public class MetricsResourceView extends AbstractD3GraphListView { private static final String COLLAPSED_TOOLTIP = MSG.chart_metrics_collapse_tooltip(); private static final String EXPANDED_TOOLTIP = MSG.chart_metrics_expand_tooltip();
- private Resource resource; - private VLayout vLayout; + private final Resource resource; private Img expandCollapseArrow; - private MetricsTableView metricsTableView; - private ResourceMetricAvailabilityView availabilityDetails; + private final MetricsTableView metricsTableView; + private final ResourceMetricAvailabilityView availabilityDetails;
public MetricsResourceView(Resource resource) { super(); + setOverflow(Overflow.AUTO); + setWidth100(); + setHeight100(); this.resource = resource; metricsTableView = new MetricsTableView(resource, this); availabilityDetails = new ResourceMetricAvailabilityView(resource); @@ -87,12 +88,8 @@ public class MetricsResourceView extends AbstractD3GraphListView { Log.debug("MetricResourceView.onDraw() for: " + resource.getName() + " id: " + resource.getId()); destroyMembers();
- vLayout = new VLayout(); - vLayout.setOverflow(Overflow.AUTO); - vLayout.setWidth100(); - vLayout.setHeight100(); - vLayout.addMember(buttonBarDateTimeRangeEditor);
+ addMember(buttonBarDateTimeRangeEditor);
availabilityGraph = new AvailabilityD3GraphView<AvailabilityOverUnderGraphType>( new AvailabilityOverUnderGraphType(resource.getId())); @@ -126,19 +123,17 @@ public class MetricsResourceView extends AbstractD3GraphListView {
expandCollapseHLayout.addMember(expandCollapseArrow); expandCollapseHLayout.addMember(availabilityGraph); - vLayout.addMember(expandCollapseHLayout); + addMember(expandCollapseHLayout); + availabilityDetails.hide(); - vLayout.addMember(availabilityDetails); + addMember(availabilityDetails);
metricsTableView.setHeight100(); - vLayout.addMember(metricsTableView); + addMember(metricsTableView);
- addMember(vLayout);
- if (resource != null) { - queryAvailability(EntityContext.forResource(resource.getId()), buttonBarDateTimeRangeEditor.getStartTime(), + queryAvailability(EntityContext.forResource(resource.getId()), buttonBarDateTimeRangeEditor.getStartTime(), buttonBarDateTimeRangeEditor.getEndTime(), null); - } }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java index 25e430b..77aeda6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java @@ -272,8 +272,6 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re addRecordExpandHandler(new RecordExpandHandler() { @Override public void onRecordExpand(RecordExpandEvent recordExpandEvent) { - Log.debug("Record Expanded: " - + recordExpandEvent.getRecord().getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL)); redrawGraphs(); }
@@ -328,6 +326,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
MetricGraphData metricGraphData = MetricGraphData.createForResource(resourceId, resource.getName(), measurementDefinition, measurementList, null); + metricGraphData.setHideLegend(true);
StackedBarMetricGraphImpl graph = GWT.create(StackedBarMetricGraphImpl.class); graph.setMetricGraphData(metricGraphData); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java index a03ad1a..431e076 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java @@ -45,7 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPre */ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
- public static final int NUMBER_OF_METRIC_POINTS = 60; + private static final int NUMBER_OF_METRIC_POINTS = 60; public static final String FIELD_SPARKLINE = "sparkline"; public static final String FIELD_METRIC_LABEL = "label"; public static final String FIELD_ALERT_COUNT = "alertCount"; @@ -58,11 +58,11 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C public static final String FIELD_METRIC_UNITS = "units"; public static final String FIELD_METRIC_NAME = "name"; public static final String FIELD_RESOURCE_ID = "resourceId"; - final private Resource resource; + private final Resource resource; private List<MetricDisplaySummary> metricDisplaySummaries; private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList; private int[] definitionArrayIds; - private MeasurementUserPreferences measurementUserPrefs; + private final MeasurementUserPreferences measurementUserPrefs;
public MetricsViewDataSource(Resource resource) { this.resource = resource; diff --git a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js index 40c7ca8..ef65e69 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js +++ b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js @@ -38,9 +38,10 @@ if (!window.console.log) window.console.log = function () { * @param singleValueLabel * @param chartXaxisTimeFormatHours * @param chartXaxisTimeFormatHoursMinutes + * @param showLegend * @constructor */ -var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, chartTitle, yAxisUnits, minChartTitle, avgChartTitle, peakChartTitle, dateLabel, timeLabel, downLabel, unknownLabel, noDataLabel, hoverStartLabel, hoverEndLabel, hoverPeriodLabel, hoverBarLabel, chartHoverTimeFormat, chartHoverDateFormat, isPortalGraph, portalId, buttonBarDateTimeFormat, singleValueLabel, chartXaxisTimeFormatHours, chartXaxisTimeFormatHoursMinutes) { +var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, chartTitle, yAxisUnits, minChartTitle, avgChartTitle, peakChartTitle, dateLabel, timeLabel, downLabel, unknownLabel, noDataLabel, hoverStartLabel, hoverEndLabel, hoverPeriodLabel, hoverBarLabel, chartHoverTimeFormat, chartHoverDateFormat, isPortalGraph, portalId, buttonBarDateTimeFormat, singleValueLabel, chartXaxisTimeFormatHours, chartXaxisTimeFormatHoursMinutes, hideLegend) { "use strict"; if (!(this instanceof ChartContext)) { throw new Error("ChartContext function cannot be called as a function.") @@ -78,6 +79,7 @@ var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, char this.buttonBarDateTimeFormat = buttonBarDateTimeFormat; this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours; this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes; + this.hideLegend = hideLegend;
}, /**
commit 87b3c824722d38276a1d1399a14bbf4d208940a1 Author: Mike Thompson mithomps@redhat.com Date: Thu Jul 18 13:14:02 2013 -0700
Remove unused chart types - LineMetricGraph and AvailabilityLineGraphType
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java deleted file mode 100644 index 34ca60b..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2012 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.inventory.common.graph.graphtype; - -import java.util.Date; -import java.util.List; - -import org.rhq.core.domain.measurement.Availability; -import org.rhq.core.domain.measurement.MeasurementUnits; -import org.rhq.core.domain.resource.group.composite.ResourceGroupAvailability; -import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.Messages; -import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AvailabilityGraphType; -import org.rhq.enterprise.gui.coregui.client.util.Log; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient; - -/** - * This is now old and for demonstration purposes only. - * Contains the javascript chart definition for an implementation of the d3 availability chart. This implementation is - * just a line that changes color based on availability type: up=green, down=red, orange=disabled, unknown=grey, - * empty=grey, warn=yellow. This version of the availability graph shows continuous intervals. - * @deprecated - * @see AvailabilityOverUnderGraphType - * - * @author Mike Thompson - */ -public class AvailabilityLineGraphType implements AvailabilityGraphType { - - private static Messages MSG = CoreGUI.getMessages(); - private List<Availability> availabilityList; - private List<ResourceGroupAvailability> groupAvailabilityList; - private Integer entityId; - - /** - * General constructor for stacked bar graph when you have all the data needed to produce the graph. (This is true - * for all cases but the dashboard portlet). - */ - public AvailabilityLineGraphType(Integer entityId) { - this.entityId = entityId; - } - - public void setAvailabilityList(List<Availability> availabilityList) { - this.availabilityList = availabilityList; - } - - public void setGroupAvailabilityList(List<ResourceGroupAvailability> groupAvailabilityList) { - this.groupAvailabilityList = groupAvailabilityList; - } - - public String getAvailabilityJson() { - StringBuilder sb = new StringBuilder("["); - if (null != availabilityList) { - // loop through the avail intervals - for (Availability availability : availabilityList) { - sb.append("{ "availType":"" + availability.getAvailabilityType() + "", "); - sb.append(" "availTypeMessage":"" + availability.getAvailabilityType()+ "", "); - sb.append(" "availStart":" + availability.getStartTime() + ", "); - // last record will be null - long endTime = availability.getEndTime() != null ? availability.getEndTime() : (new Date()).getTime(); - sb.append(" "availEnd":" + endTime + ", "); - - long availDuration = endTime - availability.getStartTime(); - String availDurationString = MeasurementConverterClient.format((double) availDuration, - MeasurementUnits.MILLISECONDS, true); - sb.append(" "availDuration": "" + availDurationString + "" },"); - - } - sb.setLength(sb.length() - 1); - - } else if (null != groupAvailabilityList) { - // loop through the group avail down intervals - for (ResourceGroupAvailability groupAvailability : groupAvailabilityList) { - // allows substitution for situations like WARN=MIXED for easier terminology - String availabilityTypeMessage = (groupAvailability.getGroupAvailabilityType().equals(ResourceGroupComposite.GroupAvailabilityType.WARN)) - ? MSG.chart_hover_availability_type_warn() : groupAvailability.getGroupAvailabilityType().name(); - - sb.append("{ "availType":"" + groupAvailability.getGroupAvailabilityType() + "", "); - sb.append(" "availTypeMessage":"" + availabilityTypeMessage + "", "); - sb.append(" "availStart":" + groupAvailability.getStartTime() + ", "); - // last record will be null - long endTime = groupAvailability.getEndTime() != null ? groupAvailability.getEndTime() : (new Date()) - .getTime(); - sb.append(" "availEnd":" + endTime + ", "); - - long availDuration = endTime - groupAvailability.getStartTime(); - String availDurationString = MeasurementConverterClient.format((double) availDuration, - MeasurementUnits.MILLISECONDS, true); - sb.append(" "availDuration": "" + availDurationString + "" },"); - - } - sb.setLength(sb.length() - 1); - } - - sb.append("]"); - Log.debug(sb.toString()); - return sb.toString(); - } - - /** - * The magic JSNI to draw the charts with d3. - */ - public native void drawJsniChart() /*-{ - console.log("Draw Availability chart"); - - var global = this, - // tidy up all of our interactions with java (via JSNI) thru AvailChartContext class - // NOTE: rhq.js has the javascript object constructors in it. - availChartContext = new $wnd.AvailChartContext(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartId()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getAvailabilityJson()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartDateLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartTimeLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverStartLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverEndLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverBarLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverAvailabilityLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverTimeFormat()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverDateFormat()() - ); - - - var availabilityGraph = function () { - "use strict"; - // privates - - var margin = {top: 5, right: 5, bottom: 5, left: 40}, - barOffset = 10, - width = 750 - margin.left - margin.right + barOffset, - height = 20 - margin.top - margin.bottom, - pixelsOffHeight = 0, - svg; - - - function drawBars(availChartContext) { - var xAxisMin = $wnd.d3.min(availChartContext.data, function (d) { - return +d.availStart; - }), - xAxisMax = $wnd.d3.max(availChartContext.data, function (d) { - return +d.availEnd; - }), - - timeScale = $wnd.d3.time.scale() - .range([0, width]) - .domain([xAxisMin, xAxisMax]), - - yScale = $wnd.d3.scale.linear() - .clamp(true) - .rangeRound([height, 0]) - .domain([0, 4]), - - svg = $wnd.d3.select(availChartContext.chartSelection).append("g") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) - .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - - - // The gray bars at the bottom leading up - svg.selectAll("rect.availBars") - .data(availChartContext.data) - .enter().append("rect") - .attr("class", "availBars") - .attr("x", function (d) { - return timeScale(+d.availStart); - }) - .attr("y", function (d) { - return yScale(0); - }) - .attr("height", function (d) { - return height - yScale(4) - pixelsOffHeight; - }) - .attr("width", function (d) { - return timeScale(+d.availEnd) - timeScale(+d.availStart); - }) - - .attr("opacity", ".9") - .attr("fill", function (d) { - if (d.availType === 'DOWN') { - return "#FF1919"; // red - } - else if (d.availType === 'DISABLED') { - return "#FF9933"; // orange - } - else if (d.availType === 'UNKNOWN') { - return "#CCC"; // gray - } - else if (d.availType === 'UP') { - return "#198C19"; // green - } - else if (d.availType === 'WARN') { - return "#FFFF00"; // yellow - } - else if (d.availType === 'EMPTY') { - return "#CCC"; // gray - } - else { - // should not ever happen, but... - console.warn("AvailabilityType not valid."); - return "#000"; //black - } - }); - } - - function createHovers() { - $wnd.jQuery('svg rect.availBars').tipsy({ - gravity: 'n', - html: true, - trigger: 'hover', - title: function () { - var d = this.__data__; - return formatHovers(d); - }, - show: function (e, el) { - el.css({ 'z-index': '990000'}) - } - }); - } - - function formatHovers(d) { - var hoverString, - timeFormatter = $wnd.d3.time.format(availChartContext.chartHoverTimeFormat), - dateFormatter = $wnd.d3.time.format(availChartContext.chartHoverDateFormat), - availStart = new Date(+d.availStart), - availEnd = new Date(+d.availEnd); - - hoverString = - '<div class="chartHoverEnclosingDiv">' + - '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverBarAvailabilityLabel + ': </span><span style="width:50px;">' + d.availTypeMessage + '</span></div>' + - '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverStartLabel + ': </span><span style="width:50px;">' + timeFormatter(availStart) + '</span></div>' + - '<div class="chartHoverAlignRight"><span >' + ' </span><span style="width:50px;">' + dateFormatter(availStart) + '</span></div>' + - '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverEndLabel + ': </span><span style="width:50px;">' + timeFormatter(availEnd) + '</span></div>' + - '<div class="chartHoverAlignRight"><span >' + ' </span><span style="width:50px;">' + dateFormatter(availEnd) + '</span></div>' + - '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverBarLabel + ': </span><span style="width:50px;">' + d.availDuration + '</span></div>' + - '</div>'; - return hoverString; - - } - - return { - // Public API - draw: function (chartContext) { - "use strict"; - console.info("AvailabilityChart"); - //console.time("availabilityChart"); - - drawBars(availChartContext); - createHovers(); - //console.timeEnd("availabilityChart"); - } - }; // end public closure - - - }(); - - if (availChartContext.data !== undefined && availChartContext.data.length > 0) { - availabilityGraph.draw(availChartContext); - } - - }-*/; - - public String getChartId() { - return String.valueOf(entityId); - } - - public String getChartTimeLabel() { - return MSG.chart_time_label(); - } - - public String getChartDateLabel() { - return MSG.chart_date_label(); - } - - public String getChartHoverAvailabilityLabel() { - return MSG.chart_hover_availability_label(); - } - - public String getChartHoverStartLabel() { - return MSG.chart_hover_start_label(); - } - - public String getChartHoverEndLabel() { - return MSG.chart_hover_end_label(); - } - - public String getChartHoverBarLabel() { - return MSG.chart_hover_bar_label(); - } - - public String getChartHoverTimeFormat() { - return MSG.chart_hover_time_format(); - } - - public String getChartHoverDateFormat() { - return MSG.chart_hover_date_format(); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java deleted file mode 100644 index 079b2ab..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2012 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.inventory.common.graph.graphtype; - -import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph; -import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData; - -/** - * Contains the javascript chart definition for a d3 Line graph chart. - * NOTE: this class isn't used just provided as an example as how to create - * other graph types. - * - * @author Mike Thompson - */ -public final class LineMetricGraph extends AbstractMetricGraph { - - /** - * General constructor for stacked bar graph when you have all the data needed to - * produce the graph. (This is true for all cases but the dashboard portlet). - */ - public LineMetricGraph(MetricGraphData metricGraphData) { - setMetricGraphData(metricGraphData); - } - - /** - * The magic JSNI to draw the charts with d3. - */ - public native void drawJsniChart() /*-{ - console.log("Draw Metric Line jsni chart"); - var global = this, - chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getChartId()(), - chartHandle = "#rChart-"+chartId, - chartSelection = chartHandle + " svg", - json = $wnd.jQuery.parseJSON(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getJsonMetrics()()), - yAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getChartTitle()(), - yAxisUnits = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getYAxisUnits()(), - xAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getXAxisTitle()(); - - console.log("chart id: "+chartSelection ); - console.log(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getJsonMetrics()()); - - - function draw(data){ - "use strict"; - - var margin = {top: 10, right: 5, bottom: 30, left: 70}, - width = 400 - margin.left - margin.right, - height = 150 - margin.top - margin.bottom; - - var timeScale = $wnd.d3.time.scale() - .range([0, width]) - .domain($wnd.d3.extent(data, function(d) { return d.x; })); - - var yScale = $wnd.d3.scale.linear() - .rangeRound([height, 0]) - .domain([$wnd.d3.min(data.map(function(x) {return x.low;})), $wnd.d3.max(data.map(function(x){return x.high;}))]); - - var xAxis = $wnd.d3.svg.axis() - .scale(timeScale) - .ticks(5) - .orient("bottom"); - - var yAxis = $wnd.d3.svg.axis() - .scale(yScale) - .ticks(5) - .orient("left"); - - var interpolation = "basis"; - - var line = $wnd.d3.svg.line() - .interpolate(interpolation) - .x(function(d) { return timeScale(d.x); }) - .y(function(d) { return yScale(+d.y); }); - - var highLine = $wnd.d3.svg.line() - .interpolate(interpolation) - .x(function(d) { return timeScale(d.x); }) - .y(function(d) { return yScale(+d.high); }); - - var lowLine = $wnd.d3.svg.line() - .interpolate(interpolation) - .x(function(d) { return timeScale(d.x); }) - .y(function(d) { return yScale(+d.low); }); - - var svg = $wnd.d3.select(chartSelection).append("g") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) - .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - - svg.append("g") - .attr("class", "x axis") - .attr("transform", "translate(0," + height + ")") - .call(xAxis); - - - svg.append("g") - .attr("class", "y axis") - .call(yAxis) - .append("text") - .attr("transform", "rotate(-90)") - .attr("y", -60) - .attr("dy", ".71em") - .style("text-anchor", "end") - .text(yAxisUnits === "NONE" ? "" : yAxisUnits); - - console.log("finished axes"); - - svg.append("path") - .datum(data) - .attr("class", "line") - .attr("fill", "none") - .attr("stroke", "steelblue") - .attr("stroke-width", "2") - .attr("d", line); - - svg.append("path") - .datum(data) - .attr("class", "highLine") - .attr("fill", "none") - .attr("stroke", "red") - .attr("stroke-width", "1.5") - //.attr("stroke-dasharray", "20,10,5,5,5,10") - .attr("stroke-dasharray", "5,5") - .attr("stroke-opacity", ".3") - .attr("d", highLine); - - svg.append("path") - .datum(data) - .attr("class", "lowLine") - .attr("fill", "none") - .attr("stroke", "blue") - .attr("stroke-width", "1.5") - .attr("stroke-dasharray", "5,5") - .attr("stroke-opacity", ".3") - .attr("d", lowLine); - - console.log("finished paths"); - }(data); - - }-*/; - -}
rhq-commits@lists.fedorahosted.org