Statistics panel refactored: there is now an activity part for the done posts, likes and replies

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/user-statistics@131057 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-08-31 08:45:58 +00:00
parent c6c9ddaa3d
commit b46c4cf006
6 changed files with 259 additions and 177 deletions

View File

@ -12,7 +12,7 @@ import org.gcube.portlet.user.userstatisticsportlet.client.events.PageBusEvents;
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent; import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent;
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEventHandler; import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEventHandler;
import org.gcube.portlet.user.userstatisticsportlet.client.resources.Images; import org.gcube.portlet.user.userstatisticsportlet.client.resources.Images;
import org.gcube.portlet.user.userstatisticsportlet.client.ui.CommentsAndLikesWidget; import org.gcube.portlet.user.userstatisticsportlet.client.ui.ActivityWidget;
import org.gcube.portlet.user.userstatisticsportlet.client.ui.StatisticWidget; import org.gcube.portlet.user.userstatisticsportlet.client.ui.StatisticWidget;
import org.gcube.portlet.user.userstatisticsportlet.shared.PostsStatsBean; import org.gcube.portlet.user.userstatisticsportlet.shared.PostsStatsBean;
import org.gcube.portlet.user.userstatisticsportlet.shared.UserInformation; import org.gcube.portlet.user.userstatisticsportlet.shared.UserInformation;
@ -23,7 +23,6 @@ import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent;
@ -72,9 +71,8 @@ public class StatisticsPanel extends Composite {
/** /**
* Labels * Labels
*/ */
private final static String POSTS_LABEL = "Posts"; private final static String ACTIVITY_LABEL = "Activity";
private final static String LIKES_COMMENTS_MADE_LABEL = "Yours"; private final static String LIKES_COMMENTS_GOT_LABEL = "Got";
private final static String LIKES_COMMENTS_GOT_LABEL = "Others";
private final static String STORAGE_LABEL = "Space Used"; private final static String STORAGE_LABEL = "Space Used";
private final static String PROFILE_STRENGTH_LABEL = "Profile Strength"; private final static String PROFILE_STRENGTH_LABEL = "Profile Strength";
private final static String SHOW_STATISTICS_OPTION_LABEL = "Show my statistics to VRE Members"; private final static String SHOW_STATISTICS_OPTION_LABEL = "Show my statistics to VRE Members";
@ -82,10 +80,8 @@ public class StatisticsPanel extends Composite {
/** /**
* Some tooltips * Some tooltips
*/ */
private final static String TOOLTIP_POSTS_ROOT_PROFILE = "Posts done during the last year"; private final static String TOOLTIP_ACTIVITY_ROOT_PROFILE = "Posts, likes, replies done during the last year";
private final static String TOOLTIP_POSTS_VRE = "Posts done in the last year in this VRE"; private final static String TOOLTIP_ACTIVITY_VRE = "Posts, likes, replies done in the last year in this VRE";
private final static String TOOLTIP_FAVORITES_REPLIES_ROOT_PROFILE = "Likes and post replies done during the last year";
private final static String TOOLTIP_FAVORITES_REPLIES_POSTS_VRE = "Likes and post replies done during the last year in this VRE";
private final static String TOOLTIP_GOT_ROOT_PROFILE = "Likes and post replies got during the last year"; private final static String TOOLTIP_GOT_ROOT_PROFILE = "Likes and post replies got during the last year";
private final static String TOOLTIP_GOT_VRE = "Likes and post replies got during the last year in this VRE"; private final static String TOOLTIP_GOT_VRE = "Likes and post replies got during the last year in this VRE";
private final static String TOOLTIP_INFRASTRUCTURE_SPACE = "Total amount of space used in the infrastructure"; private final static String TOOLTIP_INFRASTRUCTURE_SPACE = "Total amount of space used in the infrastructure";
@ -93,8 +89,10 @@ public class StatisticsPanel extends Composite {
private final static String SHOW_STATISTICS_OPTION_TOOLTIP = "Show Statistics to members viewing your profile"; private final static String SHOW_STATISTICS_OPTION_TOOLTIP = "Show Statistics to members viewing your profile";
/** /**
* Specific tooltips * Specific tooltips (for the values)
*/ */
private final static String TOOLTIP_POSTS_DONE = "Posts done during the last year";
private final static String TOOLTIP_POSTS_DONE_VRE = "Posts done during the last year in this VRE";
private final static String TOOLTIP_LIKES_GOT = "Likes got during the last year"; private final static String TOOLTIP_LIKES_GOT = "Likes got during the last year";
private final static String TOOLTIP_LIKES_GOT_VRE = "Likes got during the last year in this VRE"; private final static String TOOLTIP_LIKES_GOT_VRE = "Likes got during the last year in this VRE";
private final static String TOOLTIP_LIKES_DONE = "Likes done during the last year"; private final static String TOOLTIP_LIKES_DONE = "Likes done during the last year";
@ -143,15 +141,15 @@ public class StatisticsPanel extends Composite {
*/ */
private FlowPanel mainPanel = new FlowPanel(); private FlowPanel mainPanel = new FlowPanel();
/**
* Since the number of feeds(posts) can be manipulated when the user posts, we need a class reference
*/
private Label numberOfFeedsLabel;
/** /**
* Since the number of likes/comments got can be manipulated, we need a class reference * Since the number of likes/comments got can be manipulated, we need a class reference
*/ */
private CommentsAndLikesWidget contentLikesAndCommentsGot; private ActivityWidget activityGot;
/**
* Posts, comments, likes done
*/
private ActivityWidget activityDone;
/** /**
* Number of written posts * Number of written posts
@ -227,7 +225,7 @@ public class StatisticsPanel extends Composite {
// first of all check if the statistics can be shown to other people // first of all check if the statistics can be shown to other people
if(userid != null && !userid.equals(information.getAslSessionUsername()) && !information.isProfileShowable()){ if(userid != null && !userid.equals(information.getAslSessionUsername()) && !information.isProfileShowable()){
mainPanel.add(new HTML("Sorry but the user set his/her statistics to private")); mainPanel.add(new HTML("Sorry but the user set statistics to private"));
return; return;
} }
@ -282,57 +280,40 @@ public class StatisticsPanel extends Composite {
// add image to mainPanel // add image to mainPanel
mainPanel.add(userImage); mainPanel.add(userImage);
// feeds // feeds, posts, likes
final StatisticWidget feeds = new StatisticWidget(isRoot); final StatisticWidget activityDoneWidgetContainer = new StatisticWidget(isRoot);
feeds.setHeader(POSTS_LABEL); activityDoneWidgetContainer.setHeader(ACTIVITY_LABEL);
if(isRoot || isProfilePage) if(isRoot || isProfilePage)
feeds.setToolTip(TOOLTIP_POSTS_ROOT_PROFILE); activityDoneWidgetContainer.setToolTip(TOOLTIP_ACTIVITY_ROOT_PROFILE);
else else
feeds.setToolTip(TOOLTIP_POSTS_VRE); activityDoneWidgetContainer.setToolTip(TOOLTIP_ACTIVITY_VRE);
// add loading image that will be replaced by the incoming values // add loading image that will be replaced by the incoming values
Image postsLoader = new Image(imagePath); Image postsLoader = new Image(imagePath);
postsLoader.setStyleName("loading-image-center-small"); postsLoader.setStyleName("loading-image-center-small");
feeds.appendToPanel(postsLoader); activityDoneWidgetContainer.appendToPanel(postsLoader);
// append widget // append widget
mainPanel.add(feeds); mainPanel.add(activityDoneWidgetContainer);
// likes & comments made
final StatisticWidget likesAndCommentsMade = new StatisticWidget(isRoot);
likesAndCommentsMade.setHeader(LIKES_COMMENTS_MADE_LABEL);
if(isRoot || isProfilePage)
likesAndCommentsMade.setToolTip(TOOLTIP_FAVORITES_REPLIES_ROOT_PROFILE);
else
likesAndCommentsMade.setToolTip(TOOLTIP_FAVORITES_REPLIES_POSTS_VRE);
// add loading image that will be replaced by the incoming values
Image commentsLikesMadeLoader = new Image(imagePath);
commentsLikesMadeLoader.setStyleName("loading-image-center-small");
likesAndCommentsMade.appendToPanel(commentsLikesMadeLoader);
// append widget
mainPanel.add(likesAndCommentsMade);
// likes & comments got // likes & comments got
final StatisticWidget likesAndCommentsGot = new StatisticWidget(isRoot); final StatisticWidget activityGotWidgetContainer = new StatisticWidget(isRoot);
likesAndCommentsGot.setHeader(LIKES_COMMENTS_GOT_LABEL); activityGotWidgetContainer.setHeader(LIKES_COMMENTS_GOT_LABEL);
if(isRoot || isProfilePage) if(isRoot || isProfilePage)
likesAndCommentsGot.setToolTip(TOOLTIP_GOT_ROOT_PROFILE); activityGotWidgetContainer.setToolTip(TOOLTIP_GOT_ROOT_PROFILE);
else else
likesAndCommentsGot.setToolTip(TOOLTIP_GOT_VRE); activityGotWidgetContainer.setToolTip(TOOLTIP_GOT_VRE);
// add loading image that will be replaced by the incoming values // add loading image that will be replaced by the incoming values
Image commentsLikesLoader = new Image(imagePath); Image commentsLikesLoader = new Image(imagePath);
commentsLikesLoader.setStyleName("loading-image-center-small"); commentsLikesLoader.setStyleName("loading-image-center-small");
likesAndCommentsGot.appendToPanel(commentsLikesLoader); activityGotWidgetContainer.appendToPanel(commentsLikesLoader);
// append widget // append widget
mainPanel.add(likesAndCommentsGot); mainPanel.add(activityGotWidgetContainer);
// the storage and the profile strength(only in root) // the storage and the profile strength(only in root)
final StatisticWidget storage = new StatisticWidget(isRoot); final StatisticWidget storage = new StatisticWidget(isRoot);
@ -376,14 +357,12 @@ public class StatisticsPanel extends Composite {
if(spaceInUse == null){ if(spaceInUse == null){
appendAlertIcon(storage); appendAlertIcon(storage);
return; }else{
storage.clearPanelValues();
Label storageValue = new Label(spaceInUse);
storageValue.setStyleName("statistic-value");
storage.appendToPanel(storageValue);
} }
storage.clearPanelValues();
Label storageValue = new Label(spaceInUse);
storageValue.setStyleName("statistic-value");
storage.appendToPanel(storageValue);
} }
}); });
@ -402,62 +381,61 @@ public class StatisticsPanel extends Composite {
if(profileStrengthInt < 0){ if(profileStrengthInt < 0){
appendAlertIcon(profileStrength); appendAlertIcon(profileStrength);
return;
}else{
// clear panel
profileStrength.clearPanelValues();
final Label profileStrengthLabel = new Label(profileStrengthInt + "%");
profileStrengthLabel.setStyleName("statistic-value");
profileStrength.appendToPanel(profileStrengthLabel);
// in case too low information within the user profile
if(profileStrengthInt < profileImproveThreshold && information.isOwner()){
// Show an alert block in which underline how he can improve the profile
final AlertBlock improveProfileHint = new AlertBlock();
improveProfileHint.setType(AlertType.INFO);
improveProfileHint.addStyleName("improve-profile-hint-message");
final Button improveProfileButton = new Button(IMPROVE_BUTTON_LABEL);
improveProfileButton.setType(ButtonType.INFO);
improveProfileButton.setTitle("Improve your profile");
improveProfileButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
// set text according current url
if(isProfilePage)
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_PROFILE);
else
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_ROOT);
mainPanel.add(improveProfileHint);
}
});
profileStrengthLabel.setStyleName("statistic-value-inline");
improveProfileButton.addStyleName("button-improve-profile");
profileStrength.appendToPanel(improveProfileButton);
}
} }
// clear panel
profileStrength.clearPanelValues();
final Label profileStrengthLabel = new Label(profileStrengthInt + "%");
profileStrengthLabel.setStyleName("statistic-value");
profileStrength.appendToPanel(profileStrengthLabel);
// in case too low information within the user profile
if(profileStrengthInt < profileImproveThreshold && information.isOwner()){
// Show an alert block in which underline how he can improve the profile
final AlertBlock improveProfileHint = new AlertBlock();
improveProfileHint.setType(AlertType.INFO);
improveProfileHint.addStyleName("improve-profile-hint-message");
final Button improveProfileButton = new Button(IMPROVE_BUTTON_LABEL);
improveProfileButton.setType(ButtonType.INFO);
improveProfileButton.setTitle("Improve your profile");
improveProfileButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
// set text according current url
if(isProfilePage)
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_PROFILE);
else
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_ROOT);
mainPanel.add(improveProfileHint);
}
});
profileStrengthLabel.setStyleName("statistic-value-inline");
improveProfileButton.addStyleName("button-improve-profile");
profileStrength.appendToPanel(improveProfileButton);
}
} }
}); });
} }
// retrieve othe information about number of feeds and post replies/likes // retrieve other information about number of feeds and post replies/likes done and got
statisticsService.getPostsStats(userid, new AsyncCallback<PostsStatsBean>(){ statisticsService.getPostsStats(userid, new AsyncCallback<PostsStatsBean>(){
public void onFailure(Throwable arg0) { public void onFailure(Throwable arg0) {
appendAlertIcon(feeds); appendAlertIcon(activityDoneWidgetContainer);
appendAlertIcon(likesAndCommentsGot); appendAlertIcon(activityGotWidgetContainer);
} }
@ -466,50 +444,45 @@ public class StatisticsPanel extends Composite {
// if there are no statistics // if there are no statistics
if(postsBean == null){ if(postsBean == null){
appendAlertIcon(feeds); appendAlertIcon(activityDoneWidgetContainer);
appendAlertIcon(likesAndCommentsGot); appendAlertIcon(activityGotWidgetContainer);
return; return;
} }
// update feeds number // update feeds number, comments and likes done
feeds.clearPanelValues(); activityDoneWidgetContainer.clearPanelValues();
numberOfFeedsLabel = new Label(formattedNumbers(postsBean.getFeedsNumber())); activityDone = new ActivityWidget();
numberOfFeedsLabel.setStyleName("statistic-value");
// set the event handler if needed
if(!isProfilePage || information.isOwner())
activityDone.setEventBus(eventBus);
String urlPostsIcon = GWT.getModuleBaseURL() + "../images/share-blue.png";
if(isRoot || isProfilePage) if(isRoot || isProfilePage)
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + postsBean.getFeedsNumber() + ")"); activityDone.setPosts(
urlPostsIcon,
formattedNumbers(postsBean.getFeedsNumber()),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE + " (" + postsBean.getFeedsNumber() + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
information.getCurrentPageLanding());
else else
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + postsBean.getFeedsNumber() + ")"); activityDone.setPosts(
urlPostsIcon,
// add handler for user that clicks on the numberOfFeedsLabel formattedNumbers(postsBean.getFeedsNumber()),
if(!isProfilePage || information.isOwner()){ TOOLTIP_POSTS_DONE,
numberOfFeedsLabel.getElement().getStyle().setCursor(Cursor.POINTER); TOOLTIP_POSTS_DONE_VRE + " (" + postsBean.getFeedsNumber() + ")",
numberOfFeedsLabel.addStyleName("statistic-value-underline"); ShowUserStatisticAction.POSTS_MADE_BY_USER,
numberOfFeedsLabel.addClickHandler(new ClickHandler() { information.getCurrentPageLanding());
@Override
public void onClick(ClickEvent event) {
eventBus.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(ShowUserStatisticAction.POSTS_MADE_BY_USER, information.getCurrentPageLanding()));
}
});
}
numberOfWrittenFeeds = postsBean.getFeedsNumber(); numberOfWrittenFeeds = postsBean.getFeedsNumber();
feeds.appendToPanel(numberOfFeedsLabel); activityDoneWidgetContainer.appendToPanel(activityDone);
// updates comments and likes made
likesAndCommentsMade.clearPanelValues();
CommentsAndLikesWidget contentLikesAndCommentsMade = new CommentsAndLikesWidget();
if(!isProfilePage || information.isOwner())
contentLikesAndCommentsMade.setEventBus(eventBus);
String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png"; String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
if(isRoot || isProfilePage) if(isRoot || isProfilePage)
contentLikesAndCommentsMade.setLikes( activityDone.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(postsBean.getLikesMade()), formattedNumbers(postsBean.getLikesMade()),
TOOLTIP_LIKES_DONE, TOOLTIP_LIKES_DONE,
@ -517,7 +490,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_MADE_BY_USER, ShowUserStatisticAction.LIKES_MADE_BY_USER,
information.getCurrentPageLanding()); information.getCurrentPageLanding());
else else
contentLikesAndCommentsMade.setLikes( activityDone.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(postsBean.getLikesMade()), formattedNumbers(postsBean.getLikesMade()),
TOOLTIP_LIKES_DONE_VRE, TOOLTIP_LIKES_DONE_VRE,
@ -527,7 +500,7 @@ public class StatisticsPanel extends Composite {
String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png"; String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
if(isRoot || isProfilePage) if(isRoot || isProfilePage)
contentLikesAndCommentsMade.setComments( activityDone.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(postsBean.getCommentsMade()), formattedNumbers(postsBean.getCommentsMade()),
TOOLTIP_REPLIES_DONE, TOOLTIP_REPLIES_DONE,
@ -535,7 +508,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_MADE_BY_USER, ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
information.getCurrentPageLanding()); information.getCurrentPageLanding());
else else
contentLikesAndCommentsMade.setComments( activityDone.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(postsBean.getCommentsMade()), formattedNumbers(postsBean.getCommentsMade()),
TOOLTIP_REPLIES_DONE_VRE, TOOLTIP_REPLIES_DONE_VRE,
@ -543,17 +516,17 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_MADE_BY_USER, ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
information.getCurrentPageLanding()); information.getCurrentPageLanding());
likesAndCommentsMade.appendToPanel(contentLikesAndCommentsMade); activityDoneWidgetContainer.appendToPanel(activityDone);
// updates comments and likes got // updates comments and likes got
likesAndCommentsGot.clearPanelValues(); activityGotWidgetContainer.clearPanelValues();
contentLikesAndCommentsGot = new CommentsAndLikesWidget(); activityGot = new ActivityWidget();
if(!isProfilePage || information.isOwner()) if(!isProfilePage || information.isOwner())
contentLikesAndCommentsGot.setEventBus(eventBus); activityGot.setEventBus(eventBus);
if(isRoot || isProfilePage) if(isRoot || isProfilePage)
contentLikesAndCommentsGot.setLikes( activityGot.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(postsBean.getLikesReceived()), formattedNumbers(postsBean.getLikesReceived()),
TOOLTIP_LIKES_GOT, TOOLTIP_LIKES_GOT,
@ -561,7 +534,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_GOT_BY_USER, ShowUserStatisticAction.LIKES_GOT_BY_USER,
information.getCurrentPageLanding()); information.getCurrentPageLanding());
else else
contentLikesAndCommentsGot.setLikes( activityGot.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(postsBean.getLikesReceived()), formattedNumbers(postsBean.getLikesReceived()),
TOOLTIP_LIKES_GOT_VRE, TOOLTIP_LIKES_GOT_VRE,
@ -572,7 +545,7 @@ public class StatisticsPanel extends Composite {
numberOfLikesGot = postsBean.getLikesReceived(); numberOfLikesGot = postsBean.getLikesReceived();
if(isRoot || isProfilePage) if(isRoot || isProfilePage)
contentLikesAndCommentsGot.setComments( activityGot.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(postsBean.getCommentsReceived()), formattedNumbers(postsBean.getCommentsReceived()),
TOOLTIP_REPLIES_GOT, TOOLTIP_REPLIES_GOT,
@ -580,7 +553,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_GOT_BY_USER, ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
information.getCurrentPageLanding()); information.getCurrentPageLanding());
else else
contentLikesAndCommentsGot.setComments( activityGot.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(postsBean.getCommentsReceived()), formattedNumbers(postsBean.getCommentsReceived()),
TOOLTIP_REPLIES_GOT_VRE, TOOLTIP_REPLIES_GOT_VRE,
@ -589,7 +562,7 @@ public class StatisticsPanel extends Composite {
information.getCurrentPageLanding()); information.getCurrentPageLanding());
numberOfCommentsGot = postsBean.getCommentsReceived(); numberOfCommentsGot = postsBean.getCommentsReceived();
likesAndCommentsGot.appendToPanel(contentLikesAndCommentsGot); activityGotWidgetContainer.appendToPanel(activityGot);
} }
}); });
@ -680,11 +653,25 @@ public class StatisticsPanel extends Composite {
GWT.log("Increment number of post message received"); GWT.log("Increment number of post message received");
numberOfWrittenFeeds ++; numberOfWrittenFeeds ++;
numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds)); String urlPostsIcon = GWT.getModuleBaseURL() + "../images/share-blue.png";
if(isRoot) if(isRoot)
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + numberOfWrittenFeeds + ")"); activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else else
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + numberOfWrittenFeeds + ")"); activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE_VRE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
GWT.log("Number of written posts changed to " + numberOfWrittenFeeds); GWT.log("Number of written posts changed to " + numberOfWrittenFeeds);
} }
} }
@ -709,11 +696,25 @@ public class StatisticsPanel extends Composite {
// they can't be less than zero... // they can't be less than zero...
numberOfWrittenFeeds --; numberOfWrittenFeeds --;
numberOfWrittenFeeds = numberOfWrittenFeeds < 0 ? 0: numberOfWrittenFeeds; numberOfWrittenFeeds = numberOfWrittenFeeds < 0 ? 0: numberOfWrittenFeeds;
numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds)); String urlPostsIcon = GWT.getModuleBaseURL() + "../images/share-blue.png";
if(isRoot) if(isRoot)
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + numberOfWrittenFeeds + ")"); activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else else
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + numberOfWrittenFeeds + ")"); activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE_VRE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
GWT.log("Number of written posts changed to " + numberOfWrittenFeeds); GWT.log("Number of written posts changed to " + numberOfWrittenFeeds);
} }
}}); }});
@ -739,7 +740,7 @@ public class StatisticsPanel extends Composite {
String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png"; String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
if(isRoot) if(isRoot)
contentLikesAndCommentsGot.setLikes( activityGot.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(numberOfLikesGot), formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT, TOOLTIP_LIKES_GOT,
@ -747,7 +748,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_GOT_BY_USER, ShowUserStatisticAction.LIKES_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding()); informationBeanRetrieved.getCurrentPageLanding());
else else
contentLikesAndCommentsGot.setLikes( activityGot.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(numberOfLikesGot), formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT_VRE, TOOLTIP_LIKES_GOT_VRE,
@ -783,7 +784,7 @@ public class StatisticsPanel extends Composite {
String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png"; String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
if(isRoot) if(isRoot)
contentLikesAndCommentsGot.setLikes( activityGot.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(numberOfLikesGot), formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT, TOOLTIP_LIKES_GOT,
@ -791,7 +792,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_GOT_BY_USER, ShowUserStatisticAction.LIKES_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding()); informationBeanRetrieved.getCurrentPageLanding());
else else
contentLikesAndCommentsGot.setLikes( activityGot.setLikes(
urlLikesIcon, urlLikesIcon,
formattedNumbers(numberOfLikesGot), formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT_VRE, TOOLTIP_LIKES_GOT_VRE,
@ -826,7 +827,7 @@ public class StatisticsPanel extends Composite {
String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png"; String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
if(isRoot) if(isRoot)
contentLikesAndCommentsGot.setComments( activityGot.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(numberOfCommentsGot), formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT, TOOLTIP_REPLIES_GOT,
@ -834,7 +835,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_GOT_BY_USER, ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding()); informationBeanRetrieved.getCurrentPageLanding());
else else
contentLikesAndCommentsGot.setComments( activityGot.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(numberOfCommentsGot), formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT_VRE, TOOLTIP_REPLIES_GOT_VRE,
@ -869,7 +870,7 @@ public class StatisticsPanel extends Composite {
numberOfCommentsGot = numberOfCommentsGot < 0 ? 0: numberOfCommentsGot; numberOfCommentsGot = numberOfCommentsGot < 0 ? 0: numberOfCommentsGot;
String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png"; String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
if(isRoot) if(isRoot)
contentLikesAndCommentsGot.setComments( activityGot.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(numberOfCommentsGot), formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT, TOOLTIP_REPLIES_GOT,
@ -877,7 +878,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_GOT_BY_USER, ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding()); informationBeanRetrieved.getCurrentPageLanding());
else else
contentLikesAndCommentsGot.setComments( activityGot.setComments(
urlCommentsIcon, urlCommentsIcon,
formattedNumbers(numberOfCommentsGot), formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT_VRE, TOOLTIP_REPLIES_GOT_VRE,

View File

@ -15,13 +15,13 @@ import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
public class CommentsAndLikesWidget extends Composite { public class ActivityWidget extends Composite {
private static CommentsAndLikesWidgetUiBinder uiBinder = GWT private static CommentsAndLikesWidgetUiBinder uiBinder = GWT
.create(CommentsAndLikesWidgetUiBinder.class); .create(CommentsAndLikesWidgetUiBinder.class);
interface CommentsAndLikesWidgetUiBinder extends interface CommentsAndLikesWidgetUiBinder extends
UiBinder<Widget, CommentsAndLikesWidget> { UiBinder<Widget, ActivityWidget> {
} }
@UiField @UiField
@ -30,24 +30,39 @@ public class CommentsAndLikesWidget extends Composite {
@UiField @UiField
Image commentsImage; Image commentsImage;
@UiField
Image postsImage;
@UiField @UiField
Label likesValue; Label likesValue;
@UiField @UiField
Label commentsValue; Label commentsValue;
@UiField
Label postsValue;
private HandlerManager busEvents; private HandlerManager busEvents;
public CommentsAndLikesWidget() { public ActivityWidget() {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
} }
/**
* Set comments information
* @param url
* @param value
* @param tipIcon
* @param tipValue
* @param actionToTakeOnClick
* @param landingPage
*/
public void setComments(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){ public void setComments(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){
this.commentsImage.setUrl(url); commentsImage.setUrl(url);
this.commentsImage.setTitle(tipIcon); commentsImage.setTitle(tipIcon);
this.commentsValue.setText(value); commentsValue.setText(value);
this.commentsValue.setTitle(tipValue); commentsValue.setTitle(tipValue);
if(busEvents != null && actionToTakeOnClick != null){ if(busEvents != null && actionToTakeOnClick != null){
@ -64,14 +79,27 @@ public class CommentsAndLikesWidget extends Composite {
}); });
} }
// set to visible
commentsValue.setVisible(true);
commentsImage.setVisible(true);
} }
/**
* Set likes information
* @param url
* @param value
* @param tipIcon
* @param tipValue
* @param actionToTakeOnClick
* @param landingPage
*/
public void setLikes(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){ public void setLikes(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){
this.likesImage.setUrl(url); likesImage.setUrl(url);
this.likesImage.setTitle(tipIcon); likesImage.setTitle(tipIcon);
this.likesValue.setText(value); likesValue.setText(value);
this.likesValue.setTitle(tipValue); likesValue.setTitle(tipValue);
if(busEvents != null && actionToTakeOnClick != null){ if(busEvents != null && actionToTakeOnClick != null){
@ -88,8 +116,53 @@ public class CommentsAndLikesWidget extends Composite {
}); });
} }
// set to visible
likesValue.setVisible(true);
likesImage.setVisible(true);
}
/**
* Set posts information
* @param url
* @param value
* @param tipIcon
* @param tipValue
* @param actionToTakeOnClick
* @param landingPage
*/
public void setPosts(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){
postsImage.setUrl(url);
postsImage.setTitle(tipIcon);
postsValue.setText(value);
postsValue.setTitle(tipValue);
if(busEvents != null && actionToTakeOnClick != null){
postsValue.getElement().getStyle().setCursor(Cursor.POINTER);
postsValue.addStyleName("statistic-value-underline");
postsValue.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick, landingPage));
}
});
}
// set to visible
postsValue.setVisible(true);
postsImage.setVisible(true);
} }
/**
* Set the event bus to let this widget fire events
* @param busEvents
*/
public void setEventBus(HandlerManager busEvents){ public void setEventBus(HandlerManager busEvents){
this.busEvents = busEvents; this.busEvents = busEvents;
} }

