diff --git a/js/ds.js b/js/ds.js index 6547cc0..e485d00 100644 --- a/js/ds.js +++ b/js/ds.js @@ -89,11 +89,13 @@ DataSpace.createObjectShape = function(resource) { */ DataSpace.fetchReport = async function(uuid, format='json') { - // TODO Errors!! const jsonRep = await fetch(`${this.BASE_URL}${this.RES_ENDPOINT}${uuid}?format=${format}&indent=2`) .then(res => res.json()) - .catch(); + .catch(excep => { + _createError(excep, 'error') + document.querySelector('.modal').classList.remove('active'); + }); return jsonRep; } @@ -161,6 +163,19 @@ DataSpace.getImagesSrc = function(resource) { return fileNames; } +function _createError(message, htmlId) +{ + const error = document.createElement('div'); + const clear = document.createElement('button'); + error.className = 'toast toast-error'; + clear.className = 'btn btn-clear float-right'; + + error.appendChild(clear); + error.textContent = message; + + document.querySelector(`#${htmlId}`).appendChild(error); +} + export default DataSpace; /** * Fetch file blob (CORS...) diff --git a/report/index.html b/report/index.html index bbe0e34..54e9067 100644 --- a/report/index.html +++ b/report/index.html @@ -34,6 +34,7 @@
+