diff --git a/app.py b/app.py index 7a4678d..811eda7 100644 --- a/app.py +++ b/app.py @@ -238,6 +238,7 @@ def get_http_function_history(function_id): name = http_function['name'] version_number = http_function['version_number'] + original_script = http_function['script_content'] if version_number == 1 else None http_function_history = [] if version_number > 1: @@ -254,11 +255,13 @@ def get_http_function_history(function_id): 'version_number': post_version['version_number'], 'updated_at': post_version['updated_at'] }) - + + if raw_history: + original_script = raw_history[-1]['script_content'] if htmx: - return render_block(app.jinja_env, 'dashboard/http_functions/history.html', 'page', user_id=user_id, function_id=function_id, name=name, http_function=http_function, http_function_history=http_function_history) - return render_template("dashboard/http_functions/history.html", user_id=user_id, name=name, function_id=function_id, http_function=http_function, http_function_history=http_function_history) + return render_block(app.jinja_env, 'dashboard/http_functions/history.html', 'page', user_id=user_id, function_id=function_id, name=name, http_function=http_function, http_function_history=http_function_history, original_script=original_script) + return render_template("dashboard/http_functions/history.html", user_id=user_id, name=name, function_id=function_id, http_function=http_function, http_function_history=http_function_history, original_script=original_script) @ app.route("/dashboard/timer_functions", methods=["GET"]) @login_required diff --git a/db.py b/db.py index 30f1d5d..95b9795 100644 --- a/db.py +++ b/db.py @@ -114,5 +114,5 @@ ORDER BY invocation_time DESC""", [http_function_id]) def get_http_function_history(self, function_id): http_function_history = self.execute( - 'SELECT version_id, http_function_id, script_content, version_number, updated_at FROM http_functions_versions WHERE http_function_id=%s AND version_number > 1 ORDER BY version_number DESC', [function_id]) + 'SELECT version_id, http_function_id, script_content, version_number, updated_at FROM http_functions_versions WHERE http_function_id=%s ORDER BY version_number DESC', [function_id]) return http_function_history \ No newline at end of file diff --git a/templates/dashboard/http_functions/client.html b/templates/dashboard/http_functions/client.html index c0ac7aa..8ba5c30 100644 --- a/templates/dashboard/http_functions/client.html +++ b/templates/dashboard/http_functions/client.html @@ -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) }}