all done
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/questions@101784 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
240cdf5f1b
commit
ed60d73c58
|
@ -6,7 +6,6 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="target/generated-sources/gwt"/>
|
||||
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<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="/target/generated-sources/gwt"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="questions"/>
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -98,6 +98,11 @@
|
|||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslsocial</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google</groupId>
|
||||
|
|
|
@ -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<UserInfo> 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<ArrayList<UserInfo>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<UserInfo> 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("<div class=\"frame\" style=\"font-size: 16px;\">Ops, something went wrong. Please <a href=\"javascript: location.reload();\">reload<a/> this page.</div>"));
|
||||
} else {
|
||||
|
@ -55,13 +79,31 @@ public class VREManagersPanel extends Composite {
|
|||
});
|
||||
initWidget(mainPanel);
|
||||
|
||||
postToImage.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
final List<String> listToLogin = new ArrayList<String>();
|
||||
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);
|
||||
|
|
|
@ -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("<a class=\"manager-person-link\" href=\""+user.getAccountURL()+"\">"+myUserInfo.getFullName()+"</a>");
|
||||
|
||||
userFullName.setHTML("<a class=\"manager-person-link\" href=\""+profileURL+"\">"+myUserInfo.getFullName()+"</a>");
|
||||
|
||||
|
||||
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);
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
<g:HTML styleName="manager-institution" ui:field="institutionLabel"></g:HTML>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="manager-action">
|
||||
<g:Image title="Post question to the manager" ui:field="postToImage" styleName="manager-post-image"/>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</g:HTMLPanel>
|
||||
|
|
|
@ -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<UserModel, List<RoleModel>> usersAndRoles = null;
|
||||
try {
|
||||
|
@ -78,17 +81,16 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|||
List<RoleModel> 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<String, String> vreNames = new HashMap<String, String>();
|
||||
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()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
<module rename-to='questions'>
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
<set-property name="user.agent" value="gecko1_8" />
|
||||
<!-- <set-property name="user.agent" value="gecko1_8" /> -->
|
||||
<!-- Other module inherits -->
|
||||
<!-- inherits GCUBE Widgets -->
|
||||
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<%@page contentType="text/html"%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
|
||||
|
||||
<script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/questions/questions.nocache.js"></script>
|
||||
<div id="questionsManagersDiv"></div>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.0.0//EN" "http://www.liferay.com/dtd/liferay-display_6_0_0.dtd">
|
||||
|
||||
<display>
|
||||
<category name="gCube Social Apps">
|
||||
<portlet id="VREManagers" />
|
||||
</category>
|
||||
</display>
|
|
@ -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
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">
|
||||
|
||||
<liferay-portlet-app>
|
||||
<portlet>
|
||||
<portlet-name>VREManagers</portlet-name>
|
||||
<layout-cacheable>false</layout-cacheable>
|
||||
<instanceable>false</instanceable>
|
||||
<ajaxable>false</ajaxable>
|
||||
<header-portlet-css>/Questions.css</header-portlet-css>
|
||||
</portlet>
|
||||
<role-mapper>
|
||||
<role-name>administrator</role-name>
|
||||
<role-link>Administrator</role-link>
|
||||
</role-mapper>
|
||||
<role-mapper>
|
||||
<role-name>guest</role-name>
|
||||
<role-link>Guest</role-link>
|
||||
</role-mapper>
|
||||
<role-mapper>
|
||||
<role-name>power-user</role-name>
|
||||
<role-link>Power User</role-link>
|
||||
</role-mapper>
|
||||
<role-mapper>
|
||||
<role-name>user</role-name>
|
||||
<role-link>User</role-link>
|
||||
</role-mapper>
|
||||
</liferay-portlet-app>
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<portlet-app
|
||||
version="2.0"
|
||||
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
>
|
||||
<portlet>
|
||||
<portlet-name>VREManagers</portlet-name>
|
||||
<display-name>VRE Managers</display-name>
|
||||
<portlet-class>org.gcube.portlets.user.questions.server.portlet.VREManagersPortlet</portlet-class>
|
||||
<init-param>
|
||||
<name>view-jsp</name>
|
||||
<value>/view.jsp</value>
|
||||
</init-param>
|
||||
<expiration-cache>0</expiration-cache>
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
</supports>
|
||||
<portlet-info>
|
||||
<title>Questions? Ask the Managers</title>
|
||||
<short-title>VRE Managers</short-title>
|
||||
<keywords>VRE Managers</keywords>
|
||||
</portlet-info>
|
||||
<security-role-ref>
|
||||
<role-name>administrator</role-name>
|
||||
</security-role-ref>
|
||||
</portlet>
|
||||
</portlet-app>
|
|
@ -5,20 +5,31 @@
|
|||
|
||||
<web-app>
|
||||
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>greetServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.questions.server.QuestionsServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>greetServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.questions.server.QuestionsServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>greetServlet</servlet-name>
|
||||
<url-pattern>/questions/greet</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet>
|
||||
<servlet-name>mailWisdgetServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.wsmail.server.WsMailServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>Questions.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
<servlet-mapping>
|
||||
<servlet-name>greetServlet</servlet-name>
|
||||
<url-pattern>/questions/greet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>mailWisdgetServlet</servlet-name>
|
||||
<url-pattern>/questions/mailWisdgetServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>Questions.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
||||
|
|
Loading…
Reference in New Issue