almost done
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@68670 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
297ba682af
commit
a706e0ee30
|
@ -4,9 +4,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
|
||||||
import org.gcube.portal.databook.shared.Notification;
|
import org.gcube.portal.databook.shared.Notification;
|
||||||
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||||
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
@ -20,4 +20,6 @@ public interface NotificationsService extends RemoteService {
|
||||||
HashMap<Date, ArrayList<Notification>> getUserNotifications();
|
HashMap<Date, ArrayList<Notification>> getUserNotifications();
|
||||||
|
|
||||||
boolean setAllUserNotificationsRead();
|
boolean setAllUserNotificationsRead();
|
||||||
|
|
||||||
|
ArrayList<NotificationChannelType> getNotificationChannels();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.Notification;
|
import org.gcube.portal.databook.shared.Notification;
|
||||||
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -18,6 +19,9 @@ public interface NotificationsServiceAsync {
|
||||||
|
|
||||||
void setAllUserNotificationsRead(AsyncCallback<Boolean> callback);
|
void setAllUserNotificationsRead(AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
|
void getNotificationChannels(
|
||||||
|
AsyncCallback<ArrayList<NotificationChannelType>> callback);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.gcube.portlets.user.notifications.client.view;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||||
|
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
|
||||||
|
|
||||||
|
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.HasHorizontalAlignment;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
|
||||||
|
public class NotificationSettings extends GCubeDialog {
|
||||||
|
|
||||||
|
private VerticalPanel container = new VerticalPanel();
|
||||||
|
private HorizontalPanel buttonsContainerPanel = new HorizontalPanel();
|
||||||
|
private HorizontalPanel buttonsPanel = new HorizontalPanel();
|
||||||
|
|
||||||
|
private CheckBox portalCB = new CheckBox("This Portal");
|
||||||
|
private CheckBox emailCB = 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) {
|
||||||
|
super();
|
||||||
|
buttonsPanel.setWidth("100%");
|
||||||
|
buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
|
||||||
|
|
||||||
|
container.setStyleName("user-notification");
|
||||||
|
container.setWidth("400px");
|
||||||
|
container.add(how);
|
||||||
|
container.add(portalCB);
|
||||||
|
container.add(emailCB);
|
||||||
|
|
||||||
|
buttonsContainerPanel.add(cancel);
|
||||||
|
buttonsContainerPanel.add(save);
|
||||||
|
buttonsPanel.add(buttonsContainerPanel);
|
||||||
|
container.add(buttonsPanel);
|
||||||
|
|
||||||
|
setText("Notification Settings");
|
||||||
|
setWidget(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.Notification;
|
import org.gcube.portal.databook.shared.Notification;
|
||||||
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
import org.gcube.portlets.user.notifications.client.NotificationsService;
|
import org.gcube.portlets.user.notifications.client.NotificationsService;
|
||||||
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
|
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
|
||||||
|
@ -16,13 +17,17 @@ import org.gcube.portlets.user.notifications.client.view.templates.SingleNotific
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.Style.Unit;
|
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;
|
import com.google.gwt.user.client.Timer;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.google.gwt.user.client.ui.HasAlignment;
|
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.HasVerticalAlignment;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.gwt.user.client.ui.Image;
|
import com.google.gwt.user.client.ui.Image;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
@ -37,11 +42,24 @@ public class NotificationsPanel extends Composite {
|
||||||
private static final String warning = GWT.getModuleBaseURL() + "../images/warning_blue.png";
|
private static final String warning = GWT.getModuleBaseURL() + "../images/warning_blue.png";
|
||||||
private UserInfo myUserInfo;
|
private UserInfo myUserInfo;
|
||||||
private Image loadingImage;
|
private Image loadingImage;
|
||||||
|
|
||||||
|
private VerticalPanel container = new VerticalPanel();
|
||||||
|
private HorizontalPanel settingsPanel = new HorizontalPanel();
|
||||||
|
|
||||||
private VerticalPanel mainPanel;
|
private VerticalPanel mainPanel;
|
||||||
|
|
||||||
|
private HTML notificationSettings = new HTML("<a style=\"padding-right: 15px;\" class=\"link\">Notification Settings</a>");
|
||||||
|
|
||||||
public NotificationsPanel() {
|
public NotificationsPanel() {
|
||||||
|
notificationSettings.setVisible(false);
|
||||||
mainPanel = new VerticalPanel();
|
mainPanel = new VerticalPanel();
|
||||||
mainPanel.setWidth("100%");
|
mainPanel.setWidth("100%");
|
||||||
|
container.setWidth("100%");
|
||||||
|
settingsPanel.setWidth("100%");
|
||||||
|
settingsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
|
||||||
|
settingsPanel.add(notificationSettings);
|
||||||
|
container.add(settingsPanel);
|
||||||
|
container.add(mainPanel);
|
||||||
loadingImage = new Image(loading);
|
loadingImage = new Image(loading);
|
||||||
showLoader();
|
showLoader();
|
||||||
|
|
||||||
|
@ -59,10 +77,28 @@ public class NotificationsPanel extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
initWidget(container);
|
||||||
|
|
||||||
|
notificationSettings.addClickHandler(new ClickHandler() {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
notificationService.getNotificationChannels(new AsyncCallback<ArrayList<NotificationChannelType>>() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) { }
|
||||||
|
|
||||||
initWidget(mainPanel);
|
@Override
|
||||||
|
public void onSuccess(ArrayList<NotificationChannelType> result) {
|
||||||
|
NotificationSettings dlg = new NotificationSettings(result);
|
||||||
|
dlg.center();
|
||||||
|
dlg.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void showUserNotifications() {
|
private void showUserNotifications() {
|
||||||
showLoader();
|
showLoader();
|
||||||
notificationService.getUserNotifications(new AsyncCallback<HashMap<Date, ArrayList<Notification>>>() {
|
notificationService.getUserNotifications(new AsyncCallback<HashMap<Date, ArrayList<Notification>>>() {
|
||||||
|
@ -72,6 +108,7 @@ public class NotificationsPanel extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSuccess(HashMap<Date, ArrayList<Notification>> notificationsPerDay) {
|
public void onSuccess(HashMap<Date, ArrayList<Notification>> notificationsPerDay) {
|
||||||
|
notificationSettings.setVisible(true);
|
||||||
if (notificationsPerDay != null) {
|
if (notificationsPerDay != null) {
|
||||||
mainPanel.clear();
|
mainPanel.clear();
|
||||||
if (notificationsPerDay.size() == 0) {
|
if (notificationsPerDay.size() == 0) {
|
||||||
|
|
|
@ -13,7 +13,9 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
import org.gcube.portal.databook.server.DatabookStore;
|
||||||
import org.gcube.portal.databook.shared.Notification;
|
import org.gcube.portal.databook.shared.Notification;
|
||||||
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
|
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||||
import org.gcube.portlets.user.notifications.client.NotificationsService;
|
import org.gcube.portlets.user.notifications.client.NotificationsService;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
@ -59,8 +61,8 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
||||||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
//user = "test.user";
|
//user = "test.user";
|
||||||
user = "leonardo.candela";
|
//user = "leonardo.candela";
|
||||||
//user = "massimiliano.assante";
|
user = "massimiliano.assante";
|
||||||
_log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL");
|
_log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL");
|
||||||
withinPortal = false;
|
withinPortal = false;
|
||||||
}
|
}
|
||||||
|
@ -159,4 +161,17 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
||||||
}
|
}
|
||||||
return false;
|
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) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ a.link:hover {
|
||||||
border-bottom-color: #DADADA;
|
border-bottom-color: #DADADA;
|
||||||
border-bottom-style: solid;
|
border-bottom-style: solid;
|
||||||
border-bottom-width: 1px;
|
border-bottom-width: 1px;
|
||||||
padding: 12px 7px 3px;
|
padding: 5px 7px 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.day-label {
|
.day-label {
|
||||||
|
@ -70,6 +70,14 @@ a.link:hover {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gwt-CheckBox {
|
||||||
|
margin: 5px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gwt-CheckBox label {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
.user-notification {
|
.user-notification {
|
||||||
width: 99%;
|
width: 99%;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
|
Loading…
Reference in New Issue