Improved ImageGallery. LayerSectionViewer, ProjectViewer etc.

This commit is contained in:
Francesco Mangiacrapa 2022-11-11 16:30:20 +01:00
parent 6ab7c60643
commit 430d28ce03
11 changed files with 117 additions and 229 deletions

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -27,7 +30,10 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.0.0-SNAPSHOT">
@ -55,7 +61,10 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -83,7 +92,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -111,7 +123,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -139,7 +154,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -167,7 +185,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
@ -195,7 +216,10 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -223,7 +247,10 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -251,7 +278,10 @@
</wb-module>

View File

@ -7,6 +7,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.in
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
@ -147,24 +148,36 @@ public class ImagesSectionGallery {
JSONValue meta = JSONParser.parseStrict(subdoc.getMetadataAsJSON());
for (FilesetDV image : subdoc.getListImages()) {
if (image.getListPayload() != null) {
for (PayloadDV payloadDV : image.getListPayload()) {
JSONObject json = new JSONObject();
json.put("src", new JSONString(payloadDV.getLink()));
json.put("srct", new JSONString(payloadDV.getLink()));
json.put("downloadURL", new JSONString(payloadDV.getLink()));
json.put("title", new JSONString(getFirstValueOfJSON(meta)));
json.put("description", new JSONString(meta.toString()));
jsonArray.set(index, json);
index++;
}
try {
if (image.getListPayload() != null) {
for (PayloadDV payloadDV : image.getListPayload()) {
JSONObject json = new JSONObject();
json.put("src", new JSONString(payloadDV.getLink()));
json.put("srct", new JSONString(payloadDV.getLink()));
json.put("downloadURL", new JSONString(payloadDV.getLink()));
try {
json.put("title", new JSONString(getFirstValueOfJSON(meta)));
} catch (Exception e) {
GWT.log("Error on reading the title from: " + meta);
json.put("title", new JSONString(meta.toString()));
}
json.put("description", new JSONString(meta.toString()));
jsonArray.set(jsonArray.size(), json);
index++;
}
}
} catch (Exception e) {
GWT.log("Error on adding the image to gallery from: " + image);
}
}
}
showGallery(jsonArray.getJavaScriptObject(), galleryDivId);
if(jsonArray.size()>0) {
showGallery(jsonArray.getJavaScriptObject(), galleryDivId);
}
}
/**

View File

@ -12,8 +12,10 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.P
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.DropdownButton;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
@ -98,16 +100,30 @@ public class LayersSectionViewer extends Composite {
GWT.log("mapServerHost: " + mapServerHost);
BBOXDV bbox = layer.getBbox();
GWT.log("bbox: " + bbox);
GWT.log("bbox keys: " + bbox.keySet());
GWT.log("bbox values: " + bbox.values());
GWT.log("minX: " + bbox.getMinX());
GWT.log("minY: " + bbox.getMinY());
GWT.log("maxX: " + bbox.getMaxX());
GWT.log("maxY: " + bbox.getMaxY());
BoundsMap bounds = new BoundsMap(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY(), "");
GWT.log("bounds: " + bounds);
mapView.addWMSLayer(mapServerHost, layerName, bounds);
if(bbox!=null) {
if(!GWT.isProdMode()) {
GWT.log("bbox: " + bbox);
// GWT.log("bbox keys: " + bbox.keySet());
// GWT.log("bbox values: " + bbox.values());
GWT.log("minX: " + bbox.getMinX());
GWT.log("minY: " + bbox.getMinY());
GWT.log("maxX: " + bbox.getMaxX());
GWT.log("maxY: " + bbox.getMaxY());
}
BoundsMap bounds = new BoundsMap(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY(), "");
GWT.log("bounds: " + bounds);
mapView.addWMSLayer(mapServerHost, layerName, bounds);
}else {
Alert alert = new Alert();
alert.setType(AlertType.ERROR);
alert.setText("No BBOX found for this layer");
alert.setClose(false);
layerPanel.add(alert);
}
String htmlLinkId = mapView.getPanelMapElementId() + "-image-download";
@ -156,14 +172,6 @@ public class LayersSectionViewer extends Composite {
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
layerPanel.add(new HTML(table));
}
// mapViewPanel.add(exportMapButton);
// customTable.addNextKeyValue("Abstract", layerDV.getAbstractSection());
// customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita());
// customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati());
// customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione());
// customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR);
// layerPanel.add(customTable);
}
public static native void exportPDF(String layerURL) /*-{

View File

@ -190,6 +190,8 @@ public class ProjectViewer extends Composite {
applicationBus.fireEvent(new AddLayerToMapEvent(theProjectView.getTheProjectDV()));
}
});
setAddLayersToMapVisible(false);
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
@ -210,6 +212,11 @@ public class ProjectViewer extends Composite {
SectionViewer sectionViewer = new SectionViewer(sectionView);
pageViewDetails.add(sectionViewer);
}
if(sectionView.hasSpatialLayers()) {
setAddLayersToMapVisible(true);
}
}
}

View File

@ -1,166 +0,0 @@
//package org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery;
//
//import java.util.List;
//
//import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
//import org.gcube.application.geoportalcommon.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 ImagesSectionGallery.
// *
// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
// *
// * Jul 21, 2021
// */
//public class ImagesGallery {
//
// private HTMLPanel galleryPanel;
// private List<UploadedImageDV> 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 : '<i class="fa fa-long-arrow-right" aria-hidden="true"></i> 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 !important',
// background : '#ffffff !important',
// titleShadow : 'none !important',
// titleColor : '#696969 !important',
// labelBackground : '#f3f3f3 !important'
// },
// 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<UploadedImageDV> immagini) {
// this.galleryDivId = "nanogallery"+Random.nextInt()+Random.nextInt();
// this.galleryPanel = new HTMLPanel("<div id='"+galleryDivId+"'></div>");
// 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) {
// if(image.getListWsContent()!=null) {
// for (WorkspaceContentDV imageContent : image.getListWsContent()) {
// JSONObject json = new JSONObject();
// json.put("src", new JSONString(imageContent.getLink()));
// json.put("srct", new JSONString(imageContent.getLink()));
// List<String> 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);
// }
//}