View File

@ -5,8 +5,8 @@
.statistic-icon { .statistic-icon {
display: inline-block; display: inline-block;
vertical-align: text-bottom; vertical-align: text-bottom;
width: auto; width: 22px;
height: 19px; height: 22px;
} }
.statistic-value { .statistic-value {
@ -17,9 +17,17 @@
} }
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<g:Image styleName="{style.statistic-icon}" ui:field="likesImage"></g:Image> <g:Image styleName="{style.statistic-icon}" ui:field="postsImage"
<g:Label styleName="{style.statistic-value}" ui:field="likesValue"></g:Label> visible="false"></g:Image>
<g:Image styleName="{style.statistic-icon}" ui:field="commentsImage"></g:Image> <g:Label styleName="{style.statistic-value}" ui:field="postsValue"
<g:Label styleName="{style.statistic-value}" ui:field="commentsValue"></g:Label> visible="false"></g:Label>
<g:Image styleName="{style.statistic-icon}" ui:field="likesImage"
visible="false"></g:Image>
<g:Label styleName="{style.statistic-value}" ui:field="likesValue"
visible="false"></g:Label>
<g:Image styleName="{style.statistic-icon}" ui:field="commentsImage"
visible="false"></g:Image>
<g:Label styleName="{style.statistic-value}" ui:field="commentsValue"
visible="false"></g:Label>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder>

