diff --git a/.classpath b/.classpath index 26acc93..3ff9476 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,6 @@ - diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index e7a8609..bff1722 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -3,7 +3,6 @@ - diff --git a/pom.xml b/pom.xml index 7f5a3da..f0dd564 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,11 @@ org.gcube.applicationsupportlayer aslcore provided + + + org.gcube.applicationsupportlayer + aslsocial + provided com.google diff --git a/src/main/java/org/gcube/portlets/user/questions/client/VREManagersPanel.java b/src/main/java/org/gcube/portlets/user/questions/client/VREManagersPanel.java index d61c778..2f6433b 100644 --- a/src/main/java/org/gcube/portlets/user/questions/client/VREManagersPanel.java +++ b/src/main/java/org/gcube/portlets/user/questions/client/VREManagersPanel.java @@ -1,41 +1,65 @@ package org.gcube.portlets.user.questions.client; import java.util.ArrayList; +import java.util.List; import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portlets.user.questions.client.resources.Images; import org.gcube.portlets.user.questions.client.ui.DisplayBadge; +import org.gcube.portlets.widgets.wsmail.client.forms.MailForm; import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.RunAsyncCallback; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasAlignment; import com.google.gwt.user.client.ui.HasVerticalAlignment; +import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.VerticalPanel; public class VREManagersPanel extends Composite { private final QuestionsServiceAsync service = GWT.create(QuestionsService.class); - + public static final String DISPLAY_NAME = "Questions? Ask the managers"; private Image loadingImage; + private Image postToImage; private VerticalPanel mainPanel = new VerticalPanel(); + private ArrayList managers; public VREManagersPanel() { super(); Images images = GWT.create(Images.class); loadingImage = new Image(images.membersLoader().getSafeUri()); + postToImage = new Image(images.postToIcon().getSafeUri()); + mainPanel.add(loadingImage); showLoader(); service.getManagers(new AsyncCallback>() { @Override public void onSuccess(ArrayList users) { + managers = users; mainPanel.clear(); mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); + mainPanel.setStyleName("questions-frame"); + HTML name = new HTML(DISPLAY_NAME); + + name.setStyleName("questions-title"); + name.addStyleName("manager-action"); + HorizontalPanel hp = new HorizontalPanel(); + hp.add(name); + hp.setStyleName("manager-action"); + postToImage.setStyleName("manager-post-image"); + postToImage.setTitle("Message privately to the Managers"); + hp.add(postToImage); + mainPanel.add(hp); if (users == null || users.isEmpty()) { mainPanel.add(new HTML("
Ops, something went wrong. Please reload this page.
")); } else { @@ -55,13 +79,31 @@ public class VREManagersPanel extends Composite { }); initWidget(mainPanel); + postToImage.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + final List listToLogin = new ArrayList(); + for (UserInfo user : managers) { + listToLogin.add(user.getUsername()); + } + + GWT.runAsync(new RunAsyncCallback() { + @Override + public void onSuccess() { + new MailForm(listToLogin); + } + public void onFailure(Throwable reason) { + Window.alert("Could not load this component: " + reason.getMessage()); + } + }); + } + }); } private void showLoader() { mainPanel.clear(); mainPanel.setWidth("100%"); - mainPanel.setHeight("300px"); mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER); mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); mainPanel.add(loadingImage); diff --git a/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.java b/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.java index a804466..c3eec93 100644 --- a/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.java +++ b/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.java @@ -7,6 +7,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.AnchorElement; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; @@ -20,7 +21,7 @@ public class DisplayBadge extends Composite { @UiField HTMLPanel mainPanel; @UiField Image avatarImage; - @UiField Image postToImage; + @UiField HTML userFullName; @UiField HTML headlineLabel; @@ -31,8 +32,17 @@ public class DisplayBadge extends Composite { public DisplayBadge(UserInfo user) { initWidget(uiBinder.createAndBindUi(this)); + String profileURL = ""; + String location = Window.Location.getHref(); + if (location.split("/").length == 5) + profileURL = location + "/" + user.getAccountURL(); + else + profileURL = user.getAccountURL(); + + + Images images = GWT.create(Images.class); - postToImage.setUrl(images.postToIcon().getSafeUri()); + avatarImage.setUrl(images.avatarLoader().getSafeUri()); mainPanel.addStyleName("profile-section"); @@ -42,12 +52,12 @@ public class DisplayBadge extends Composite { avatarImage.setUrl(images.avatarDefaultImage().getSafeUri()); else avatarImage.setUrl(myUserInfo.getAvatarId()); - userFullName.setHTML(""+myUserInfo.getFullName()+""); + + userFullName.setHTML(""+myUserInfo.getFullName()+""); - headlineLabel.setText("Head"); - institutionLabel.setText("Isti"); - imageRedirect.setHref(""); + headlineLabel.setText(user.getEmailaddress()); //it is the headline + imageRedirect.setHref(profileURL); String title = "See profile of " + myUserInfo.getFullName(); avatarImage.setTitle(title); userFullName.setTitle(title); diff --git a/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.ui.xml b/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.ui.xml index 1bf6fa9..fea6836 100644 --- a/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.ui.xml +++ b/src/main/java/org/gcube/portlets/user/questions/client/ui/DisplayBadge.ui.xml @@ -20,11 +20,7 @@ - -
- -
- + diff --git a/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java b/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java index a6987a5..081858e 100644 --- a/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java @@ -5,10 +5,12 @@ import java.util.HashMap; import java.util.List; import java.util.Set; +import org.apache.commons.codec.binary.Base64; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; +import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portlets.user.questions.client.QuestionsService; import org.gcube.vomanagement.usermanagement.GroupManager; @@ -66,6 +68,7 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi return new ArrayList<>(); } if (isWithinPortal()) { + _log.trace("Asking user and roles ..."); UserManager userM = new LiferayUserManager(); HashMap> usersAndRoles = null; try { @@ -78,17 +81,16 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi List roles = usersAndRoles.get(usr); for (int i = 0; i < roles.size(); i++) { if (roles.get(i).getRoleName().equals("VRE-Manager")) { - String username = ""; - String email = username+"@isti.cnr.it"; - String fullName = username+" FULL"; + String username = usr.getScreenName(); + _log.trace("Found Manager ... " + username); + String fullName = usr.getFullname(); String thumbnailURL = "images/Avatar_default.png"; try { com.liferay.portal.model.User user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username); thumbnailURL = user.isMale() ? "/image/user_male_portrait?img_id="+user.getPortraitId() : "/image/user_female_portrait?img_id="+user.getPortraitId(); - fullName = user.getFirstName() + " " + user.getLastName(); - email = user.getEmailAddress(); HashMap vreNames = new HashMap(); - UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, email, "", user.isMale(), false, vreNames); + String headline = user.getJobTitle(); + UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, headline, getUserProfileLink(username), user.isMale(), false, vreNames); toReturn.add(userInfo); } catch (Exception e) { @@ -140,7 +142,11 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi } return null; } - + + private String getUserProfileLink(String username) { + return "profile?"+ new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+new String(Base64.encodeBase64(username.getBytes())); + } + } diff --git a/src/main/java/org/gcube/portlets/user/questions/server/portlet/VREManagersPortlet.java b/src/main/java/org/gcube/portlets/user/questions/server/portlet/VREManagersPortlet.java new file mode 100644 index 0000000..c8fa073 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/questions/server/portlet/VREManagersPortlet.java @@ -0,0 +1,30 @@ + +package org.gcube.portlets.user.questions.server.portlet; + +import javax.portlet.GenericPortlet; +import javax.portlet.ActionRequest; +import javax.portlet.RenderRequest; +import javax.portlet.ActionResponse; +import javax.portlet.RenderResponse; +import javax.portlet.PortletException; +import java.io.IOException; +import javax.portlet.PortletRequestDispatcher; + +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; + +/** + * + * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it + */ + public class VREManagersPortlet extends GenericPortlet { + public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { + response.setContentType("text/html"); + ScopeHelper.setContext(request); + PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/VREManagers_view.jsp"); + dispatcher.include(request, response); + } + + public void processAction(ActionRequest request, ActionResponse response) + throws PortletException, IOException { + } +} diff --git a/src/main/resources/org/gcube/portlets/user/questions/Questions.gwt.xml b/src/main/resources/org/gcube/portlets/user/questions/Questions.gwt.xml index 23d8fe4..7101ba6 100644 --- a/src/main/resources/org/gcube/portlets/user/questions/Questions.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/questions/Questions.gwt.xml @@ -2,7 +2,7 @@ - + diff --git a/src/main/webapp/Questions.css b/src/main/webapp/Questions.css index 2e170cb..83cdfa6 100644 --- a/src/main/webapp/Questions.css +++ b/src/main/webapp/Questions.css @@ -1,7 +1,26 @@ +#questionsManagersDiv { + margin-right: 10px; +} +.questions-title { + display: block; + font-size: 16px; + color: #555; + font-weight: 400; + margin-bottom: 10px; +} + +.questions-frame { + padding: 10px; + background-color: #FFF; + border-radius: 6px !important; + -moz-border-radius: 6px !important; + -webkit-border-radius: 6px !important; + border: 1px solid #DBDBDB; +} .manager-user-photo { - padding: 5px; + padding: 3px; border: 1px solid #E6E6E6; width: 50px; height: 50px; @@ -18,8 +37,7 @@ } .manager-action { - width: 32px; - text-align: center; + padding: 5px; } .manager-post-image:hover { @@ -54,6 +72,7 @@ a.manager-person-link:hover { font-size: 13px; color: #444444; line-height: 16px; + width: 200px; } .manager-institution { diff --git a/src/main/webapp/WEB-INF/jsp/VREManagers_view.jsp b/src/main/webapp/WEB-INF/jsp/VREManagers_view.jsp new file mode 100644 index 0000000..86e2e85 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/VREManagers_view.jsp @@ -0,0 +1,7 @@ +<%@page contentType="text/html"%> +<%@page pageEncoding="UTF-8"%> + + + +
+ diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml new file mode 100644 index 0000000..64928ca --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties new file mode 100644 index 0000000..621b168 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -0,0 +1,9 @@ +name=VREManagers +module-group-id=liferay +module-incremental-version=1 +tags= +short-description= +change-log= +page-url=http://www.d4science.org +author=D4Science.org +licenses=EUPL \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml new file mode 100644 index 0000000..ea33f62 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -0,0 +1,28 @@ + + + + + + VREManagers + false + false + false + /Questions.css + + + administrator + Administrator + + + guest + Guest + + + power-user + Power User + + + user + User + + diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml new file mode 100644 index 0000000..c7ba5b7 --- /dev/null +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -0,0 +1,30 @@ + + + + + VREManagers + VRE Managers + org.gcube.portlets.user.questions.server.portlet.VREManagersPortlet + + view-jsp + /view.jsp + + 0 + + text/html + + + Questions? Ask the Managers + VRE Managers + VRE Managers + + + administrator + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index f78bfc0..f4355b7 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -5,20 +5,31 @@ - - - greetServlet - org.gcube.portlets.user.questions.server.QuestionsServiceImpl - + + + greetServlet + org.gcube.portlets.user.questions.server.QuestionsServiceImpl + - - greetServlet - /questions/greet - + + mailWisdgetServlet + org.gcube.portlets.widgets.wsmail.server.WsMailServiceImpl + - - - Questions.html - + + greetServlet + /questions/greet + + + + + mailWisdgetServlet + /questions/mailWisdgetServlet + + + + + Questions.html +