Skip to content

Commit

Permalink
Added embedded viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosjepard committed Nov 4, 2024
1 parent afe7750 commit 28d1d24
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,18 @@ public class ViewerConstants {
/**
* Template Engine
*/

public static final String OPEN_TEMPLATE_ENGINE = "{{";
public static final String CLOSE_TEMPLATE_ENGINE = "}}";
public static final String TEMPLATE_UV_LINK = "uv_link";
public static final String TEMPLATE_LOB_DOWNLOAD_LABEL = "download_label";
public static final String TEMPLATE_LOB_DOWNLOAD_LINK = "download_link";
public static final String TEMPLATE_LOB_ROW_INDEX = "row_index";
public static final String TEMPLATE_LOB_COLUMN_INDEX = "column_index";
public static final String TEMPLATE_LOB_AUTO_DETECTED_MIME_TYPE = "auto_detected_mime_type";
public static final String TEMPLATE_LOB_AUTO_DETECTED_EXTENSION = "auto_detected_extension";
public static final String DEFAULT_DOWNLOAD_LABEL_TEMPLATE = "<a href=\"" + ViewerConstants.OPEN_TEMPLATE_ENGINE
+ ViewerConstants.TEMPLATE_UV_LINK + ViewerConstants.CLOSE_TEMPLATE_ENGINE + ViewerConstants.OPEN_TEMPLATE_ENGINE
+ ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LINK + ViewerConstants.CLOSE_TEMPLATE_ENGINE + "\">"
+ ViewerConstants.OPEN_TEMPLATE_ENGINE + ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LABEL
+ ViewerConstants.CLOSE_TEMPLATE_ENGINE + "</a>";
Expand Down Expand Up @@ -569,4 +572,12 @@ public class ViewerConstants {
*/
private ViewerConstants() {
}

/**
* External viewer information
* //TODO PUT VALUES ON PROPERTIES FILE
*/

public static final String UV_EXTERNAL_VIEWER_ADDRESS = "uv/";
public static final String PRESENTATION_EXTERNAL_ADDRESS = "presentation/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,14 @@ public SafeHtml getValue(ViewerRow row) {
String template = configColumn.getSearchStatus().getList().getTemplate().getTemplate();
if (template != null && !template.isEmpty()) {
String json = JSOUtils.cellsToJson(cells, nestedTable);
GWT.log("json -> " + json);
String blob = getBlobKey(configColumn.getTypeName());
if (!blob.isEmpty() && json.contains(blob)) {
String tempTemplate = template.replace("{{" + blob + "}}", "");
tempTemplate = tempTemplate.replace("}{", "} {");
if (tempTemplate.isEmpty())
tempTemplate = messages.row_downloadLOB();
template = "<a href=\"" + com.google.gwt.core.client.GWT.getHostPageBaseURL() + "{{" + blob + "}}\">"
+
tempTemplate + "</a>";
+ tempTemplate + "</a>";
String s = JavascriptUtils.compileTemplate(template, json);
aggregationList.add(s);
}
Expand All @@ -320,7 +318,6 @@ public SafeHtml getValue(ViewerRow row) {
} else {
if (!aggregationList.isEmpty()) {
ret = SafeHtmlUtils.fromSafeConstant(aggregationList.get(0));
GWT.log("ret -> " + ret.asString());
}
}
}
Expand Down Expand Up @@ -432,6 +429,7 @@ private SafeHtml getLobDownload(ViewerDatabase database, ColumnStatus configColu
String template = configColumn.getSearchStatus().getList().getTemplate().getTemplate();
if (template != null && !template.isEmpty()) {
String json = JSOUtils.cellsToJson(ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LABEL, messages.row_downloadLOB(),
ViewerConstants.TEMPLATE_UV_LINK, RestUtils.createUVLob(),
ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LINK, RestUtils.createExportLobUri(database.getUuid(),
table.getSchemaName(), table.getName(), row.getUuid(), columnIndex));
return SafeHtmlUtils.fromSafeConstant(JavascriptUtils.compileTemplate(template, json));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.TreeMap;
import java.util.TreeSet;

import com.databasepreservation.common.client.models.structure.ViewerPrimaryKey;
import org.roda.core.data.v2.index.sublist.Sublist;

import com.databasepreservation.common.client.ClientConfigurationManager;
Expand Down Expand Up @@ -335,6 +334,7 @@ private void getCellHTML(ViewerColumn column, Set<Ref> relatedTo, Set<Ref> refer
String template = columnStatus.getDetailsStatus().getTemplateStatus().getTemplate();
if (template != null && !template.isEmpty()) {
String json = JSOUtils.cellsToJson(ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LABEL, messages.row_downloadLOB(),
ViewerConstants.TEMPLATE_UV_LINK, RestUtils.createUVLob(),
ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LINK, RestUtils.createExportLobUri(database.getUuid(),
table.getSchemaName(), table.getName(), row.getUuid(), columnStatus.getColumnIndex()));
safeHtml = SafeHtmlUtils.fromSafeConstant(JavascriptUtils.compileTemplate(template, json));
Expand All @@ -350,6 +350,7 @@ private void getCellHTML(ViewerColumn column, Set<Ref> relatedTo, Set<Ref> refer
String template = columnStatus.getDetailsStatus().getTemplateStatus().getTemplate();
if (template != null && !template.isEmpty()) {
String json = JSOUtils.cellsToJson(ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LABEL, messages.row_downloadLOB(),
ViewerConstants.TEMPLATE_UV_LINK, RestUtils.createUVLob(),
ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LINK, RestUtils.createExportLobUri(database.getUuid(),
table.getSchemaName(), table.getName(), row.getUuid(), columnStatus.getColumnIndex()));
safeHtml = SafeHtmlUtils.fromSafeConstant(JavascriptUtils.compileTemplate(template, json));
Expand Down Expand Up @@ -420,15 +421,12 @@ private void getNestedHTML(ColumnStatus columnStatus) {
null, false, new ArrayList<>());
CollectionService.Util.call((IndexResult<ViewerRow> result) -> {
if (result.getTotalCount() >= 1) {
GWT.log("count -> " +result.getTotalCount());
RowField rowField;
String json = JSOUtils.cellsToJson(result.getResults().get(0).getCells(), nestedTable);
String s = JavascriptUtils.compileTemplate(template, json);
if (columnStatus.getTypeName().contains("BINARY LARGE OBJECT")) {
String templateLob = "<a href=\"{{download_link}}\">{{download_label}}</a>";
GWT.log("collumn status ->" + columnStatus.toString());
int originalCollumnIndex = 0;
GWT.log("collumn status -> " + result.getResults().get(0).getCells());

//loop to find the original column index
for (Map.Entry<String, ViewerCell> entry : result.getResults().get(0).getCells().entrySet()) {
Expand All @@ -442,9 +440,8 @@ private void getNestedHTML(ColumnStatus columnStatus) {
rowField = RowField.createInstance(new Label(s).getText(), new HTML(messages.rowPanelTextForLobUnavailable()));
} else {
SafeHtml safeHtml = SafeHtmlUtils.EMPTY_SAFE_HTML;
GWT.log("uuid -> " + result.getResults().get(0).toString());
GWT.log("id -> " + columnStatus.getId());
json = JSOUtils.cellsToJson(ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LABEL, messages.row_downloadLOB(),
ViewerConstants.TEMPLATE_UV_LINK, RestUtils.createUVLob(),
ViewerConstants.TEMPLATE_LOB_DOWNLOAD_LINK, RestUtils.createExportLobUri(database.getUuid(),
nestedTable.getSchemaName(), nestedTable.getName(), result.getResults().get(0).getUuid(), originalCollumnIndex));
safeHtml = SafeHtmlUtils.fromSafeConstant(JavascriptUtils.compileTemplate(templateLob, json));
Expand All @@ -457,7 +454,6 @@ private void getNestedHTML(ColumnStatus columnStatus) {
}

rowField.addColumnDescription(columnStatus.getCustomDescription());
GWT.log("rowField -> " + rowField.toString());
panel.add(rowField);
}
}).findRows(database.getUuid(), database.getUuid(), nestedTable.getSchemaName(), nestedTable.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public static String createExportLobUri(String databaseUUID, String schemaName,
+ columnIndex;
}

public static String createUVLob() {
return ViewerConstants.UV_EXTERNAL_VIEWER_ADDRESS + "#?iiifManifestId=" + GWT.getHostPageBaseURL()
+ ViewerConstants.PRESENTATION_EXTERNAL_ADDRESS + "manifest?downloadLink=";

}

public static String createExportTableUri(String databaseUUID, String schemaName, String tableName,
FindRequest findRequest, String zipFilename, String filename, boolean descriptions, boolean lobs,
List<String> fieldsToHeader) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/com/databasepreservation/common/public/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3462,4 +3462,16 @@ rgba(0, 0, 0, .125);
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}

/************************************************
* Universal embedded viewer
************************************************/

.embedded-viewer {
height: 1000px;
width: 1000px;
display: inline-block;
vertical-align: top;
margin-left: -6%;
}
7 changes: 7 additions & 0 deletions src/main/resources/config/dbvtk-viewer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,10 @@ ui.lists.DatabaseList_all.search.selectedInfo.label.default.i18n=lists.label.Dat
# Show schema name in reference table
##############################################
ui.reference.table.show.schema.name=true

###############################################
# Universal Viewer and presentation addresses
// change TO READ CORRECTLY
#ui.universalViewer.address=http://localhost/uv/
#ui.presentation.address=http://localhost/presentation/

0 comments on commit 28d1d24

Please sign in to comment.