View File

@ -889,6 +889,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
}
LOG.info("returning project view for id: " + projectView.getTheProjectDV().getId());
return projectView;

View File

@ -490,9 +490,10 @@ public class Geoportal_JSON_Mapper {
String jsonPath = null;
try {
jsonPath = String.format("%s.%s", JSON_$_POINTER, _BBOX);
BBOXDV bbox = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath, BBOXDV.class);
gsdiLayer.setBbox(bbox);
LOG.debug(_BBOX + " is: " + bbox);
HashMap<String, Object> bbox = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath, HashMap.class);
BBOXDV bboxDV = new BBOXDV(bbox);
gsdiLayer.setBbox(bboxDV);
LOG.debug(_BBOX + " is: " + bboxDV);
} catch (Exception e) {
LOG.warn(jsonPath + " error: ", e);
}
@ -500,7 +501,7 @@ public class Geoportal_JSON_Mapper {
jsonPath = String.format("%s.%s", JSON_$_POINTER, _OGC_LINKS);
String jsonString = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath).toString();
Gson gson = new Gson();
HashMap map = gson.fromJson(jsonString, HashMap.class);
HashMap<String, String> map = gson.fromJson(jsonString, HashMap.class);
gsdiLayer.setOgcLinks(map);
LOG.debug(_OGC_LINKS + " are: " + map);
} catch (Exception e) {

View File

@ -624,18 +624,6 @@ body {
RESPONSIVE
***/
@media all and (max-width: 1919px) {
.details-panel {
width: 400px;
}
}
@media all and (max-width: 1919px) {
.inner-toolbar {
width: 100px;
}
}
@media all and (max-width: 2350px) {
#timeline-data {
width: 700px;
@ -643,12 +631,16 @@ RESPONSIVE
}
}
@media all and (max-width: 1700px) {
@media all and (max-width: 2048px) {
#timeline-data {
width: 400px;
left: 210px;
width: 600px;
left: 310px;
bottom: 50px
}
.details-panel {
width: 600px;
}
}
@media all and (max-width: 1024px) {
@ -657,8 +649,14 @@ RESPONSIVE
left: 140px;
bottom: 50px
}
.details-panel {
width: 400px;
}
.search-facility {
width: 250px;
max-width: 300px;
}
.inner-toolbar {
width: 100px;
}
}

View File

@ -5,7 +5,6 @@ import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.junit.Test;
public class GNABaseMaps {

View File

@ -25,8 +25,6 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.Geoportal_JSON_Mapper;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
/**
* The Class GeoportalViewer_Tests.

View File

@ -4,7 +4,6 @@ import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.IAMClientCredentialsReader;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientCredentials;
import org.junit.Test;
public class IAMClient {