Add js function to show alerts when updating http functions

This commit is contained in:
Peter Stockings
2023-12-18 18:39:55 +11:00
parent 8ffdf4c28c
commit 8ad1b6bb85
3 changed files with 35 additions and 8 deletions

8
app.py
View File

@@ -102,7 +102,7 @@ def create_http_function():
return render_template("dashboard/http_functions.html", http_functions=http_functions)
except Exception as e:
print(e)
return render_template("dashboard/http_functions/new.html", name=name, script=script_content)
return { "status": "error", "message": str(e) }
@ app.route("/dashboard/http_functions/edit_form", methods=["GET"])
def get_http_function_edit_form():
@@ -122,10 +122,10 @@ def edit_http_function():
environment_info = json.dumps(eval(request.json.get('environment_info')))
db.edit_http_function(name, script_content, environment_info)
return render_template("dashboard/http_functions/edit.html", name=name, script=script_content, environment_info=environment_info)
return { "status": "success", "message": f'{name} updated' }
except Exception as e:
print(e)
return render_template("dashboard/http_functions/edit.html", name=name, script=script_content)
return { "status": "error", "message": str(e) }
@ app.route("/dashboard/http_functions/delete", methods=["DELETE"])
def delete_http_function():
@@ -137,7 +137,7 @@ def delete_http_function():
http_functions = create_http_functions_view_model(http_functions)
return render_template("dashboard/http_functions.html", http_functions=http_functions)
except Exception as e:
return jsonify({'error': str(e)}), 500
return jsonify({"status": 'error', "message": str(e)}), 500
@ app.route("/dashboard/timer_functions", methods=["GET"])
def dashboard_timer_functions():