Analysis report draft
This commit is contained in:
parent
dc497a44bd
commit
e7b5eb67d4
18
css/ds.css
18
css/ds.css
@ -1,5 +1,9 @@
|
|||||||
@import '../vendor/fontawesome-free/css/all.css';
|
@import '../vendor/fontawesome-free/css/all.css';
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--ispc-blue: #213B55;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
@ -51,6 +55,20 @@ td ul {
|
|||||||
.mt-2 {
|
.mt-2 {
|
||||||
margin-top: 2rem !important;
|
margin-top: 2rem !important;
|
||||||
}
|
}
|
||||||
|
.blue-bg {
|
||||||
|
background-color: var(--ispc-blue) !important;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
color: #fff;
|
||||||
|
background-color: var(--ispc-blue);
|
||||||
|
border-color: var(--ispc-blue);
|
||||||
|
}
|
||||||
|
.btn:hover {
|
||||||
|
color: #fff;
|
||||||
|
background-color: var(--ispc-blue);
|
||||||
|
opacity: 0.7;
|
||||||
|
border-color: var(--ispc-blue);
|
||||||
|
}
|
||||||
table.table td,
|
table.table td,
|
||||||
table.table th {
|
table.table th {
|
||||||
border: none;
|
border: none;
|
||||||
|
72
js/ds.js
72
js/ds.js
@ -14,6 +14,7 @@ DataSpace.RESOURCE_REPORT = {
|
|||||||
'Object' : resmap.OBJECT_REPORT,
|
'Object' : resmap.OBJECT_REPORT,
|
||||||
'Context' : resmap.CONTEXT_REPORT,
|
'Context' : resmap.CONTEXT_REPORT,
|
||||||
'Sample' : resmap.SAMPLE_REPORT,
|
'Sample' : resmap.SAMPLE_REPORT,
|
||||||
|
'Analysis' : resmap.ANALYSIS_REPORT,
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Populate partial objects from
|
* Populate partial objects from
|
||||||
@ -70,7 +71,7 @@ DataSpace.createShape = function (resource, resType) {
|
|||||||
*
|
*
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
DataSpace.renderReport = function (report, archesJson, images)
|
DataSpace.renderReport = async function (report, archesJson, images)
|
||||||
{
|
{
|
||||||
let resource = report.resource;
|
let resource = report.resource;
|
||||||
let resKeys = Object.keys(resource);
|
let resKeys = Object.keys(resource);
|
||||||
@ -82,14 +83,6 @@ DataSpace.renderReport = function (report, archesJson, images)
|
|||||||
|
|
||||||
let resType = resKeys[0].split(' ')[0];
|
let resType = resKeys[0].split(' ')[0];
|
||||||
|
|
||||||
if (resType === 'Sample') {
|
|
||||||
const container = document.querySelector('#analysis');
|
|
||||||
container.classList.remove('d-hide');
|
|
||||||
// TODO handle click on "View Analysis"
|
|
||||||
container.querySelector('button').onclick = () => {
|
|
||||||
console.log(this.getRelatedAnalysisId(archesJson));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (['Object', 'Context'].includes(resType)) {
|
if (['Object', 'Context'].includes(resType)) {
|
||||||
const geoJSON = JSON.parse(
|
const geoJSON = JSON.parse(
|
||||||
@ -125,6 +118,62 @@ DataSpace.renderReport = function (report, archesJson, images)
|
|||||||
|
|
||||||
// Create after-gallery...
|
// Create after-gallery...
|
||||||
_createReportTail(resType, shape, resource);
|
_createReportTail(resType, shape, resource);
|
||||||
|
|
||||||
|
if (resType === 'Sample') {
|
||||||
|
const container = document.querySelector('#analysis');
|
||||||
|
container.classList.remove('d-hide');
|
||||||
|
const report = await this.fetchReport(
|
||||||
|
this.getRelatedAnalysisId(archesJson)
|
||||||
|
);
|
||||||
|
|
||||||
|
container.innerHTML += this.renderAnalysisReport(
|
||||||
|
report.resource,
|
||||||
|
report.displayname
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Create Analysis report
|
||||||
|
* @param {string} uuid The analysis resource's UUID
|
||||||
|
* @param {string} type The analysis displayname
|
||||||
|
*
|
||||||
|
* @returns {string} HTML
|
||||||
|
*/
|
||||||
|
DataSpace.renderAnalysisReport = function (resource, type)
|
||||||
|
{
|
||||||
|
const shape = this.createShape(resource, 'Analysis');
|
||||||
|
let html = `
|
||||||
|
<div class="column col-12 mt-2">
|
||||||
|
<h3 class="p-2 text-center">${type}</h3>
|
||||||
|
`;
|
||||||
|
|
||||||
|
let table = '<table class="table table-hover">';
|
||||||
|
|
||||||
|
for (const key in shape.get('before-gallery')) {
|
||||||
|
table += `<tr><td class="text-bold key">
|
||||||
|
${key.replace('Analysis', '')}</td>
|
||||||
|
<td>${resource[key]}</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
table += '</table>';
|
||||||
|
html += table + '</div>';
|
||||||
|
|
||||||
|
const photos = resource['Analysis Photos'];
|
||||||
|
|
||||||
|
for (const key in photos) {
|
||||||
|
if (photos[key] !== '') {
|
||||||
|
html += `
|
||||||
|
<div class="column col-12 mt-2 pl-2">
|
||||||
|
<h4 class="pl-2">Photos</h4>
|
||||||
|
<p class="mt-2 text-bold pl-2">${key.replace('Analysis Photos', '')}</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
console.warn(photos[key], key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fetch JSON report...
|
* Fetch JSON report...
|
||||||
@ -136,13 +185,12 @@ DataSpace.renderReport = function (report, archesJson, images)
|
|||||||
DataSpace.fetchReport = async function (uuid, format='json')
|
DataSpace.fetchReport = async function (uuid, format='json')
|
||||||
{
|
{
|
||||||
return await fetch(
|
return await fetch(
|
||||||
`${this.BASE_URL}${this.RES_ENDPOINT}${uuid}?format=${format}&indent=2`
|
`${this.BASE_URL}${this.RES_ENDPOINT}${uuid}?format=${format}`
|
||||||
)
|
)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.catch(excep => {
|
.catch(excep => {
|
||||||
_fetchError(excep, 'error');
|
_fetchError(excep, 'error');
|
||||||
document.querySelector('.modal')
|
document.querySelector('.modal').classList.remove('active');
|
||||||
.classList.remove('active');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
22
js/resmap.js
22
js/resmap.js
@ -87,23 +87,21 @@ ANALYSIS_REPORT.set(
|
|||||||
ANALYSIS_REPORT.set(
|
ANALYSIS_REPORT.set(
|
||||||
'gallery',
|
'gallery',
|
||||||
{
|
{
|
||||||
"Analysis Photos" : null,
|
"Analysis Photos" : {
|
||||||
/*
|
"Analysis Photos Microscopy" : null,
|
||||||
"Analysis Photos Microscopy" : null,
|
"Analysis Photos SEM EDS" : null,
|
||||||
"Analysis Photos SEM EDS" : null,
|
"Analysis Photos Microscopic" : null,
|
||||||
"Analysis Photos Microscopic" : null,
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ANALYSIS_REPORT.set(
|
ANALYSIS_REPORT.set(
|
||||||
'after-gallery',
|
'after-gallery',
|
||||||
{
|
{
|
||||||
"Analysis Spectrum" : null
|
"Analysis Spectrum" : {
|
||||||
/*
|
"Spectrum Raw Data" : null,
|
||||||
"Spectrum Raw Data" : null,
|
"Spectrum Technique" : null,
|
||||||
"Spectrum Technique" : null,
|
"Spectrum Interpreted Data" : null,
|
||||||
"Spectrum Interpreted Data" : null,
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -62,11 +62,6 @@
|
|||||||
<div class="columns mt-2" id="res-after">
|
<div class="columns mt-2" id="res-after">
|
||||||
</div>
|
</div>
|
||||||
<div id="analysis" class="d-hide columns mt-2 mb-2 pb-2">
|
<div id="analysis" class="d-hide columns mt-2 mb-2 pb-2">
|
||||||
<div class="column col-12 text-center">
|
|
||||||
<button class="btn btn-primary btn-lg">
|
|
||||||
View Analysis
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
Loading…
Reference in New Issue
Block a user