release ready
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@68672 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a706e0ee30
commit
187cd8b799
|
@ -22,4 +22,6 @@ public interface NotificationsService extends RemoteService {
|
|||
boolean setAllUserNotificationsRead();
|
||||
|
||||
ArrayList<NotificationChannelType> getNotificationChannels();
|
||||
|
||||
boolean setNotificationChannels(HashMap<NotificationChannelType, Boolean> newSettings);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ public interface NotificationsServiceAsync {
|
|||
void getNotificationChannels(
|
||||
AsyncCallback<ArrayList<NotificationChannelType>> callback);
|
||||
|
||||
void setNotificationChannels(
|
||||
HashMap<NotificationChannelType, Boolean> newSettings,
|
||||
AsyncCallback<Boolean> callback);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
package org.gcube.portlets.user.notifications.client.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
|
||||
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.CheckBox;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HasAlignment;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
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;
|
||||
|
||||
|
||||
|
@ -19,14 +28,18 @@ public class NotificationSettings extends GCubeDialog {
|
|||
private HorizontalPanel buttonsContainerPanel = new HorizontalPanel();
|
||||
private HorizontalPanel buttonsPanel = new HorizontalPanel();
|
||||
|
||||
private CheckBox portalCB = new CheckBox("This Portal");
|
||||
private CheckBox emailCB = new CheckBox("Email");
|
||||
public static final String loading = GWT.getModuleBaseURL() + "../images/feeds-loader.gif";
|
||||
public static final String mailSentOK = GWT.getModuleBaseURL() + "../images/yes.png";
|
||||
public static final String mailSentNOK = GWT.getModuleBaseURL() + "../images/warning_blue.png";
|
||||
|
||||
private CheckBox portalCheckbox = new CheckBox("Infrastructure Gateway (this portal)");
|
||||
private CheckBox emailCheckbox = new CheckBox("Email");
|
||||
private HTML how = new HTML("<span style=\"font-size: 13px;\">How You Get Notifications:</span>");
|
||||
|
||||
private Button cancel = new Button("Cancel");
|
||||
private Button save = new Button("Save");
|
||||
|
||||
public NotificationSettings(ArrayList<NotificationChannelType> currentChannels) {
|
||||
public NotificationSettings(final ArrayList<NotificationChannelType> currentChannels, final NotificationsServiceAsync notificationService) {
|
||||
super();
|
||||
buttonsPanel.setWidth("100%");
|
||||
buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
|
@ -34,8 +47,9 @@ public class NotificationSettings extends GCubeDialog {
|
|||
container.setStyleName("user-notification");
|
||||
container.setWidth("400px");
|
||||
container.add(how);
|
||||
container.add(portalCB);
|
||||
container.add(emailCB);
|
||||
container.add(new HTML(" "));
|
||||
container.add(portalCheckbox);
|
||||
container.add(emailCheckbox);
|
||||
|
||||
buttonsContainerPanel.add(cancel);
|
||||
buttonsContainerPanel.add(save);
|
||||
|
@ -44,6 +58,86 @@ 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);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cancel.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showDeliveryResult(boolean success) {
|
||||
container.clear();
|
||||
container.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||||
container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
if (success) {
|
||||
setText("Notifications Settings Saved");
|
||||
container.add(new Image(mailSentOK));
|
||||
}
|
||||
else {
|
||||
setText("Notifications Settings Saving Error");
|
||||
container.add(new Image(mailSentNOK));
|
||||
container.add(new HTML("There were problems contacting the server, please try again in a short while."));
|
||||
Button close = new Button("Close");
|
||||
close.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
Button close = new Button("Close");
|
||||
close.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
container.add(close);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
|
@ -16,7 +14,6 @@ import org.gcube.portlets.user.notifications.client.view.templates.DayWrapper;
|
|||
import org.gcube.portlets.user.notifications.client.view.templates.SingleNotificationView;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
|
@ -88,7 +85,7 @@ public class NotificationsPanel extends Composite {
|
|||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<NotificationChannelType> result) {
|
||||
NotificationSettings dlg = new NotificationSettings(result);
|
||||
NotificationSettings dlg = new NotificationSettings(result, notificationService);
|
||||
dlg.center();
|
||||
dlg.show();
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|||
String sessionID = this.getThreadLocalRequest().getSession().getId();
|
||||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
if (user == null) {
|
||||
//user = "test.user";
|
||||
user = "test.user";
|
||||
//user = "leonardo.candela";
|
||||
user = "massimiliano.assante";
|
||||
// user = "massimiliano.assante";
|
||||
_log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL");
|
||||
withinPortal = false;
|
||||
}
|
||||
|
@ -174,4 +174,14 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in New Issue