From beb9ecb29b2f6bc8dc32d44b256cc4ee963fb730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Thu, 23 Mar 2023 14:01:22 +0100 Subject: [PATCH] Restructure JS module --- js/ds.js | 115 ++-------------------------------------------- js/resmap.js | 67 +++++++++++++++++++++++++++ report/index.html | 2 +- 3 files changed, 72 insertions(+), 112 deletions(-) create mode 100644 js/resmap.js diff --git a/js/ds.js b/js/ds.js index d82c899..2d0fdc2 100644 --- a/js/ds.js +++ b/js/ds.js @@ -1,5 +1,6 @@ 'use strict'; const MAPBOX_TOKEN = 'pk.eyJ1Ijoibmljb3BhIiwiYSI6ImNsZmNiZGN0ZTJzbGgzdG8xYnZxOXRvd28ifQ.nvK1VYF6lwPpA094cL83KQ'; +import * as resmap from './resmap.js'; /** * @namespace DataSpace */ @@ -8,116 +9,14 @@ const DataSpace = {}; DataSpace.BASE_URL = 'http://dataspace.ispc.cnr.it'; DataSpace.RES_ENDPOINT = '/resources/'; DataSpace.FILES_URI = `${DataSpace.BASE_URL}/files/uploadedfiles/`; -DataSpace.OBJECT_ORDER = { - "Object Type" : null, - "Object ID" : null, - "Object Excavation code" : null, - "Object Chronology" : null, - "Object Era" : null, - "Object Geographical Context of Discovery" : null, - "Object Dimensions" : null, - "Object Material" : null, - "Object Description" : null, - "Object Conservation State" : null, - "Object Reused?" : null, - "Object Project" : null, - "Object Compiler" : null, - "Object Bibliography" : null, -}; -DataSpace.CONTEXT_ORDER = { - "Context Name" : null, - "Context Typology" : null, - "Context Chronology" : null, - "Context Era" : null, - "Context Surface" : null, - "Context Square meters" : null, - "Context Quality of the marble used/extracted" : null, - "Context Description" : null, - "Context Traces of extraction tools" : null, - "Context Amount of debris (cm3)" : null, - "Context Presence of unfinished materials" : null, - "Context Collections for the lifting machine" : null, - "Context Current status" : null, - "Context Streets of contention" : null, - "Context Project" : null, - "Context Compiler" : null, - "Context Bibliography" : null, -}; -const OBJECT_REPORT = new Map(); -OBJECT_REPORT.set( - 'before-gallery', - { - "Object Type" : null, - "Object ID" : null, - "Object Excavation code" : null, - "Object Chronology" : null, - "Object Era" : null, - "Object Geographical Context of Discovery" : null, - "Object Dimensions" : null, - "Object Material" : null, - } -); -OBJECT_REPORT.set( - 'after-gallery-1-col', - { - "Object Description" : null, - "Object Conservation State" : null, - } -); -OBJECT_REPORT.set( - 'after-gallery-2-col', - { - "Object Reused?" : null, - "Object Project" : null, - "Object Compiler" : null, - "Object Bibliography" : null, - } -); -const CONTEXT_REPORT = new Map(); -CONTEXT_REPORT.set( - 'before-gallery', - { - "Context Name" : null, - "Context Typology" : null, - "Context Chronology" : null, - "Context Era" : null, - "Context Surface" : null, - "Context Square meters" : null, - "Context Quality of the marble used/extracted" : null, - "Context Quantity of extracted material (cm3)" : null, - "Context Traces of extraction tools" : null, - "Context Amount of debris (cm3)" : null, - "Context Presence of unfinished materials" : null, - "Context Collections for the lifting machine" : null, - "Context Current status" : null, - "Context Streets of contention" : null - } -); -CONTEXT_REPORT.set( - 'after-gallery-1-col', - { - "Context Description" : null, - } -); -CONTEXT_REPORT.set( - 'after-gallery-2-col', - { - - "Context Project" : null, - "Context Compiler" : null, - "Context Bibliography" : null, - } -); -DataSpace.OBJECT_REPORT = OBJECT_REPORT; -DataSpace.CONTEXT_REPORT = CONTEXT_REPORT; +// TODO maybe these assignments are non needed? DataSpace.RESOURCE_REPORT = { - 'Object' : DataSpace.OBJECT_REPORT, - 'Context' : DataSpace.CONTEXT_REPORT, + 'Object' : resmap.OBJECT_REPORT, + 'Context' : resmap.CONTEXT_REPORT, }; /** * Populate partial objects from * resource object based on Map - * @todo * @param {object} resource * @param {string} resType * @@ -182,12 +81,6 @@ DataSpace.renderReport = function (report, images) let resType = resKeys[0].split(' ')[0]; - const reportOrder = { - 'Object' : this.OBJECT_ORDER, - 'Context' : this.CONTEXT_ORDER, - }; - - resource = Object.assign(reportOrder[resType], resource); const geoJSON = JSON.parse( resource[`${resType} Coordinates`] .replaceAll('\'', '"') diff --git a/js/resmap.js b/js/resmap.js new file mode 100644 index 0000000..5f5e08c --- /dev/null +++ b/js/resmap.js @@ -0,0 +1,67 @@ +const OBJECT_REPORT = new Map(); +OBJECT_REPORT.set( + 'before-gallery', + { + "Object Type" : null, + "Object ID" : null, + "Object Excavation code" : null, + "Object Chronology" : null, + "Object Era" : null, + "Object Geographical Context of Discovery" : null, + "Object Dimensions" : null, + "Object Material" : null, + } +); +OBJECT_REPORT.set( + 'after-gallery-1-col', + { + "Object Description" : null, + "Object Conservation State" : null, + } +); +OBJECT_REPORT.set( + 'after-gallery-2-col', + { + "Object Reused?" : null, + "Object Project" : null, + "Object Compiler" : null, + "Object Bibliography" : null, + } +); +const CONTEXT_REPORT = new Map(); +CONTEXT_REPORT.set( + 'before-gallery', + { + "Context Name" : null, + "Context Typology" : null, + "Context Chronology" : null, + "Context Era" : null, + "Context Surface" : null, + "Context Square meters" : null, + "Context Quality of the marble used/extracted" : null, + "Context Quantity of extracted material (cm3)" : null, + "Context Traces of extraction tools" : null, + "Context Amount of debris (cm3)" : null, + "Context Presence of unfinished materials" : null, + "Context Collections for the lifting machine" : null, + "Context Current status" : null, + "Context Streets of contention" : null + } +); +CONTEXT_REPORT.set( + 'after-gallery-1-col', + { + "Context Description" : null, + } +); +CONTEXT_REPORT.set( + 'after-gallery-2-col', + { + + "Context Project" : null, + "Context Compiler" : null, + "Context Bibliography" : null, + } +); + +export {OBJECT_REPORT, CONTEXT_REPORT}; diff --git a/report/index.html b/report/index.html index 8528a52..176a073 100644 --- a/report/index.html +++ b/report/index.html @@ -98,7 +98,7 @@
- +
2023 All rights reserved