mirror of
https://github.com/OpenBankProject/API-Explorer.git
synced 2026-02-06 10:47:23 +00:00
Simpler formatting
This commit is contained in:
parent
c9b80a708b
commit
6df91ddef8
@ -81,12 +81,22 @@ class LiveDocs extends Loggable {
|
||||
logger.info(s"requestUrl is $requestUrl")
|
||||
logger.info(s"resourceId is $resourceId")
|
||||
|
||||
|
||||
// Create json object from input string
|
||||
val jsonObject = JsonParser.parse(requestBody).asInstanceOf[JObject]
|
||||
// Call the url with optional body and put the response into the appropriate result div
|
||||
SetHtml("result_" + resourceId, Text(getResponse(apiVersion, requestUrl, requestVerb, jsonObject))) &
|
||||
|
||||
val target = "result_" + resourceId
|
||||
val command : String = s"DOLLAR_SIGN('#$target').each(function(i, block) { hljs.highlightBlock(block);});".replace("DOLLAR_SIGN","$")
|
||||
|
||||
logger.info(s"command is $command")
|
||||
|
||||
|
||||
SetHtml(target, Text(getResponse(apiVersion, requestUrl, requestVerb, jsonObject))) &
|
||||
// This applies json highlighting to the json
|
||||
Run ("$('pre code').each(function(i, block) { hljs.highlightBlock(block);});")
|
||||
// val command : String = "$('pre code').each(function(i, block) { hljs.highlightBlock(block);});"
|
||||
//Run ("$('pre code').each(function(i, block) { hljs.highlightBlock(block);});")
|
||||
Run (command)
|
||||
}
|
||||
|
||||
|
||||
@ -142,14 +152,13 @@ class LiveDocs extends Loggable {
|
||||
// replace the node identified by the class "resource" with the following
|
||||
// This creates the list of resources in the DOM
|
||||
".resource" #> resources.map { i =>
|
||||
".resource_verb" #> i.verb &
|
||||
".resource_url" #> i.url &
|
||||
//".resource_verb" #> i.verb &
|
||||
//".resource_url" #> i.url &
|
||||
".resource_description" #> i.description &
|
||||
".resource_representation" #> "JSON" &
|
||||
".resource_url_td [id]" #> s"resource_url_td_${i.id}" & // Probably don't need this now
|
||||
".resource_verb_td [id]" #> s"resource_verb_td_${i.id}" & // Probably don't need this now
|
||||
".url_caller [id]" #> s"url_caller_${i.id}" &
|
||||
".try_me_button [onclick]" #> s"$$(DOUBLE-QUOTE#url_caller_${i.id}DOUBLE-QUOTE).fadeToggle();".replaceAll("DOUBLE-QUOTE",""""""") &
|
||||
// ".try_me_button [onclick]" #> s"$$(DOUBLE-QUOTE#url_caller_${i.id}DOUBLE-QUOTE).fadeToggle();".replaceAll("DOUBLE-QUOTE",""""""") &
|
||||
".result [id]" #> s"result_${i.id}" &
|
||||
"@request_body [id]" #> s"request_body_${i.id}" &
|
||||
"@request_body [style]" #> s"display: ${displayBody(i.verb)};" &
|
||||
@ -162,13 +171,12 @@ class LiveDocs extends Loggable {
|
||||
// Extraction.decompose creates json representation of JObject.
|
||||
"@request_body_input" #> text(pretty(render(i.request_body)), s => requestBody = s, "type" -> "text") &
|
||||
// We're not using the id at the moment
|
||||
"@request_verb_input" #> text(i.verb, s => requestVerb = s, "type" -> "text", "id" -> s"request_verb_input_${i.id}") &
|
||||
"@resource_id_input" #> text(i.id.toString, s => resourceId = s, "type" -> "text", "id" -> s"resource_id_input_${i.id}") &
|
||||
"@request_verb_input" #> text(i.verb, s => requestVerb = s, "type" -> "hidden", "id" -> s"request_verb_input_${i.id}") &
|
||||
"@resource_id_input" #> text(i.id.toString, s => resourceId = s, "type" -> "hidden", "id" -> s"resource_id_input_${i.id}") &
|
||||
// Replace the type=submit with Javascript that makes the ajax call.
|
||||
// ".call_button" #> ajaxSubmit("Call", process(i.id, apiVersion, i.url, i.verb,"{}"))
|
||||
//".call_button" #> ajaxSubmit("Call", process(123, "apiVersion", "i.url", "i.verb","{}"))
|
||||
".call_button" #> ajaxSubmit("Call", process)
|
||||
// def process(resourceId: String, apiVersion : String, requestUrl: String, requestVerb: String, requestBody: String = "{}"): JsCmd = {
|
||||
// The button. First argument is the text of the button (GET, POST etc). Second argument is function to call. Arguments to the func could be sent in third argument
|
||||
"@response_body [id]" #> s"response_body_${i.id}" &
|
||||
".call_button" #> ajaxSubmit(i.verb, process)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,52 +14,33 @@
|
||||
<!-- Multiple instances of this row are generated in LiveDocs.scala -->
|
||||
<!-- Note: id's are added so we can manipulate individual elements -->
|
||||
<tr class="resource">
|
||||
<td>
|
||||
<table>
|
||||
<tr class="resource_row">
|
||||
<!-- GET, POST etc -->
|
||||
<td class="resource_verb_td"><span class="resource_verb"></span></td>
|
||||
<!-- The URL -->
|
||||
<td class="resource_url_td"><span class="resource_url"></span></td>
|
||||
<!-- Some documentation -->
|
||||
<td><span class="resource_description"></span></td>
|
||||
<!-- JSON -->
|
||||
<td><span class="resource_representation"></span></td>
|
||||
<!-- Button that shows the execute form. It's onclick property is set in LiveDocs.scala -->
|
||||
<td><input class="try_me_button" type="submit" value="Try Me" onclick="alert('i will be replaced');" /> </td>
|
||||
</tr>
|
||||
<!-- Some documentation -->
|
||||
<td><span class="resource_description"></span></td>
|
||||
<td>
|
||||
|
||||
<!-- This section starts hidden and is shown with the Try Me button -->
|
||||
<tr class="url_caller" style="display: block;">
|
||||
<td colspan="5">
|
||||
<form class="lift:form.ajax">
|
||||
<div class="xxxlift:LiveDocs">
|
||||
<!-- Attributes for these fields are replaced -->
|
||||
<input name="resource_id_input">
|
||||
<input name="request_verb_input" placeholder="GET or POST etc.">
|
||||
<!-- The url_to_call is populated at render (but it can be edited manually) -->
|
||||
<input name="request_url_input" placeholder="OBP URL to call">
|
||||
<form class="lift:form.ajax">
|
||||
<!-- Attributes for these fields are replaced -->
|
||||
<input type="hidden" name="resource_id_input">
|
||||
<input type="hidden" name="request_verb_input" placeholder="GET or POST etc.">
|
||||
<!-- The url_to_call is populated at render (but it can be edited manually) -->
|
||||
<input type="hidden" name="request_url_input" placeholder="OBP URL to call">
|
||||
|
||||
<div name="request_body" style="display: block;">
|
||||
<input name="request_body_input" placeholder="JSON body to POST">
|
||||
</div>
|
||||
<div name="request_body" style="display: block;">
|
||||
<input name="request_body_input" placeholder="JSON body to POST">
|
||||
</div>
|
||||
|
||||
<input name="test_input" placeholder="Test input">
|
||||
<!-- This submit button is also modified by LiveDocs.scala -->
|
||||
<input class="call_button" type="submit">
|
||||
</form>
|
||||
|
||||
<!-- API call result goes here It is highlighted by javascript called from the submit button -->
|
||||
<pre>
|
||||
<code class="result json" id="result" name="response_body">
|
||||
</code>
|
||||
</pre>
|
||||
</td>
|
||||
|
||||
<!-- This submit button is also modified by LiveDocs.scala -->
|
||||
<input class="call_button" type="submit">
|
||||
</div>
|
||||
</form>
|
||||
<!-- API call result goes here It is highlighted by javascript called from the submit button -->
|
||||
<pre>
|
||||
<code class="result json" id="result">
|
||||
</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user