added notification config files, still need to create the VIEW over the Preferences Map
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@76761 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
287d96552f
commit
aca6fd95bd
|
@ -3,9 +3,11 @@ package org.gcube.portlets.user.notifications.client;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
import org.gcube.portal.databook.shared.NotificationType;
|
||||
import org.gcube.portal.databook.shared.UserInfo;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -21,7 +23,7 @@ public interface NotificationsService extends RemoteService {
|
|||
|
||||
boolean setAllUserNotificationsRead();
|
||||
|
||||
ArrayList<NotificationChannelType> getNotificationChannels();
|
||||
HashMap<NotificationType, NotificationChannelType[]> getUserNotificationPreferences();
|
||||
|
||||
boolean setNotificationChannels(HashMap<NotificationChannelType, Boolean> newSettings);
|
||||
boolean setUserNotificationPreferences(Map<NotificationType, NotificationChannelType[]> enabledChannels);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@ package org.gcube.portlets.user.notifications.client;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
import org.gcube.portal.databook.shared.NotificationType;
|
||||
import org.gcube.portal.databook.shared.UserInfo;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -19,11 +21,10 @@ public interface NotificationsServiceAsync {
|
|||
|
||||
void setAllUserNotificationsRead(AsyncCallback<Boolean> callback);
|
||||
|
||||
void getNotificationChannels(
|
||||
AsyncCallback<ArrayList<NotificationChannelType>> callback);
|
||||
void getUserNotificationPreferences(AsyncCallback<HashMap<NotificationType, NotificationChannelType[]>> callback);
|
||||
|
||||
void setNotificationChannels(
|
||||
HashMap<NotificationChannelType, Boolean> newSettings,
|
||||
void setUserNotificationPreferences(
|
||||
Map<NotificationType, NotificationChannelType[]> enabledChannels,
|
||||
AsyncCallback<Boolean> callback);
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
import org.gcube.portal.databook.shared.NotificationType;
|
||||
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
|
||||
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
|
||||
import org.gcube.portlets.user.notifications.client.view.templates.NotificationPreference;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
|
@ -43,15 +45,22 @@ public class NotificationSettings extends GCubeDialog {
|
|||
private Button cancel = new Button("Cancel");
|
||||
private Button save = new Button("Save");
|
||||
|
||||
public NotificationSettings(final ArrayList<NotificationChannelType> currentChannels, final NotificationsServiceAsync notificationService) {
|
||||
private HashMap<NotificationType,NotificationChannelType[]> preferences;
|
||||
|
||||
public NotificationSettings(final HashMap<NotificationType,NotificationChannelType[]> preferences, final NotificationsServiceAsync notificationService) {
|
||||
super();
|
||||
this.preferences = preferences;
|
||||
buttonsPanel.setWidth("100%");
|
||||
buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
|
||||
container.setStyleName("user-notification");
|
||||
container.setWidth("400px");
|
||||
container.setWidth("800px");
|
||||
container.add(how);
|
||||
container.add(new HTML(" "));
|
||||
container.add(new NotificationPreference());
|
||||
|
||||
|
||||
|
||||
container.add(portalCheckbox);
|
||||
container.add(emailCheckbox);
|
||||
|
||||
|
@ -63,44 +72,11 @@ public class NotificationSettings extends GCubeDialog {
|
|||
setText("Notification Settings");
|
||||
setWidget(container);
|
||||
|
||||
if (currentChannels.contains(NotificationChannelType.EMAIL))
|
||||
emailCheckbox.setValue(true);
|
||||
|
||||
if (currentChannels.contains(NotificationChannelType.PORTAL))
|
||||
portalCheckbox.setValue(true);
|
||||
|
||||
save.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
boolean portalChanged = (portalCheckbox.getValue() && !currentChannels.contains(NotificationChannelType.PORTAL) ||
|
||||
!portalCheckbox.getValue() && currentChannels.contains(NotificationChannelType.PORTAL));
|
||||
|
||||
boolean emailChanged = (emailCheckbox.getValue() && !currentChannels.contains(NotificationChannelType.EMAIL) ||
|
||||
!emailCheckbox.getValue() && currentChannels.contains(NotificationChannelType.EMAIL));
|
||||
|
||||
HashMap<NotificationChannelType, Boolean> newSettings = new HashMap<NotificationChannelType, Boolean>();
|
||||
if (portalChanged) {
|
||||
newSettings.put(NotificationChannelType.PORTAL, portalCheckbox.getValue());
|
||||
}
|
||||
if (emailChanged) {
|
||||
newSettings.put(NotificationChannelType.EMAIL, emailCheckbox.getValue());
|
||||
}
|
||||
|
||||
if (portalChanged || emailChanged)
|
||||
notificationService.setNotificationChannels(newSettings, new AsyncCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
showDeliveryResult(result);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
showDeliveryResult(false);
|
||||
}
|
||||
});
|
||||
else
|
||||
showDeliveryResult(true);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.HashMap;
|
|||
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
import org.gcube.portal.databook.shared.NotificationType;
|
||||
import org.gcube.portal.databook.shared.UserInfo;
|
||||
import org.gcube.portlets.user.notifications.client.NotificationsService;
|
||||
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
|
||||
|
@ -83,17 +84,21 @@ public class NotificationsPanel extends Composite {
|
|||
notificationSettings.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
notificationService.getNotificationChannels(new AsyncCallback<ArrayList<NotificationChannelType>>() {
|
||||
|
||||
notificationService.getUserNotificationPreferences(new AsyncCallback<HashMap<NotificationType,NotificationChannelType[]>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) { }
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<NotificationChannelType> result) {
|
||||
public void onSuccess(HashMap<NotificationType, NotificationChannelType[]> result) {
|
||||
NotificationSettings dlg = new NotificationSettings(result, notificationService);
|
||||
dlg.center();
|
||||
dlg.show();
|
||||
dlg.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.portlets.user.notifications.client.view.templates;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HasText;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class NotificationPreference extends Composite {
|
||||
|
||||
private static NotificationPreferenceUiBinder uiBinder = GWT
|
||||
.create(NotificationPreferenceUiBinder.class);
|
||||
|
||||
interface NotificationPreferenceUiBinder extends
|
||||
UiBinder<Widget, NotificationPreference> {
|
||||
}
|
||||
|
||||
public NotificationPreference() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||
<g:HTMLPanel>
|
||||
<div id="preferenceContainer">
|
||||
<div id="preferenceType">WP_FOLDER_SHARE</div>
|
||||
<div id="preferenceDesc">use to notify a user he got a workspace folder shared</div>
|
||||
<div id="preferenceSettingOff"></div>
|
||||
<div id="preferenceSettingPortal"></div>
|
||||
<div id="preferenceSettingEmail"></div>
|
||||
</div>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
|
@ -14,8 +15,10 @@ import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
|||
import org.gcube.portal.databook.server.DatabookStore;
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
import org.gcube.portal.databook.shared.NotificationType;
|
||||
import org.gcube.portal.databook.shared.UserInfo;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
|
||||
import org.gcube.portlets.user.notifications.client.NotificationsService;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
@ -61,7 +64,7 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
if (user == null) {
|
||||
user = "test.user";
|
||||
//user = "massimiliano.assante";
|
||||
user = "massimiliano.assante";
|
||||
|
||||
_log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL");
|
||||
withinPortal = false;
|
||||
|
@ -152,27 +155,23 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<NotificationChannelType> getNotificationChannels() {
|
||||
ArrayList<NotificationChannelType> toReturn = new ArrayList<NotificationChannelType>();
|
||||
try {
|
||||
for (NotificationChannelType channel : store.getUserNotificationChannels(getASLSession().getUsername()))
|
||||
toReturn.add(channel);
|
||||
|
||||
} catch (NotificationChannelTypeNotFoundException e) {
|
||||
public HashMap<NotificationType, NotificationChannelType[]> getUserNotificationPreferences() {
|
||||
String userid = getASLSession().getUsername();
|
||||
HashMap<NotificationType, NotificationChannelType[]> toReturn = new HashMap<NotificationType, NotificationChannelType[]>();
|
||||
try {
|
||||
toReturn.putAll(store.getUserNotificationPreferences(userid));
|
||||
} catch (Exception e) {
|
||||
_log.error("While trying to get getUser Notification Preferences");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setNotificationChannels(HashMap<NotificationChannelType, Boolean> newSettings) {
|
||||
boolean toReturn = false;
|
||||
for (NotificationChannelType type : newSettings.keySet()) {
|
||||
_log.error("Trying to set User notification Setting: " + type + " to: " + newSettings.get(type));
|
||||
toReturn = store.setUserNotificationChannel(getASLSession().getUsername(), type, newSettings.get(type));
|
||||
}
|
||||
return toReturn;
|
||||
public boolean setUserNotificationPreferences(Map<NotificationType, NotificationChannelType[]> enabledChannels) {
|
||||
return store.setUserNotificationPreferences(getASLSession().getUsername(), enabledChannels);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,57 @@ table {
|
|||
border-spacing: 0;
|
||||
}
|
||||
|
||||
#preferenceContainer {
|
||||
border: 1px solid black;
|
||||
position: relative;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
#preferenceType {
|
||||
border: 1px solid black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 50px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
#preferenceDesc {
|
||||
border: 1px solid black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 150px;
|
||||
height: 50px;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#preferenceSettingOff {
|
||||
border: 1px solid black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 650px;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
#preferenceSettingPortal {
|
||||
border: 1px solid black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 700px;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
#preferenceSettingEmail {
|
||||
border: 1px solid black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 750px;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
a.link,a.link:active,a.link:visited {
|
||||
font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial,
|
||||
sans-serif;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Sharing=WP_FOLDER_SHARE,WP_FOLDER_ADDEDUSER,WP_FOLDER_REMOVEDUSER,WP_FOLDER_RENAMED,WP_ITEM_DELETE,WP_ITEM_UPDATED,WP_ITEM_RENAMED,WP_ITEM_NEW
|
||||
Social=OWN_COMMENT,COMMENT,MENTION,LIKE,MESSAGE
|
||||
DocumentWorkflows=DOCUMENT_WORKFLOW_EDIT,DOCUMENT_WORKFLOW_VIEW,DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT,DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER,DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER,DOCUMENT_WORKFLOW_STEP_FORWARD_PEER
|
|
@ -0,0 +1,20 @@
|
|||
WP_FOLDER_SHARE=sharing of workspace folders with you
|
||||
WP_FOLDER_ADDEDUSER=someone added users one to one of your workspace shared folder
|
||||
WP_FOLDER_REMOVEDUSER=someone removed users from one of your workspace shared folder
|
||||
WP_FOLDER_RENAMED=someone renamed one of your workspace shared folder
|
||||
WP_ITEM_DELETE=someone deleted an item in one of your workspace shared folder
|
||||
WP_ITEM_UPDATED=someone updated an item in one of your workspace shared folder
|
||||
WP_ITEM_RENAMED=someone renamed an item in one of your workspace shared folder
|
||||
WP_ITEM_NEW=someone added an item in one of your workspace shared folder
|
||||
OWN_COMMENT=someone replied to your post
|
||||
COMMENT=someone replied too to a post you replied
|
||||
MENTION=someone mentioned you in a post
|
||||
LIKE=someone set favorite your post
|
||||
MESSAGE=someone sent you a message
|
||||
DOCUMENT_WORKFLOW_EDIT=a document workflow you created was editeded
|
||||
DOCUMENT_WORKFLOW_VIEW=a document workflow you created was viewed
|
||||
DOCUMENT_WORKFLOW_STEP_REQUEST_TASK=someone requested you to perform a task on his document workflow
|
||||
DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT=someone involved you on his document workflow
|
||||
DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER=a document workflow you created was forwarded to another step
|
||||
DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER=a document workflow you created was forwarded to the another step by all the users involved in the step
|
||||
DOCUMENT_WORKFLOW_STEP_FORWARD_PEER=someone completed his task on a document workflow where you still need to do yours
|
|
@ -0,0 +1,20 @@
|
|||
WP_FOLDER_SHARE=shared folder
|
||||
WP_FOLDER_ADDEDUSER=user added to shared folder
|
||||
WP_FOLDER_REMOVEDUSER=user removed from shared folder
|
||||
WP_FOLDER_RENAMED=shared folder renamed
|
||||
WP_ITEM_DELETE=shared item deleted
|
||||
WP_ITEM_UPDATED=shared item updated
|
||||
WP_ITEM_RENAMED=shared item renamed
|
||||
WP_ITEM_NEW=shared item added
|
||||
OWN_COMMENT=own replies
|
||||
COMMENT=replies
|
||||
MENTION=mentions
|
||||
LIKE=favorites
|
||||
MESSAGE=messages
|
||||
DOCUMENT_WORKFLOW_EDIT=edit
|
||||
DOCUMENT_WORKFLOW_VIEW=view
|
||||
DOCUMENT_WORKFLOW_STEP_REQUEST_TASK=task request
|
||||
DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT=involvement request
|
||||
DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER=forward
|
||||
DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER=step completed
|
||||
DOCUMENT_WORKFLOW_STEP_FORWARD_PEER=forward from peer
|
Loading…
Reference in New Issue