Remove unnecessary lines and add plugins_errors endpoint

This commit is contained in:
TheophileDiot 2022-11-16 16:10:11 +01:00
parent b57e50db2d
commit b3cfc1f01c
2 changed files with 11 additions and 19 deletions

View file

@ -1179,3 +1179,8 @@ class Database:
return format_exc()
return ""
def get_plugins_errors(self) -> int:
"""Get plugins errors."""
with self.__db_session() as session:
return session.query(Jobs).filter(Jobs.success == False).count()

View file

@ -1161,23 +1161,6 @@ def cache():
)
@app.route("/cache/download", methods=["GET"])
@login_required
def cache_download():
path = request.args.get("path")
if not path:
return redirect(url_for("loading", next=url_for("cache"))), 400
operation = app.config["CONFIGFILES"].check_path(path, "/var/cache/bunkerweb/")
if operation:
flash(operation, "error")
return redirect(url_for("loading", next=url_for("plugins"))), 500
return send_file(path, as_attachment=True)
@app.route("/logs", methods=["GET"])
@login_required
def logs():
@ -1188,8 +1171,6 @@ def logs():
"logs.html",
first_instance=first_instance,
instances=instances,
is_swarm=getenv("SWARM_MODE", "no") == "yes",
is_kubernetes=getenv("KUBERNETES_MODE", "no") == "yes",
dark_mode=app.config["DARK_MODE"],
)
@ -1427,6 +1408,12 @@ def darkmode():
return jsonify({"status": "ok"})
@app.route("/plugins_errors", methods=["GET"])
@login_required
def plugins_errors():
return jsonify({"status": "ok", "plugins_errors": db.get_plugins_errors()})
@app.route("/check_reloading")
@login_required
def check_reloading():