Fix issue where on page refresh when on function edit/new sub pages you would be redirected back to dashboard
This commit is contained in:
@@ -89,7 +89,9 @@
|
||||
</a>
|
||||
</header>
|
||||
<main class="flex flex-1 flex-col gap-4 p-4 md:p-6" data-id="50" id="container">
|
||||
{% block page %}
|
||||
{{ render_partial('dashboard/http_functions/overview.html', http_functions=http_functions) }}
|
||||
{% endblock %}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{% extends 'base.html' %}
|
||||
{% extends 'dashboard.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% block page %}
|
||||
|
||||
{{ render_partial('dashboard/http_functions/header.html', title='Try', user_id=user_id, name=name,
|
||||
{{ 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) }}
|
||||
|
||||
<div class="mx-auto w-full pt-4">
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
{{ render_partial('dashboard/http_functions/header.html', title='Update', user_id=user_id, name=name,
|
||||
refresh_url=url_for('get_http_function_edit_form', name=name), show_logs=True, show_client=True) }}
|
||||
{% extends 'dashboard.html' %}
|
||||
|
||||
{{ render_partial('function_editor.html', name=name, script=script, environment_info=environment_info,
|
||||
is_public=is_public, log_request=log_request, log_response=log_response, is_edit=True) }}
|
||||
{% block page %}
|
||||
|
||||
{{ render_partial('dashboard/http_functions/header.html', title='Update', user_id=user_id, function_id=function_id,
|
||||
name=name,
|
||||
refresh_url=url_for('get_http_function_edit_form', function_id=function_id), show_logs=True, show_client=True) }}
|
||||
|
||||
{{ render_partial('function_editor.html', function_id=function_id, name=name, script=script,
|
||||
environment_info=environment_info,
|
||||
is_public=is_public, log_request=log_request, log_response=log_response, is_edit=True) }}
|
||||
|
||||
{% endblock %}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
{% if show_refresh|default(true, false) %}
|
||||
<div class="ml-2 cursor-pointer text-gray-500" hx-get="{{ refresh_url }}" hx-target="#container"
|
||||
hx-swap="innerHTML">
|
||||
hx-swap="innerHTML" hx-push-url="true">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-6 h-6" data-darkreader-inline-stroke=""
|
||||
style="--darkreader-inline-stroke: currentColor;">
|
||||
@@ -20,8 +20,9 @@
|
||||
{% endif %}
|
||||
|
||||
{% if show_logs|default(false, true) %}
|
||||
<div class="ml-2 cursor-pointer text-gray-500" hx-get="{{ url_for('get_http_function_logs', name=name) }}"
|
||||
hx-target="#container" hx-swap="innerHTML">
|
||||
<div class="ml-2 cursor-pointer text-gray-500"
|
||||
hx-get="{{ url_for('get_http_function_logs', function_id=function_id) }}" hx-target="#container"
|
||||
hx-swap="innerHTML" hx-push-url="true">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" data-slot="icon" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
@@ -31,9 +32,8 @@
|
||||
{% endif %}
|
||||
|
||||
{% if show_client|default(false, true) %}
|
||||
<div class="ml-2 cursor-pointer text-gray-500"
|
||||
hx-get="{{ url_for('client', user_id=user_id, function=name) }}" hx-target="#container"
|
||||
hx-swap="innerHTML">
|
||||
<div class="ml-2 cursor-pointer text-gray-500" hx-get="{{ url_for('client', function_id=function_id) }}"
|
||||
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
@@ -44,8 +44,8 @@
|
||||
|
||||
{% if show_edit_form|default(false, true) %}
|
||||
<div class="ml-2 cursor-pointer text-gray-500"
|
||||
hx-get="{{ url_for('get_http_function_edit_form', name=name) }}" hx-target="#container"
|
||||
hx-swap="innerHTML">
|
||||
hx-get="{{ url_for('get_http_function_edit_form', function_id=function_id) }}" hx-target="#container"
|
||||
hx-swap="innerHTML" hx-push-url="true">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" data-slot="icon" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
@@ -57,7 +57,8 @@
|
||||
</div>
|
||||
<button
|
||||
class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded flex mr-2 items-center ml-auto"
|
||||
hx-get="{{ url_for('dashboard_http_functions') }}" hx-target="#container" hx-swap="innerHTML">
|
||||
hx-get="{{ url_for('dashboard_http_functions') }}" hx-target="#container" hx-swap="innerHTML"
|
||||
hx-push-url="true">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5 mr-2" data-darkreader-inline-stroke=""
|
||||
style="--darkreader-inline-stroke: currentColor;">
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
{{ render_partial('dashboard/http_functions/header.html', title='Logs', user_id=user_id, name=name,
|
||||
refresh_url=url_for('get_http_function_logs', name=name), show_edit_form=True, show_client=True) }}
|
||||
{% extends 'dashboard.html' %}
|
||||
|
||||
{% block page %}
|
||||
|
||||
{{ render_partial('dashboard/http_functions/header.html', title='Logs', user_id=user_id, function_id=function_id,
|
||||
name=name,
|
||||
refresh_url=url_for('get_http_function_logs', function_id=function_id), show_edit_form=True, show_client=True) }}
|
||||
|
||||
<div class="block md:grid md:grid-cols-4 md:gap-4 p-4">
|
||||
<!-- Headers -->
|
||||
@@ -39,4 +44,6 @@ refresh_url=url_for('get_http_function_logs', name=name), show_edit_form=True, s
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,8 +1,13 @@
|
||||
{% extends 'dashboard.html' %}
|
||||
|
||||
{% block page %}
|
||||
|
||||
{{ render_partial('dashboard/http_functions/header.html', title='New HTTP function', user_id=user_id, show_name=False,
|
||||
show_refresh=False, show_logs=False,
|
||||
show_client=False, show_link=False)
|
||||
}}
|
||||
|
||||
|
||||
{{ render_partial('function_editor.html', name=name, script=script, environment_info=environment_info,
|
||||
is_public=is_public, log_request=log_request, log_response=log_response, is_add=True) }}
|
||||
is_public=is_public, log_request=log_request, log_response=log_response, is_add=True) }}
|
||||
|
||||
{% endblock %}
|
||||
@@ -2,7 +2,8 @@
|
||||
<h1 class="leading-normal text-gray-800 text-base md:text-xl lg:text-2xl">HTTP functions</h1>
|
||||
<button
|
||||
class="bg-transparent hover:bg-green-500 text-green-700 font-semibold hover:text-white py-2 px-4 border border-green-500 hover:border-transparent rounded flex mr-2 items-center ml-auto"
|
||||
hx-get="{{ url_for('get_http_function_add_form') }}" hx-target="#container" hx-swap="innerHTML">
|
||||
hx-get="{{ url_for('get_http_function_add_form') }}" hx-target="#container" hx-swap="innerHTML"
|
||||
hx-push-url="true">
|
||||
<span class="sr-only" data-id="4">Bold</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||
class="w-5 h-5" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: currentColor;">
|
||||
@@ -66,19 +67,19 @@
|
||||
<div class="flex gap-1">
|
||||
<button
|
||||
class="inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 rounded-md px-3 text-gray-800"
|
||||
hx-get="{{ url_for('get_http_function_logs', name=function.name) }}"
|
||||
hx-get="{{ url_for('get_http_function_logs', function_id=function.id) }}"
|
||||
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
||||
Logs
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 rounded-md px-3 text-gray-800"
|
||||
hx-get="{{ url_for('get_http_function_edit_form', name=function.name) }}"
|
||||
hx-get="{{ url_for('get_http_function_edit_form', function_id=function.id) }}"
|
||||
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 rounded-md px-3 text-gray-800"
|
||||
hx-get="{{ url_for('client', user_id=function.user_id, function=function.name) }}"
|
||||
hx-get="{{ url_for('client', user_id=function.user_id, function_id=function.id) }}"
|
||||
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
||||
Try
|
||||
</button>
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
<button
|
||||
class="bg-transparent hover:bg-red-500 text-red-700 font-semibold hover:text-white py-2 px-4 border border-red-500 hover:border-transparent rounded flex mr-2 items-center"
|
||||
hx-delete="{{ url_for('delete_http_function', name=name) }}" hx-target="#container" hx-swap="innerHTML"
|
||||
hx-confirm="Are you sure you want to delete {{ name }}?">
|
||||
hx-confirm="Are you sure you want to delete {{ name }}?" hx-push-url="true">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-4 h-4 mr-2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
@@ -306,10 +306,9 @@
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
if (name != updated_name) {
|
||||
htmx.ajax('GET', "{{ url_for('get_http_function_edit_form') }}", {
|
||||
htmx.ajax('GET', "{{ url_for('get_http_function_edit_form', function_id=function_id) }}", {
|
||||
target: '#container',
|
||||
swap: 'innerHTML',
|
||||
values: { name: updated_name }
|
||||
swap: 'innerHTML'
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user