Fix darkmode + Add new variables to pass to the front
This commit is contained in:
parent
547021e7b0
commit
1d4998356d
|
@ -1015,8 +1015,23 @@ def plugins():
|
|||
),
|
||||
)
|
||||
|
||||
app.config["CONFIG"].reload_plugins()
|
||||
plugins = app.config["CONFIG"].get_plugins()
|
||||
plugins_internal = 0
|
||||
plugins_external = 0
|
||||
|
||||
for plugin in plugins:
|
||||
if plugin["external"] is True:
|
||||
plugins_external += 1
|
||||
else:
|
||||
plugins_internal += 1
|
||||
|
||||
return render_template(
|
||||
"plugins.html",
|
||||
plugins=plugins,
|
||||
plugins_internal=plugins_internal,
|
||||
plugins_external=plugins_external,
|
||||
plugins_errors=db.get_plugins_errors(),
|
||||
dark_mode=app.config["DARK_MODE"],
|
||||
)
|
||||
|
||||
|
@ -1389,6 +1404,7 @@ def jobs():
|
|||
return render_template(
|
||||
"jobs.html",
|
||||
jobs=db.get_jobs(),
|
||||
jobs_errors=db.get_plugins_errors(),
|
||||
dark_mode=app.config["DARK_MODE"],
|
||||
)
|
||||
|
||||
|
@ -1460,13 +1476,15 @@ def login():
|
|||
@app.route("/darkmode", methods=["POST"])
|
||||
@login_required
|
||||
def darkmode():
|
||||
if "darkmode" in request.form:
|
||||
if request.form["darkmode"] == "true":
|
||||
app.config["DARK_MODE"] = True
|
||||
else:
|
||||
app.config["DARK_MODE"] = False
|
||||
if not request.is_json:
|
||||
return jsonify({"status": "ko", "message": "invalid request"}), 400
|
||||
|
||||
return jsonify({"status": "ok"})
|
||||
if "darkmode" in request.json:
|
||||
app.config["DARK_MODE"] = request.json["darkmode"] == "true"
|
||||
else:
|
||||
return jsonify({"status": "ko", "message": "darkmode is required"}), 422
|
||||
|
||||
return jsonify({"status": "ok"}), 200
|
||||
|
||||
|
||||
@app.route("/check_reloading")
|
||||
|
|
|
@ -69,10 +69,11 @@ class darkMode {
|
|||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRF-Token": this.csrf.value,
|
||||
},
|
||||
body: JSON.stringify({ darkmode: isDark, csrf_token: this.csrf.value }),
|
||||
body: JSON.stringify({ darkmode: isDark }),
|
||||
};
|
||||
const send = await fetch(`${location.href}/darkmode}`, data);
|
||||
const send = await fetch(`${location.href.split("/").slice(0, -1).join("/")}/darkmode`, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ url_for(request.endpoint)[1:].split("/")[-1].strip() %}
|
|||
<p
|
||||
class="transition duration-300 ease-in-out pl-2 col-span-1 mb-0 font-sans text-sm font-semibold leading-normal uppercase dark:text-white dark:opacity-80"
|
||||
>
|
||||
{{jobs_total}}
|
||||
{{jobs|length}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center my-4">
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "base.html" %} {% block content %}{% set current_endpoint =
|
||||
url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', '-') %} {% set
|
||||
plugins = config["CONFIG"].get_plugins() %}
|
||||
url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', '-') %}
|
||||
<!-- info -->
|
||||
<div
|
||||
class="p-4 col-span-12 md:col-span-5 2xl:col-span-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border"
|
||||
|
@ -15,7 +14,7 @@ plugins = config["CONFIG"].get_plugins() %}
|
|||
<p
|
||||
class="transition duration-300 ease-in-out pl-2 col-span-1 mb-0 font-sans text-sm font-semibold leading-normal uppercase dark:text-white dark:opacity-80"
|
||||
>
|
||||
{{plugins_total}}
|
||||
{{plugins|length}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center my-4">
|
||||
|
|
Loading…
Reference in New Issue