Update report view style
This commit is contained in:
BIN
js/.ds.js.swp
Normal file
BIN
js/.ds.js.swp
Normal file
Binary file not shown.
7
js/ds.js
7
js/ds.js
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
export const BASE_URL = 'http://150.145.56.132';
|
||||
export const BASE_URL = 'http://dataspace.ispc.cnr.it';
|
||||
const RES_ENDPOINT = '/resources/';
|
||||
|
||||
/**
|
||||
@@ -57,6 +57,9 @@ export async function fetchReport(uuid)
|
||||
// Arbitrary slice...
|
||||
return jsonRep;
|
||||
}
|
||||
export function printReport() {
|
||||
document.querySelector('#print').onclick = window.print();
|
||||
}
|
||||
/**
|
||||
* Fetch file blob (CORS...)
|
||||
* @todo
|
||||
@@ -69,4 +72,4 @@ export async function fetchReport(uuid)
|
||||
/**
|
||||
* Query report links to determine
|
||||
* resource instance type...
|
||||
*/
|
||||
*/
|
||||
|
||||
8
js/object.json
Normal file
8
js/object.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Object M.P. Report",
|
||||
"component": "reports/object",
|
||||
"defaultconfig": {},
|
||||
"description": "Custom report for the Marmora Phrygiae Object Model.",
|
||||
"componentname": "object",
|
||||
"templateid": "e4e8d54f-c666-193c-1404-ab4ee0204b13"
|
||||
}
|
||||
BIN
js/views/.report.js.swp
Normal file
BIN
js/views/.report.js.swp
Normal file
Binary file not shown.
@@ -2,14 +2,20 @@
|
||||
|
||||
import {
|
||||
fetchReport,
|
||||
printReport,
|
||||
} from "../ds.js";
|
||||
|
||||
document.addEventListener('readystatechange', async () => {
|
||||
const report = await fetchReport(location.search.replace("?id=", ''));
|
||||
const resKeys = Object.keys(report.resource);
|
||||
const resource = report.resource;
|
||||
|
||||
document.querySelector('#print').addEventListener('click', () => {
|
||||
window.print();
|
||||
});
|
||||
|
||||
let resKeys = Object.keys(resource);
|
||||
// Default value...
|
||||
let resType = 'Object';
|
||||
|
||||
// TODO
|
||||
if (!resKeys.length) {
|
||||
location.href = '/404.html';
|
||||
@@ -17,6 +23,8 @@ document.addEventListener('readystatechange', async () => {
|
||||
}
|
||||
|
||||
resType = resKeys[0].split(' ')[0];
|
||||
const coordinates = resource['Coordinates'];
|
||||
resKeys = resKeys.filter(e => !e.includes('Coordinates'));
|
||||
|
||||
document.querySelector('#rep-tit')
|
||||
.innerText = `${resType} ${report.displayname}`;
|
||||
@@ -25,7 +33,6 @@ document.addEventListener('readystatechange', async () => {
|
||||
// TODO manage files and nested objects
|
||||
for (const key of resKeys) {
|
||||
const row = document.createElement('tr');
|
||||
let rowspan = '';
|
||||
let innerList = null;
|
||||
|
||||
// TODO refactor
|
||||
@@ -33,9 +40,7 @@ document.addEventListener('readystatechange', async () => {
|
||||
const boolValue = '@value' in report.resource[key];
|
||||
innerList = document.createElement('ul');
|
||||
|
||||
if (!boolValue) {
|
||||
rowspan = Object.keys(report.resource[key]).length;
|
||||
|
||||
if (! boolValue) {
|
||||
for (const k in report.resource[key]) {
|
||||
const li = document.createElement('li');
|
||||
li.innerHTML =
|
||||
@@ -52,16 +57,14 @@ document.addEventListener('readystatechange', async () => {
|
||||
}
|
||||
|
||||
// TODO Pop coordinates before traversing the object
|
||||
if (!key.includes('Coordinates')) {
|
||||
let value = innerList !== null ?
|
||||
innerList.outerHTML : report.resource[key];
|
||||
let value = innerList !== null ?
|
||||
innerList.outerHTML : report.resource[key];
|
||||
|
||||
row.innerHTML = `
|
||||
<td class="text-bold key">${key.replace(resType, '')}</td>
|
||||
<td>${value}</td>
|
||||
`;
|
||||
}
|
||||
row.innerHTML = `
|
||||
<td class="text-bold key">${key.replace(resType, '')}</td>
|
||||
<td>${value}</td>
|
||||
`;
|
||||
|
||||
repTable.appendChild(row);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user