From e0f7c488012fc2857621fce6da850fab975cd794 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Fri, 3 Feb 2023 12:12:17 +0100 Subject: [PATCH 1/4] Implemented dynamic host finding --- .../{tools => common}/jquery-3.6.0.slim.min.js | 0 Frontend/assets/scripts/dyn_host.js | 8 ++++++++ Frontend/assets/scripts/tools/scripts.js | 2 +- Frontend/index.html | 14 +++++++++++--- 4 files changed, 20 insertions(+), 4 deletions(-) rename Frontend/assets/scripts/{tools => common}/jquery-3.6.0.slim.min.js (100%) create mode 100644 Frontend/assets/scripts/dyn_host.js diff --git a/Frontend/assets/scripts/tools/jquery-3.6.0.slim.min.js b/Frontend/assets/scripts/common/jquery-3.6.0.slim.min.js similarity index 100% rename from Frontend/assets/scripts/tools/jquery-3.6.0.slim.min.js rename to Frontend/assets/scripts/common/jquery-3.6.0.slim.min.js diff --git a/Frontend/assets/scripts/dyn_host.js b/Frontend/assets/scripts/dyn_host.js new file mode 100644 index 0000000..0a1110f --- /dev/null +++ b/Frontend/assets/scripts/dyn_host.js @@ -0,0 +1,8 @@ +$(document).ready( function() { + document.getElementsByName("iframe")[0].src = + window.location.protocol + "//" + window.location.hostname + ":8097"; + document.getElementById("rest-mock").href = + window.location.protocol + "//" + window.location.hostname + ":8097"; + console.log("DONE") +}); + \ No newline at end of file diff --git a/Frontend/assets/scripts/tools/scripts.js b/Frontend/assets/scripts/tools/scripts.js index f0ced97..23818b3 100644 --- a/Frontend/assets/scripts/tools/scripts.js +++ b/Frontend/assets/scripts/tools/scripts.js @@ -106,7 +106,7 @@ function performRequest(text, checkXML, checkTransform){ async function restRequest(text) { const escapeChar = "specialEscapeChar"; // const addr = "http://localhost:8081/" + text; - const addr = "http://tools.zipper.release11.com" + text; + const addr = window.location.protocol + "//" + window.location.hostname + ":8081/" + text; var xmlData = document.getElementById("xmlArea").value.trim(); var transformData = document.getElementById("transformArea").value.trim(); diff --git a/Frontend/index.html b/Frontend/index.html index 0bb9ddf..a5647f6 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -4,8 +4,12 @@ + + + - + + @@ -16,16 +20,20 @@
- +
+ + From c0f117a4afa8e71f16bdaf6e21f27a0b72eafb2c Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Fri, 3 Feb 2023 13:32:36 +0100 Subject: [PATCH 2/4] Updated .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ab3e096..4a86338 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ .vscode nbactions.xml target/ +__pycache__ +venv From 74f1f6f1c296bd3ad18c09ed790ee0f1792733e5 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Fri, 3 Feb 2023 14:45:39 +0100 Subject: [PATCH 3/4] Implemented dynamic host for links in mock.html --- .../src/main/resources/static/html/mock.html | 1 + .../src/main/resources/static/js/dyn_host.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Backend/mocked-services/src/main/resources/static/js/dyn_host.js diff --git a/Backend/mocked-services/src/main/resources/static/html/mock.html b/Backend/mocked-services/src/main/resources/static/html/mock.html index 79f52b4..f597720 100644 --- a/Backend/mocked-services/src/main/resources/static/html/mock.html +++ b/Backend/mocked-services/src/main/resources/static/html/mock.html @@ -8,6 +8,7 @@ +
diff --git a/Backend/mocked-services/src/main/resources/static/js/dyn_host.js b/Backend/mocked-services/src/main/resources/static/js/dyn_host.js new file mode 100644 index 0000000..14f19ae --- /dev/null +++ b/Backend/mocked-services/src/main/resources/static/js/dyn_host.js @@ -0,0 +1,25 @@ +// $(document).ready( function() { +// console.log("Here") +// let links = document.getElementsByTagName("link") +// for (let e in links) { +// let oldStr = links[e].href.split("/") +// console.log(oldStr) +// let endpoint = oldStr.slice(3).join() +// console.log(endpoint) +// e.href = window.location.protocol + "//" + window.location.hostname + "/" + endpoint +// } +// }); + +$(document).ready( function() { + console.log("Here") + let links = document.getElementsByTagName("link") + for (let i = 0; i < links.length; i++) { + let oldStr = links[i].href.split("/") + console.log(oldStr) + let endpoint = oldStr.slice(3).join("/") + console.log(endpoint) + links[i].href = window.location.protocol + "//" + window.location.hostname + ":8086/" + endpoint + } + +}); + From dd695a1c2dde541e938e7b7d276ea37ea233592d Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Fri, 3 Feb 2023 14:57:46 +0100 Subject: [PATCH 4/4] Removed unused code --- .../src/main/resources/static/js/dyn_host.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Backend/mocked-services/src/main/resources/static/js/dyn_host.js b/Backend/mocked-services/src/main/resources/static/js/dyn_host.js index 14f19ae..b13a6e1 100644 --- a/Backend/mocked-services/src/main/resources/static/js/dyn_host.js +++ b/Backend/mocked-services/src/main/resources/static/js/dyn_host.js @@ -1,23 +1,9 @@ -// $(document).ready( function() { -// console.log("Here") -// let links = document.getElementsByTagName("link") -// for (let e in links) { -// let oldStr = links[e].href.split("/") -// console.log(oldStr) -// let endpoint = oldStr.slice(3).join() -// console.log(endpoint) -// e.href = window.location.protocol + "//" + window.location.hostname + "/" + endpoint -// } -// }); - $(document).ready( function() { console.log("Here") let links = document.getElementsByTagName("link") for (let i = 0; i < links.length; i++) { let oldStr = links[i].href.split("/") - console.log(oldStr) let endpoint = oldStr.slice(3).join("/") - console.log(endpoint) links[i].href = window.location.protocol + "//" + window.location.hostname + ":8086/" + endpoint }