Merge pull request #224 from constantine2nd/develop

gitCommit bugfix
This commit is contained in:
Simon Redfern 2023-09-15 15:50:34 +02:00 committed by GitHub
commit 3c0f915548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 18 deletions

View File

@ -477,10 +477,10 @@ WIP to add comments on resource docs. This code copied from Sofit.
val requestHeader = customRequestHeader.trim.isEmpty match {
case true => Nil
case false =>
customRequestHeader.split("::").map(_.trim).map {
customRequestHeader.split(":::").map(_.trim).map {
i =>
val key = i.split(":").toList.head
val value = i.split(":").toList.reverse.head
val key = i.split("::").toList.head
val value = i.split("::").toList.reverse.head
Header(key, value)
}.toList
}
@ -1908,13 +1908,18 @@ WIP to add comments on resource docs. This code copied from Sofit.
/*
Return the git commit. If we can't for some reason (not a git root etc) then log and return ""
*/
def gitCommit : String = {
lazy val gitCommit : String = {
val commit = try {
val properties = new java.util.Properties()
logger.debug("Before getResourceAsStream git.properties")
properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"))
logger.debug("Before get Property git.commit.id")
properties.getProperty("git.commit.id", "")
val stream = getClass().getClassLoader().getResourceAsStream("git.properties")
try {
properties.load(stream)
logger.debug("Before get Property git.commit.id")
properties.getProperty("git.commit.id", "")
} finally {
stream.close()
}
} catch {
case e : Throwable => {
logger.warn("gitCommit says: Could not return git commit. Does resources/git.properties exist?")

View File

@ -385,7 +385,7 @@
<div name="example_request_header" id="example_request_header" style="display: block;">
<!-- It is populated at render (but it can be edited manually) -->
<input type="text" name="request_header_input" class="default-input" placeholder="Request Header (Header1:Value1::Header2:Value2)">
<input type="text" name="request_header_input" class="default-input" placeholder="Request Header (Header1::Value1:::Header2::Value2)">
</div>
<div name="example_request_body" id="example_request_body" style="display: block;">
<input name="example_request_body_input" class="default-input" placeholder="JSON body to POST or PUT">

View File

@ -274,12 +274,15 @@ function filterMessageDocs(element) {
// when we press a copy icon in top left corner.
// In case that action is successful the icon is changed for a 2 seconds in order to notify a user about it.
function copyJsonResultToClipboard(element) {
var id = String(element.id).replace('result_copy_icon_','result_');
var id = String(element.id).replace("result_copy_icon_", "result_");
var r = document.createRange();
r.selectNode(document.getElementById(id));
window.getSelection().removeAllRanges();
window.getSelection().addRange(r);
document.execCommand('copy');
navigator.clipboard.writeText(window.getSelection().toString()).then(
() => console.log("clipboard successfully set"),
() => console.log("clipboard write failed")
);
window.getSelection().removeAllRanges();
// Store original values
var titleText = document.getElementById(element.id).title;
@ -287,25 +290,25 @@ function copyJsonResultToClipboard(element) {
// and then change hey
document.getElementById(element.id).title = "";
document.getElementById(element.id).className = "fa-regular fa-copy";
// Below code is GUI related i.e. to notify a user that text is copied to clipboard
// --------------------------------------------------------------------------------
// It delays the call by ms milliseconds
function defer(f, ms) {
return function() {
return function () {
setTimeout(() => f.apply(this, arguments), ms);
};
}
// Function which revert icon and text to the initial state.
function revertTextAndClass(titleText, iconClass) {
document.getElementById(element.id).title = titleText;
document.getElementById(element.id).className = iconClass
document.getElementById(element.id).className = iconClass;
}
var revertTextAndClassDeferred = defer(revertTextAndClass, 2000);
// Revert the original values of text and icon after 2 seconds
revertTextAndClassDeferred(titleText, iconClass);
revertTextAndClassDeferred(titleText, iconClass);
}