fixed entityHTMLMessage

This commit is contained in:
Francesco Mangiacrapa 2024-04-22 15:12:37 +02:00
parent 9203782e49
commit c868c36f78
1 changed files with 7 additions and 13 deletions

View File

@ -13,6 +13,7 @@ public class HTML_Page {
public static String entityHTMLMessage(String action, String message, boolean waiting, String viewPdfURL) {
String newHTML = "<html>\n"
+ "\n"
+ " <head>\n"
+ " <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n"
+ " <style>\n"
@ -48,18 +49,17 @@ public class HTML_Page {
+ " <script type=\"text/javascript\">\n"
+ " async function fetchPDF_URL() {\n"
+ " try {\n"
+ "\n"
+ " const response = await fetch('"+viewPdfURL+"');\n"
+ " console.log(\"polling response\");\n"
+ " return response.json();\n"
+ " } catch (error) {\n"
+ " console.error(\"polling errro: \" + error);\n"
+ " console.error(\"polling error: \" + error);\n"
+ " }\n"
+ " }\n"
+ " async function playPDFPoll() {\n"
+ " const response_object = await fetchPDF_URL();\n"
+ " console.log(\"response is: \" + response_object);\n"
+ " let isJsonResponse = isJsonString(response_object);\n"
+ " if (isJsonResponse) {\n"
+ " try {\n"
+ " console.log(\"json response \" + response_object);\n"
+ " if (response_object.state === \"OK\") {\n"
+ " if (!(response_object.url === null || response_object.url === undefined)) {\n"
@ -72,8 +72,9 @@ public class HTML_Page {
+ " } else {\n"
+ " showError(response_object.messagge);\n"
+ " }\n"
+ " } else {\n"
+ " } catch (error) {\n"
+ " console.log(\"no json response \" + response_object);\n"
+ " console.log(\"error \" + error);\n"
+ " showError(\"Error when exporting PDF :-(\");\n"
+ " }\n"
+ "\n"
@ -84,17 +85,10 @@ public class HTML_Page {
+ " inner_div.innerHTML = error_msg;\n"
+ " }\n"
+ "\n"
+ " function isJsonString(str) {\n"
+ " try {\n"
+ " JSON.parse(str);\n"
+ " } catch (e) {\n"
+ " return false;\n"
+ " }\n"
+ " return true;\n"
+ " }\n"
+ " </script>\n"
+ " <title>D4Science Geoportal - Action</title>\n"
+ " </head>\n"
+ "\n"
+ " <body onload=\"playPDFPoll()\">";
newHTML += "<img alt=\"D4Science Logo\" src=\"https://services.d4science.org/image/layout_set_logo?img_id=32727\"><br />";