Added Default Show to Accounting Manager
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@117356 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ee8d5f95bc
commit
012eb588cb
|
@ -108,6 +108,7 @@ public class AccountingManager implements EntryPoint {
|
|||
bind(mainPanelLayout);
|
||||
controller.setMainPanelLayout(mainPanelLayout);
|
||||
controller.restoreUISession();
|
||||
|
||||
}
|
||||
|
||||
protected void bind(BorderLayoutContainer mainWidget) {
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.gcube.portlets.admin.accountingmanager.client.type.StateChangeType;
|
|||
import org.gcube.portlets.admin.accountingmanager.client.type.UIStateType;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
|
@ -30,6 +32,7 @@ import com.google.gwt.i18n.client.LocaleInfo;
|
|||
import com.google.gwt.user.client.Cookies;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.datepicker.client.CalendarUtil;
|
||||
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
|
||||
|
||||
/**
|
||||
|
@ -155,7 +158,7 @@ public class AccountingManagerController {
|
|||
//
|
||||
public void restoreUISession() {
|
||||
checkLocale();
|
||||
|
||||
showDefault();
|
||||
}
|
||||
|
||||
// Bind Controller to events on bus
|
||||
|
@ -206,25 +209,90 @@ public class AccountingManagerController {
|
|||
case STORAGE:
|
||||
case TASK:
|
||||
case JOB:
|
||||
Log.debug("AccountingType: "+event.getAccountingType());
|
||||
accountingType = event.getAccountingType();
|
||||
Log.debug("AccountingType: " + event.getAccountingType());
|
||||
accountingStateData = accountingState.getState(event
|
||||
.getAccountingType());
|
||||
if (accountingStateData == null) {
|
||||
accountingStateData = new AccountingStateData(
|
||||
event.getAccountingType(), null, null);
|
||||
accountingState.setState(event.getAccountingType(),
|
||||
accountingStateData);
|
||||
createDefaultChart(event.getAccountingType());
|
||||
} else {
|
||||
accountingType = event.getAccountingType();
|
||||
StateChangeEvent stateChangeEvent = new StateChangeEvent(
|
||||
StateChangeType.Restore, accountingStateData);
|
||||
eventBus.fireEvent(stateChangeEvent);
|
||||
}
|
||||
StateChangeEvent stateChangeEvent = new StateChangeEvent(
|
||||
StateChangeType.Restore, accountingStateData);
|
||||
eventBus.fireEvent(stateChangeEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showDefault(){
|
||||
createDefaultChart(AccountingType.STORAGE);
|
||||
}
|
||||
|
||||
|
||||
private void createDefaultChart(AccountingType accountingType) {
|
||||
accountingMonitor = new AccountingMonitor();
|
||||
Date d=new Date();
|
||||
CalendarUtil.addMonthsToDate(d, -1);
|
||||
|
||||
SeriesRequest seriesRequest=new SeriesRequest(
|
||||
new AccountingPeriod(d,new Date(),AccountingPeriodMode.DAILY));
|
||||
this.accountingType = accountingType;
|
||||
|
||||
AccountingStateData accountingStateData = new AccountingStateData(
|
||||
accountingType, seriesRequest, null);
|
||||
accountingState.setState(accountingType,
|
||||
accountingStateData);
|
||||
|
||||
callDefaultSeriesRequest(accountingStateData);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void callDefaultSeriesRequest(final AccountingStateData accountingStateData) {
|
||||
|
||||
AccountingManagerServiceAsync.INSTANCE.getSeries(
|
||||
accountingStateData.getAccountingType(),
|
||||
accountingStateData.getSeriesRequest(),
|
||||
new AsyncCallback<SeriesResponse>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(SeriesResponse seriesResponse) {
|
||||
Log.debug("SeriesResponse: " + seriesResponse);
|
||||
accountingStateData.setSeriesResponse(seriesResponse);
|
||||
accountingState.setState(accountingType,
|
||||
accountingStateData);
|
||||
StateChangeEvent stateChangeEvent = new StateChangeEvent(
|
||||
StateChangeType.Restore, accountingStateData);
|
||||
eventBus.fireEvent(stateChangeEvent);
|
||||
accountingMonitor.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
accountingMonitor.hide();
|
||||
if (caught instanceof AccountingManagerSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error:" + caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
StateChangeEvent stateChangeEvent = new StateChangeEvent(
|
||||
StateChangeType.Restore, accountingStateData);
|
||||
eventBus.fireEvent(stateChangeEvent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void doFiltersChangeCommand(FiltersChangeEvent event) {
|
||||
if (event == null || event.getFiltersChangeType() == null) {
|
||||
|
@ -236,7 +304,7 @@ public class AccountingManagerController {
|
|||
AccountingStateData accountingStateData = accountingState
|
||||
.getState(accountingType);
|
||||
if (accountingStateData != null) {
|
||||
accountingMonitor=new AccountingMonitor();
|
||||
accountingMonitor = new AccountingMonitor();
|
||||
accountingStateData.setSeriesRequest(seriesRequest);
|
||||
accountingState.setState(accountingType, accountingStateData);
|
||||
callSeriesRequest(accountingStateData);
|
||||
|
|
|
@ -206,7 +206,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
|
||||
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
||||
ChartOptions options = highchartsFactory.createChartOptions();
|
||||
options.chart().zoomType("x");
|
||||
options.chart().zoomType("xy");
|
||||
|
||||
options.title().text("Accounting Storage");
|
||||
|
||||
|
@ -223,6 +223,8 @@ public class HightChartPanel extends FramedPanel {
|
|||
// yAxis
|
||||
// options.yAxis().title().text("Exchange rate");
|
||||
// Highcharts.getOptions().colors[0]
|
||||
|
||||
|
||||
String multiAxis = "[{" + " \"id\": \"OperationCount\","
|
||||
+ " \"labels\": { " + " \"format\": \"{value}\","
|
||||
+ " \"style\": { " + " \"color\": \""
|
||||
|
@ -258,7 +260,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
+ " }," + " \"opposite\": \"true\"" + "}]";
|
||||
|
||||
options.setFieldAsJsonObject("yAxis", multiAxis);
|
||||
|
||||
|
||||
// TODO does not seem to be working
|
||||
String fillcolor = "{" + "\"linearGradient\": {" + "\"x1\": 0,"
|
||||
+ "\"y1\": 0," + "\"x2\": 0," + "\"y2\": 1" + "},"
|
||||
|
@ -354,7 +356,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
|
||||
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
||||
ChartOptions options = highchartsFactory.createChartOptions();
|
||||
options.chart().zoomType("x");
|
||||
options.chart().zoomType("xy");
|
||||
|
||||
options.title().text("Accounting Service");
|
||||
|
||||
|
@ -371,6 +373,48 @@ public class HightChartPanel extends FramedPanel {
|
|||
// yAxis
|
||||
// options.yAxis().title().text("Exchange rate");
|
||||
// Highcharts.getOptions().colors[0]
|
||||
|
||||
/*
|
||||
String multiAxis = "[{" + " \"id\": \"OperationCount\","
|
||||
+ " \"labels\": { " + " \"format\": \"{value}\","
|
||||
+ " \"style\": { " + " \"color\": \""
|
||||
+ colors.get(1)
|
||||
+ "\""
|
||||
+ " }"
|
||||
+ " },"
|
||||
+ " \"title\": { "
|
||||
+ " \"text\": \"Operation Count\","
|
||||
+ " \"style\": {"
|
||||
+ " \"color\": \""
|
||||
+ colors.get(1)
|
||||
+ "\""
|
||||
+ " }"
|
||||
+ " }"
|
||||
+ "} , {"
|
||||
+ " \"id\": \"ServiceData\", "
|
||||
+ " \"linkedTo\": \"0\","
|
||||
+" \"gridLineWidth\": \"0\","
|
||||
+ " \"title\": {"
|
||||
+ " \"text\": \"\","
|
||||
+ " \"style\": {"
|
||||
+ " \"color\": \""
|
||||
+ colors.get(1)
|
||||
+ "\""
|
||||
+ " }"
|
||||
+ " },"
|
||||
+ " \"labels\": {"
|
||||
+ " \"format\": \"{value} ms\","
|
||||
+ " \"style\": {"
|
||||
+ " \"color\": \""
|
||||
+ colors.get(1)
|
||||
+ "\""
|
||||
+ " }"
|
||||
+ " }," + " \"opposite\": \"true\""
|
||||
//+ ", \"showFirstLabel\": \"false\""
|
||||
+ "}]";
|
||||
*/
|
||||
|
||||
|
||||
String multiAxis = "[{" + " \"id\": \"OperationCount\","
|
||||
+ " \"labels\": { " + " \"format\": \"{value}\","
|
||||
+ " \"style\": { " + " \"color\": \""
|
||||
|
@ -404,6 +448,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
+ "\""
|
||||
+ " }"
|
||||
+ " }," + " \"opposite\": \"true\""
|
||||
+ ", \"showFirstLabel\": \"false\""
|
||||
+ "} , {"
|
||||
+ " \"id\": \"MaxInvocationTime\", "
|
||||
+ " \"title\": {"
|
||||
|
@ -422,6 +467,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
+ "\""
|
||||
+ " }"
|
||||
+ " }," + " \"opposite\": \"true\""
|
||||
+ ", \"showFirstLabel\": \"false\""
|
||||
+ "} , {"
|
||||
+ " \"id\": \"MinInvocationTime\", "
|
||||
+ " \"title\": {"
|
||||
|
@ -439,10 +485,12 @@ public class HightChartPanel extends FramedPanel {
|
|||
+ colors.get(3)
|
||||
+ "\""
|
||||
+ " }"
|
||||
+ " }," + " \"opposite\": \"true\"" + "}]"
|
||||
+ " }," + " \"opposite\": \"true\""
|
||||
+ ", \"showFirstLabel\": \"false\""
|
||||
+ "}]"
|
||||
|
||||
;
|
||||
|
||||
|
||||
options.setFieldAsJsonObject("yAxis", multiAxis);
|
||||
|
||||
// TODO does not seem to be working
|
||||
|
@ -496,7 +544,6 @@ public class HightChartPanel extends FramedPanel {
|
|||
seriesMinInvocationTime.color(colors.get(3));
|
||||
seriesMinInvocationTime.yAxisAsString("MinInvocationTime");
|
||||
|
||||
|
||||
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime.dataAsArrayNumber();
|
||||
|
||||
|
||||
|
@ -568,7 +615,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
|
||||
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
||||
ChartOptions options = highchartsFactory.createChartOptions();
|
||||
options.chart().zoomType("x");
|
||||
options.chart().zoomType("xy");
|
||||
|
||||
options.title().text("Accounting Portlet");
|
||||
|
||||
|
@ -714,7 +761,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
|
||||
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
||||
ChartOptions options = highchartsFactory.createChartOptions();
|
||||
options.chart().zoomType("x");
|
||||
options.chart().zoomType("xy");
|
||||
|
||||
options.title().text("Accounting Task");
|
||||
|
||||
|
@ -861,7 +908,7 @@ public class HightChartPanel extends FramedPanel {
|
|||
|
||||
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
||||
ChartOptions options = highchartsFactory.createChartOptions();
|
||||
options.chart().zoomType("x");
|
||||
options.chart().zoomType("xy");
|
||||
|
||||
options.title().text("Accounting Job");
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class AccountingCaller {
|
|||
throw new AccountingManagerServiceException(
|
||||
"Error retrieving list of info: list is null!");
|
||||
}
|
||||
logger.debug("Retrived Infos");
|
||||
logger.debug("Retrieved Infos");
|
||||
|
||||
SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder(
|
||||
accountingType, infos);
|
||||
|
|
|
@ -27,7 +27,10 @@ public class SeriesResponse4Job extends SeriesResponseBuilder {
|
|||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
logger.debug("Infos: "+infos);
|
||||
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for job accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
}
|
||||
|
||||
SeriesResponse seriesResponse = new SeriesResponse();
|
||||
|
||||
|
|
|
@ -28,7 +28,10 @@ public class SeriesResponse4Portlet extends SeriesResponseBuilder {
|
|||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
logger.debug("Infos: "+infos);
|
||||
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for portlet accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
}
|
||||
|
||||
SeriesResponse seriesResponse = new SeriesResponse();
|
||||
|
||||
|
|
|
@ -33,7 +33,11 @@ public class SeriesResponse4Service extends SeriesResponseBuilder {
|
|||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
try {
|
||||
logger.debug("Infos: " + infos);
|
||||
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for service accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
}
|
||||
|
||||
ArrayList<SeriesServiceData> series=new ArrayList<SeriesServiceData>();
|
||||
for (Info info : infos) {
|
||||
Date date = info.getDate();
|
||||
|
|
|
@ -33,7 +33,11 @@ public class SeriesResponse4Storage extends SeriesResponseBuilder {
|
|||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
try {
|
||||
logger.debug("Infos: " + infos);
|
||||
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for storage accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
}
|
||||
|
||||
ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>();
|
||||
for (Info info : infos) {
|
||||
Date date = info.getDate();
|
||||
|
|
|
@ -27,7 +27,10 @@ public class SeriesResponse4Task extends SeriesResponseBuilder {
|
|||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
logger.debug("Infos: "+infos);
|
||||
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for task accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
}
|
||||
|
||||
SeriesResponse seriesResponse = new SeriesResponse();
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ public class Constants {
|
|||
public static final String AM_LANG_COOKIE = "AMLangCookie";
|
||||
public static final String AM_LANG = "AMLang";
|
||||
public final static String DEFAULT_USER = "test.user";
|
||||
public final static String DEFAULT_SCOPE = "/gcube/devNext";
|
||||
//public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
|
||||
//public final static String DEFAULT_SCOPE = "/gcube/devNext";
|
||||
public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue