first release for testing of #19600

This commit is contained in:
Francesco Mangiacrapa 2020-07-14 15:43:41 +02:00
parent 239810f194
commit ad937c9f13
5 changed files with 87 additions and 40 deletions

View File

@ -6,6 +6,7 @@ import java.util.Map;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer; import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel; import org.gcube.portlets.user.workspace.client.model.FileModel;
@ -29,6 +30,7 @@ import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
@ -37,6 +39,7 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -83,7 +86,7 @@ public class DialogGetInfoBootstrap extends Composite {
HorizontalPanel hpHeaderDetails; HorizontalPanel hpHeaderDetails;
@UiField @UiField
HorizontalPanel hpImagePreview; HTMLPanel htmlPanelImagePreview;
@UiField @UiField
HTML txtName; HTML txtName;
@ -139,6 +142,9 @@ public class DialogGetInfoBootstrap extends Composite {
@UiField @UiField
Button buttonUpdateGcubeProperties; Button buttonUpdateGcubeProperties;
@UiField
Button buttonUpdateShare;
@UiField @UiField
ControlGroup cgSharedWith; ControlGroup cgSharedWith;
@ -146,6 +152,11 @@ public class DialogGetInfoBootstrap extends Composite {
HTML txtSharedWith; HTML txtSharedWith;
private FileModel fileModel; private FileModel fileModel;
private Command onCloseCommand;
private DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd MMM yyyy, hh:mm aaa");
/* /*
* textAreaSharedWith = new TextArea(); private Html htmlUsersWidget = new * textAreaSharedWith = new TextArea(); private Html htmlUsersWidget = new
@ -164,6 +175,7 @@ public class DialogGetInfoBootstrap extends Composite {
public DialogGetInfoBootstrap(final FileModel fileModel, final Command onCloseCommand) { public DialogGetInfoBootstrap(final FileModel fileModel, final Command onCloseCommand) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.fileModel = fileModel; this.fileModel = fileModel;
this.onCloseCommand = onCloseCommand;
hpHeaderDetails.add(new HTML("Details")); hpHeaderDetails.add(new HTML("Details"));
@ -243,7 +255,7 @@ public class DialogGetInfoBootstrap extends Composite {
if(fileModel instanceof FileGridModel) { if(fileModel instanceof FileGridModel) {
FileGridModel fileGridModel = ((FileGridModel) fileModel); FileGridModel fileGridModel = ((FileGridModel) fileModel);
//last update //last update
htmlSetValue(txtLastMofication, fileGridModel.getLastModification().toString()); htmlSetValue(txtLastMofication, dateFormatter.format(fileGridModel.getLastModification()));
//size //size
htmlSetValue(txtSize, getFormattedSize(fileGridModel.getSize())); htmlSetValue(txtSize, getFormattedSize(fileGridModel.getSize()));
}else { }else {
@ -319,6 +331,15 @@ public class DialogGetInfoBootstrap extends Composite {
editProperties.setProperties(gCubeProperties); editProperties.setProperties(gCubeProperties);
} }
}); });
buttonUpdateShare.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
AppControllerExplorer.getEventBus().fireEvent(new CreateSharedFolderEvent(fileModel, fileModel.getParentFileModel(),false));
onCloseCommand.execute();
}
});
} }
/** /**
@ -439,11 +460,11 @@ public class DialogGetInfoBootstrap extends Composite {
} }
@Override @Override
public void onSuccess(Date result) { public void onSuccess(Date dateResult) {
removePlaceHolder(txtCreated); removePlaceHolder(txtCreated);
if (result != null) if (dateResult != null) {
htmlSetValue(txtCreated, result.toString()); htmlSetValue(txtCreated, dateFormatter.format(dateResult));
else }else
htmlSetValue(txtCreated, null); htmlSetValue(txtCreated, null);
} }
@ -467,11 +488,11 @@ public class DialogGetInfoBootstrap extends Composite {
} }
@Override @Override
public void onSuccess(Date result) { public void onSuccess(Date dateResult) {
removePlaceHolder(txtLastMofication); removePlaceHolder(txtLastMofication);
if (result != null) if (dateResult != null) {
htmlSetValue(txtLastMofication, result.toString()); htmlSetValue(txtLastMofication, dateFormatter.format(dateResult));
else }else
htmlSetValue(txtLastMofication, null); htmlSetValue(txtLastMofication, null);
} }
@ -580,9 +601,9 @@ public class DialogGetInfoBootstrap extends Composite {
*/ */
private void loadThumbnailsForImage() { private void loadThumbnailsForImage() {
hpImagePreview.setVisible(true); htmlPanelImagePreview.setVisible(true);
final HTML txtLoadingPreview = new HTML(); final HTML txtLoadingPreview = new HTML();
hpImagePreview.add(txtLoadingPreview); htmlPanelImagePreview.add(txtLoadingPreview);
setPlaceholder(txtLoadingPreview, "loading preview..."); setPlaceholder(txtLoadingPreview, "loading preview...");
AppControllerExplorer.rpcWorkspaceService.getImageById(fileModel.getIdentifier(), AppControllerExplorer.rpcWorkspaceService.getImageById(fileModel.getIdentifier(),
@ -597,18 +618,18 @@ public class DialogGetInfoBootstrap extends Composite {
@Override @Override
public void onSuccess(GWTWorkspaceItem item) { public void onSuccess(GWTWorkspaceItem item) {
removePlaceHolder(txtLoadingPreview);
GWT.log("Image loaded: " + item.getName() + " label: " + item.getLabel() + " type: " GWT.log("Image loaded: " + item.getName() + " label: " + item.getLabel() + " type: "
+ fileModel.getGXTFolderItemType()); + fileModel.getGXTFolderItemType());
if (fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT)) { if (fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT)) {
GWTImageDocument theItemImage = (GWTImageDocument) item; GWTImageDocument theItemImage = (GWTImageDocument) item;
hpImagePreview.add(new Image(theItemImage.getThumbnailUrl())); htmlPanelImagePreview.add(new Image(theItemImage.getThumbnailUrl()));
hpImagePreview.setVisible(true); htmlPanelImagePreview.setVisible(true);
}else { }else {
GWTExternalImage theExternalImage = (GWTExternalImage) item; GWTExternalImage theExternalImage = (GWTExternalImage) item;
hpImagePreview.add(new Image(theExternalImage.getThumbnailUrl())); htmlPanelImagePreview.add(new Image(theExternalImage.getThumbnailUrl()));
hpImagePreview.setVisible(true); htmlPanelImagePreview.setVisible(true);
} }
removePlaceHolder(txtLoadingPreview);
} }
}); });
} }

View File

@ -14,9 +14,9 @@
<g:HorizontalPanel ui:field="hpItemType" <g:HorizontalPanel ui:field="hpItemType"
addStyleNames="item-type-style"> addStyleNames="item-type-style">
</g:HorizontalPanel> </g:HorizontalPanel>
<g:HorizontalPanel ui:field="hpImagePreview" <g:HTMLPanel ui:field="htmlPanelImagePreview"
visible="false"> visible="false" addStyleNames="preview-image-style">
</g:HorizontalPanel> </g:HTMLPanel>
<b:Form type="HORIZONTAL"> <b:Form type="HORIZONTAL">
<b:Alert ui:field="actionAlert" close="false" type="INFO" <b:Alert ui:field="actionAlert" close="false" type="INFO"
visible="false"> visible="false">
@ -81,9 +81,9 @@
<b:TextArea ui:field="txtAreaDescription" <b:TextArea ui:field="txtAreaDescription"
readOnly="true"> readOnly="true">
</b:TextArea> </b:TextArea>
<b:Tooltip trigger="MANUAL" text="Update description"> <b:Tooltip text="Update the Description">
<b:Button icon="PENCIL" <b:Button icon="PENCIL"
ui:field="buttonUpdateDescription" type="PRIMARY"></b:Button> ui:field="buttonUpdateDescription" type="LINK">Edit</b:Button>
</b:Tooltip> </b:Tooltip>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
@ -95,10 +95,9 @@
<b:TextArea ui:field="txtAreaGcubeProperties" <b:TextArea ui:field="txtAreaGcubeProperties"
readOnly="true"> readOnly="true">
</b:TextArea> </b:TextArea>
<b:Tooltip trigger="MANUAL" <b:Tooltip text="Update the Gcube Properties">
text="Update Gcube Properties">
<b:Button icon="PENCIL" <b:Button icon="PENCIL"
ui:field="buttonUpdateGcubeProperties" type="PRIMARY"></b:Button> ui:field="buttonUpdateGcubeProperties" type="LINK">Edit</b:Button>
</b:Tooltip> </b:Tooltip>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
@ -150,10 +149,13 @@
<b:Controls> <b:Controls>
<g:HTML ui:field="txtSharedWith"> <g:HTML ui:field="txtSharedWith">
</g:HTML> </g:HTML>
<b:Tooltip text="Go to Share">
<b:Button icon="USER"
ui:field="buttonUpdateShare" type="LINK">Share</b:Button>
</b:Tooltip>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:Alert close="false" ui:field="errorAlert" type="ERROR" <b:Alert close="false" ui:field="errorAlert" type="ERROR"
visible="false"></b:Alert> visible="false"></b:Alert>
</b:Fieldset> </b:Fieldset>

