added notification images
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@67107 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Widget, SingleNotificationView> {
|
||||
UiBinder<Widget, SingleNotificationView> {
|
||||
}
|
||||
|
||||
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(
|
||||
"<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"\">"+
|
||||
toShow.getSenderFullName()+"</a> " + 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 754 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
|
@ -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<Date, ArrayList<Notification>> toReturn = new HashMap<Date, ArrayList<Notification>>();
|
||||
try {
|
||||
for (Notification notification : store.getAllNotificationByUser(getASLSession().getUsername(), 20)) {
|
||||
if (! toReturn.containsKey(notification.getTime())) {
|
||||
Date dateWithoutTime = removeTimePart(notification.getTime());
|
||||
if (! toReturn.containsKey(dateWithoutTime)) {
|
||||
ArrayList<Notification> nots = new ArrayList<Notification>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|