View File

@ -61,7 +61,7 @@ public class ServerUtils {
*/ */
public static String getDevelopmentUser() { public static String getDevelopmentUser() {
String user = UserStatisticsServiceImpl.defaultUserId; String user = UserStatisticsServiceImpl.defaultUserId;
// user = "costantino.perciante"; // user = "costantino.perciante";
return user; return user;
} }

View File

@ -53,7 +53,7 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
@Override @Override
public void init() { public void init() {
// get connection to Cassandra // get connection to Cassandra
logger.debug("Getting connection to Cassandra.."); logger.debug("Getting connection to Cassandra..");
store = new DBCassandraAstyanaxImpl(); store = new DBCassandraAstyanaxImpl();
@ -256,12 +256,12 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
// page landing // page landing
String pageLanding = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest()); String pageLanding = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
UserInformation bean = new UserInformation(isInfrastructure, thumbnailURL, userName, actualVre, isOwner, isProfileShowable); UserInformation bean = new UserInformation(isInfrastructure, thumbnailURL, userName, actualVre, isOwner, isProfileShowable);
bean.setCurrentPageLanding(pageLanding); bean.setCurrentPageLanding(pageLanding);
return bean; return bean;
} }
else return new UserInformation(true, null, userName, vreID, true, true); else
return new UserInformation(true, null, userName, vreID, true, true);
} }
/** /**

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B