frame the mainpanel if in VRE
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@73154 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e1d2c1e23f
commit
64de50b635
|
@ -29,8 +29,6 @@ import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEvent;
|
|||
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEventHandler;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEvent;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEventHandler;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.StopTimerEvent;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.StopTimerEventHandler;
|
||||
import org.gcube.portlets.user.newsfeed.client.panels.dialog.LikesDialog;
|
||||
import org.gcube.portlets.user.newsfeed.client.templates.FilterPanel;
|
||||
import org.gcube.portlets.user.newsfeed.client.templates.NewFeedsAvailable;
|
||||
|
@ -54,8 +52,6 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
|
|||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
|
@ -113,21 +109,9 @@ public class NewsFeedPanel extends Composite {
|
|||
});
|
||||
|
||||
|
||||
eventBus.addHandler(StopTimerEvent.TYPE, new StopTimerEventHandler() {
|
||||
@Override
|
||||
public void onStopTimer(StopTimerEvent event) {
|
||||
GWT.log("Stop timer");
|
||||
if (event.isRestart())
|
||||
resetTimer();
|
||||
else
|
||||
stopTimer();
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(AddLikeEvent.TYPE, new AddLikeEventHandler() {
|
||||
@Override
|
||||
public void onAddLike(AddLikeEvent event) {
|
||||
resetTimer();
|
||||
doAddLike( event.getOwner(), event.getFeedId());
|
||||
}
|
||||
});
|
||||
|
@ -135,7 +119,6 @@ public class NewsFeedPanel extends Composite {
|
|||
eventBus.addHandler(AddCommentEvent.TYPE, new AddCommentEventHandler() {
|
||||
@Override
|
||||
public void onAddComment(AddCommentEvent event) {
|
||||
resetTimer();
|
||||
doAddComment(event.getOwner(), event.getText());
|
||||
}
|
||||
});
|
||||
|
@ -143,7 +126,6 @@ public class NewsFeedPanel extends Composite {
|
|||
eventBus.addHandler(EditCommentEvent.TYPE, new EditCommentEventHandler() {
|
||||
@Override
|
||||
public void onEditComment(EditCommentEvent event) {
|
||||
resetTimer();
|
||||
doEditComment(event.getOwner(), event.getCommentInstance());
|
||||
}
|
||||
});
|
||||
|
@ -152,7 +134,6 @@ public class NewsFeedPanel extends Composite {
|
|||
eventBus.addHandler(SeeLikesEvent.TYPE, new SeeLikesEventHandler() {
|
||||
@Override
|
||||
public void onSeeLikes(SeeLikesEvent event) {
|
||||
resetTimer();
|
||||
doShowLikes(event.getFeedId());
|
||||
}
|
||||
});
|
||||
|
@ -160,7 +141,6 @@ public class NewsFeedPanel extends Composite {
|
|||
eventBus.addHandler(SeeCommentsEvent.TYPE, new SeeCommentsEventHandler() {
|
||||
@Override
|
||||
public void onSeeComments(SeeCommentsEvent event) {
|
||||
resetTimer();
|
||||
doShowComments(event.getOwner(), event.isCommentForm2Add());
|
||||
}
|
||||
});
|
||||
|
@ -168,7 +148,6 @@ public class NewsFeedPanel extends Composite {
|
|||
eventBus.addHandler(DeleteCommentEvent.TYPE, new DeleteCommentEventHandler() {
|
||||
@Override
|
||||
public void onDeleteComment(DeleteCommentEvent event) {
|
||||
resetTimer();
|
||||
doDeleteComment(event.getOwner(), event.getCommentId());
|
||||
}
|
||||
});
|
||||
|
@ -176,7 +155,6 @@ public class NewsFeedPanel extends Composite {
|
|||
eventBus.addHandler(DeleteFeedEvent.TYPE, new DeleteFeedEventHandler() {
|
||||
@Override
|
||||
public void onDeleteFeed(DeleteFeedEvent event) {
|
||||
resetTimer();
|
||||
doDeleteFeed(event.getToDelete());
|
||||
}
|
||||
});
|
||||
|
@ -189,7 +167,9 @@ public class NewsFeedPanel extends Composite {
|
|||
*/
|
||||
public NewsFeedPanel() {
|
||||
bind();
|
||||
mainPanel.setWidth("600px");
|
||||
mainPanel.add(filterPanel);
|
||||
filterPanel.setVisible(false);
|
||||
mainPanel.add(newUpdatesPanel);
|
||||
mainPanel.add(newsPanel);
|
||||
|
||||
|
@ -219,6 +199,12 @@ public class NewsFeedPanel extends Composite {
|
|||
showAllUpdatesFeeds();
|
||||
currentFilter = FilterType.ALL_UPDATES;
|
||||
}
|
||||
//adjustments in the UI Depending on the scope
|
||||
if (result.isInfrastructure())
|
||||
filterPanel.setVisible(true);
|
||||
else
|
||||
mainPanel.addStyleName("framed");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -231,13 +217,6 @@ public class NewsFeedPanel extends Composite {
|
|||
feedsTimer.scheduleRepeating(delayMillis);
|
||||
}
|
||||
|
||||
private void resetTimer() {
|
||||
feedsTimer.cancel();
|
||||
feedsTimer.scheduleRepeating(delayMillis);
|
||||
}
|
||||
private void stopTimer() {
|
||||
feedsTimer.cancel();
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -369,7 +348,6 @@ public class NewsFeedPanel extends Composite {
|
|||
*/
|
||||
public void showAllUpdatesFeeds() {
|
||||
showLoader();
|
||||
resetTimer();
|
||||
newsService.getAllUpdateUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||
|
@ -416,7 +394,6 @@ public class NewsFeedPanel extends Composite {
|
|||
*/
|
||||
public void showOnlyConnectionsFeeds() {
|
||||
showLoader();
|
||||
resetTimer();
|
||||
newsService.getOnlyConnectionsUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||
|
@ -457,7 +434,6 @@ public class NewsFeedPanel extends Composite {
|
|||
*/
|
||||
public void showOnlyMyFeeds() {
|
||||
showLoader();
|
||||
resetTimer();
|
||||
newsService.getOnlyMyUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||
|
@ -497,7 +473,6 @@ public class NewsFeedPanel extends Composite {
|
|||
*/
|
||||
public void showOnlyLikedFeeds() {
|
||||
showLoader();
|
||||
resetTimer();
|
||||
newsService.getOnlyLikedFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||
|
@ -549,7 +524,6 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
||||
"Ops! There were problems while retrieving your feeds!. <br> " +
|
||||
"Looks like we are not able to communicate with the infrastructure,<br> (or your session expired)<br> please try again in a short while or refresh the page.</div>"));
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
private void doAddLike(final TweetTemplate owner, final String feedId) {
|
||||
|
|
|
@ -94,14 +94,61 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
if (user == null) {
|
||||
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
|
||||
user = "test.user";
|
||||
//user = "massimiliano.assante";
|
||||
//user = "test.user";
|
||||
user = "massimiliano.assante";
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
|
||||
}
|
||||
else {
|
||||
withinPortal = true;
|
||||
}
|
||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
}
|
||||
/**
|
||||
* this is the first method called by the web app
|
||||
*/
|
||||
@Override
|
||||
public UserSettings getUserSettings() {
|
||||
if (getUserSettingsFromSession() != null)
|
||||
return getUserSettingsFromSession();
|
||||
try {
|
||||
ASLSession session = getASLSession();
|
||||
String username = session.getUsername();
|
||||
String email = username+"@isti.cnr.it";
|
||||
String fullName = username+" FULL";
|
||||
String thumbnailURL = "images/Avatar_default.png";
|
||||
|
||||
if (withinPortal) {
|
||||
UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
||||
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
||||
fullName = user.getFirstName() + " " + user.getLastName();
|
||||
email = user.getEmailAddress();
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||
String accountURL = themeDisplay.getURLMyAccount().toString();
|
||||
|
||||
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
|
||||
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis(), session.getScopeName(), isInfrastructureScope());
|
||||
setUserSettingsInSession(toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
else {
|
||||
_log.info("Returning test USER");
|
||||
UserInfo user = new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, null);
|
||||
return new UserSettings(user, getFeedsRefreshTimeInMillis(), session.getScopeName(), isInfrastructureScope());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new UserSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the scope is the whole infrastructure.
|
||||
* @return <code>true</code> if it is, <code>false</code> otherwise.
|
||||
*/
|
||||
private boolean isInfrastructureScope() {
|
||||
return getASLSession().getScope().isInfrastructure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<EnhancedFeed> getAllUpdateUserFeeds() {
|
||||
|
@ -122,37 +169,50 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
|
||||
_log.info("****** retrieving feeds for user: " + userName);
|
||||
User currUser = OrganizationsUtil.validateUser(userName);
|
||||
/**
|
||||
* this handles the case where the portlet is deployed outside of VREs (regular)
|
||||
*/
|
||||
if (isInfrastructureScope()) {
|
||||
//VRE Feeds
|
||||
for (Organization org : currUser.getOrganizations()) {
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
if (gm.isVRE(org.getOrganizationId()+"")) {
|
||||
String vreid = gm.getScope(""+org.getOrganizationId()); //get the scope
|
||||
_log.trace("Reading feeds for VRE: " + vreid);
|
||||
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, 10);
|
||||
for (Feed feed : OrganizationFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
}
|
||||
}
|
||||
//User Own Feeds
|
||||
ArrayList<Feed> userFeeds = (ArrayList<Feed>) store.getRecentFeedsByUser(userName, 10);
|
||||
for (Feed feed : userFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
|
||||
//VRE Feeds
|
||||
for (Organization org : currUser.getOrganizations()) {
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
if (gm.isVRE(org.getOrganizationId()+"")) {
|
||||
String vreid = gm.getScope(""+org.getOrganizationId()); //get the scope
|
||||
_log.trace("Reading feeds for VRE: " + vreid);
|
||||
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, 10);
|
||||
for (Feed feed : OrganizationFeeds) {
|
||||
//UserFriends Feeds
|
||||
ArrayList<String> userFriendsIds = (ArrayList<String>)store.getFriends(userName);
|
||||
for (String userid : userFriendsIds) {
|
||||
for (Feed feed : store.getRecentFeedsByUser(userid, 10)) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
}
|
||||
}
|
||||
//User Own Feeds
|
||||
ArrayList<Feed> userFeeds = (ArrayList<Feed>) store.getRecentFeedsByUser(userName, 10);
|
||||
for (Feed feed : userFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
|
||||
//UserFriends Feeds
|
||||
ArrayList<String> userFriendsIds = (ArrayList<String>)store.getFriends(userName);
|
||||
for (String userid : userFriendsIds) {
|
||||
for (Feed feed : store.getRecentFeedsByUser(userid, 10)) {
|
||||
//Portal Feeds
|
||||
ArrayList<Feed> portalFeeds = (ArrayList<Feed>) store.getAllPortalPrivacyLevelFeeds();
|
||||
for (Feed feed : portalFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
}
|
||||
|
||||
//Portal Feeds
|
||||
ArrayList<Feed> portalFeeds = (ArrayList<Feed>) store.getAllPortalPrivacyLevelFeeds();
|
||||
for (Feed feed : portalFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
//else must be in a VRE scope
|
||||
else {
|
||||
String vreid = getASLSession().getScopeName();
|
||||
_log.trace("News Feed in VRE, Reading feeds for VRE: " + vreid);
|
||||
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, 30);
|
||||
for (Feed feed : OrganizationFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
}
|
||||
|
||||
for (String key: feedsMap.keySet()) {
|
||||
|
@ -472,40 +532,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserSettings getUserSettings() {
|
||||
if (getUserSettingsFromSession() != null)
|
||||
return getUserSettingsFromSession();
|
||||
try {
|
||||
String username = getASLSession().getUsername();
|
||||
String email = username+"@isti.cnr.it";
|
||||
String fullName = username+" FULL";
|
||||
String thumbnailURL = "images/Avatar_default.png";
|
||||
|
||||
if (withinPortal) {
|
||||
UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
||||
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
||||
fullName = user.getFirstName() + " " + user.getLastName();
|
||||
email = user.getEmailAddress();
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||
String accountURL = themeDisplay.getURLMyAccount().toString();
|
||||
|
||||
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
|
||||
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis());
|
||||
setUserSettingsInSession(toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
else {
|
||||
_log.info("Returning test USER");
|
||||
UserInfo user = new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, null);
|
||||
return new UserSettings(user, getFeedsRefreshTimeInMillis());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new UserSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Like> getAllLikesByFeed(String feedid) {
|
||||
|
@ -704,6 +731,6 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
return toReturn;
|
||||
}
|
||||
else
|
||||
return 30000; //30 secs for testing
|
||||
return 60000; //60 secs for testing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,18 @@ import org.gcube.portal.databook.shared.UserInfo;
|
|||
public class UserSettings implements Serializable {
|
||||
private UserInfo userInfo;
|
||||
private int refreshingTimeInMillis;
|
||||
private String currentScope;
|
||||
boolean isInfrastructure;
|
||||
public UserSettings() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis) {
|
||||
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis,
|
||||
String currentScope, boolean isInfrastructure) {
|
||||
super();
|
||||
this.userInfo = userInfo;
|
||||
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
||||
this.currentScope = currentScope;
|
||||
this.isInfrastructure = isInfrastructure;
|
||||
}
|
||||
public UserInfo getUserInfo() {
|
||||
return userInfo;
|
||||
|
@ -29,9 +33,24 @@ public class UserSettings implements Serializable {
|
|||
public void setRefreshingTimeInMillis(int refreshingTimeInMillis) {
|
||||
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
||||
}
|
||||
public String getCurrentScope() {
|
||||
return currentScope;
|
||||
}
|
||||
public void setCurrentScope(String currentScope) {
|
||||
this.currentScope = currentScope;
|
||||
}
|
||||
public boolean isInfrastructure() {
|
||||
return isInfrastructure;
|
||||
}
|
||||
public void setInfrastructure(boolean isInfrastructure) {
|
||||
this.isInfrastructure = isInfrastructure;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserSettings [userInfo=" + userInfo
|
||||
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis + "]";
|
||||
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis
|
||||
+ ", currentScope=" + currentScope + ", isInfrastructure="
|
||||
+ isInfrastructure + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,20 @@ table {
|
|||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.framed {
|
||||
margin: 0 0 10px;
|
||||
padding: 10px;
|
||||
margin: 0px 5px;
|
||||
|
||||
background: #FFF url(images/vre_bg_gray.png) repeat-x left bottom;
|
||||
|
||||
border-radius: 6px !important;
|
||||
-moz-border-radius: 6px !important;
|
||||
-webkit-border-radius: 6px !important;
|
||||
|
||||
border: 1px solid #DBDBDB;
|
||||
}
|
||||
|
||||
.new-feeds-container {
|
||||
position: relative;
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in New Issue