1831: Accounting Manager - On Storage Accounting the graph axes must show more formats (kB, MB, GB)

Task-Url: https://support.d4science.org/issues/1831

Added more formats to Data Volume

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@122416 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-01-21 13:34:31 +00:00
parent fb4624762a
commit 1363631eb9
12 changed files with 194 additions and 69 deletions

View File

@ -4,7 +4,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="accounting-manager-theme-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/accounting-manager-theme/accounting-manager-theme"> <dependent-module archiveName="accounting-manager-theme-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/accounting-manager-theme/accounting-manager-theme">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<property name="java-output-path" value="/accounting-manager/target/accounting-manager-0.0.1-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/accounting-manager/target/accounting-manager-0.0.1-SNAPSHOT/WEB-INF/classes"/>

View File

@ -1,5 +1,7 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-1-0" date="2016-01-31"> <Changeset component="org.gcube.portlets.admin.accounting-manager.1-1-0" date="2016-01-31">
<Change>Added to Storage Accounting more formats for DataVolume axis [Ticket #1831]</Change>
<Change>Fixed on Storage Accounting the popup validation on filters [Ticket #1832]</Change>
<Change>Fixed library dependencies</Change> <Change>Fixed library dependencies</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-0-0" date="2015-10-15"> <Changeset component="org.gcube.portlets.admin.accounting-manager.1-0-0" date="2015-10-15">

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storag
import java.util.Date; import java.util.Date;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
@ -44,18 +45,32 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
*/ */
public class StorageChart extends SimpleContainer { public class StorageChart extends SimpleContainer {
private DateTimeFormat dtf=DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY); private static final String DATA_VOLUME_UNIT = "Data Volume Unit";
private DateTimeFormat dtf = DateTimeFormat
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private AccountingStateData accountingStateData; private AccountingStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel; private HighchartsLayoutPanel highchartsLayoutPanel;
// Replace Menu // Download Menu
private MenuItem downloadPNGItem; private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem; private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem; private MenuItem downloadPDFItem;
private MenuItem downloadSVGItem; private MenuItem downloadSVGItem;
// Unit Menu
private MenuItem kBItem;
private MenuItem MBItem;
private MenuItem GBItem;
private MenuItem TBItem;
ChartOptions options; ChartOptions options;
private VerticalLayoutContainer vert;
private long unitMeasure = ByteUnitMeasure.getMegaByteDimForStorage();
private String unitMeasureLabel = ByteUnitMeasure.MB;
public StorageChart(AccountingStateData accountingStateData) { public StorageChart(AccountingStateData accountingStateData) {
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
@ -67,16 +82,22 @@ public class StorageChart extends SimpleContainer {
ToolBar toolBar = new ToolBar(); ToolBar toolBar = new ToolBar();
toolBar.setSpacing(2); toolBar.setSpacing(2);
// Download // Download
final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD, final TextButton downloadButton = new TextButton(
AccountingManagerResources.INSTANCE DownloadConstants.DOWNLOAD,
.accountingDownload24()); AccountingManagerResources.INSTANCE.accountingDownload24());
// downloadButton.setScale(ButtonScale.MEDIUM); // downloadButton.setScale(ButtonScale.MEDIUM);
downloadButton.setIconAlign(IconAlign.RIGHT); downloadButton.setIconAlign(IconAlign.RIGHT);
downloadButton.setArrowAlign(ButtonArrowAlign.RIGHT); downloadButton.setArrowAlign(ButtonArrowAlign.RIGHT);
downloadButton.setMenu(createDownloadMenu()); downloadButton.setMenu(createDownloadMenu());
toolBar.add(downloadButton, new BoxLayoutData(new Margins(0))); final TextButton unitButton = new TextButton(DATA_VOLUME_UNIT,
AccountingManagerResources.INSTANCE.accountingByte24());
unitButton.setIconAlign(IconAlign.RIGHT);
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
unitButton.setMenu(createUnitMenu());
toolBar.add(downloadButton, new BoxLayoutData(new Margins(0)));
toolBar.add(unitButton, new BoxLayoutData(new Margins(0)));
// //
createChart(); createChart();
@ -85,7 +106,7 @@ public class StorageChart extends SimpleContainer {
highchartsLayoutPanel.renderChart(options); highchartsLayoutPanel.renderChart(options);
// //
VerticalLayoutContainer vert = new VerticalLayoutContainer(); vert = new VerticalLayoutContainer();
vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1,
new Margins(0))); new Margins(0)));
@ -94,26 +115,35 @@ public class StorageChart extends SimpleContainer {
} }
private void updateChart() {
vert.remove(highchartsLayoutPanel);
//
createChart();
highchartsLayoutPanel = new HighchartsLayoutPanel();
highchartsLayoutPanel.renderChart(options);
vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1,
new Margins(0)));
forceLayout();
}
private Menu createDownloadMenu() { private Menu createDownloadMenu() {
Menu menuDownload = new Menu(); Menu menuDownload = new Menu();
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE AccountingManagerResources.INSTANCE.accountingFilePNG24());
.accountingFilePNG24());
downloadPNGItem.setHeight(30); downloadPNGItem.setHeight(30);
downloadJPGItem = new MenuItem(DownloadConstants.DOWNLOAD_JPG, downloadJPGItem = new MenuItem(DownloadConstants.DOWNLOAD_JPG,
AccountingManagerResources.INSTANCE AccountingManagerResources.INSTANCE.accountingFileJPG24());
.accountingFileJPG24());
downloadJPGItem.setHeight(30); downloadJPGItem.setHeight(30);
downloadPDFItem = new MenuItem(DownloadConstants.DOWNLOAD_PDF, downloadPDFItem = new MenuItem(DownloadConstants.DOWNLOAD_PDF,
AccountingManagerResources.INSTANCE AccountingManagerResources.INSTANCE.accountingFilePDF24());
.accountingFilePDF24());
downloadPDFItem.setHeight(30); downloadPDFItem.setHeight(30);
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG, downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
AccountingManagerResources.INSTANCE AccountingManagerResources.INSTANCE.accountingFileSVG24());
.accountingFileSVG24());
downloadSVGItem.setHeight(30); downloadSVGItem.setHeight(30);
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() { downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override @Override
@ -159,6 +189,65 @@ public class StorageChart extends SimpleContainer {
} }
private Menu createUnitMenu() {
Menu menuUnit = new Menu();
kBItem = new MenuItem(ByteUnitMeasure.KILOBYTE);
kBItem.setHeight(30);
MBItem = new MenuItem(ByteUnitMeasure.MEGABYTE);
MBItem.setHeight(30);
GBItem = new MenuItem(ByteUnitMeasure.GIGABYTE);
GBItem.setHeight(30);
TBItem = new MenuItem(ByteUnitMeasure.TERABYTE);
TBItem.setHeight(30);
kBItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getKiloByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.kB;
updateChart();
}
});
MBItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getMegaByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.MB;
updateChart();
}
});
GBItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getGigaByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.GB;
updateChart();
}
});
TBItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getTeraByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.TB;
updateChart();
}
});
menuUnit.add(kBItem);
menuUnit.add(MBItem);
menuUnit.add(GBItem);
menuUnit.add(TBItem);
return menuUnit;
}
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick(); // chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
public static native void onDownloadPNG(String id) /*-{ public static native void onDownloadPNG(String id) /*-{
@ -223,10 +312,11 @@ public class StorageChart extends SimpleContainer {
.calculateInterval(accountingStateData.getSeriesRequest() .calculateInterval(accountingStateData.getSeriesRequest()
.getAccountingPeriod()); .getAccountingPeriod());
Date dateStart=dtf.parse(accountingStateData.getSeriesRequest() Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
.getAccountingPeriod().getStartDate()); .getAccountingPeriod().getStartDate());
dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset()*ChartTimeMeasure.MINUTE); dateStart.setTime(dateStart.getTime()
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: " Log.debug("BuildChart DateStart: "
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL) + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
@ -281,13 +371,13 @@ public class StorageChart extends SimpleContainer {
+ " }" + " }"
+ " }," + " },"
+ " \"labels\": {" + " \"labels\": {"
+ " \"format\": \"{value} kB\"," + " \"format\": \"{value} "
+ unitMeasureLabel
+ "\","
+ " \"style\": {" + " \"style\": {"
+ " \"color\": \"" + " \"color\": \""
+ colors.get(0) + colors.get(0)
+ "\"" + "\"" + " }" + " }," + " \"opposite\": \"true\"" + "}]";
+ " }"
+ " }," + " \"opposite\": \"true\"" + "}]";
options.setFieldAsJsonObject("yAxis", multiAxis); options.setFieldAsJsonObject("yAxis", multiAxis);
@ -325,7 +415,8 @@ public class StorageChart extends SimpleContainer {
for (SeriesStorageData seriesStorageData : seriesStorage.getSeries()) { for (SeriesStorageData seriesStorageData : seriesStorage.getSeries()) {
dataOperationCount.push(seriesStorageData.getOperationCount()); dataOperationCount.push(seriesStorageData.getOperationCount());
dataDataVolume.push(seriesStorageData.getDataVolume()); dataDataVolume
.push(seriesStorageData.getDataVolume() / unitMeasure);
} }
options.series().addToEnd(seriesOperationCount); options.series().addToEnd(seriesOperationCount);

View File

@ -0,0 +1,39 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils;
/**
* Note Storage Data are in kB
*
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ByteUnitMeasure {
public static final String KILOBYTE = "KiloByte (kB)";
public static final String MEGABYTE = "MegaByte (MB)";
public static final String GIGABYTE = "GigaByte (GB)";
public static final String TERABYTE = "TeraByte (TB)";
public static final String kB = "kB";
public static final String MB = "MB";
public static final String GB = "GB";
public static final String TB = "TB";
public static long getKiloByteDimForStorage() {
return 1;
}
public static long getMegaByteDimForStorage() {
return 1000;
}
public static long getGigaByteDimForStorage() {
return 1000000;
}
public static long getTeraByteDimForStorage() {
return 1000000000;
}
}

View File

@ -1,5 +1,11 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils; package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DownloadConstants { public class DownloadConstants {
public static final String DOWNLOAD = "Download"; public static final String DOWNLOAD = "Download";
public static final String DOWNLOAD_PNG = "Download PNG Image"; public static final String DOWNLOAD_PNG = "Download PNG Image";

View File

@ -122,6 +122,12 @@ public interface AccountingManagerResources extends ClientBundle {
@Source("accounting-download_24.png") @Source("accounting-download_24.png")
ImageResource accountingDownload24(); ImageResource accountingDownload24();
@Source("accounting-byte_32.png")
ImageResource accountingByte32();
@Source("accounting-byte_24.png")
ImageResource accountingByte24();
@Source("accounting-download_32.png") @Source("accounting-download_32.png")
ImageResource accountingDownload32(); ImageResource accountingDownload32();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -112,13 +112,15 @@ public class AccountingCaller {
switch (filterValuesRequest.getAccountingType()) { switch (filterValuesRequest.getAccountingType()) {
case JOB: case JOB:
//values = rrq.getPossibleValuesForKey(AggregatedJobUsageRecord.class, filterValuesRequest // values =
// .getFilterKey().getKey()); // rrq.getPossibleValuesForKey(AggregatedJobUsageRecord.class,
// filterValuesRequest
// .getFilterKey().getKey());
return filteValues; return filteValues;
case PORTLET: case PORTLET:
//values = rrq.getPossibleValuesForKey( // values = rrq.getPossibleValuesForKey(
// AggregatedPortletUsageRecord.class, filterValuesRequest // AggregatedPortletUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey()); // .getFilterKey().getKey());
return filteValues; return filteValues;
case SERVICE: case SERVICE:
values = rrq.getPossibleValuesForKey( values = rrq.getPossibleValuesForKey(
@ -131,9 +133,9 @@ public class AccountingCaller {
.getFilterKey().getKey()); .getFilterKey().getKey());
break; break;
case TASK: case TASK:
//values = rrq.getPossibleValuesForKey( // values = rrq.getPossibleValuesForKey(
// AggregatedTaskUsageRecord.class, filterValuesRequest // AggregatedTaskUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey()); // .getFilterKey().getKey());
return filteValues; return filteValues;
default: default:
return filteValues; return filteValues;
@ -219,33 +221,10 @@ public class AccountingCaller {
"Error accounting type is null"); "Error accounting type is null");
} }
/* logger.debug("StartCalendar: "
SimpleDateFormat stz = new SimpleDateFormat("Z"); + seriesRequest.getAccountingPeriod().getStartDate());
String timeZone=stz.format(seriesRequest.getAccountingPeriod().getStartDate()); logger.debug("EndCalendar: "
int tzOffSet=TimeZone.getTimeZone(timeZone).getRawOffset()-TemporalConstraint.DEFAULT_TIME_ZONE.getRawOffset(); + seriesRequest.getAccountingPeriod().getEndDate());
logger.debug("TimeZone[zone="+timeZone+", offset="+tzOffSet+"]");
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
long startTime=seriesRequest.getAccountingPeriod()
.getStartDate().getTime()+tzOffSet;
startCalendar.setTimeInMillis(startTime);
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
long endTime=seriesRequest.getAccountingPeriod()
.getEndDate().getTime()+tzOffSet;
endCalendar.setTimeInMillis(endTime);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
sdf.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
logger.debug("StartCalendar: " + sdf.format(startCalendar.getTime()));
logger.debug("EndCalendar: " + sdf.format(endCalendar.getTime()));
seriesRequest.getAccountingPeriod().setStartDate(
startCalendar.getTime());
seriesRequest.getAccountingPeriod().setEndDate(endCalendar.getTime());
*/
logger.debug("StartCalendar: " + seriesRequest.getAccountingPeriod().getStartDate());
logger.debug("EndCalendar: " + seriesRequest.getAccountingPeriod().getEndDate());
switch (accountingType) { switch (accountingType) {
case JOB: case JOB:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,5 +1,7 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-1-0" date="2016-01-31"> <Changeset component="org.gcube.portlets.admin.accounting-manager.1-1-0" date="2016-01-31">
<Change>Added to Storage Accounting more formats for DataVolume axis [Ticket #1831]</Change>
<Change>Fixed on Storage Accounting the popup validation on filters [Ticket #1832]</Change>
<Change>Fixed library dependencies</Change> <Change>Fixed library dependencies</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-0-0" date="2015-10-15"> <Changeset component="org.gcube.portlets.admin.accounting-manager.1-0-0" date="2015-10-15">