Added support for Terms of Use Display
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@150820 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1ae3bf20cf
commit
3101ad62ab
|
@ -1,4 +1,8 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset component="org.gcube.portlets-user.join-vre.3.4.0" date="2017-07-05">
|
||||||
|
<Change>Ported to GWT 2.8.1</Change>
|
||||||
|
<Change>Added support for Terms of Use Display</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.join-vre.3.3.0" date="2017-05-15">
|
<Changeset component="org.gcube.portlets-user.join-vre.3.3.0" date="2017-05-15">
|
||||||
<Change>Ported to Java8</Change>
|
<Change>Ported to Java8</Change>
|
||||||
<Change>Added support for template emails</Change>
|
<Change>Added support for template emails</Change>
|
||||||
|
|
|
@ -23,7 +23,7 @@ public interface JoinService extends RemoteService {
|
||||||
|
|
||||||
VRE getSelectedVRE(Long vreId);
|
VRE getSelectedVRE(Long vreId);
|
||||||
|
|
||||||
void addMembershipRequest(String scope, String optionalMessage);
|
void addMembershipRequest(VRE theVRE, String optionalMessage);
|
||||||
|
|
||||||
boolean registerUser(String scope, long vreId, boolean isInvitation);
|
boolean registerUser(String scope, long vreId, boolean isInvitation);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ public interface JoinServiceAsync {
|
||||||
|
|
||||||
void getSelectedVRE(Long vreId, AsyncCallback<VRE> callback);
|
void getSelectedVRE(Long vreId, AsyncCallback<VRE> callback);
|
||||||
|
|
||||||
void addMembershipRequest(String scope, String optionalMessage,
|
void addMembershipRequest(VRE theVRE, String optionalMessage,
|
||||||
AsyncCallback<Void> callback);
|
AsyncCallback<Void> callback);
|
||||||
|
|
||||||
void registerUser(String scope, long vreId, boolean isInvitation,
|
void registerUser(String scope, long vreId, boolean isInvitation,
|
||||||
|
|
|
@ -7,18 +7,26 @@ import org.gcube.portlets.user.joinvre.shared.VRE;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.HelpBlock;
|
import com.github.gwtbootstrap.client.ui.HelpBlock;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
import com.github.gwtbootstrap.client.ui.Modal;
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
|
import com.google.gwt.user.client.Window.Location;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
public class RequestMembershipDialog extends Composite {
|
public class RequestMembershipDialog extends Composite {
|
||||||
|
|
||||||
|
private static final String OPTIONAL_COMMENT_TEXT = "You can add an optional comment here, it will be attached to your request and read by this VRE Moderators.";
|
||||||
|
|
||||||
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
|
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
|
||||||
|
|
||||||
private static RequestAccessModalUiBinder uiBinder = GWT
|
private static RequestAccessModalUiBinder uiBinder = GWT
|
||||||
|
@ -32,19 +40,57 @@ public class RequestMembershipDialog extends Composite {
|
||||||
@UiField Button confirmRequest;
|
@UiField Button confirmRequest;
|
||||||
@UiField TextArea optionalText;
|
@UiField TextArea optionalText;
|
||||||
@UiField HelpBlock helpBlock;
|
@UiField HelpBlock helpBlock;
|
||||||
|
@UiField Icon loading;
|
||||||
private VRE myVRE = null;
|
private VRE myVRE = null;
|
||||||
private ResponsivePanel responsivePanel;
|
private ResponsivePanel responsivePanel;
|
||||||
|
|
||||||
|
@UiField HelpBlock touGatewayBlock;
|
||||||
|
@UiField HTML touText;
|
||||||
|
|
||||||
public RequestMembershipDialog(ResponsivePanel responsivePanel, VRE myVRE) {
|
public RequestMembershipDialog(ResponsivePanel responsivePanel, VRE myVRE) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
this.myVRE = myVRE;
|
this.myVRE = myVRE;
|
||||||
this.responsivePanel = responsivePanel;
|
this.responsivePanel = responsivePanel;
|
||||||
optionalText.setWidth("95%");
|
optionalText.setWidth("95%");
|
||||||
optionalText.setPlaceholder("You can add an optional comment here");
|
optionalText.setPlaceholder(OPTIONAL_COMMENT_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
m.setTitle("Join request for " +myVRE.getName());
|
m.setTitle("Join request for " +myVRE.getName());
|
||||||
|
loading.setVisible(true);
|
||||||
|
joinService.getTermsOfUse(this.myVRE.getId(), new AsyncCallback<String>() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
m.setTitle("Ops, an error occurred please check your connection and try again");
|
||||||
|
confirmRequest.setText("Try again");
|
||||||
|
confirmRequest.addClickHandler(new ClickHandler() {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
Location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loading.setVisible(false);
|
||||||
|
touGatewayBlock.setVisible(true);
|
||||||
|
m.show();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String result) {
|
||||||
|
loading.setVisible(false);
|
||||||
|
if (result != null) { // terms of use exist
|
||||||
|
String text = "By using <b>" + myVRE.getName() + "</b> VRE services, you agree to the Terms of Use below. Please read it carefully.";
|
||||||
|
helpBlock.setHTML(text);
|
||||||
|
String buttonText = "Accept Terms of Use & Request Access";
|
||||||
|
confirmRequest.setText(buttonText);
|
||||||
|
m.addStyleName("modal-custom");
|
||||||
|
((Element)m.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom");
|
||||||
|
touText.setHTML(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
m.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
m.show();
|
m.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +102,7 @@ public class RequestMembershipDialog extends Composite {
|
||||||
void confirm(ClickEvent e) {
|
void confirm(ClickEvent e) {
|
||||||
String text = optionalText.getText();
|
String text = optionalText.getText();
|
||||||
confirmRequest.setEnabled(false);
|
confirmRequest.setEnabled(false);
|
||||||
joinService.addMembershipRequest(myVRE.getinfraScope(), text, new AsyncCallback<Void>() {
|
joinService.addMembershipRequest(myVRE, text, new AsyncCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
confirmRequest.removeFromParent();
|
confirmRequest.removeFromParent();
|
||||||
|
@ -65,6 +111,7 @@ public class RequestMembershipDialog extends Composite {
|
||||||
helpBlock.setText("You will receive an email as soon as your request will be processed.");
|
helpBlock.setText("You will receive an email as soon as your request will be processed.");
|
||||||
responsivePanel.setPending(myVRE);
|
responsivePanel.setPending(myVRE);
|
||||||
confirmRequest.setEnabled(false);
|
confirmRequest.setEnabled(false);
|
||||||
|
touText.removeFromParent();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -72,6 +119,7 @@ public class RequestMembershipDialog extends Composite {
|
||||||
optionalText.removeFromParent();
|
optionalText.removeFromParent();
|
||||||
m.setTitle("An error occurred! Your request has not been sent");
|
m.setTitle("An error occurred! Your request has not been sent");
|
||||||
helpBlock.setText("An email with the cause of the error has been sent to the support team, we'll be back to you shortly.");
|
helpBlock.setText("An email with the cause of the error has been sent to the support team, we'll be back to you shortly.");
|
||||||
|
touText.removeFromParent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,19 @@
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
<b:Modal ui:field="m" title="My Modal" backdrop="STATIC"
|
<b:Modal ui:field="m" title="My Modal" backdrop="STATIC"
|
||||||
keyboard="true" animation="true">
|
keyboard="true" animation="true">
|
||||||
|
<b:Icon type="COG" size="FOUR_TIMES" spin="true" ui:field="loading"
|
||||||
|
visible="false" />
|
||||||
<b:ControlGroup>
|
<b:ControlGroup>
|
||||||
<b:Controls>
|
<b:Controls>
|
||||||
<b:HelpBlock ui:field="helpBlock">Please confirm your request</b:HelpBlock>
|
<b:TextArea ui:field="optionalText" alternateSize="XLARGE" />
|
||||||
<b:TextArea ui:field="optionalText" alternateSize="XLARGE"/>
|
<b:HelpBlock ui:field="helpBlock">Your request will be reviewed by this VRE moderators, you will be notified via email about the result as soon as possible (tipically within a few hours).</b:HelpBlock>
|
||||||
|
<b:HelpBlock ui:field="touGatewayBlock" visible="false">
|
||||||
|
By asking access to this VRE you agree to the terms indicated in
|
||||||
|
the
|
||||||
|
<a href="/terms-of-use" target="_blank">Terms of Use</a>
|
||||||
|
of this gateway.
|
||||||
|
</b:HelpBlock>
|
||||||
|
<g:HTML ui:field="touText"></g:HTML>
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
<b:ModalFooter>
|
<b:ModalFooter>
|
||||||
|
|
|
@ -44,7 +44,6 @@ import com.liferay.portal.kernel.exception.PortalException;
|
||||||
import com.liferay.portal.kernel.exception.SystemException;
|
import com.liferay.portal.kernel.exception.SystemException;
|
||||||
import com.liferay.portal.kernel.log.Log;
|
import com.liferay.portal.kernel.log.Log;
|
||||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||||
import com.liferay.portal.kernel.util.WebKeys;
|
|
||||||
import com.liferay.portal.model.Group;
|
import com.liferay.portal.model.Group;
|
||||||
import com.liferay.portal.model.VirtualHost;
|
import com.liferay.portal.model.VirtualHost;
|
||||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||||
|
@ -355,16 +354,16 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMembershipRequest(String scope, String optionalMessage) {
|
public void addMembershipRequest(VRE theVRE, String optionalMessage) {
|
||||||
|
String scope = theVRE.getinfraScope();
|
||||||
String username = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()).getUsername();
|
String username = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||||
if (optionalMessage == null || optionalMessage.compareTo("") == 0)
|
if (optionalMessage == null || optionalMessage.compareTo("") == 0)
|
||||||
optionalMessage = "none";
|
optionalMessage = "none";
|
||||||
try {
|
try {
|
||||||
CacheRegistryUtil.clear();
|
CacheRegistryUtil.clear();
|
||||||
GroupManager gm = new LiferayGroupManager();
|
long groupId = theVRE.getId();
|
||||||
long groupId = gm.getGroupIdFromInfrastructureScope(scope);
|
|
||||||
_log.debug("Look if a request exists already");
|
_log.debug("Look if a request exists already");
|
||||||
List<GCubeGroup> userGroups = gm.listGroupsByUser(new LiferayUserManager().getUserId(username));
|
List<GCubeGroup> userGroups = new LiferayGroupManager().listGroupsByUser(new LiferayUserManager().getUserId(username));
|
||||||
for (GCubeGroup g : userGroups) {
|
for (GCubeGroup g : userGroups) {
|
||||||
if (g.getGroupId() == groupId) {
|
if (g.getGroupId() == groupId) {
|
||||||
_log.warn("User already belongs to " + scope + " SKIP addMembershipRequest");
|
_log.warn("User already belongs to " + scope + " SKIP addMembershipRequest");
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<inherits name='com.google.gwt.activity.Activity' />
|
<inherits name='com.google.gwt.activity.Activity' />
|
||||||
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
||||||
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
|
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
|
||||||
<!-- <set-property name="user.agent" value="gecko1_8" /> -->
|
<set-property name="user.agent" value="gecko1_8" />
|
||||||
|
|
||||||
<!-- Specify the app entry point class. -->
|
<!-- Specify the app entry point class. -->
|
||||||
<entry-point class='org.gcube.portlets.user.joinvre.client.JoinVRE' />
|
<entry-point class='org.gcube.portlets.user.joinvre.client.JoinVRE' />
|
||||||
|
|
Loading…
Reference in New Issue