started implementing the groups panel. Added a loading icon on the organizations page, while waiting for the list to be returned
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@134404 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
99db1074b2
commit
d0a912b954
|
@ -4,6 +4,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="ckan-metadata-publisher-widget-1.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-metadata-publisher-widget/ckan-metadata-publisher-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="gcube-ckan-datacatalog"/>
|
||||
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
|
@ -46,6 +47,13 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
|
|||
* @return the ckan organizations names and urls for user
|
||||
*/
|
||||
List<BeanUserInOrgRole> getCkanOrganizationsNamesAndUrlsForUser();
|
||||
|
||||
/**
|
||||
* Retrieve the list of groups to whom the user belongs and their urls.
|
||||
*
|
||||
* @return the ckan groups names and urls for user
|
||||
*/
|
||||
List<BeanUserInGroupRole> getCkanGroupsNamesAndUrlsForUser();
|
||||
|
||||
/**
|
||||
* Logout from ckan.
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
|
@ -71,5 +72,14 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
* @param callback the callback
|
||||
*/
|
||||
void outsidePortal(AsyncCallback<Boolean> callback);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the list of groups to whom the user belongs and their urls.
|
||||
*
|
||||
* @return the ckan groups names and urls for user
|
||||
*/
|
||||
void getCkanGroupsNamesAndUrlsForUser(
|
||||
AsyncCallback<List<BeanUserInGroupRole>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Footer;
|
||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||
import com.github.gwtbootstrap.client.ui.base.ListItem;
|
||||
import com.github.gwtbootstrap.client.ui.base.UnorderedList;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
/**
|
||||
* The ckan panel that shows the user groups
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class CkanGroupsPanel extends VerticalPanel{
|
||||
|
||||
private List<BeanUserInGroupRole> groups;
|
||||
private GCubeCkanDataCatalogPanel father;
|
||||
private Image loading = new Image(CkanPortletResources.ICONS.loading());
|
||||
|
||||
public CkanGroupsPanel(
|
||||
GCubeCkanDataCatalogPanel gCubeCkanDataCatalogPanel) {
|
||||
father = gCubeCkanDataCatalogPanel;
|
||||
this.setHeight("500px");
|
||||
this.setWidth("100%");
|
||||
this.add(loading);
|
||||
this.setCellHorizontalAlignment(loading, HasHorizontalAlignment.ALIGN_CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the groups to show. If a null list is passed, it is an error
|
||||
* @param result
|
||||
*/
|
||||
public void setGroups(List<BeanUserInGroupRole> result) {
|
||||
|
||||
this.groups = result;
|
||||
|
||||
// prepare panels
|
||||
this.remove(loading);
|
||||
HorizontalPanel hPanel = new HorizontalPanel();
|
||||
hPanel.setStyleName("horizontal-panel-organizations");
|
||||
VerticalPanel vPanel = new VerticalPanel();
|
||||
hPanel.add(vPanel);
|
||||
this.add(hPanel);
|
||||
|
||||
//generate the list of organizations
|
||||
if(result == null){
|
||||
Paragraph p = new Paragraph("There was an error while retrieving your groups, sorry.");
|
||||
p.setStyleName("no-organizations-found-paragraph");
|
||||
p.getElement().getStyle().setColor("#aaaaaa");
|
||||
vPanel.add(p);
|
||||
}
|
||||
else if(result.isEmpty()){
|
||||
|
||||
Paragraph p = new Paragraph("You are not a member of any group.");
|
||||
p.setStyleName("no-organizations-found-paragraph");
|
||||
p.getElement().getStyle().setColor("#aaaaaa");
|
||||
vPanel.add(p);
|
||||
|
||||
}else{
|
||||
|
||||
UnorderedList list = new UnorderedList();
|
||||
|
||||
for (final BeanUserInGroupRole org : groups) {
|
||||
|
||||
Paragraph line = new Paragraph();
|
||||
Button b = new Button();
|
||||
b.setType(ButtonType.LINK);
|
||||
b.setText(org.getGroupName());
|
||||
b.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
String request = getCkanRequest(org.getOrgUrl(), null);
|
||||
father.instanceCkanFrame(request);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
line.add(b);
|
||||
Button role = new Button();
|
||||
role.setType(ButtonType.LINK);
|
||||
role.setText("as " + org.getRole().toString().toLowerCase());
|
||||
role.addStyleName("button-as-role-style");
|
||||
role.getElement().getStyle().setProperty("pointer-events", "none");
|
||||
line.add(role);
|
||||
ListItem item = new ListItem(line);
|
||||
list.add(item);
|
||||
}
|
||||
|
||||
list.addStyleName("list-panel-organizations-style");
|
||||
vPanel.add(list);
|
||||
}
|
||||
|
||||
// add the footer
|
||||
String html = "Powered by <a href=\"http://www.gcube-system.org\" target=\"_blank\">gCube</a> | <a href=\"http://ckan.org\" target=\"_blank\">CKAN</a>";
|
||||
Footer footer = new Footer(html);
|
||||
footer.setStyleName("footer-organizations");
|
||||
this.add(footer);
|
||||
this.setWidth("100%");
|
||||
this.setStyleName("my-organizations-container-style");
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the correct url to the ckan connector
|
||||
* @param pathInfo
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
private String getCkanRequest(String pathInfo, String query){
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getBaseURLCKANConnector(), "");
|
||||
ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
|
||||
pathInfo = CkanConnectorAccessPoint.checkNullString(pathInfo);
|
||||
query = CkanConnectorAccessPoint.checkNullString(query);
|
||||
ckan.addPathInfo(pathInfo);
|
||||
ckan.addQueryString(query);
|
||||
return ckan.buildURI();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
|
||||
|
@ -13,7 +14,9 @@ import com.github.gwtbootstrap.client.ui.base.UnorderedList;
|
|||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
/**
|
||||
|
@ -24,10 +27,15 @@ public class CkanOrganizationsPanel extends VerticalPanel{
|
|||
|
||||
private List<BeanUserInOrgRole> organizations;
|
||||
private GCubeCkanDataCatalogPanel father;
|
||||
private Image loading = new Image(CkanPortletResources.ICONS.loading());
|
||||
|
||||
public CkanOrganizationsPanel(
|
||||
GCubeCkanDataCatalogPanel gCubeCkanDataCatalogPanel) {
|
||||
father = gCubeCkanDataCatalogPanel;
|
||||
this.setHeight("500px");
|
||||
this.setWidth("100%");
|
||||
this.add(loading);
|
||||
this.setCellHorizontalAlignment(loading, HasHorizontalAlignment.ALIGN_CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,14 +44,15 @@ public class CkanOrganizationsPanel extends VerticalPanel{
|
|||
*/
|
||||
public void setOrganizations(List<BeanUserInOrgRole> result) {
|
||||
|
||||
this.organizations = result;
|
||||
|
||||
// prepare panels
|
||||
this.remove(loading);
|
||||
HorizontalPanel hPanel = new HorizontalPanel();
|
||||
hPanel.setStyleName("horizontal-panel-organizations");
|
||||
VerticalPanel vPanel = new VerticalPanel();
|
||||
|
||||
hPanel.add(vPanel);
|
||||
add(hPanel);
|
||||
|
||||
this.organizations = result;
|
||||
this.add(hPanel);
|
||||
|
||||
//generate the list of organizations
|
||||
if(result == null){
|
||||
|
@ -54,7 +63,7 @@ public class CkanOrganizationsPanel extends VerticalPanel{
|
|||
}
|
||||
else if(result.isEmpty()){
|
||||
|
||||
Paragraph p = new Paragraph("You are not a member of any organizations.");
|
||||
Paragraph p = new Paragraph("You are not a member of any organization.");
|
||||
p.setStyleName("no-organizations-found-paragraph");
|
||||
p.getElement().getStyle().setColor("#aaaaaa");
|
||||
vPanel.add(p);
|
||||
|
@ -99,9 +108,9 @@ public class CkanOrganizationsPanel extends VerticalPanel{
|
|||
String html = "Powered by <a href=\"http://www.gcube-system.org\" target=\"_blank\">gCube</a> | <a href=\"http://ckan.org\" target=\"_blank\">CKAN</a>";
|
||||
Footer footer = new Footer(html);
|
||||
footer.setStyleName("footer-organizations");
|
||||
add(footer);
|
||||
setWidth("100%");
|
||||
setStyleName("my-organizations-container-style");
|
||||
this.add(footer);
|
||||
this.setWidth("100%");
|
||||
this.setStyleName("my-organizations-container-style");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.gcube.datacatalogue.ckanutillibrary.utils.SessionCatalogueAttributes;
|
|||
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
|
@ -510,4 +511,10 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BeanUserInGroupRole> getCkanGroupsNamesAndUrlsForUser() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* A bean that contains the tuple :
|
||||
* <Group Name, Organization Url, User's role in it>
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
* (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class BeanUserInGroupRole implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9022496195659804838L;
|
||||
private String groupName;
|
||||
private String orgUrl;
|
||||
private CkanRole role;
|
||||
|
||||
public BeanUserInGroupRole() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupName
|
||||
* @param orgUrl
|
||||
* @param role
|
||||
*/
|
||||
public BeanUserInGroupRole(String groupName, String orgUrl, CkanRole role) {
|
||||
super();
|
||||
this.groupName = groupName;
|
||||
this.orgUrl = orgUrl;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
public String getOrgUrl() {
|
||||
return orgUrl;
|
||||
}
|
||||
|
||||
public void setOrgUrl(String orgUrl) {
|
||||
this.orgUrl = orgUrl;
|
||||
}
|
||||
|
||||
public CkanRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(CkanRole role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BeanUserInGroupRole [groupName=" + groupName + ", orgUrl="
|
||||
+ orgUrl + ", role=" + role + "]";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue