diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index dcfb6eb..7397c4c 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -3,6 +3,12 @@ + + uses + + + uses + diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java index f4d426c..18db272 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java @@ -7,7 +7,6 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.rpc.ServiceDefTarget; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.VerticalPanel; @@ -16,21 +15,14 @@ import com.google.gwt.user.client.ui.VerticalPanel; * Entry point classes define onModuleLoad(). */ public class GCubeLoggedin implements EntryPoint { - - - /** - * Create a remote service proxy to talk to the server-side Greeting service. - */ private final LoggedinServiceAsync loggedinService = GWT.create(LoggedinService.class); - private ServiceDefTarget endpoint = (ServiceDefTarget) loggedinService; + private VerticalPanel main_panel = new VerticalPanel(); /** * This is the entry point method. */ public void onModuleLoad() { main_panel.setWidth("100%"); - - endpoint.setServiceEntryPoint(GWT.getModuleBaseURL()+"LoggedinServiceImpl"); main_panel.add(AboutView.getLoadingHTML()); // Associate the new panel with the HTML host page. RootPanel.get("LoggedinDiv").add(main_panel); diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java index dbdf8d0..728e0d2 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java @@ -11,4 +11,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath("LoggedinServiceImpl") public interface LoggedinService extends RemoteService { VObject getSelectedRE(String portalURL); + + String saveVREDescription(String toSave); } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java index 2992d6f..30335ad 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java @@ -9,4 +9,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback; */ public interface LoggedinServiceAsync { void getSelectedRE(String portalURL, AsyncCallback callback); + + void saveVREDescription(String toSave, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java index 4950aa0..20af5c2 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java @@ -31,13 +31,15 @@ public class AboutView extends Composite { public AboutView() { initWidget(uiBinder.createAndBindUi(this)); } - + private String vreDescription; @UiField Image vreImage; @UiField Heading vreName; @UiField HTML description; @UiField Button seeMore; + @UiField Button editButton; @UiField Hero mainPanel; + private EditDescriptionModal mod; public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) { initWidget(uiBinder.createAndBindUi(this)); @@ -52,7 +54,11 @@ public class AboutView extends Composite { description.addStyleName("vre-description"); seeMore.setVisible(true); seeMore.setText(SEE_MORE); + if (vobj.isManager()) { + editButton.setVisible(true); + } } + mod = new EditDescriptionModal(vobj.getName(), vobj.getDescription()); } boolean open = false; @UiHandler("seeMore") @@ -69,6 +75,13 @@ public class AboutView extends Composite { } } + @UiHandler("editButton") + void onEditButton(ClickEvent e) { + mod.show(); + } + + + /** * * @return diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml index 5172a33..7873ce0 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml @@ -12,7 +12,7 @@ See more - Unregister from this group + Edit VRE Description (VRE-Managers only) diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java new file mode 100644 index 0000000..e884b4a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java @@ -0,0 +1,108 @@ +package org.gcube.portlets.user.gcubeloggedin.client.ui; + +import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService; +import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync; +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; + +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.Icon; +import com.github.gwtbootstrap.client.ui.Modal; +import com.github.gwtbootstrap.client.ui.Paragraph; +import com.github.gwtbootstrap.client.ui.TextArea; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +import com.google.gwt.user.client.Window.Location; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + +public class EditDescriptionModal extends Composite { + private final LoggedinServiceAsync loggedinService = GWT.create(LoggedinService.class); + private static EditDescriptionModalUiBinder uiBinder = GWT + .create(EditDescriptionModalUiBinder.class); + + interface EditDescriptionModalUiBinder extends + UiBinder { + } + + private String currDescription; + + @UiField Modal modal; + @UiField TextArea text2Edit; + @UiField Button cancel; + @UiField Button save; + @UiField Icon loading; + @UiField Paragraph loadingContainer; + @UiField Paragraph loadingText; + + + public EditDescriptionModal(String vreName, String currDescription) { + initWidget(uiBinder.createAndBindUi(this)); + modal.setTitle(vreName + " description/abstract"); + text2Edit.setBlockLevel(true); + text2Edit.setVisibleLines(10); + this.currDescription = currDescription; + } + + public void show() { + text2Edit.setText(transformDescription(currDescription)); + text2Edit.setVisible(true); + loadingContainer.setVisible(false); + save.setVisible(true); + modal.show(); + } + + @UiHandler("cancel") + void onCancelButton(ClickEvent e) { + modal.hide(); + } + + + @UiHandler("save") + void onSaveButton(ClickEvent e) { + final String vreDescription = text2Edit.getText(); + text2Edit.setText(""); + text2Edit.setVisible(false); + loadingContainer.setVisible(true); + ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback() { + @Override + public void onSuccess(Boolean result) { + doSave(vreDescription); + } + @Override + public void onFailure(Throwable caught) { + loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem."); + } + }); + } + + private void doSave(String toSave) { + loggedinService.saveVREDescription(toSave, new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem."); + } + + @Override + public void onSuccess(String result) { + loading.setIcon(IconType.CHECK_SIGN); + loading.setSpin(false); + loadingText.setText("Saving successful, please refresh the page to see your changes."); + save.setVisible(false); + } + }); + + } + + private String transformDescription(String VREDescription) { + String toReturn = VREDescription; + // replace all the line breaks by
+ toReturn = toReturn.replaceAll(" + + + + Modal Content! + + Saving VRE Description please wait ... + + + + Close + Save + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java index 7a8f58c..15c4164 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java @@ -14,6 +14,8 @@ import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient; import org.gcube.portlets.user.gcubeloggedin.shared.VREClient; import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl; import org.gcube.vomanagement.usermanagement.GroupManager; +import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; +import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.model.GCubeGroup; @@ -49,7 +51,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi return SessionManager.getInstance().getASLSession(sessionID, user); } - + /** * return the current selected VRE */ @@ -69,7 +71,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi + "
  • approximately 25 collections, i.e. set of D4Science Information Objects including Earth images, AquaMaps, Graphs on catch statistics;
  • " + "
  • approximately 66 metadata collections, i.e. set of Metadata Objects describing the Information Objects through various features and schemas;
  • " + "
  • approximately 58 other resources including transformation programs, index types, etc.
  • " - , "http://placehold.it/300x200", "", UserBelongingClient.BELONGING, false, true); + , "http://placehold.it/300x200", "", UserBelongingClient.BELONGING, false, true, true); } _log.trace("getting Selected Research Environment"); GroupManager gm = new LiferayGroupManager(); @@ -105,21 +107,12 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi //set the description for the vre if (currSite.getDescription() != null) desc = currSite.getDescription(); - - System.out.println(" **** debuggaaa"); - Boolean isRequestBasedGroup = false; - Boolean isMandatory = false; - try { - isMandatory = (Boolean) gm.readCustomAttr(currSite.getGroupId(), org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys.MANDATORY.getKeyName()); - isRequestBasedGroup = currSite.isRequestBasedGroup(); - } catch (Exception e) { - isMandatory = false; - isRequestBasedGroup = false; - return new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, isMandatory, isRequestBasedGroup); - } - - VREClient vre = new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, isMandatory, isRequestBasedGroup); - return vre; + return new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, false, false, isCurrUserVREManager()); + } + + //TODO: implement this through UM + private boolean isCurrUserVREManager() { + return true; } protected static ArrayList getAdministratorsEmails(String scope) { @@ -161,4 +154,19 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi } return adminEmailsList; } + + @Override + public String saveVREDescription(String toSave) { + try { + String scope = getASLSession().getScope(); + GroupManager gm = new LiferayGroupManager(); + long groupId = gm.getGroupIdFromInfrastructureScope(scope); + return gm.updateGroupDescription(groupId, toSave); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VOClient.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VOClient.java index c5a0d99..c0890ce 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VOClient.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VOClient.java @@ -23,7 +23,7 @@ public class VOClient extends VObject implements Comparable, Serializa String imageURL, String friendlyURL, UserBelongingClient userBelonging) { - super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true); + super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true, false); // TODO Auto-generated constructor stub } @@ -35,7 +35,7 @@ public class VOClient extends VObject implements Comparable, Serializa String friendlyURL, UserBelongingClient userBelonging, boolean isRoot, List vres) { - super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true); + super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true, false); this.isRoot = isRoot; this.vres = vres; } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VObject.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VObject.java index c8e7bc3..94cc6ba 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VObject.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VObject.java @@ -18,6 +18,7 @@ public class VObject implements Serializable { private boolean mandatory; private boolean uponRequest; + private boolean isManager; private UserBelongingClient userBelonging; @@ -26,7 +27,7 @@ public class VObject implements Serializable { public VObject(String name, String groupName, String description, String imageURL, String friendlyURL, UserBelongingClient userBelonging, boolean mandatory, - boolean uponRequest) { + boolean uponRequest, boolean isManager) { this.name = name; this.groupName = groupName; this.description = description; @@ -35,6 +36,7 @@ public class VObject implements Serializable { this.mandatory = mandatory; this.uponRequest = uponRequest; this.userBelonging = userBelonging; + this.isManager = isManager; } @@ -92,5 +94,22 @@ public class VObject implements Serializable { public void setUponRequest(boolean uponRequest) { this.uponRequest = uponRequest; } + + public boolean isManager() { + return isManager; + } + + public void setManager(boolean isManager) { + this.isManager = isManager; + } + + @Override + public String toString() { + return "VObject [name=" + name + ", groupName=" + groupName + + ", description=" + description + ", imageURL=" + imageURL + + ", friendlyURL=" + friendlyURL + ", mandatory=" + mandatory + + ", uponRequest=" + uponRequest + ", isManager=" + isManager + + ", userBelonging=" + userBelonging + "]"; + } } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VREClient.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VREClient.java index 2348d47..578adcf 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VREClient.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VREClient.java @@ -1,22 +1,16 @@ package org.gcube.portlets.user.gcubeloggedin.shared; -/** - * - * @author massi - * - */ + @SuppressWarnings("serial") public class VREClient extends VObject { public VREClient() { super(); - // TODO Auto-generated constructor stub } public VREClient(String name, String groupName, String description, String imageURL, String friendlyURL, - UserBelongingClient userBelonging, boolean isMandatory, boolean isUponRequest) { - super(name, groupName, description, imageURL, friendlyURL, userBelonging, isMandatory, isUponRequest); - // TODO Auto-generated constructor stub + UserBelongingClient userBelonging, boolean isMandatory, boolean isUponRequest, boolean isManager) { + super(name, groupName, description, imageURL, friendlyURL, userBelonging, isMandatory, isUponRequest, isManager); } diff --git a/src/main/webapp/GCubeLoggedin.css b/src/main/webapp/GCubeLoggedin.css index 5a36838..d58c56f 100644 --- a/src/main/webapp/GCubeLoggedin.css +++ b/src/main/webapp/GCubeLoggedin.css @@ -8,3 +8,9 @@ div.gwt-HTML.vre-description { font-size: 14px; line-height: 22px; } + + +.loading-text { + width: 100%; + text-align: center; +} \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index a25f3e2..d09a486 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -14,6 +14,16 @@ LoggedinServiceImpl /gcubeloggedin/LoggedinServiceImpl + + + scopeService + org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl + + + + scopeService + /gcubeloggedin/scopeService +