Added yesterday recognition
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@94236 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
23c4798335
commit
d6409d7287
|
@ -7,16 +7,16 @@
|
|||
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/notifications/src/test/java/org/gcube/portlets/user/notifications/client/GwtTestNotifications.java"/>
|
||||
<listEntry value="/notifications"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.notifications.client.GwtTestNotifications"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.notifications.test.GwtTestNotifications"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="notifications"/>
|
||||
</launchConfiguration>
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
|
||||
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="true"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/notifications/src/test/java/org/gcube/portlets/user/notifications/client/GwtTestNotifications.java"/>
|
||||
<listEntry value="/notifications"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.notifications.client.GwtTestNotifications"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.notifications.test.GwtTestNotifications"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="notifications"/>
|
||||
</launchConfiguration>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlet.user.notifications.1-2-0"
|
||||
date="2014-4-02">
|
||||
<Change>Added support for show notifications by range</Change>
|
||||
date="2014-4-03">
|
||||
<Change>Implemented automatic notifications scroll back in time</Change>
|
||||
<Change>Updated description for post alerts</Change>
|
||||
<Change>Made Notification Settings more evident</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlet.user.notifications.1-1-0"
|
||||
date="2014-3-03">
|
||||
|
|
|
@ -49,7 +49,6 @@ public class NotificationsPanel extends Composite {
|
|||
public static final String loading = GWT.getModuleBaseURL() + "../images/feeds-loader.gif";
|
||||
private static final String spacer = GWT.getModuleBaseURL() + "../images/feeds-spacer.gif";
|
||||
private static final String warning = GWT.getModuleBaseURL() + "../images/warning_blue.png";
|
||||
private UserInfo myUserInfo;
|
||||
private Image loadingImage;
|
||||
private ShowMoreNotifications showMoreWidget;
|
||||
//needed to know the next range start
|
||||
|
@ -85,7 +84,6 @@ public class NotificationsPanel extends Composite {
|
|||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
public void onSuccess(UserInfo result) {
|
||||
myUserInfo = result;
|
||||
if (result.getUsername().equals("test.user")) {
|
||||
Window.alert("Your session has expired, please log out and login again");
|
||||
}
|
||||
|
@ -174,7 +172,7 @@ public class NotificationsPanel extends Composite {
|
|||
mainPanel.add(new Image(spacer));
|
||||
|
||||
//if you are showing more than NotificationConstants.NOTIFICATION_NUMBER
|
||||
if (notCounter >= NotificationConstants.NOTIFICATION_NUMBER) {
|
||||
if (notCounter >= NotificationConstants.NOTIFICATION_NUMBER_PRE) {
|
||||
GWT.log("Show MORE ");
|
||||
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||||
showMoreWidget = new ShowMoreNotifications();
|
||||
|
@ -193,15 +191,13 @@ public class NotificationsPanel extends Composite {
|
|||
* called when a user scroll down the page to the bottom
|
||||
*/
|
||||
private void doShowMoreNotifications() {
|
||||
GWT.log("doShowMoreNotifications()");
|
||||
showMoreNotificationsPanel.remove(0);
|
||||
loadingImage.getElement().getStyle().setMargin(10, Unit.PX);
|
||||
showMoreNotificationsPanel.add(loadingImage);
|
||||
int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER+1 : fromStartingPoint;
|
||||
int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER_PRE+1 : fromStartingPoint;
|
||||
fromStartingPoint = from;
|
||||
final int quantity = 10;
|
||||
GWT.log("StartingPoint = " + from);
|
||||
|
||||
final int quantity = NotificationConstants.NOTIFICATION_NUMBER_PER_REQUEST;
|
||||
|
||||
notificationService.getUserNotificationsByRange(from, quantity, new AsyncCallback<HashMap<Date,ArrayList<Notification>>>() {
|
||||
@Override
|
||||
public void onSuccess(HashMap<Date, ArrayList<Notification>> notificationsPerDay) {
|
||||
|
@ -218,10 +214,8 @@ public class NotificationsPanel extends Composite {
|
|||
notCounter++;
|
||||
}
|
||||
}
|
||||
fromStartingPoint += notCounter;
|
||||
GWT.log("StartingPoint incremented = " + fromStartingPoint);
|
||||
fromStartingPoint += notCounter;
|
||||
if (notCounter >= quantity) { //there could be more notifications
|
||||
GWT.log("Show MORE ");
|
||||
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||||
showMoreWidget = new ShowMoreNotifications();
|
||||
showMoreNotificationsPanel.clear();
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.google.gwt.uibinder.client.UiField;
|
|||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.user.datepicker.client.CalendarUtil;
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
|
@ -27,12 +28,34 @@ public class DayWrapper extends Composite {
|
|||
public DayWrapper(Date day) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
||||
String notificationDate = DateTimeFormat.getFormat("yyyy MMMM dd").format(day);
|
||||
String today = DateTimeFormat.getFormat("yyyy MMMM dd").format(new Date());
|
||||
if (notificationDate.equals(today))
|
||||
dayLabel.setHTML("Today");
|
||||
else
|
||||
dayLabel.setHTML(DateTimeFormat.getFormat("EE, dd MMMM").format(day));
|
||||
Date now = new Date();
|
||||
@SuppressWarnings("deprecation")
|
||||
int currYear = now.getYear();
|
||||
@SuppressWarnings("deprecation")
|
||||
int notificationDateYear = day.getYear();
|
||||
|
||||
|
||||
|
||||
int dayInBetween = CalendarUtil.getDaysBetween(now, day);
|
||||
String theDay = "";
|
||||
switch (dayInBetween) {
|
||||
case 0:
|
||||
theDay = "Today";
|
||||
break;
|
||||
case -1:
|
||||
theDay = "Yesterday";
|
||||
break;
|
||||
default:
|
||||
if (currYear == notificationDateYear)
|
||||
theDay = (DateTimeFormat.getFormat("EE, dd MMMM").format(day));
|
||||
else {
|
||||
theDay = (DateTimeFormat.getFormat("dd MMMM yyyy").format(day));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
this.dayLabel.setHTML(theDay);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,9 +74,7 @@ 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 = "massimiliano.assante";
|
||||
|
||||
user = getDevelopmentUser();
|
||||
_log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL");
|
||||
withinPortal = false;
|
||||
}
|
||||
|
@ -86,7 +84,11 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|||
System.out.println("SessionID = " + sessionID);
|
||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
}
|
||||
|
||||
public String getDevelopmentUser() {
|
||||
String user = "test.user";
|
||||
user = "massimiliano.assante";
|
||||
return user;
|
||||
}
|
||||
public UserInfo getUserInfo() {
|
||||
try {
|
||||
String username = getASLSession().getUsername();
|
||||
|
@ -121,7 +123,7 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|||
public HashMap<Date, ArrayList<Notification>> getUserNotifications() {
|
||||
HashMap<Date, ArrayList<Notification>> toReturn = new HashMap<Date, ArrayList<Notification>>();
|
||||
try {
|
||||
for (Notification notification : store.getAllNotificationByUser(getASLSession().getUsername(), NotificationConstants.NOTIFICATION_NUMBER)) {
|
||||
for (Notification notification : store.getAllNotificationByUser(getASLSession().getUsername(), NotificationConstants.NOTIFICATION_NUMBER_PRE)) {
|
||||
Date dateWithoutTime = removeTimePart(notification.getTime());
|
||||
if (! toReturn.containsKey(dateWithoutTime)) {
|
||||
ArrayList<Notification> nots = new ArrayList<Notification>();
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
package org.gcube.portlets.user.notifications.shared;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
*
|
||||
*/
|
||||
public class NotificationConstants {
|
||||
public final static int NOTIFICATION_NUMBER = 70;
|
||||
/**
|
||||
* the initial number of notification to be loaded at startup
|
||||
*/
|
||||
public final static int NOTIFICATION_NUMBER_PRE = 70;
|
||||
/**
|
||||
* the number of notification to be loaded each time after the startup
|
||||
*/
|
||||
public final static int NOTIFICATION_NUMBER_PER_REQUEST = 15;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
|||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Print the date in ISO 8601 format
|
||||
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
||||
log4j.appender.A1.layout.ConversionPattern=[%-5p] %d %c - %m%n
|
||||
|
||||
# Print only messages of level TRACE or above in the package org.gcube
|
||||
log4j.logger.org.gcube=TRACE
|
||||
log4j.logger.org.gcube=TRACE
|
||||
log4j.logger.com.netflix.astyanax.connectionpool.impl=ERROR
|
|
@ -0,0 +1,19 @@
|
|||
package org.gcube.portlets.user.notifications.test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.gcube.portlets.user.notifications.server.NotificationsServiceImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestForDeploy {
|
||||
|
||||
@Test
|
||||
public void testUserIsTestUser() {
|
||||
NotificationsServiceImpl serviceImpl = new NotificationsServiceImpl();
|
||||
String username = serviceImpl.getDevelopmentUser();
|
||||
System.out.println("username for deploy is: " + username);
|
||||
assertTrue(username.compareTo("test.user") == 0);
|
||||
System.out.println("Test OK!");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue