Prompt before restarting the server if anything is playing

This commit is contained in:
Marks Polakovs 2021-10-20 20:49:19 +01:00
parent 896af0798b
commit e4cc6f7b61
2 changed files with 14 additions and 0 deletions

View file

@ -0,0 +1,9 @@
{% extends 'base.html' %}
{% block content_inner %}
<div class="text-center">
<p class="lead text-gray-800 mb-2">Hang on a second!</p>
<p class="text-gray-900 mb-3">Something is currently playing. Restarting will interrupt it! Are you sure?</p>
<a href="/status" class="btn btn-info">Cancel</a>
<a href="/restart?confirm=true" class="btn btn-danger">Confirm</a>
</div>
{% endblock %}

View file

@ -496,6 +496,11 @@ def quit(request):
@app.route("/restart") @app.route("/restart")
def restart(request): def restart(request):
if request.args.get("confirm", '') != "true":
for i in range(server_state.get()["num_channels"]):
state = status(i)
if state["playing"]:
return render_template("restart-confirm.html", data=None)
server_state.update("running_state", "restarting") server_state.update("running_state", "restarting")
data = { data = {