Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
work in progress: implementing reporting page for validation result
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Mar 20, 2013
1 parent 2b340bc commit 3f4d2e1
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 15 deletions.
@@ -1,18 +1,23 @@
package org.zanata.webtrans.client.events;

import java.util.Date;
import java.util.Set;

import org.zanata.webtrans.shared.model.DocumentId;

import com.google.gwt.event.shared.GwtEvent;

public class RunDocValidationResultEvent extends GwtEvent<RunDocValidationResultHandler>
{
private Date startTime;
private Date endTime;
private Set<DocumentId> errorDocs;

public RunDocValidationResultEvent(Date startTime, Date endTime)
public RunDocValidationResultEvent(Date startTime, Date endTime, Set<DocumentId> errorDocs)
{
this.startTime = startTime;
this.endTime = endTime;
this.errorDocs = errorDocs;
}

/**
Expand Down Expand Up @@ -55,4 +60,9 @@ public Date getEndTime()
{
return endTime;
}

public Set<DocumentId> getErrorDocs()
{
return errorDocs;
}
}
Expand Up @@ -556,7 +556,7 @@ public void onFailure(Throwable caught)
{
eventBus.fireEvent(new NotificationEvent(NotificationEvent.Severity.Error, "Unable to run validation"));
display.showLoading(false);
eventBus.fireEvent(new RunDocValidationResultEvent(startTime, new Date()));
eventBus.fireEvent(new RunDocValidationResultEvent(startTime, new Date(), null));
}

@Override
Expand All @@ -577,7 +577,7 @@ public void onSuccess(RunDocValidationResult result)
}
dataProvider.refresh();
display.showLoading(false);
eventBus.fireEvent(new RunDocValidationResultEvent(startTime, new Date()));
eventBus.fireEvent(new RunDocValidationResultEvent(startTime, new Date(), resultMap.keySet()));
}
});
}
Expand Down
Expand Up @@ -21,6 +21,7 @@
package org.zanata.webtrans.client.presenter;

import java.util.ArrayList;
import java.util.Set;

import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;
Expand All @@ -33,6 +34,7 @@
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.service.ValidationService;
import org.zanata.webtrans.client.view.ValidationOptionsDisplay;
import org.zanata.webtrans.shared.model.DocumentId;
import org.zanata.webtrans.shared.model.ValidationAction;
import org.zanata.webtrans.shared.model.ValidationInfo;

Expand All @@ -52,6 +54,7 @@ public class ValidationOptionsPresenter extends WidgetPresenter<ValidationOption
private final ValidationService validationService;
private final WebTransMessages messages;
private MainView currentView;
private Set<DocumentId> errorDocs;

@Inject
public ValidationOptionsPresenter(ValidationOptionsDisplay display, EventBus eventBus, final ValidationService validationService, final WebTransMessages messages)
Expand All @@ -69,6 +72,7 @@ protected void onBind()
initDisplay();

display.updateValidationResult(null, null);
display.showReportLink(false);

display.setListener(this);
}
Expand Down Expand Up @@ -135,11 +139,16 @@ public void setCurrentView(MainView view)
{
display.setRunValidationVisible(true);
display.setRunValidationTitle(messages.documentValidationTitle());
if(hasErrorReport())
{
display.showReportLink(true);
}
}
else
{
display.setRunValidationVisible(false);
display.setRunValidationTitle(messages.editorValidationTitle());
display.showReportLink(false);
}
}

Expand All @@ -153,6 +162,23 @@ public void onRunValidation()
public void onCompleteRunDocValidation(RunDocValidationResultEvent event)
{
display.updateValidationResult(event.getStartTime(), event.getEndTime());
errorDocs = event.getErrorDocs();
if (currentView == MainView.Documents)
{
display.showReportLink(true);
}
}

@Override
public void onRequestValidationReport()
{
// display.showReportPopup(errorDocs);
// run RPC call, by each docs
}

private boolean hasErrorReport()
{
return errorDocs != null && !errorDocs.isEmpty();
}
}

Expand Down
Expand Up @@ -527,7 +527,10 @@ public interface WebTransMessages extends Messages
@DefaultMessage("Last run: {0}")
String lastValidationRun(String completeTime);

@DefaultMessage("Start time: {0}")
String lastValidationRunTooltip(String startTime);
@DefaultMessage("Validation run - Start time: {0}, End time: {1}")
String lastValidationRunTooltip(String startTime, String endTime);

@DefaultMessage("View report")
String validationReportLink();

}
Expand Up @@ -42,9 +42,13 @@ public interface ValidationOptionsDisplay extends WidgetDisplay
interface Listener
{
void onRunValidation();

void onRequestValidationReport();
}

void setRunValidationTitle(String title);

void updateValidationResult(Date startTime, Date endTime);

void showReportLink(boolean visible);
}
Expand Up @@ -38,7 +38,7 @@ interface ValidationOptionsViewUiBinder extends UiBinder<Widget, ValidationOptio
PushButton runValidation;

@UiField
InlineLabel lastValidationRun;
InlineLabel reportLink;

private Listener listener;

Expand All @@ -53,6 +53,8 @@ public ValidationOptionsView(WebTransMessages messages)

validationOptionsHeader.setText(messages.validationOptions());
runValidation.setText(messages.runValidation());

reportLink.setText(messages.validationReportLink());
}

@Override
Expand Down Expand Up @@ -95,7 +97,6 @@ public void clearValidationSelector()
public void setRunValidationVisible(boolean visible)
{
runValidation.setVisible(visible);
lastValidationRun.setVisible(visible);
}

@Override
Expand All @@ -110,6 +111,13 @@ public void onRunValidationClicked(ClickEvent event)
listener.onRunValidation();

}

@UiHandler("reportLink")
public void onReportLinkClicked(ClickEvent event)
{
listener.onRequestValidationReport();

}

@Override
public void setListener(Listener listener)
Expand All @@ -123,13 +131,19 @@ public void updateValidationResult(Date startTime, Date endTime)
{
if (startTime != null && endTime != null)
{
lastValidationRun.setText(messages.lastValidationRun(DateUtil.formatLongDateTime(endTime)));
lastValidationRun.setTitle(messages.lastValidationRunTooltip(DateUtil.formatLongDateTime(startTime)));
reportLink.setTitle(messages.lastValidationRunTooltip(DateUtil.formatLongDateTime(startTime), DateUtil.formatLongDateTime(endTime)));
reportLink.setVisible(true);
}
else
{
lastValidationRun.setText(messages.lastValidationRun("none"));
lastValidationRun.setText("");
reportLink.setTitle("");
}
}

@Override
public void showReportLink(boolean visible)
{
reportLink.setVisible(visible);

}
}
Expand Up @@ -25,9 +25,11 @@
display:inline-block;
}

.lastValidationRunLabel
.reportLink
{
color:#ffa500;
text-decoration:underline;
cursor:pointer;
}

</ui:style>
Expand All @@ -43,7 +45,7 @@
</g:VerticalPanel>
</g:ScrollPanel>
<g:PushButton ui:field="runValidation" addStyleNames="{style.runValidationButton}"/>
<g:InlineLabel ui:field="lastValidationRun" styleName="{style.lastValidationRunLabel}"/>
<g:InlineLabel ui:field="reportLink" styleName="{style.reportLink}"/>
</g:HTMLPanel>
</g:layer>
</g:LayoutPanel>
Expand Down
Expand Up @@ -121,7 +121,7 @@ private List<HTextFlow> getTextFlows(GetTransUnitList action, HLocale hLocale, i
else
{
textFlows = textFlowDAO.getAllTextFlowsByDocumentId(action.getDocumentId());
textFlows = validationServiceImpl.filterHasErrorTexFlow(textFlows, action.getValidationIds(), hLocale.getId(), offset, action.getCount());
textFlows = validationServiceImpl.filterHasErrorTexFlow(textFlows, action.getValidationIds(), hLocale.getLocaleId(), offset, action.getCount());
}
}
// has status and phrase filter
Expand All @@ -141,7 +141,7 @@ private List<HTextFlow> getTextFlows(GetTransUnitList action, HLocale hLocale, i
else
{
textFlows = textFlowDAO.getAllTextFlowByDocumentIdWithConstraint(action.getDocumentId(), hLocale, constraints);
textFlows = validationServiceImpl.filterHasErrorTexFlow(textFlows, action.getValidationIds(), hLocale.getId(), offset, action.getCount());
textFlows = validationServiceImpl.filterHasErrorTexFlow(textFlows, action.getValidationIds(), hLocale.getLocaleId(), offset, action.getCount());
}
}
return textFlows;
Expand Down

0 comments on commit 3f4d2e1

Please sign in to comment.