|
|
|
@ -17,6 +17,7 @@ import org.gcube.portal.databook.shared.Feed;
|
|
|
|
|
import org.gcube.portal.databook.shared.FeedType;
|
|
|
|
|
import org.gcube.portal.databook.shared.Like;
|
|
|
|
|
import org.gcube.portal.databook.shared.PrivacyLevel;
|
|
|
|
|
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
|
|
|
|
|
import org.gcube.portal.databook.shared.UserInfo;
|
|
|
|
|
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
|
|
|
|
|
import org.gcube.portlets.user.newsfeed.client.FilterType;
|
|
|
|
@ -123,6 +124,7 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
public static final String COMMENT_LABEL = "Reply";
|
|
|
|
|
public static final String SHARE_FWD_LABEL = "Share";
|
|
|
|
|
private static final int SEARCHED_FEEDS_TO_SHOW = 10;
|
|
|
|
|
private static final int FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW = 10;
|
|
|
|
|
|
|
|
|
|
private String vreLabel;
|
|
|
|
|
|
|
|
|
@ -141,6 +143,12 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
// the current query (if isSearch is true)
|
|
|
|
|
protected String currentQuery;
|
|
|
|
|
|
|
|
|
|
// is the user seeing her statistics?
|
|
|
|
|
private boolean isFeedsRelatedToStatistics = false;
|
|
|
|
|
|
|
|
|
|
// the feeds related to user statistics to show
|
|
|
|
|
protected ShowUserStatisticAction relatedFeedsToUserStatisticsToShow;
|
|
|
|
|
|
|
|
|
|
private LoadingText loadingIcon = new LoadingText();
|
|
|
|
|
private Image loadingImage;
|
|
|
|
|
private UserInfo myUserInfo;
|
|
|
|
@ -271,6 +279,7 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
newsPanel.add(loadingIcon);
|
|
|
|
|
CheckSession.getInstance().startPolling();
|
|
|
|
|
isSearch = false;
|
|
|
|
|
isFeedsRelatedToStatistics = false;
|
|
|
|
|
|
|
|
|
|
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
|
|
|
|
|
@Override
|
|
|
|
@ -322,7 +331,21 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
isSearch = true;
|
|
|
|
|
showFeedsSearch(query, 0, SEARCHED_FEEDS_TO_SHOW);
|
|
|
|
|
filterPanel.removeFilterSelected();
|
|
|
|
|
}
|
|
|
|
|
}else if(getShowUserStatisticParam() != null){
|
|
|
|
|
String action = "";
|
|
|
|
|
try {
|
|
|
|
|
action = Encoder.decode(getShowUserStatisticParam());
|
|
|
|
|
relatedFeedsToUserStatisticsToShow = ShowUserStatisticAction.valueOf(action);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
newsPanel.clear();
|
|
|
|
|
newsPanel.add(new HTML("<div class=\"nofeed-message\"><div style=\"padding-top: 90px;\">" +
|
|
|
|
|
"We're sorry, it seems you used an invalid character</div>"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
isFeedsRelatedToStatistics = true;
|
|
|
|
|
showUserStatisticsRelatedFeeds(relatedFeedsToUserStatisticsToShow, 0, FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW);
|
|
|
|
|
filterPanel.removeFilterSelected();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
showAllUpdatesFeeds();
|
|
|
|
|
}
|
|
|
|
@ -334,8 +357,8 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
showFeedTimelineSource = result.isShowTimelineSourceLabel();
|
|
|
|
|
isInfrastructure = true;
|
|
|
|
|
}
|
|
|
|
|
// else
|
|
|
|
|
// mainPanel.addStyleName("framed");
|
|
|
|
|
// else
|
|
|
|
|
// mainPanel.addStyleName("framed");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -399,6 +422,14 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
return Window.Location.getParameter(Encoder.encode(GCubeSocialNetworking.HASHTAG_OID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if some user statistic related feeds must be shown
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String getShowUserStatisticParam(){
|
|
|
|
|
return Window.Location.getParameter(Encoder.encode(GCubeSocialNetworking.SHOW_STATISTICS_ACTION_OID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* check if it has to show the feeds given a query
|
|
|
|
|
* @return
|
|
|
|
@ -568,6 +599,85 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when a user wants to show some feeds related to her statistics
|
|
|
|
|
*/
|
|
|
|
|
private void showUserStatisticsRelatedFeeds(final ShowUserStatisticAction relatedFeedsToUserStatisticsToShow, final int from, final int to) {
|
|
|
|
|
|
|
|
|
|
// show loader while waiting
|
|
|
|
|
showLoader();
|
|
|
|
|
|
|
|
|
|
// stop asking for feeds
|
|
|
|
|
doStopFeedsTimer();
|
|
|
|
|
|
|
|
|
|
final String actionToPrint = relatedFeedsToUserStatisticsToShow.getHumanFriendlyAction();
|
|
|
|
|
|
|
|
|
|
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(UserSettings result) {
|
|
|
|
|
if (result.getUserInfo().getUsername().equals(NewsConstants.TEST_USER)) {
|
|
|
|
|
doShowSessionExpired();
|
|
|
|
|
} else {
|
|
|
|
|
/**
|
|
|
|
|
* this check avoids the 2 tabs open in 2 different scope, if the previous tab was open at VRE Level and then antoher
|
|
|
|
|
* is open at infra level the first tab stops checking for updates
|
|
|
|
|
*/
|
|
|
|
|
if (result.getCurrentScope().compareTo(currentScope) == 0) {
|
|
|
|
|
newsService.getFeedsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, from, to, new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
|
|
|
|
|
|
|
|
|
filterPanelWrapper.setVisible(false);
|
|
|
|
|
newsPanel.clear();
|
|
|
|
|
if (feeds != null) {
|
|
|
|
|
|
|
|
|
|
GWT.log("Retrieved " + feeds.size() + " hits for search.");
|
|
|
|
|
if (feeds.size() == 0) {
|
|
|
|
|
newsPanel.add(new ResultsFor("Results for ", actionToPrint));
|
|
|
|
|
newsPanel.add(new HTML("<div class=\"nofeed-message\" style=\"height: 200px;\">" +
|
|
|
|
|
"Sorry, looks like we found no match for action : " + actionToPrint +"</div>"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
newsPanel.setHeight("");
|
|
|
|
|
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
|
|
|
|
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
|
|
|
|
newsPanel.add(new ResultsFor("Results for ", actionToPrint));
|
|
|
|
|
for (EnhancedFeed feed : feeds) {
|
|
|
|
|
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
|
|
|
|
|
// save them (they will be used when asking more feeds)
|
|
|
|
|
allUpdates.add(feed);
|
|
|
|
|
}
|
|
|
|
|
if (feeds.size() < 5) {
|
|
|
|
|
newsPanel.add(new Image(spacer));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// add widget to lookup more feeds: if the size of the returned data is less
|
|
|
|
|
// than the required disable this feature.
|
|
|
|
|
if(feeds.size() == FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW){
|
|
|
|
|
showMoreWidget = new ShowMoreFeeds(eventBus);
|
|
|
|
|
showMoreUpdatesPanel.add(showMoreWidget);
|
|
|
|
|
newsPanel.add(showMoreUpdatesPanel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showProblems();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
showProblems();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when a user search something
|
|
|
|
|
*/
|
|
|
|
@ -578,7 +688,7 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
|
|
|
|
|
// stop asking for feeds
|
|
|
|
|
doStopFeedsTimer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
@ -784,7 +894,7 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
newsPanel.setHeight("");
|
|
|
|
|
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
|
|
|
|
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (EnhancedFeed feed : feeds) {
|
|
|
|
|
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
|
|
|
|
|
allUpdates.add(feed); //in the model
|
|
|
|
@ -850,7 +960,7 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
|
|
|
|
|
// clear panel
|
|
|
|
|
showMoreUpdatesPanel.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if we can ask for other data
|
|
|
|
|
if(feeds.size() == SEARCHED_FEEDS_TO_SHOW){
|
|
|
|
|
GWT.log("It seems there are no more feeds for this query. Stop asking further");
|
|
|
|
@ -870,6 +980,50 @@ public class NewsFeedPanel extends Composite {
|
|
|
|
|
"Please try again in a short while.</div>"));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else if(isFeedsRelatedToStatistics){
|
|
|
|
|
GWT.log("Going to request more feeds for this user's statisics");
|
|
|
|
|
|
|
|
|
|
// start position
|
|
|
|
|
int start = allUpdates.size();
|
|
|
|
|
|
|
|
|
|
GWT.log("StartingPoint = " + start);
|
|
|
|
|
newsService.getFeedsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, start, FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW , new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(ArrayList<EnhancedFeed> feeds){
|
|
|
|
|
newsPanel.remove(showMoreUpdatesPanel);
|
|
|
|
|
if (feeds != null) {
|
|
|
|
|
GWT.log("There are " + feeds.size() + " more feeds");
|
|
|
|
|
|
|
|
|
|
for (EnhancedFeed feed : feeds) {
|
|
|
|
|
// avoid to insert same data
|
|
|
|
|
if(!isFeedPresent(feed)){
|
|
|
|
|
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
|
|
|
|
|
allUpdates.add(feed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// clear panel
|
|
|
|
|
showMoreUpdatesPanel.clear();
|
|
|
|
|
|
|
|
|
|
// check if we can ask for other data
|
|
|
|
|
if(feeds.size() == FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW){
|
|
|
|
|
GWT.log("It seems there are no more feeds for this query. Stop asking further");
|
|
|
|
|
showMoreWidget = new ShowMoreFeeds(eventBus);
|
|
|
|
|
showMoreUpdatesPanel.add(showMoreWidget);
|
|
|
|
|
newsPanel.add(showMoreUpdatesPanel);
|
|
|
|
|
}else{
|
|
|
|
|
showMoreWidget = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
showMoreUpdatesPanel.clear();
|
|
|
|
|
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
|
|
|
|
"Ops! There were problems while retrieving your feeds!. <br> " +
|
|
|
|
|
"Please try again in a short while.</div>"));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
|
|