modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java | 13 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java | 12 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java | 10 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java | 6 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java | 52 ++++------ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java | 11 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java | 28 ----- modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js | 12 +- 10 files changed, 70 insertions(+), 78 deletions(-)
New commits: commit 6c46519865100f090124e0146d78c4dbe2097291 Author: Mike Thompson mithomps@redhat.com Date: Thu Apr 4 14:34:11 2013 -0700
[BZ 924942] - Add portlet key to New charts on dashboard so the same resource, metric can be displayed on multiple dashboards.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java index 279dfea..84177c0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java @@ -70,16 +70,25 @@ public class ResourceGroupD3GraphPortlet extends ResourceGroupMetricD3GraphView public static final String CFG_DEFINITION_ID = "definitionId";
public ResourceGroupD3GraphPortlet() { - super(new MetricStackedBarGraph(MetricGraphData.createForDashboard())); + super(new MetricStackedBarGraph(MetricGraphData.createForDashboard(0))); setOverflow(Overflow.HIDDEN); }
+ @Override + /** + * Portlet Charts are defined by an additional portletId to enable a particular groupId/measurementId + * combination to be valid in multiple dashboards. + */ + public String getFullChartId(){ + return "rChart-"+ graph.getMetricGraphData().getChartId() +"-"+portletWindow.getStoredPortlet().getId(); + } + public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
if (null == this.portletWindow && null != portletWindow) { this.portletWindow = portletWindow; } - setMetricGraphData(MetricGraphData.createForDashboard()); + setMetricGraphData(MetricGraphData.createForDashboard(portletWindow.getStoredPortlet().getId()));
if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { return; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java index f461f25..d39f35a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java @@ -93,7 +93,7 @@ public class ResourceD3GraphPortlet extends ResourceMetricD3Graph implements Aut }
- setGraph(new MetricStackedBarGraph(MetricGraphData.createForDashboard())); + setGraph(new MetricStackedBarGraph(MetricGraphData.createForDashboard(portletWindow.getStoredPortlet().getId())));
if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { return; @@ -272,7 +272,6 @@ public class ResourceD3GraphPortlet extends ResourceMetricD3Graph implements Aut
@Override public void redraw() { - Log.debug("Redraw Portlet Graph and set data, width: "+portletWindow.getWidth());
DashboardPortlet storedPortlet = portletWindow.getStoredPortlet(); PropertySimple simple = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID); @@ -292,6 +291,15 @@ public class ResourceD3GraphPortlet extends ResourceMetricD3Graph implements Aut super.redraw(); }
+ @Override + /** + * Portlet Charts are defined by an additional portletId to enable a particular resourceId/measurementId + * combination to be valid in multiple dashboards. + */ + public String getFullChartId(){ + return "rChart-"+ graph.getMetricGraphData().getChartId() +"-"+portletWindow.getStoredPortlet().getId(); + } + public static final class Factory implements PortletViewFactory { public static PortletViewFactory INSTANCE = new Factory();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java index 2818b86..0a1155e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java @@ -117,13 +117,13 @@ public abstract class AbstractMetricD3GraphView extends EnhancedVLayout { * */ protected void drawGraph() { - Log.debug("drawGraph marker in AbstractMetricD3GraphView for: " + graph.getMetricGraphData().getChartId() + " " + Log.debug("drawGraph marker in AbstractMetricD3GraphView for: " + getFullChartId() + " " + graph.getChartTitle());
StringBuilder divAndSvgDefs = new StringBuilder(); divAndSvgDefs - .append("<div id="rChart-" - + graph.getMetricGraphData().getChartId() + .append("<div id="" + + getFullChartId() + "" ><svg xmlns="http://www.w3.org/2000/svg%5C" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink%5C" style="height:" + getChartHeight() + "px;">"); divAndSvgDefs.append(getSvgDefs()); @@ -147,6 +147,10 @@ public abstract class AbstractMetricD3GraphView extends EnhancedVLayout { }.schedule(200); }
+ public String getFullChartId(){ + return "rChart-"+ graph.getMetricGraphData().getChartId(); + + } public void setGraph(AbstractGraph graph) { this.graph = graph; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java index 125a740..27a6c02 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java @@ -138,7 +138,7 @@ public abstract class AbstractGraph extends VLayout implements HasD3MetricJsniCh }
- public Integer getChartHeight() { + public int getChartHeight() { return metricGraphData.getChartHeight(); }
@@ -166,8 +166,8 @@ public abstract class AbstractGraph extends VLayout implements HasD3MetricJsniCh return metricGraphData.getJsonMetrics(); }
- public Integer getWindowWidth() { - return metricGraphData.getWindowWidth(); + public int getPortalId() { + return metricGraphData.getPortalId(); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java index b9222d0..d3a00e6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java @@ -63,73 +63,60 @@ public class MetricGraphData implements JsonMetricProducer { private int entityId = 0; private String entityName; private int definitionId; + private int portalId; private MeasurementUnits adjustedMeasurementUnits; private MeasurementDefinition definition; private List<MeasurementDataNumericHighLowComposite> metricData; private PageList<MeasurementOOBComposite> measurementOOBCompositeList; private MeasurementOOBComposite lastOOB; private Integer chartHeight; - private Boolean isPortalGraph; + private boolean isPortalGraph; /** * WindowWidth is used in determining what size graph to display in the dashboard portlets. */ - private Integer windowWidth; + //private Integer windowWidth;
- private MetricGraphData() { + private MetricGraphData(int portalId) { isPortalGraph = true; - + this.portalId = portalId; }
- public static MetricGraphData createForDashboard(){ - return new MetricGraphData(); + public static MetricGraphData createForDashboard(int portalId){ + return new MetricGraphData(portalId); }
- /** - * - * @param entityId - * @param entityName - * @param def - * @param metricData - */ + private MetricGraphData(int entityId, String entityName, MeasurementDefinition def, - List<MeasurementDataNumericHighLowComposite> metricData, Integer windowWidth) { + List<MeasurementDataNumericHighLowComposite> metricData ) { this.entityName = entityName; setEntityId(entityId); setDefinitionId(def.getId()); this.definition = def; this.metricData = metricData; - this.windowWidth = windowWidth; this.isPortalGraph = false; }
public static MetricGraphData createForResourceGroup(int groupId, String groupName, MeasurementDefinition def, - List<MeasurementDataNumericHighLowComposite> metricData, - Integer windowWidth){ - return new MetricGraphData(groupId,groupName,def, metricData, windowWidth); + List<MeasurementDataNumericHighLowComposite> metricData ){ + return new MetricGraphData(groupId,groupName,def, metricData ); }
private MetricGraphData(int entityId, String entityName, MeasurementDefinition measurementDef, List<MeasurementDataNumericHighLowComposite> metrics, - PageList<MeasurementOOBComposite> measurementOOBCompositeList, Integer windowWidth) { + PageList<MeasurementOOBComposite> measurementOOBCompositeList ) { this.entityName = entityName; setEntityId(entityId); setDefinitionId(measurementDef.getId()); this.definition = measurementDef; this.metricData = metrics; this.measurementOOBCompositeList = measurementOOBCompositeList; - this.windowWidth = windowWidth; this.isPortalGraph = false; }
public static MetricGraphData createForResource(int resourceId, String resourceName, MeasurementDefinition measurementDef, List<MeasurementDataNumericHighLowComposite> metrics, - PageList<MeasurementOOBComposite> measurementOOBCompositeList, - Integer windowWidth){ - return new MetricGraphData(resourceId, resourceName,measurementDef, metrics, measurementOOBCompositeList, windowWidth); - } - - public Integer getWindowWidth() { - return windowWidth; + PageList<MeasurementOOBComposite> measurementOOBCompositeList ){ + return new MetricGraphData(resourceId, resourceName,measurementDef, metrics, measurementOOBCompositeList); }
public int getEntityId() { @@ -165,7 +152,11 @@ public class MetricGraphData implements JsonMetricProducer { }
public String getChartId() { + if(isPortalGraph){ + return entityId + "-" + definition.getId(); + }else { return entityId + "-" + definitionId; + } }
@@ -230,6 +221,10 @@ public class MetricGraphData implements JsonMetricProducer { return chartHoverDateFormat; }
+ public int getPortalId() { + return portalId; + } + public Integer getChartHeight() { if (null != chartHeight) { return chartHeight; @@ -243,7 +238,7 @@ public class MetricGraphData implements JsonMetricProducer { this.chartHeight = chartHeight; }
- public Boolean isPortalGraph() { + public boolean isPortalGraph() { return isPortalGraph; }
@@ -444,7 +439,6 @@ public class MetricGraphData implements JsonMetricProducer { sb.append(", entityName='").append(entityName).append('''); sb.append(", definitionId=").append(definitionId); sb.append(", isPortalGraph=").append(isPortalGraph); - sb.append(", windowWidth=").append(windowWidth); sb.append('}'); return sb.toString(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java index 33e1279..763bfaa 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java @@ -67,7 +67,7 @@ public final class MetricStackedBarGraph extends AbstractGraph { global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverTimeFormat()(), global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverDateFormat()(), global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::isPortalGraph()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getWindowWidth()() + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getPortalId()() );
@@ -99,10 +99,11 @@ public final class MetricStackedBarGraph extends AbstractGraph { svg;
function getChartWidth() { - return $wnd.jQuery(chartContext.chartSelection).width(); + return $wnd.jQuery("#"+chartContext.chartHandle).width(); }
function useSmallCharts() { + console.info("Chart Width for : "+chartContext.chartHandle+" is "+getChartWidth()); return getChartWidth() <= smallChartThresholdInPixels; }
@@ -111,14 +112,14 @@ public final class MetricStackedBarGraph extends AbstractGraph {
// if window is too small server up small chart if (useSmallCharts()) { - console.info("Using Small Charts Profile"); + console.log("Using Small Charts Profile"); width = 250; xTicks = 3; xTickSubDivide = 2; chartData = chartContext.data.slice(chartContext.data.length - numberOfBarsForSmallGraph, chartContext.data.length - 1); } else { - console.info("Using Large Charts Profile"); + console.log("Using Large Charts Profile"); // we use the width already defined above xTicks = 12; xTickSubDivide = 5; @@ -194,7 +195,7 @@ public final class MetricStackedBarGraph extends AbstractGraph { .orient("bottom");
// create the actual chart group - chart = $wnd.d3.select(chartContext.chartSelection); + chart = $wnd.d3.select("#"+chartContext.chartSelection);
svg = chart.append("g") .attr("width", width + margin.left + margin.right) diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java index 1d88a64..54466cf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java @@ -193,7 +193,7 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen List<MeasurementDataNumericHighLowComposite> data) {
MetricGraphData metricGraphData = MetricGraphData.createForResourceGroup(resourceGroup.getId(), - resourceGroup.getName(), measurementDefinition, data, getWidth()); + resourceGroup.getName(), measurementDefinition, data ); MetricStackedBarGraph graph = new MetricStackedBarGraph(metricGraphData); ResourceMetricD3Graph graphView = new ResourceMetricD3Graph(graph);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java index 4a64509..f66ea33 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java @@ -368,7 +368,7 @@ public class D3GraphListView extends AbstractD3GraphListView { MeasurementDefinition measurementDefinition, List<MeasurementDataNumericHighLowComposite> data, int height) {
MetricGraphData metricGraphData = MetricGraphData.createForResource(resource.getId(), resource.getName(), - measurementDefinition, data, measurementOOBCompositeList, getWidth()); + measurementDefinition, data, measurementOOBCompositeList ); MetricStackedBarGraph graph = new MetricStackedBarGraph(metricGraphData);
ResourceMetricD3Graph graphView = new ResourceMetricD3Graph(graph); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java index 93c99d3..962c341 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java @@ -18,8 +18,6 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshUtil; -import org.rhq.enterprise.gui.coregui.client.inventory.AutoRefresh; import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricD3GraphView; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.HasD3MetricJsniChart; @@ -40,7 +38,6 @@ public class ResourceMetricD3Graph extends AbstractMetricD3GraphView { public ResourceMetricD3Graph(AbstractGraph graph) {
super(graph); - //startRefreshCycle(); }
@@ -59,29 +56,4 @@ public class ResourceMetricD3Graph extends AbstractMetricD3GraphView { }
-// @Override -// public void startRefreshCycle() { -// refreshTimer = AutoRefreshUtil.startRefreshCycle(this, this, refreshTimer); -// } -// -// @Override -// protected void onDestroy() { -// AutoRefreshUtil.onDestroy( refreshTimer); -// -// super.onDestroy(); -// } -// -// @Override -// public boolean isRefreshing() { -// return false; -// } -// -// //Custom refresh operation as we are not directly extending Table -// @Override -// public void refresh() { -// if (isVisible() && !isRefreshing()) { -// drawGraph(); -// } -// } - } 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 f863ab0..c455c60 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js +++ b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js @@ -9,15 +9,13 @@ * A ChartContext can be passed to multiple chart renders to display different chart types * of that data. */ -var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, chartTitle, yAxisUnits, minChartTitle, avgChartTitle, peakChartTitle, dateLabel, timeLabel, downLabel, unknownLabel, noDataLabel, hoverStartLabel,hoverEndLabel, hoverPeriodLabel, hoverBarLabel, chartHoverTimeFormat, chartHoverDateFormat, isPortalGraph, windowWidth ) +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 ) { "use strict"; if(!(this instanceof ChartContext)){ throw new Error("ChartContext function cannot be called as a function.") } this.chartId = chartId; - this.chartHandle = "#rChart-" + this.chartId; - this.chartSelection = this.chartHandle + " svg"; this.chartHeight = chartHeight; this.data = jQuery.parseJSON(metricsData); // make into json this.xAxisLabel = xAxisLabel; @@ -38,7 +36,13 @@ var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, char this.chartHoverTimeFormat = chartHoverTimeFormat; this.chartHoverDateFormat = chartHoverDateFormat; this.isPortalGraph = isPortalGraph; - this.windowWidth = windowWidth; + this.portalId = portalId; + if(isPortalGraph){ + this.chartHandle = "rChart-"+chartId+"-"+portalId; + }else { + this.chartHandle = "rChart-"+chartId; + } + this.chartSelection = this.chartHandle + " svg";
}, AvailChartContext = function (chartId, availData, dateLabel, timeLabel, hoverStartLabel, hoverEndLabel, hoverBarLabel, availabilityLabel, chartHoverTimeFormat, chartHoverDateFormat) {
rhq-commits@lists.fedorahosted.org