diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java index 45132ac..0be6b08 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java @@ -22,7 +22,13 @@ public class DayWrapper extends Composite { public DayWrapper(Date day) { initWidget(uiBinder.createAndBindUi(this)); - dayLabel.setHTML(DateTimeFormat.getFormat("MMMM dd, h:mm a").format(day)); + + 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)); } } diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java index 67fe669..fe3098b 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java @@ -1,10 +1,16 @@ package org.gcube.portlets.user.notifications.client.view.templates; +import java.util.Date; + +import com.google.gwt.user.datepicker.client.CalendarUtil; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.shared.Notification; +import org.gcube.portal.databook.shared.NotificationType; +import org.gcube.portlets.user.notifications.client.view.templates.images.NotificationImages; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; +import com.google.gwt.resources.client.ImageResource; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; @@ -19,10 +25,13 @@ public class SingleNotificationView extends Composite { .create(NotificationsDayUiBinder.class); interface NotificationsDayUiBinder extends - UiBinder { + UiBinder { } + + NotificationImages images = GWT.create(NotificationImages.class); + private Notification myNotification; - + @UiField Image notificationImage; @UiField HTMLPanel mainPanel; @@ -33,14 +42,47 @@ public class SingleNotificationView extends Composite { initWidget(uiBinder.createAndBindUi(this)); myNotification = toShow; String notificationToShow = toShow.getDescription(); - + notificationText.setHTML( ""+ toShow.getSenderFullName()+" " + notificationToShow); - - timeArea.setHTML(DateTimeFormat.getFormat("MMMM dd, h:mm a").format(toShow.getTime())); + timeArea.setHTML(DateTimeFormat.getFormat("h:mm a").format(toShow.getTime())); + + notificationImage.setResource(getImageType(toShow.getType())); } + private ImageResource getImageType(NotificationType type) { + switch (type) { + case LIKE: + return images.like(); + case COMMENT: + return images.comment(); + case MESSAGE: + return images.message(); + case WP_FOLDER_ADDEDUSER: + return images.share(); + case WP_FOLDER_REMOVEDUSER: + return images.share(); + case WP_FOLDER_SHARE: + return images.share(); + case WP_ITEM_NEW: + return images.share(); + case WP_ITEM_DELETE: + return images.share(); + case WP_ITEM_UPDATED: + return images.share(); + case OWN_COMMENT: + return images.comment(); + case REQUEST_CONNECTION: + return images.connectionRequest(); + case JOB_COMPLETED_NOK: + return images.jobNOK(); + case JOB_COMPLETED_OK: + return images.jobOK(); + default: + return images.generic(); + } + } } diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/NotificationImages.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/NotificationImages.java new file mode 100644 index 0000000..5ec2524 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/NotificationImages.java @@ -0,0 +1,30 @@ +package org.gcube.portlets.user.notifications.client.view.templates.images; + +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; + +public interface NotificationImages extends ClientBundle { + @Source("comment_edit.png") + ImageResource comment(); + + @Source("star_blue.png") + ImageResource like(); + + @Source("mail.png") + ImageResource message(); + + @Source("share_blue.png") + ImageResource share(); + + @Source("connection_new.png") + ImageResource connectionRequest(); + + @Source("job_ok.png") + ImageResource jobOK(); + + @Source("job_nok.png") + ImageResource jobNOK(); + + @Source("notification-generic.png") + ImageResource generic(); +} diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/comment_edit.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/comment_edit.png new file mode 100644 index 0000000..d31e68a Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/comment_edit.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/connection_new.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/connection_new.png new file mode 100644 index 0000000..bda518f Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/connection_new.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/job_nok.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/job_nok.png new file mode 100644 index 0000000..eb70d41 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/job_nok.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/job_ok.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/job_ok.png new file mode 100644 index 0000000..45835de Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/job_ok.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/mail.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/mail.png new file mode 100644 index 0000000..e5eab71 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/mail.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/notification-generic.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/notification-generic.png new file mode 100644 index 0000000..654713d Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/notification-generic.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/share_blue.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/share_blue.png new file mode 100644 index 0000000..bf1fe18 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/share_blue.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/star_blue.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/star_blue.png new file mode 100644 index 0000000..55e41c3 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/star_blue.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/user-photo.png b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/user-photo.png new file mode 100644 index 0000000..c3dea6f Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/images/user-photo.png differ diff --git a/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java b/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java index 571fcb9..f1bc703 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.notifications.server; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -113,12 +114,13 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No HashMap> toReturn = new HashMap>(); try { for (Notification notification : store.getAllNotificationByUser(getASLSession().getUsername(), 20)) { - if (! toReturn.containsKey(notification.getTime())) { + Date dateWithoutTime = removeTimePart(notification.getTime()); + if (! toReturn.containsKey(dateWithoutTime)) { ArrayList nots = new ArrayList(); nots.add(notification); - toReturn.put(notification.getTime(), nots); + toReturn.put(dateWithoutTime, nots); } else { - toReturn.get(notification.getTime()).add(notification); + toReturn.get(dateWithoutTime).add(notification); } } } catch (Exception e) { @@ -127,4 +129,21 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No } return toReturn; } + /** + * we want notification split per day + * @param date + * @return the date passad as param with time part set to 00:00:00.0 + */ + private Date removeTimePart(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + + // Set time fields to zero + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + + return cal.getTime(); + } } diff --git a/src/main/webapp/Notifications.css b/src/main/webapp/Notifications.css index 9476af5..8194dbe 100644 --- a/src/main/webapp/Notifications.css +++ b/src/main/webapp/Notifications.css @@ -3,6 +3,21 @@ table { border-spacing: 0; } +a.link,a.link:active,a.link:visited { + font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, + sans-serif; + font-size: 12px; + cursor: pointer; + cursor: hand; + text-decoration: none; + color: #3B5998; +} + +a.link:hover { + opacity: 0.8; + text-decoration: underline; +} + .day-wrapper { width: 100%; border-bottom-color: #DADADA; @@ -12,15 +27,20 @@ table { } .day-label { - color: #333; - font-size: 12px; + color: #444444; font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; - line-height: 14px; + font-size: 14px; + font-weight: bold; + line-height: 13px; + padding-bottom: 5px; + padding-top: 5px; } .single-notification-table { width: 100%; + padding: 5px; + border-top: 1px solid #E9E9E9; } .no-notification-message { @@ -40,7 +60,8 @@ table { color: #999; font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; - font-size: 11px; + font-size: 12px; + padding-left: 10px; white-space: nowrap; } @@ -49,9 +70,10 @@ table { color: #333; font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; - font-size: 11px; + font-size: 12px; border-color: #999; border-width: 1px; letter-spacing: normal; white-space: nowrap; + padding-left: 10px; } \ No newline at end of file