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="/WEB-INF/classes" source-path="/src/main/java"/>
<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>
</dependent-module>
<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>
<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>
</Changeset>
<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 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.DownloadConstants;
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 {
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 HighchartsLayoutPanel highchartsLayoutPanel;
// Replace Menu
// Download Menu
private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem;
private MenuItem downloadSVGItem;
// Unit Menu
private MenuItem kBItem;
private MenuItem MBItem;
private MenuItem GBItem;
private MenuItem TBItem;
ChartOptions options;
private VerticalLayoutContainer vert;
private long unitMeasure = ByteUnitMeasure.getMegaByteDimForStorage();
private String unitMeasureLabel = ByteUnitMeasure.MB;
public StorageChart(AccountingStateData accountingStateData) {
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
@ -67,25 +82,31 @@ public class StorageChart extends SimpleContainer {
ToolBar toolBar = new ToolBar();
toolBar.setSpacing(2);
// Download
final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD,
AccountingManagerResources.INSTANCE
.accountingDownload24());
final TextButton downloadButton = new TextButton(
DownloadConstants.DOWNLOAD,
AccountingManagerResources.INSTANCE.accountingDownload24());
// downloadButton.setScale(ButtonScale.MEDIUM);
downloadButton.setIconAlign(IconAlign.RIGHT);
downloadButton.setArrowAlign(ButtonArrowAlign.RIGHT);
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();
highchartsLayoutPanel = new HighchartsLayoutPanel();
highchartsLayoutPanel.renderChart(options);
//
VerticalLayoutContainer vert = new VerticalLayoutContainer();
vert = new VerticalLayoutContainer();
vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1,
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() {
Menu menuDownload = new Menu();
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE
.accountingFilePNG24());
AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30);
downloadJPGItem = new MenuItem(DownloadConstants.DOWNLOAD_JPG,
AccountingManagerResources.INSTANCE
.accountingFileJPG24());
AccountingManagerResources.INSTANCE.accountingFileJPG24());
downloadJPGItem.setHeight(30);
downloadPDFItem = new MenuItem(DownloadConstants.DOWNLOAD_PDF,
AccountingManagerResources.INSTANCE
.accountingFilePDF24());
AccountingManagerResources.INSTANCE.accountingFilePDF24());
downloadPDFItem.setHeight(30);
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
AccountingManagerResources.INSTANCE
.accountingFileSVG24());
AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30);
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@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();
public static native void onDownloadPNG(String id) /*-{
@ -222,18 +311,19 @@ public class StorageChart extends SimpleContainer {
double interval = ChartTimeMeasure
.calculateInterval(accountingStateData.getSeriesRequest()
.getAccountingPeriod());
Date dateStart=dtf.parse(accountingStateData.getSeriesRequest()
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
.getAccountingPeriod().getStartDate());
dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset()*ChartTimeMeasure.MINUTE);
dateStart.setTime(dateStart.getTime()
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: "
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
.format(dateStart));
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
options = highchartsFactory.createChartOptions();
options.chart().zoomType("xy");
options.exporting().buttons().contextButton().enabled(false);
@ -281,13 +371,13 @@ public class StorageChart extends SimpleContainer {
+ " }"
+ " },"
+ " \"labels\": {"
+ " \"format\": \"{value} kB\","
+ " \"format\": \"{value} "
+ unitMeasureLabel
+ "\","
+ " \"style\": {"
+ " \"color\": \""
+ colors.get(0)
+ "\""
+ " }"
+ " }," + " \"opposite\": \"true\"" + "}]";
+ "\"" + " }" + " }," + " \"opposite\": \"true\"" + "}]";
options.setFieldAsJsonObject("yAxis", multiAxis);
@ -325,7 +415,8 @@ public class StorageChart extends SimpleContainer {
for (SeriesStorageData seriesStorageData : seriesStorage.getSeries()) {
dataOperationCount.push(seriesStorageData.getOperationCount());
dataDataVolume.push(seriesStorageData.getDataVolume());
dataDataVolume
.push(seriesStorageData.getDataVolume() / unitMeasure);
}
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;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DownloadConstants {
public static final String DOWNLOAD = "Download";
public static final String DOWNLOAD_PNG = "Download PNG Image";

View File

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

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()) {
case JOB:
//values = rrq.getPossibleValuesForKey(AggregatedJobUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey());
// values =
// rrq.getPossibleValuesForKey(AggregatedJobUsageRecord.class,
// filterValuesRequest
// .getFilterKey().getKey());
return filteValues;
case PORTLET:
//values = rrq.getPossibleValuesForKey(
// AggregatedPortletUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey());
// values = rrq.getPossibleValuesForKey(
// AggregatedPortletUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey());
return filteValues;
case SERVICE:
values = rrq.getPossibleValuesForKey(
@ -131,9 +133,9 @@ public class AccountingCaller {
.getFilterKey().getKey());
break;
case TASK:
//values = rrq.getPossibleValuesForKey(
// AggregatedTaskUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey());
// values = rrq.getPossibleValuesForKey(
// AggregatedTaskUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey());
return filteValues;
default:
return filteValues;
@ -218,35 +220,12 @@ public class AccountingCaller {
throw new AccountingManagerServiceException(
"Error accounting type is null");
}
/*
SimpleDateFormat stz = new SimpleDateFormat("Z");
String timeZone=stz.format(seriesRequest.getAccountingPeriod().getStartDate());
int tzOffSet=TimeZone.getTimeZone(timeZone).getRawOffset()-TemporalConstraint.DEFAULT_TIME_ZONE.getRawOffset();
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());
logger.debug("StartCalendar: "
+ seriesRequest.getAccountingPeriod().getStartDate());
logger.debug("EndCalendar: "
+ seriesRequest.getAccountingPeriod().getEndDate());
switch (accountingType) {
case JOB:
return new AccountingQuery4Job(seriesRequest);

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>
<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>
</Changeset>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-0-0" date="2015-10-15">