Show original script as well, still need to add revert/switch version functionality
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
{{ render_partial('dashboard/http_functions/header.html', title='Try', user_id=user_id, function_id=function_id,
|
||||
name=name,
|
||||
show_refresh=False, show_link=False, show_edit_form=True, show_client=True, show_logs=True) }}
|
||||
show_refresh=False, show_link=False, show_edit_form=True, show_client=True, show_logs=True, show_history=True) }}
|
||||
|
||||
<div class="mx-auto w-full pt-4" id="client-u{{ user_id }}-f{{ function_id }}">
|
||||
</div>
|
||||
@@ -70,6 +70,20 @@ show_refresh=False, show_link=False, show_edit_form=True, show_client=True, show
|
||||
}
|
||||
}
|
||||
|
||||
var TabContent = (activeTab, queryParams, hearders, body) => {
|
||||
var tabMappings = {
|
||||
'Query Params': m(KeyValueList, { list: this.queryParams }),
|
||||
'Headers': m(KeyValueList, { list: this.headers }),
|
||||
'Body': m("textarea", {
|
||||
oninput: (e) => this.body = e.target.value,
|
||||
value: this.body,
|
||||
rows: 4,
|
||||
class: "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300"
|
||||
})
|
||||
}
|
||||
return tabMappings[this.activeTab];
|
||||
}
|
||||
|
||||
var RequestClient = {
|
||||
// Initialize component state
|
||||
init: function () {
|
||||
@@ -155,10 +169,15 @@ show_refresh=False, show_link=False, show_edit_form=True, show_client=True, show
|
||||
m("div", [
|
||||
// Tab headers
|
||||
m("ul.flex.mt-5.border.border-gray-300.rounded-t-lg", [
|
||||
[{ name: "Query Params", count: this.queryParams.filter(p => p.key && p.value).length }, { name: "Headers", count: this.headers.filter(p => p.key && p.value).length }, { name: "Body", count: null }].map(({ name, count }, index) => m("li.mr-3.py-2.px-4.border-orange-400.focus:outline-none.hover:text-orange-500.cursor-pointer", {
|
||||
class: this.activeTab === name ? "border-b-2 text-orange-600" : "",
|
||||
onclick: () => this.activeTab = name
|
||||
}, `${name}${count ? ` (${count})` : ``}`))
|
||||
[
|
||||
{ name: "Query Params", count: this.queryParams.filter(p => p.key && p.value).length },
|
||||
{ name: "Headers", count: this.headers.filter(p => p.key && p.value).length },
|
||||
{ name: "Body", count: null }
|
||||
].map(({ name, count }, index) =>
|
||||
m("li.mr-3.py-2.px-4.border-orange-400.focus:outline-none.hover:text-orange-500.cursor-pointer", {
|
||||
class: this.activeTab === name ? "border-b-2 text-orange-600" : "",
|
||||
onclick: () => this.activeTab = name
|
||||
}, `${name}${count ? ` (${count})` : ``}`))
|
||||
]),
|
||||
// Tab content
|
||||
this.activeTab === 'Query Params' ? m(KeyValueList, { list: this.queryParams }) : '',
|
||||
|
||||
@@ -123,6 +123,18 @@ show_edit_form=True) }}
|
||||
</div>
|
||||
<!-- End Right Content -->
|
||||
</div>
|
||||
|
||||
<div id="diff_1_editor" class="relative rounded-lg shadow-lg p-4 text-opacity-0">{{ original_script }}</div>
|
||||
<script>
|
||||
var editor = ace.edit("diff_1_editor");
|
||||
editor.setOptions({
|
||||
maxLines: 100
|
||||
});
|
||||
editor.setTheme("ace/theme/github_dark");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
|
||||
editor.session.$worker.send("changeOptions", [{ asi: true }]);
|
||||
</script>
|
||||
<!-- End Item -->
|
||||
{% else %}
|
||||
|
||||
@@ -159,7 +171,23 @@ show_edit_form=True) }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- End Right Content -->
|
||||
|
||||
</div>
|
||||
|
||||
<div id="diff_1_editor" class="relative rounded-lg shadow-lg p-4 text-opacity-0">{{ original_script }}</div>
|
||||
<script>
|
||||
var editor = ace.edit("diff_1_editor");
|
||||
editor.setOptions({
|
||||
maxLines: 100,
|
||||
readOnly: true, // Disable editing
|
||||
highlightActiveLine: false, // Optionally, disable highlighting the active line
|
||||
highlightGutterLine: false // Optionally, disable highlighting the gutter line
|
||||
});
|
||||
editor.setTheme("ace/theme/github_dark");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
|
||||
</script>
|
||||
|
||||
<!-- End Item -->
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user