diff --git a/.classpath b/.classpath index 5ef800e..285ac7e 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -36,5 +36,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index 24ea67a..afbfdeb 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.1.0 +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.2.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 4155b4e..0d454c2 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,58 +1,68 @@ - + - - + + + + - + + - + + - + + - + + - + + - + + - + + - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 13d7560..ab37615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.2.0-SNAPSHOT] - 2021-07-19 + +#### Enhancements + +[#21847] Integrated with an Image and LighBox gallery for images +Moved to maven-portal-bom 3.6.3 + ## [v1.1.0] - 2020-12-21 #### Enhancements diff --git a/pom.xml b/pom.xml index f5ae810..433770e 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 1.1.0 + 1.2.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface @@ -54,7 +54,7 @@ org.gcube.distribution maven-portal-bom - 3.6.0 + 3.6.3-SNAPSHOT pom import @@ -109,6 +109,16 @@ ${gwt.version} provided + + org.gcube.portal + oidc-library-portal + provided + + + org.gcube.common + oidc-library + provided + com.github.tdesjardins gwt-ol3 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml index 6a5dd72..a673605 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml @@ -11,8 +11,11 @@ - - + + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index db328a7..e844663 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -24,6 +24,7 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.core.client.ScriptInjector; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; @@ -93,10 +94,13 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void execute() { - olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),layerManager.getLayerManagerBus()); + olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(), + layerManager.getLayerManagerBus()); layerManager.setOlMap(olMapMng.getOLOSMMap()); mainPanel.setMap(olMapMng.getOLOSMMap()); updateSize(); + ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js") + .setWindow(ScriptInjector.TOP_WINDOW).inject(); } }); @@ -109,74 +113,84 @@ public class GeoportalDataViewer implements EntryPoint { paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); - //paramUUID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER); + // paramUUID = + // Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER); paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID); paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE); GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest); GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType); GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); - //GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID); + // GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID); GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); - - //VALIDATING THE LONG FORMAT FOR GID + + // VALIDATING THE LONG FORMAT FOR GID try { - if(paramGeonaItemID!=null) + if (paramGeonaItemID != null) Long.parseLong(paramGeonaItemID); - }catch (Exception e) { - Window.alert("Bad format for parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_ID+". It must be a Long"); + } catch (Exception e) { + Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + + ". It must be a Long"); paramGeonaItemID = null; } - + Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { - GeoportalDataViewerServiceAsync.Util.getInstance().getGeoNaDataViewProfile(new AsyncCallback() { + GeoportalDataViewerServiceAsync.Util.getInstance() + .getGeoNaDataViewProfile(new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - Window.alert(caught.getMessage()); - - } + @Override + public void onFailure(Throwable caught) { + Window.alert(caught.getMessage()); - @Override - public void onSuccess(GeoNaDataViewerProfile profile) { - geonaDataViewerProfile = profile; - GWT.log("Profile: "+geonaDataViewerProfile); - Iterator it; - String theItemType = paramGeonaItemType; - if(theItemType==null) { - it = geonaDataViewerProfile.getMapLayers().keySet().iterator(); - it.hasNext(); - theItemType= it.next(); - } - - LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(theItemType); - - if(layerItem==null) { - Window.alert("Not detected any layer with type: "+theItemType); - return; - } - - GWT.log("The layerItem is: "+layerItem); - layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, null, true); - - if(paramGeonaItemID!=null) { - if(paramGeonaItemType==null) { - Window.alert("Missing parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE +" (GeoNa Data Type) where to search the item id: "+paramGeonaItemID); - return; } - GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType); - applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null)); - } - - } - }); + + @Override + public void onSuccess(GeoNaDataViewerProfile profile) { + geonaDataViewerProfile = profile; + GWT.log("Profile: " + geonaDataViewerProfile); + Iterator it; + String theItemType = paramGeonaItemType; + if (theItemType == null) { + it = geonaDataViewerProfile.getMapLayers().keySet().iterator(); + it.hasNext(); + theItemType = it.next(); + } + + LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(theItemType); + + if (layerItem == null) { + Window.alert("Not detected any layer with type: " + theItemType); + return; + } + + GWT.log("The layerItem is: " + layerItem); + layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, + null, true); + + if (paramGeonaItemID != null) { + if (paramGeonaItemType == null) { + Window.alert( + "Missing parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + + " (GeoNa Data Type) where to search the item id: " + + paramGeonaItemID); + return; + } + GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType); + applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null)); + } + + } + }); } }); - + bindEvents(); + } + + /** * Update window size. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java new file mode 100644 index 0000000..fd14c8a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java @@ -0,0 +1,164 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery; + +import java.util.List; + +import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; +import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; + +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.json.client.JSONArray; +import com.google.gwt.json.client.JSONObject; +import com.google.gwt.json.client.JSONString; +import com.google.gwt.user.client.Random; +import com.google.gwt.user.client.ui.HTMLPanel; + + +/** + * The Class ImagesGallery. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Jul 21, 2021 + */ +public class ImagesGallery { + + private HTMLPanel galleryPanel; + private List listImages; + private String galleryDivId; + + /** + * Show gallery. + * + * @param json_array_images the json array images + */ + private native void showGallery(JavaScriptObject json_array_images, String galleryDivId) /*-{ + + console.log("showing: " + json_array_images) + var waitForJQuery = setInterval( + function() { + if (typeof $wnd.$ != 'undefined') { + + $wnd + .$("#"+galleryDivId) + .nanogallery2( + { + thumbnailHeight : '200 XS150 SM150', // RESPONSIVE THUMBNAIL HEIGHT: default=200px, XS resolution=150px, SM resolution=150px + thumbnailWidth : '218 XS150 SM150', // RESPONSIVE THUMBNAIL WIDTH: auto + thumbnailAlignment : 'left', + thumbnailBorderHorizontal : 0, + thumbnailBorderVertical : 0, + thumbnailGutterWidth : '10 XS10 SM10', + thumbnailGutterHeight : '10 XS10 SM10', + + // THUMBNAIL TOOLS & LABEL + thumbnailLabel : { + display : true, + position : 'onBottom', + align : 'left' + }, + thumbnailToolbarImage : { + bottomLeft : 'display' + }, + // replace the default DISPLAY tool icon + icons : { + thumbnailDisplay : ' display' + }, + + // DISPLAY ANIMATION + galleryDisplayTransition : 'slideUp', + galleryDisplayTransitionDuration : 1000, + thumbnailDisplayTransition : 'scaleDown', + thumbnailDisplayTransitionDuration : 300, + thumbnailDisplayInterval : 50, + + // THUMBNAIL'S HOVER ANIMATION + //thumbnailBuildInit2 : 'tools_font-size_1.5em|title_font-size_1.5em', + thumbnailHoverEffect2 : 'imageScaleIn80|tools_opacity_0_1|tools_translateX_-30px_0px|title_opacity_1_0|title_translateX_0px_-30px', + touchAnimation : true, + touchAutoOpenDelay : 800, + + // GALLERY THEME + galleryTheme : { + thumbnail : { + borderRadius : '2px', + background : '#fff', + titleShadow : 'none', + titleColor : '#696969', + labelBackground : '#f3f3f3' + }, + thumbnailIcon : { + color : '#000', + shadow : 'none' + }, + }, + viewerToolbar : { + display : true, + standard : 'minimizeButton, label', + minimized : 'minimizeButton, label, fullscreenButton, downloadButton' + }, + viewerTools : { + topLeft : 'pageCounter', + topRight : 'playPauseButton, zoomButton, fullscreenButton, downloadButton, closeButton' + }, + + // DEEP LINKING + locationHash : false, + items : json_array_images + }) + + clearInterval(waitForJQuery); + } + }, 200); + + }-*/; + + /** + * Instantiates a new images gallery. + * + * @param immagini the immagini + */ + public ImagesGallery(List immagini) { + this.galleryDivId = "nanogallery"+Random.nextInt()+Random.nextInt(); + this.galleryPanel = new HTMLPanel("
"); + this.listImages = immagini; + } + + /** + * Gets the gallery panel. + * + * @return the gallery panel + */ + public HTMLPanel getGalleryPanel() { + return galleryPanel; + } + + /** + * Fill gallery. + */ + public void fillGallery() { + + JSONArray jsonArray = new JSONArray(); + int index = 0; + for (UploadedImageDV image : listImages) { + for (WorkspaceContentDV imageContent : image.getListWsContent()) { + JSONObject json = new JSONObject(); + json.put("src", new JSONString(imageContent.getLink())); + json.put("srct", new JSONString(imageContent.getLink())); + List listAuthors = image.getResponsabili(); + String txtAuthors = listAuthors.size()>1 ? "Authors: ": "Author: "; + for (String author : listAuthors) { + txtAuthors+= " "+author +","; + } + txtAuthors = txtAuthors.substring(0,txtAuthors.length()-2); + String description = txtAuthors + ". ID Licenza: "+image.getLicenseID(); + json.put("title", new JSONString(image.getDidascalia())); + json.put("description", new JSONString(description)); + json.put("downloadURL", new JSONString(imageContent.getLink())); + jsonArray.set(index, json); + index++; + } + + } + showGallery(jsonArray.getJavaScriptObject(), galleryDivId); + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 19fa3f9..40a115e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; +import java.util.ArrayList; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; @@ -8,7 +9,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerSer import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow; import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.images.ThumbnailImageView; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; @@ -318,27 +319,28 @@ public class ConcessioneView extends Composite { } private void addUploadedImages() { + GWT.log("Managing immagini: "+concessioneDV.getImmaginiRappresentative()); List immagini = concessioneDV.getImmaginiRappresentative(); if (immagini != null && immagini.size() > 0) { imagesPanel.setVisible(true); - boolean addedImage = false; - imagesPanel.add(thumbNails); + + List immaginiToShow = new ArrayList(); + //SHOWING ONLY OPEN IMAGES OR IF THE USER IS LOGGED for (UploadedImageDV uploadedImageDV : immagini) { if(uploadedImageDV.getPolicy()==null || uploadedImageDV.getPolicy().equalsIgnoreCase("OPEN")) { - thumbNails.add(new ThumbnailImageView(uploadedImageDV, viewImageButtonVisible, openImageButtonVisible)); - addedImage = true; + immaginiToShow.add(uploadedImageDV); }else { if(myLogin!=null) { - thumbNails.add(new ThumbnailImageView(uploadedImageDV, viewImageButtonVisible, openImageButtonVisible)); - addedImage = true; + immaginiToShow.add(uploadedImageDV); } } - } - if(!addedImage) { - imagesPanel.remove(thumbNails); + if(immaginiToShow.size()>0) { + ImagesGallery gallery = new ImagesGallery(immaginiToShow); + imagesPanel.add(gallery.getGalleryPanel()); + gallery.fillGallery(); } } } diff --git a/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml b/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml index 6a5dd72..a673605 100644 --- a/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml @@ -11,8 +11,11 @@ - - + + + + diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 9eb0fc3..99a7645 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -230,4 +230,27 @@ body { .info-interaction .gwt-Label { font-weight: bold; padding-bottom: 5px; -} \ No newline at end of file +} + + + +/** NanoGallery2 **/ + +.nGY2Viewer { + background: rgba(4, 4, 4, .8) !important; +} + +.nGY2Viewer .toolbarBackground { + background: rgba(4, 4, 4, .8) !important; +} + + +.nGY2 .toolbar .ngbt { + font-size: 1em !important; + padding: 12px 12px !important; +} + +.nGY2 .toolbar .label .title { + font-size: .9em !important; + margin-bottom: 5px !important +} diff --git a/src/main/webapp/GeoportalDataViewer.html b/src/main/webapp/GeoportalDataViewer.html index 38a20f0..9eb5b3d 100644 --- a/src/main/webapp/GeoportalDataViewer.html +++ b/src/main/webapp/GeoportalDataViewer.html @@ -6,46 +6,56 @@ - - + + - - - - - - - - - - - Web Application Starter Project + + - - - - - - - + - - - - - - + + + + + + + +Web Application Starter Project - - + + + + + + + - - -
- + + + + + + + + + + + + +
+ diff --git a/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp index c2eb463..8e799df 100644 --- a/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp @@ -22,6 +22,10 @@ src="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/build/ol.js" type="text/javascript"> + + @@ -29,4 +33,5 @@ +
\ No newline at end of file