updated HTML_Page response

This commit is contained in:
Francesco Mangiacrapa 2024-04-22 10:58:23 +02:00
parent 30a02fe94f
commit 933efabb3f
1 changed files with 39 additions and 16 deletions

View File

@ -2,7 +2,6 @@ package org.gcube.datatransfer.resolver.geoportal.exporter;
public class HTML_Page {
/**
* Sets the HTML message.
*
@ -49,21 +48,44 @@ public class HTML_Page {
+ " </style>\n"
+ " <script type=\"text/javascript\">\n"
+ " async function fetchPDF_URL() {\n"
+ " const response = await fetch('"+viewPdfURL+"');\n"
+ " console.log(\"polling response\");\n"
+ " return response.json();\n"
+ " }\n"
+ " async function playPDFPoll() {\n"
+ " const pdf_json = await fetchPDF_URL();\n"
+ " console.log(\"response \"+pdf_json);\n"
+ " if (!(pdf_json.url === null || pdf_json.url === undefined)) {\n"
+ " window.location.replace(pdf_json.url);\n"
+ " } else {\n"
+ " setTimeout(() => {\n"
+ " playPDFPoll();\n"
+ " }, 1000);\n"
+ " }\n"
+ " try {\n"
+ "\n"
+ " const response = await fetch('https://data.dev.d4science.org/geoportal/view/profiledConcessioni_661d2c6f8804530afb90b132_1713774501389');\n"
+ " console.log(\"polling response\");\n"
+ " return response.json();\n"
+ " } catch (error) {\n"
+ " cconsole.error(\"polling errro: \" + error);\n"
+ " }\n"
+ " }\n"
+ " async function playPDFPoll() {\n"
+ " const response_object = await fetchPDF_URL();\n"
+ " isJsonresponse = isJsonString(response_object);\n"
+ " if (isJsonResponse) {\n"
+ " console.log(\"json response \" + response_object);\n"
+ " if (!(response_object.url === null || response_object.url === undefined)) {\n"
+ " window.location.replace(response_object.url);\n"
+ " } else {\n"
+ " setTimeout(() => {\n"
+ " playPDFPoll();\n"
+ " }, 1000);\n"
+ " }\n"
+ " } else {\n"
+ " console.log(\"no json response \" + response_object);\n"
+ " let inner_div = document.getElementById(\"inner-content\");\n"
+ " inner_div.innerHTML = response_object;\n"
+ " }\n"
+ "\n"
+ " }\n"
+ "\n"
+ " function isJsonString(str) {\n"
+ " try {\n"
+ " JSON.parse(str);\n"
+ " } catch (e) {\n"
+ " return false;\n"
+ " }\n"
+ " return true;\n"
+ " }\n"
+ "\n"
+ " </script>\n"
+ " <title>D4Science Geoportal - Action</title>\n"
+ " </head>\n"
@ -74,6 +96,7 @@ public class HTML_Page {
newHTML += "<div id=\"content\">";
newHTML += "<p id=\"title-geo\">Geoportal</p><br />";
newHTML += "<div id=\"inner-content\">";
newHTML += "<p style=\"font-size: 18px;\">" + action + "</p>";
if (waiting) {
@ -81,7 +104,7 @@ public class HTML_Page {
}
newHTML += "<br/><p id=\"message\">" + message + "</p>";
newHTML += "</div></body></html>";
newHTML += "</div></div></body></html>";
return newHTML;
}