support for Organisations added as well
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@158334 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
69b192a0f0
commit
7259b24fdd
|
@ -28,7 +28,7 @@ public interface JoinService extends RemoteService {
|
||||||
|
|
||||||
LinkedHashMap<VRECategory, ArrayList<VRE>> getVREsByCategory(String categoryName);
|
LinkedHashMap<VRECategory, ArrayList<VRE>> getVREsByCategory(String categoryName);
|
||||||
|
|
||||||
ArrayList<String> getAllOrganisations();
|
List<String> getAllOrganisations();
|
||||||
|
|
||||||
ArrayList<String> getAllCategories();
|
ArrayList<String> getAllCategories();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public interface JoinServiceAsync {
|
||||||
void getVREsByOrganisation(String organisationName,
|
void getVREsByOrganisation(String organisationName,
|
||||||
AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>> callback);
|
AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>> callback);
|
||||||
|
|
||||||
void getAllOrganisations(AsyncCallback<ArrayList<String>> callback);
|
void getAllOrganisations(AsyncCallback<List<String>> callback);
|
||||||
|
|
||||||
void getAllCategories(AsyncCallback<ArrayList<String>> callback);
|
void getAllCategories(AsyncCallback<ArrayList<String>> callback);
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,6 @@ public class JoinVRE implements EntryPoint {
|
||||||
|
|
||||||
private TabPanel mainTabPanel = new TabPanel(Tabs.ABOVE);
|
private TabPanel mainTabPanel = new TabPanel(Tabs.ABOVE);
|
||||||
|
|
||||||
|
|
||||||
private boolean portfolioLoaded = false;
|
|
||||||
|
|
||||||
|
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
checkIsReferral();
|
checkIsReferral();
|
||||||
}
|
}
|
||||||
|
@ -121,7 +117,11 @@ public class JoinVRE implements EntryPoint {
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param rp
|
||||||
|
* @param tabNames
|
||||||
|
*/
|
||||||
private void showTabs(ResponsivePanel rp, List<String> tabNames) {
|
private void showTabs(ResponsivePanel rp, List<String> tabNames) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final String theTabName : tabNames) {
|
for (final String theTabName : tabNames) {
|
||||||
|
@ -136,7 +136,7 @@ public class JoinVRE implements EntryPoint {
|
||||||
tab2Add.addClickHandler(new ClickHandler() {
|
tab2Add.addClickHandler(new ClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
final ResponsivePanel rpPort = new ResponsivePanel(theTabName);
|
final ResponsivePanel rpPort = new ResponsivePanel(tab2Add);
|
||||||
tab2Add.clear();
|
tab2Add.clear();
|
||||||
tab2Add.add(rpPort);
|
tab2Add.add(rpPort);
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,45 @@ public class JoinVRE implements EntryPoint {
|
||||||
mainPanel.add(mainTabPanel);
|
mainPanel.add(mainTabPanel);
|
||||||
|
|
||||||
addCategoriesTab(mainTabPanel);
|
addCategoriesTab(mainTabPanel);
|
||||||
|
addOrganisationsTab(mainTabPanel);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* add the Organisation Tab to the page, lazy load
|
||||||
|
* @param mainTabPanel
|
||||||
|
*/
|
||||||
|
private void addOrganisationsTab(final TabPanel mainTabPanel) {
|
||||||
|
joinService.getAllOrganisations(new AsyncCallback<List<String>>() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<String> result) {
|
||||||
|
if (result.size() > 0) {
|
||||||
|
final DropdownTab dropdownCategoriesTab = new DropdownTab(ORGANISATIONS_LABEL);
|
||||||
|
for (String orgName : result) {
|
||||||
|
final String organizationName = orgName;
|
||||||
|
|
||||||
|
final Tab tab2Add = new Tab();
|
||||||
|
tab2Add.setHeading(organizationName);
|
||||||
|
dropdownCategoriesTab.add(tab2Add);
|
||||||
|
|
||||||
|
tab2Add.addClickHandler(new ClickHandler() {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
tab2Add.clear();
|
||||||
|
tab2Add.add(new ResponsivePanel(organizationName));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
mainTabPanel.add(dropdownCategoriesTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* add the Categories Tab to the page, lazy load
|
||||||
|
* @param mainTabPanel
|
||||||
|
*/
|
||||||
private void addCategoriesTab(final TabPanel mainTabPanel) {
|
private void addCategoriesTab(final TabPanel mainTabPanel) {
|
||||||
joinService.getAllCategories(new AsyncCallback<ArrayList<String>>() {
|
joinService.getAllCategories(new AsyncCallback<ArrayList<String>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.portlets.user.joinvre.shared.VRECategory;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.PageHeader;
|
import com.github.gwtbootstrap.client.ui.PageHeader;
|
||||||
import com.github.gwtbootstrap.client.ui.Row;
|
import com.github.gwtbootstrap.client.ui.Row;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Tab;
|
||||||
import com.github.gwtbootstrap.client.ui.Thumbnails;
|
import com.github.gwtbootstrap.client.ui.Thumbnails;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -26,6 +27,10 @@ public class ResponsivePanel extends Composite {
|
||||||
public static final String loading = GWT.getModuleBaseURL() + "../images/vre-loader.gif";
|
public static final String loading = GWT.getModuleBaseURL() + "../images/vre-loader.gif";
|
||||||
private Row mainPanel = new Row();
|
private Row mainPanel = new Row();
|
||||||
private ArrayList<VreThumbnail> myThumbnails = new ArrayList<VreThumbnail>();
|
private ArrayList<VreThumbnail> myThumbnails = new ArrayList<VreThumbnail>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor (No tabs)
|
||||||
|
*/
|
||||||
public ResponsivePanel() {
|
public ResponsivePanel() {
|
||||||
GWT.log("ResponsivePanel()");
|
GWT.log("ResponsivePanel()");
|
||||||
joinService.getVREs(new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
|
joinService.getVREs(new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
|
||||||
|
@ -40,9 +45,12 @@ public class ResponsivePanel extends Composite {
|
||||||
});
|
});
|
||||||
initWidget(mainPanel);
|
initWidget(mainPanel);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public ResponsivePanel(String tabName) {
|
* constructor used when one tab is clicked
|
||||||
GWT.log("ResponsivePanel()");
|
* @param selectedTab
|
||||||
|
*/
|
||||||
|
public ResponsivePanel(Tab selectedTab) {
|
||||||
|
final String tabName = selectedTab.getHeading();
|
||||||
joinService.getPortalSitesMappedToVRE(tabName, new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
|
joinService.getPortalSitesMappedToVRE(tabName, new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(LinkedHashMap<VRECategory, ArrayList<VRE>> categories) {
|
public void onSuccess(LinkedHashMap<VRECategory, ArrayList<VRE>> categories) {
|
||||||
|
@ -55,7 +63,10 @@ public class ResponsivePanel extends Composite {
|
||||||
});
|
});
|
||||||
initWidget(mainPanel);
|
initWidget(mainPanel);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* constructor used when one category is selected
|
||||||
|
* @param category
|
||||||
|
*/
|
||||||
public ResponsivePanel(VRECategory category) {
|
public ResponsivePanel(VRECategory category) {
|
||||||
GWT.log("ResponsivePanel()");
|
GWT.log("ResponsivePanel()");
|
||||||
joinService.getVREsByCategory(category.getName(), new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
|
joinService.getVREsByCategory(category.getName(), new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
|
||||||
|
@ -70,6 +81,23 @@ public class ResponsivePanel extends Composite {
|
||||||
});
|
});
|
||||||
initWidget(mainPanel);
|
initWidget(mainPanel);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* constructor used when one organisation is selected
|
||||||
|
* @param category
|
||||||
|
*/
|
||||||
|
public ResponsivePanel(String organisation) {
|
||||||
|
joinService.getVREsByOrganisation(organisation, new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(LinkedHashMap<VRECategory, ArrayList<VRE>> categories) {
|
||||||
|
populatePanel(categories);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
showError("Sorry, looks like something is broken with the server connection");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
initWidget(mainPanel);
|
||||||
|
}
|
||||||
|
|
||||||
private void populatePanel(LinkedHashMap<VRECategory, ArrayList<VRE>> categories) {
|
private void populatePanel(LinkedHashMap<VRECategory, ArrayList<VRE>> categories) {
|
||||||
mainPanel.clear();
|
mainPanel.clear();
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
//tell whether the
|
//tell whether the
|
||||||
public static final String TABBED_LAYOUT_ATTRIBUTE = "TabbedLayout";
|
public static final String TABBED_LAYOUT_ATTRIBUTE = "TabbedLayout";
|
||||||
public static final String TAB_NAMES_ATTRIBUTE = "TabName";
|
public static final String TAB_NAMES_ATTRIBUTE = "TabName";
|
||||||
|
public static final String ORGANIZATION_NAMES_ATTRIBUTE = "OrganisationName";
|
||||||
|
|
||||||
public static final String ALLVRES_SESSION_ATTRIBUTE = "ALLVRES_SESSION";
|
public static final String ALLVRES_SESSION_ATTRIBUTE = "ALLVRES_SESSION";
|
||||||
|
|
||||||
|
@ -185,7 +186,6 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
if (isWithinPortal()) {
|
if (isWithinPortal()) {
|
||||||
if (isTabbedPanel() != null) {
|
if (isTabbedPanel() != null) {
|
||||||
String firstTabName = getTabNames().get(0);
|
String firstTabName = getTabNames().get(0);
|
||||||
_log.debug("\n\n ****isTabbedLayout isTabbedLayout, first TabName= "+firstTabName);
|
|
||||||
return getPortalSitesMappedToVRE(firstTabName);
|
return getPortalSitesMappedToVRE(firstTabName);
|
||||||
} else {
|
} else {
|
||||||
toReturn = getPortalSitesMappedToVRE();
|
toReturn = getPortalSitesMappedToVRE();
|
||||||
|
@ -207,6 +207,8 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE(String tabName) {
|
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE(String tabName) {
|
||||||
|
tabName = tabName.trim();
|
||||||
|
_log.debug("Asked for vres of Tab " + tabName);
|
||||||
LinkedHashMap<VRECategory, ArrayList<VRE>> tabVREs = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
LinkedHashMap<VRECategory, ArrayList<VRE>> tabVREs = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
||||||
try {
|
try {
|
||||||
LinkedHashMap<VRECategory, ArrayList<VRE>> allVREs = getPortalSitesMappedToVRE();
|
LinkedHashMap<VRECategory, ArrayList<VRE>> allVREs = getPortalSitesMappedToVRE();
|
||||||
|
@ -226,7 +228,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
_log.error("Error getting VREs", e);
|
_log.error("Error getting VREs by Category", e);
|
||||||
}
|
}
|
||||||
return tabVREs;
|
return tabVREs;
|
||||||
}
|
}
|
||||||
|
@ -236,10 +238,27 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LinkedHashMap<VRECategory, ArrayList<VRE>> getVREsByOrganisation(String organisationName) {
|
public LinkedHashMap<VRECategory, ArrayList<VRE>> getVREsByOrganisation(String organisationName) {
|
||||||
|
LinkedHashMap<VRECategory, ArrayList<VRE>> organizationVREs = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
||||||
|
try {
|
||||||
|
LinkedHashMap<VRECategory, ArrayList<VRE>> allVREs = getPortalSitesMappedToVRE();
|
||||||
|
|
||||||
//TODO:
|
for (VRECategory cat : allVREs.keySet()) {
|
||||||
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
ArrayList<VRE> toAdd = new ArrayList<VRE>();
|
||||||
return toReturn;
|
organizationVREs.put(cat, toAdd);
|
||||||
|
for (VRE vre : allVREs.get(cat)) {
|
||||||
|
String[] vreOrgNames = (String[]) groupsManager.readCustomAttr(vre.getId(), ORGANIZATION_NAMES_ATTRIBUTE);
|
||||||
|
String vreOrgName = vreOrgNames[0];
|
||||||
|
if (organisationName.equals(vreOrgName)) {
|
||||||
|
toAdd.add(vre);
|
||||||
|
_log.debug("Added " + vre.getName() + " as it belongs to organisation " + organisationName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
_log.error("Error getting VREs by Organization", e);
|
||||||
|
}
|
||||||
|
return organizationVREs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,9 +294,24 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<String> getAllOrganisations() {
|
public List<String> getAllOrganisations() {
|
||||||
// TODO Auto-generated method stub
|
List<String> toReturn = new ArrayList<String>();
|
||||||
return null;
|
if (isWithinPortal()) {
|
||||||
|
try {
|
||||||
|
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
||||||
|
Group site = GroupLocalServiceUtil.getGroup(currentSiteGroupId);
|
||||||
|
String[] values = (String[]) site.getExpandoBridge().getAttributeDefault(ORGANIZATION_NAMES_ATTRIBUTE);
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
toReturn.add(values[i]);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Arrays.asList(new String[]{"BlueBRIDGE", "iMarine"});
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,6 +2,13 @@ body {
|
||||||
border: 5px solid white;
|
border: 5px solid white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav-tabs .dropdown-toggle .caret {
|
||||||
|
border-top: 8px solid black !important;
|
||||||
|
border-right: 8px solid transparent !important;;
|
||||||
|
border-left: 8px solid transparent !important;;
|
||||||
|
border-top-color: #08c !important;;
|
||||||
|
}
|
||||||
|
|
||||||
ul.dropdown-menu > li {
|
ul.dropdown-menu > li {
|
||||||
font-size: 1.1em !important;
|
font-size: 1.1em !important;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue