made notification to members option configurable as default, see Feature #121
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@117026 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
96dcf96949
commit
499703699a
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/share-updates-1.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/share-updates-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -31,5 +31,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/share-updates-1.7.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/share-updates-1.8.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.shareupdates.1-8-0"
|
||||
date="2015-07-06">
|
||||
<Change>made notification to members option configurable as default, see Feature #121</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.shareupdates.1-7-0"
|
||||
date="2015-05-27">
|
||||
<Change>Integrated gwt-bootstrap and revised css</Change>
|
||||
|
@ -7,7 +11,8 @@
|
|||
<Changeset component="org.gcube.portlets-user.shareupdates.1-6-1"
|
||||
date="2014-12-13">
|
||||
<Change>Added Client scope handler, to set the scope from the client
|
||||
and help preventing the browser back button cache problem</Change>
|
||||
and help preventing the browser back button cache problem
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.shareupdates.1-6-0"
|
||||
date="2014-11-03">
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>share-updates</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<version>1.8.0-SNAPSHOT</version>
|
||||
|
||||
<name>gCube Share Updates Portlet</name>
|
||||
<description>
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressPanel;
|
|||
import org.jsonmaker.gwt.client.Jsonizer;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.dom.client.Style.Display;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.dom.client.Style.Visibility;
|
||||
|
@ -30,7 +31,6 @@ import com.google.gwt.uibinder.client.UiBinder;
|
|||
import com.google.gwt.uibinder.client.UiFactory;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.Element;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
|
@ -46,7 +46,6 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
/**
|
||||
*
|
||||
* @author Massimiliano Assante
|
||||
* @version 1.2 Nov 2012
|
||||
*
|
||||
*/
|
||||
public class ShareUpdateForm extends Composite {
|
||||
|
@ -59,13 +58,13 @@ public class ShareUpdateForm extends Composite {
|
|||
final PageBusAdapter pageBusAdapter = new PageBusAdapter();
|
||||
// the label for all Vres/channels
|
||||
private final static String ALL_VRES = "Share with: your Virtual Research Environments";
|
||||
|
||||
|
||||
protected final static String SHARE_UPDATE_TEXT = "Share an update or a link, use “@” to mention and “#” to add a topic";
|
||||
protected final static String ERROR_UPDATE_TEXT = "Looks like empty to me!";
|
||||
public final static String NO_TEXT_FILE_SHARE = "_N0_73X7_SH4R3_";
|
||||
private final static String LISTBOX_LEVEL = " - ";
|
||||
|
||||
|
||||
|
||||
|
||||
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
|
||||
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
|
||||
public static final String attach = GWT.getModuleBaseURL() + "../images/attach.png";
|
||||
|
@ -75,7 +74,7 @@ public class ShareUpdateForm extends Composite {
|
|||
*/
|
||||
private String uploadedFilePathOnServer;
|
||||
private String uploadedFileNameOnServer;
|
||||
|
||||
|
||||
private HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
private static ShareUpdateFormUiBinder uiBinder = GWT
|
||||
|
@ -110,10 +109,10 @@ public class ShareUpdateForm extends Composite {
|
|||
@UiField SuperPosedTextArea shareTextArea;
|
||||
|
||||
@UiField
|
||||
ListBox privacyLevel = new ListBox(false);
|
||||
|
||||
ListBox privacyLevel = new ListBox();
|
||||
|
||||
@UiField
|
||||
ListBox notifyListbox = new ListBox(false);
|
||||
ListBox notifyListbox = new ListBox();
|
||||
|
||||
private UserInfo myUserInfo;
|
||||
|
||||
|
@ -131,18 +130,18 @@ public class ShareUpdateForm extends Composite {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public ShareUpdateForm() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
singleton = this;
|
||||
bind();
|
||||
avatarImage.setUrl(loading);
|
||||
shareTextArea.setText(SHARE_UPDATE_TEXT);
|
||||
|
||||
|
||||
attachButton.getElement().getStyle().setDisplay(Display.INLINE);
|
||||
attachButton.setHTML("<span style=\"padding: 5px 1px; background: url('"+attach+"') 50% 50% no-repeat;\"> </span>");
|
||||
|
||||
|
||||
|
||||
|
||||
shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
avatarImage.setSize("60px", "60px");
|
||||
|
@ -155,6 +154,9 @@ public class ShareUpdateForm extends Composite {
|
|||
avatarImage.setSize("60px", "60px");
|
||||
avatarImage.setUrl(myUserInfo.getAvatarId());
|
||||
String singleVREName = "";
|
||||
|
||||
boolean notificationEmail = userSettings.isNotificationViaEmailEnabled();
|
||||
|
||||
if (myUserInfo.getOwnVREs().size() > 1) {
|
||||
privacyLevel.addItem(ALL_VRES, PrivacyLevel.VRES.toString());
|
||||
for (String vreId : myUserInfo.getOwnVREs().keySet())
|
||||
|
@ -171,9 +173,14 @@ public class ShareUpdateForm extends Composite {
|
|||
privacyLevel.addItem("Share with: Everyone", PrivacyLevel.PORTAL.toString());
|
||||
//change css if deployed in VRE scope
|
||||
if (!userSettings.isInfrastructure()) {
|
||||
mainPanel.addStyleName("framed");
|
||||
notifyListbox.addItem("Share with: " + singleVREName);
|
||||
notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members");
|
||||
mainPanel.addStyleName("framed");
|
||||
if (notificationEmail) {
|
||||
notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members");
|
||||
notifyListbox.addItem("Share with: " + singleVREName);
|
||||
} else {
|
||||
notifyListbox.addItem("Share with: " + singleVREName);
|
||||
notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members");
|
||||
}
|
||||
notifyListbox.setVisible(true);
|
||||
}
|
||||
else
|
||||
|
@ -181,7 +188,7 @@ public class ShareUpdateForm extends Composite {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** Used by UiBinder to instantiate UploadProgressView */
|
||||
@UiFactory
|
||||
UploadProgressPanel instatiateProgressView() {
|
||||
|
@ -213,7 +220,7 @@ public class ShareUpdateForm extends Composite {
|
|||
public static native void fileBrowse(Element el) /*-{
|
||||
el.click();
|
||||
}-*/;
|
||||
|
||||
|
||||
|
||||
@UiHandler("submitButton")
|
||||
void onClick(ClickEvent e) {
|
||||
|
@ -229,7 +236,7 @@ public class ShareUpdateForm extends Composite {
|
|||
}
|
||||
myUserInfo = result.getUserInfo();
|
||||
String toShare = shareTextArea.getText().trim();
|
||||
|
||||
|
||||
//We allow to post a file without writing nothing in the sharing textarea
|
||||
if (myLinkPreviewer != null && myLinkPreviewer.isSharingFile() && (toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT) || toShare.equals("")) ) {
|
||||
toShare = NO_TEXT_FILE_SHARE;
|
||||
|
@ -280,7 +287,7 @@ public class ShareUpdateForm extends Composite {
|
|||
}
|
||||
LinkPreview preview2Share = new LinkPreview(linkTitle, linkDescription, linkUrl, linkHost, null);
|
||||
boolean notifyGroup = notifyListbox.getSelectedIndex() > 0;
|
||||
|
||||
|
||||
shareupdateService.share(toShare, FeedType.TWEET, getPrivacyLevel(), vreId, preview2Share, linkUrlThumbnail, mentionedUsers, fileName, filePath, notifyGroup, new AsyncCallback<ClientFeed>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
submitButton.setEnabled(true);
|
||||
|
@ -395,7 +402,7 @@ public class ShareUpdateForm extends Composite {
|
|||
final Button close = new Button("Try Again");
|
||||
final HTML reportIssue = new HTML("<a href=\"https://support.d4science.research-infrastructures.eu\" target=\"_blank\">"
|
||||
+ "<span>Report the issue</span></a>");
|
||||
|
||||
|
||||
close.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
@ -403,7 +410,7 @@ public class ShareUpdateForm extends Composite {
|
|||
preview.remove(hp);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
hp.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
|
||||
hp.add(close);
|
||||
hp.add(reportIssue);
|
||||
|
@ -419,7 +426,7 @@ public class ShareUpdateForm extends Composite {
|
|||
uploadedFilePathOnServer = absolutePathOnServer;
|
||||
uploadedFileNameOnServer = fileName;
|
||||
submitButton.setEnabled(true);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ import org.gcube.contentmanagement.blobstorage.service.IClient;
|
|||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.gcube.portal.custom.communitymanager.OrganizationManager;
|
||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
||||
import org.gcube.portal.custom.communitymanager.impl.OrganizationManagerImpl;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||
import org.gcube.portal.databook.server.DatabookStore;
|
||||
|
@ -116,7 +118,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
}
|
||||
public String getDevelopmentUser() {
|
||||
String user = TEST_USER;
|
||||
// user = "massimiliano.assante";
|
||||
user = "massimiliano.assante";
|
||||
return user;
|
||||
}
|
||||
/**
|
||||
|
@ -272,16 +274,20 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
String thumbnailURL = "images/Avatar_default.png";
|
||||
|
||||
if (isWithinPortal() && username.compareTo(TEST_USER) != 0) {
|
||||
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
||||
long companyId = OrganizationsUtil.getCompany().getCompanyId();
|
||||
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(companyId, username);
|
||||
Organization currOrg = OrganizationLocalServiceUtil.getOrganization(session.getGroupId());
|
||||
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
||||
fullName = user.getFirstName() + " " + user.getLastName();
|
||||
email = user.getEmailAddress();
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||
|
||||
String accountURL = themeDisplay.getURLMyAccount().toString();
|
||||
HashMap<String, String> vreNames = getUserVreNames(username);
|
||||
|
||||
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), vreNames);
|
||||
UserSettings toReturn = new UserSettings(userInfo, 0, session.getScopeName(), isInfrastructureScope());
|
||||
|
||||
UserSettings toReturn = new UserSettings(userInfo, 0, session.getScopeName(), isInfrastructureScope(), isNotificationViaEmailEnabled(username, currOrg));
|
||||
return toReturn;
|
||||
}
|
||||
else {
|
||||
|
@ -291,7 +297,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
//fakeVreNames.put("/gcube/devNext/NexNext","NexNext");
|
||||
|
||||
UserInfo user = new UserInfo(session.getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames);
|
||||
return new UserSettings(user, 0, session.getScopeName(), false);
|
||||
return new UserSettings(user, 0, session.getScopeName(), false, true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -299,6 +305,12 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
}
|
||||
return new UserSettings();
|
||||
}
|
||||
|
||||
private boolean isNotificationViaEmailEnabled(String username, Organization currOrg) {
|
||||
final String ATTR_TO_CHECK = "PostNotificationViaEmail";
|
||||
return OrganizationManagerImpl.get().readOrganizationCustomAttribute(username, currOrg, ATTR_TO_CHECK);
|
||||
}
|
||||
|
||||
/**
|
||||
* generate a preview of the file, upload the file on the storage and shorts the link
|
||||
*/
|
||||
|
|
|
@ -10,17 +10,30 @@ public class UserSettings implements Serializable {
|
|||
private int refreshingTimeInMillis;
|
||||
private String currentScope;
|
||||
boolean isInfrastructure;
|
||||
boolean isNotificationViaEmailEnabled;
|
||||
public UserSettings() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis,
|
||||
String currentScope, boolean isInfrastructure) {
|
||||
String currentScope, boolean isInfrastructure,
|
||||
boolean isNotificationViaEmailEnabled) {
|
||||
super();
|
||||
this.userInfo = userInfo;
|
||||
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
||||
this.currentScope = currentScope;
|
||||
this.isInfrastructure = isInfrastructure;
|
||||
this.isNotificationViaEmailEnabled = isNotificationViaEmailEnabled;
|
||||
}
|
||||
|
||||
public boolean isNotificationViaEmailEnabled() {
|
||||
return isNotificationViaEmailEnabled;
|
||||
}
|
||||
|
||||
public void setNotificationViaEmailEnabled(boolean isNotificationViaEmailEnabled) {
|
||||
this.isNotificationViaEmailEnabled = isNotificationViaEmailEnabled;
|
||||
}
|
||||
|
||||
public UserInfo getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue