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:
54
app.py
54
app.py
@@ -95,16 +95,6 @@ def map_isolator_response_to_flask_response(response):
|
||||
def home():
|
||||
return render_template("home.html", name='Try me', script=DEFAULT_SCRIPT, environment_info=DEFAULT_ENVIRONMENT)
|
||||
|
||||
@ app.route("/client/<int:user_id>/<function>", methods=["GET"])
|
||||
@login_required
|
||||
def client(user_id, function):
|
||||
http_function = db.get_http_function(user_id, function)
|
||||
if not http_function:
|
||||
return jsonify({'error': 'Function not found'}), 404
|
||||
|
||||
http_function = create_http_function_view_model(http_function)
|
||||
return render_template("dashboard/http_functions/client.html", **http_function)
|
||||
|
||||
@ app.route("/dashboard", methods=["GET"])
|
||||
@login_required
|
||||
def dashboard():
|
||||
@@ -125,8 +115,11 @@ def dashboard_http_functions():
|
||||
@login_required
|
||||
def get_http_function_add_form():
|
||||
user_id = current_user.id
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/new.html', 'page', user_id=user_id, name=DEFAULT_FUNCTION_NAME, script=DEFAULT_SCRIPT, environment_info=DEFAULT_ENVIRONMENT, is_public=False, log_request=True, log_response=False)
|
||||
return render_template("dashboard/http_functions/new.html", user_id=user_id, name=DEFAULT_FUNCTION_NAME, script=DEFAULT_SCRIPT, environment_info=DEFAULT_ENVIRONMENT, is_public=False, log_request=True, log_response=False)
|
||||
|
||||
|
||||
@ app.route("/dashboard/http_functions/create", methods=["POST"])
|
||||
@login_required
|
||||
def create_http_function():
|
||||
@@ -148,20 +141,23 @@ def create_http_function():
|
||||
print(e)
|
||||
return { "status": "error", "message": str(e) }
|
||||
|
||||
@ app.route("/dashboard/http_functions/edit_form", methods=["GET"])
|
||||
@ app.route("/dashboard/http_functions/<int:function_id>/edit_form", methods=["GET"])
|
||||
@login_required
|
||||
def get_http_function_edit_form():
|
||||
def get_http_function_edit_form(function_id):
|
||||
user_id = current_user.id
|
||||
name = request.args.get('name')
|
||||
http_function = db.get_http_function(user_id, name)
|
||||
http_function = db.get_http_function_by_id(user_id, function_id)
|
||||
if not http_function:
|
||||
return jsonify({'error': 'Function not found'}), 404
|
||||
name = http_function['name']
|
||||
script = http_function['script_content']
|
||||
environment_info = json.dumps(http_function['environment_info'], indent=2)
|
||||
is_public = http_function['is_public']
|
||||
log_request = http_function['log_request']
|
||||
log_response = http_function['log_response']
|
||||
return render_template("dashboard/http_functions/edit.html", user_id=user_id, name=name, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response)
|
||||
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/edit.html', 'page', user_id=user_id, function_id=function_id, name=name, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response)
|
||||
return render_template("dashboard/http_functions/edit.html", user_id=user_id, name=name, function_id=function_id, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response)
|
||||
|
||||
@ app.route("/dashboard/http_functions/edit", methods=["POST"])
|
||||
@login_required
|
||||
@@ -197,19 +193,31 @@ def delete_http_function():
|
||||
except Exception as e:
|
||||
return jsonify({"status": 'error', "message": str(e)}), 500
|
||||
|
||||
@ app.route("/dashboard/http_functions/logs", methods=["GET"])
|
||||
@ app.route("/dashboard/http_functions/<int:function_id>/logs", methods=["GET"])
|
||||
@login_required
|
||||
def get_http_function_logs():
|
||||
def get_http_function_logs(function_id):
|
||||
user_id = current_user.id
|
||||
name = request.args.get('name')
|
||||
http_function = db.get_http_function(user_id, name)
|
||||
http_function = db.get_http_function_by_id(user_id, function_id)
|
||||
if not http_function:
|
||||
return jsonify({'error': 'Function not found'}), 404
|
||||
name = http_function['name']
|
||||
http_function_invocations = db.get_http_function_invocations(function_id)
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/logs.html', 'page', user_id=user_id, function_id=function_id, name=name, http_function_invocations=http_function_invocations)
|
||||
return render_template("dashboard/http_functions/logs.html", user_id=user_id, name=name, function_id=function_id, http_function_invocations=http_function_invocations)
|
||||
|
||||
@ app.route("/http_functions/<int:function_id>/client", methods=["GET"])
|
||||
@login_required
|
||||
def client(function_id):
|
||||
user_id = current_user.id
|
||||
http_function = db.get_http_function_by_id(user_id, function_id)
|
||||
if not http_function:
|
||||
return jsonify({'error': 'Function not found'}), 404
|
||||
|
||||
http_function_id = http_function['id']
|
||||
http_function_invocations = db.get_http_function_invocations(http_function_id)
|
||||
return render_template("dashboard/http_functions/logs.html", user_id=user_id, name=name, http_function_invocations=http_function_invocations)
|
||||
|
||||
http_function = create_http_function_view_model(http_function)
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/client.html', 'page', function_id=function_id, **http_function)
|
||||
return render_template("dashboard/http_functions/client.html", function_id=function_id, **http_function)
|
||||
|
||||
@ app.route("/dashboard/timer_functions", methods=["GET"])
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user