View File

@ -303,7 +303,7 @@ table.userssuggest th {
} }
.my-control-group-get-info { .my-control-group-get-info {
margin-bottom: 10px !important; margin-bottom: 5px !important;
font-size: 14px !important; font-size: 14px !important;
font-family: Arial, serif; font-family: Arial, serif;
color: #222; color: #222;
@ -328,6 +328,7 @@ table.userssuggest th {
.my-control-group-get-info .gwt-HTML { .my-control-group-get-info .gwt-HTML {
padding-top: 5px; padding-top: 5px;
font-family: Roboto, Arial, serif !important; font-family: Roboto, Arial, serif !important;
overflow-wrap: break-word;
} }
.my-control-group-get-info .gwt-TextBox:hover { .my-control-group-get-info .gwt-TextBox:hover {
@ -335,12 +336,17 @@ table.userssuggest th {
} }
.my-control-group-get-info .gwt-TextArea { .my-control-group-get-info .gwt-TextArea {
width: 250px; width: 260px;
min-height: 60px;
height: 60px; height: 60px;
} }
.my-control-group-get-info .btn-link {
margin-left: 7px !important;
}
.item-type-style { .item-type-style {
margin-top: 10px; margin-top: 1px;
margin-left: 10px; margin-left: 10px;
margin-bottom: 10px; margin-bottom: 10px;
padding-top: 5px; padding-top: 5px;
@ -362,7 +368,9 @@ table.userssuggest th {
} }
.item-details-header { .item-details-header {
margin: 15px; margin-top: 15px;
margin-left: 15px;
margin-right: 15px;
} }
.item-details-header td { .item-details-header td {
@ -390,3 +398,14 @@ table.userssuggest th {
display: inline-block !important; display: inline-block !important;
} }
.preview-image-style {
width: 95%;
display: flex;
align-items: center;
justify-content: center;
}
.preview-image-style img {
max-width: 400px;
}

View File

@ -145,17 +145,21 @@ public class ImageServlet extends HttpServlet{
try{ try{
streamDescr = wa.getThumbnailData(image.getId()); streamDescr = wa.getThumbnailData(image.getId());
logger.debug("Thumbnail data has size: "+streamDescr.getSize());
/*TODO //CHECKING IF THE STREAM IS A VALID IMAGE
* UNCOMMENT THIS IF YOU WANT TO ADD MORE CONTROLS /* TODO
ReusableInputStream ris = new ReusableInputStream(streamDescr.getStream()); * ReusableInputStream ris = new ReusableInputStream(streamDescr.getStream());
boolean isAvalidImage = isAnImage(ris, image.getName()); boolean isAvalidImage = isAnImage(ris, image.getName());
if(!isAvalidImage) if(!isAvalidImage) {
//CREATING THE THUMBNAIL //CREATING THE THUMBNAIL
logger.debug("the stream seems not be a valid image, creating the thumbnail");
streamDescr = createThumbnailForImage(wa, image); streamDescr = createThumbnailForImage(wa, image);
else { }else {
//ASSIGNING THE REUSABLE STREAM //ASSIGNING THE REUSABLE STREAM
streamDescr = new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(ris, image.getName(), null, image.getMimeType()); logger.debug("using reusable stream");
size = streamDescr.getSize()==null?0:streamDescr.getSize();
logger.debug("ReusableInputStream has size: "+size);
streamDescr = new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(ris, image.getName(), size, streamDescr.getMimeType());
}*/ }*/
@ -186,8 +190,9 @@ public class ImageServlet extends HttpServlet{
resp.setContentType(mimeType); resp.setContentType(mimeType);
//if image/thumbnail size is 0, skipping setContentLength //if image/thumbnail size is 0, skipping setContentLength
if(size!=0) //AVOIDING TO SET IT, SOME CASES THE SIZE MISMATCH
resp.setContentLength((int)size); // if(size!=0)
// resp.setContentLength((int)size);
InputStream in = streamDescr.getStream(); InputStream in = streamDescr.getStream();

View File

@ -136,7 +136,7 @@ public class ThumbnailGenerator {
extension = extension.startsWith(".") ? extension : "." + extension; extension = extension.startsWith(".") ? extension : "." + extension;
final File tempFile = File.createTempFile(filename, extension); final File tempFile = File.createTempFile(filename, extension);
//tempFile.deleteOnExit(); tempFile.deleteOnExit();
try (FileOutputStream out = new FileOutputStream(tempFile)) { try (FileOutputStream out = new FileOutputStream(tempFile)) {
IOUtils.copy(in, out); IOUtils.copy(in, out);
} }