Fix dashboard -> http functions over view page not working on refresh (was sending html partial for htmx)
This commit is contained in:
8
app.py
8
app.py
@@ -110,8 +110,11 @@ def dashboard_http_functions():
|
|||||||
user_id = current_user.id
|
user_id = current_user.id
|
||||||
http_functions = db.get_http_functions_for_user(user_id)
|
http_functions = db.get_http_functions_for_user(user_id)
|
||||||
http_functions = create_http_functions_view_model(http_functions)
|
http_functions = create_http_functions_view_model(http_functions)
|
||||||
|
if htmx:
|
||||||
|
return render_block(app.jinja_env, "dashboard/http_functions/overview.html", "page", http_functions=http_functions)
|
||||||
return render_template("dashboard/http_functions/overview.html", http_functions=http_functions)
|
return render_template("dashboard/http_functions/overview.html", http_functions=http_functions)
|
||||||
|
|
||||||
|
|
||||||
@ app.route("/dashboard/http_functions/add_form", methods=["GET"])
|
@ app.route("/dashboard/http_functions/add_form", methods=["GET"])
|
||||||
@login_required
|
@login_required
|
||||||
def get_http_function_add_form():
|
def get_http_function_add_form():
|
||||||
@@ -137,7 +140,7 @@ def create_http_function():
|
|||||||
|
|
||||||
http_functions = db.get_http_functions_for_user(user_id)
|
http_functions = db.get_http_functions_for_user(user_id)
|
||||||
http_functions = create_http_functions_view_model(http_functions)
|
http_functions = create_http_functions_view_model(http_functions)
|
||||||
return render_template("dashboard/http_functions/overview.html", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
|
return render_block(app.jinja_env, "dashboard/http_functions/overview.html", "page", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return { "status": "error", "message": str(e) }
|
return { "status": "error", "message": str(e) }
|
||||||
@@ -184,12 +187,11 @@ def edit_http_function(function_id):
|
|||||||
def delete_http_function(function_id):
|
def delete_http_function(function_id):
|
||||||
try:
|
try:
|
||||||
user_id = current_user.id
|
user_id = current_user.id
|
||||||
name = request.args.get('name')
|
|
||||||
db.delete_http_function(user_id, function_id)
|
db.delete_http_function(user_id, function_id)
|
||||||
|
|
||||||
http_functions = db.get_http_functions_for_user(user_id)
|
http_functions = db.get_http_functions_for_user(user_id)
|
||||||
http_functions = create_http_functions_view_model(http_functions)
|
http_functions = create_http_functions_view_model(http_functions)
|
||||||
return render_template("dashboard/http_functions/overview.html", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
|
return render_block(app.jinja_env, "dashboard/http_functions/overview.html", "page", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"status": 'error', "message": str(e)}), 500
|
return jsonify({"status": 'error', "message": str(e)}), 500
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
{% extends 'dashboard.html' %}
|
||||||
|
|
||||||
|
{% block page %}
|
||||||
|
|
||||||
<div class="flex items-center" data-id="51">
|
<div class="flex items-center" data-id="51">
|
||||||
<h1 class="leading-normal text-gray-800 text-base md:text-xl lg:text-2xl">HTTP functions</h1>
|
<h1 class="leading-normal text-gray-800 text-base md:text-xl lg:text-2xl">HTTP functions</h1>
|
||||||
<button
|
<button
|
||||||
@@ -100,4 +104,6 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user