2023 All rights reserved
diff --git a/js/ds.js b/js/ds.js
index e33dbc4..3373e3b 100644
--- a/js/ds.js
+++ b/js/ds.js
@@ -7,6 +7,7 @@ import * as resmap from './resmap.js';
const DataSpace = {};
DataSpace.BASE_URL = 'http://dataspace.ispc.cnr.it';
+DataSpace.FE_URL = `${DataSpace.BASE_URL}/custome-fe`;
DataSpace.RES_ENDPOINT = '/resources/';
DataSpace.FILES_URI = `${DataSpace.BASE_URL}/files/uploadedfiles/`;
// TODO maybe these assignments are non needed?
@@ -78,7 +79,7 @@ DataSpace.renderReport = async function (report, archesJson, images)
let resType = resKeys[0].split(' ')[0];
if (!resKeys.length || ! (resType in this.RESOURCE_REPORT)) {
- location.href = '/404.html';
+ location.href = `${this.FE_URL}/404.html`;
return;
}
@@ -121,10 +122,10 @@ DataSpace.renderReport = async function (report, archesJson, images)
const container = document.querySelector('#analysis');
container.classList.remove('d-hide');
const report = await this.fetchReport(
- this.getRelatedAnalysisId(archesJson)
+ this.getRelatedAnalysisId(archesJson)
);
- container.innerHTML += this.renderAnalysisReport(
+ container.innerHTML += await this.renderAnalysisReport(
report.resource,
report.displayname
);
@@ -137,15 +138,16 @@ DataSpace.renderReport = async function (report, archesJson, images)
*
* @returns {string} HTML
*/
-DataSpace.renderAnalysisReport = function (resource, type)
+DataSpace.renderAnalysisReport = async function (resource, type)
{
const shape = this.createShape(resource, 'Analysis');
let html = `
-
-
${type}
+
+
+
${type.replace(/(\w+\s\w+).*$/,"$1")}
`;
- let table = '
';
+ let table = '';
for (const key in shape.get('before-gallery')) {
table += `
@@ -156,34 +158,56 @@ DataSpace.renderAnalysisReport = function (resource, type)
table += ' |
';
html += table + '';
+ html += `
+
+
Photos
+
+ `;
const photos = resource['Analysis Photos'];
for (const key in photos) {
if (photos[key] !== '') {
+ const imgUrl = await this.fetchFileUrl(photos[key]);
html += `
-
-
Photos
-
${key.replace('Analysis Photos', '')}
+
+
${key.replace('Analysis Photos', '')}
+
+

+
+
`;
- console.warn(photos[key], key);
}
}
-
return html;
}
+/**
+ * @todo Generic fetch...
+ * @param {string} uri
+ * @returns {string}
+ */
+DataSpace.fetchFileUrl = async function (uri)
+{
+ return await fetch(
+ `${this.BASE_URL}${uri}`
+ ).then(res => res.url)
+ .catch(excep => {
+ _fetchError(excep, 'error');
+ document.querySelector('.modal').classList.remove('active');
+ });
+}
/**
* Fetch JSON report...
* @param {string} uuid The resource's UUID in Arches
* @param {string} format Either 'json' or 'arches-json'
*
- * @return {object}
+ * @returns {object}
*/
DataSpace.fetchReport = async function (uuid, format='json')
{
return await fetch(
- `${this.BASE_URL}${this.RES_ENDPOINT}${uuid}?format=${format}`
+ `${this.BASE_URL}${this.RES_ENDPOINT}${uuid}?format=${format}`
)
.then(res => res.json())
.catch(excep => {