From 37140cf2479e04ffe8b78d032a0f337101fc8b31 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 24 Oct 2020 03:13:02 +0100 Subject: [PATCH] Add initial theming to web UI. --- multiplay-flask.py | 40 ++++++++++++++++--------- templates/base.html | 69 +++++++++++++++++++++++++++++++++++++++++++ templates/index.html | 52 ++++++++++++++++---------------- templates/status.html | 37 +++++++++++++++++++++++ 4 files changed, 159 insertions(+), 39 deletions(-) create mode 100644 templates/base.html create mode 100644 templates/status.html diff --git a/multiplay-flask.py b/multiplay-flask.py index ecfea95..b246d94 100644 --- a/multiplay-flask.py +++ b/multiplay-flask.py @@ -1,10 +1,10 @@ import multiprocessing import bapsicle_standalone -from flask import Flask, render_template +from flask import Flask, render_template, send_from_directory import json import sounddevice as sd -app = Flask(__name__) +app = Flask(__name__, static_url_path='') channel_to_q = [] channel_from_q = [] @@ -15,10 +15,16 @@ channel_p = [] - - @app.route("/") -def status(): +def ui_index(): + data = { + 'ui_page': "index", + "ui_title": "" + } + return render_template('index.html', data=data) + +@app.route("/status") +def ui_status(): channel_states = [] for i in range(3): channel_states.append(details(i)) @@ -35,8 +41,10 @@ def status(): data = { 'channels': channel_states, 'outputs': outputs, + 'ui_page': "status", + "ui_title": "Status" } - return render_template('index.html', data=data) + return render_template('status.html', data=data) @app.route("/player//play") @@ -44,7 +52,7 @@ def play(channel): channel_to_q[channel].put("PLAY") - return status() + return ui_status() @app.route("/player//pause") @@ -52,7 +60,7 @@ def pause(channel): channel_to_q[channel].put("PAUSE") - return status() + return ui_status() @app.route("/player//unpause") @@ -60,7 +68,7 @@ def unPause(channel): channel_to_q[channel].put("UNPAUSE") - return status() + return ui_status() @app.route("/player//stop") @@ -68,7 +76,7 @@ def stop(channel): channel_to_q[channel].put("STOP") - return status() + return ui_status() @app.route("/player//seek/") @@ -76,13 +84,13 @@ def seek(channel, pos): channel_to_q[channel].put("SEEK:" + str(pos)) - return status() + return ui_status() @app.route("/player//output/") def output(channel, name): channel_to_q[channel].put("OUTPUT:" + name) channel_to_q[channel].put("LOAD:test"+str(channel)+".mp3") - return status() + return ui_status() @app.route("/player//details") @@ -100,15 +108,19 @@ def details(channel): def all_stop(): for channel in channel_to_q: channel.put("STOP") - status() + ui_status() +@app.route('/static/') +def send_static(path): + return send_from_directory('ui-static', path) + if __name__ == "__main__": for channel in range(3): channel_to_q.append(multiprocessing.Queue()) channel_from_q.append(multiprocessing.Queue()) - channel_to_q[-1].put_nowait("LOAD:test"+str(channel)+".mp3") + # channel_to_q[-1].put_nowait("LOAD:test"+str(channel)+".mp3") channel_p.append( multiprocessing.Process( target=bapsicle_standalone.bapsicle, diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..02d9331 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,69 @@ + + + + + + + + + + {% block head %}{% endblock %} + + BAPSicle {% if data.ui_title %} | {{data.ui_title}}{% endif %} + + + + + + + + + + + + + +
+ + +
+ +
+
+ +

BAPSicle

+
+ +
+ {% block content %}{% endblock %} +
+
+ +
+ +
+ +
+ + + + + + + + + + + + + diff --git a/templates/index.html b/templates/index.html index 8817c81..f60f6d6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,26 +1,28 @@ - - - BAPSicle - - - - {% if data %} - - {% for player in data.channels %} - Play - Stop - Seek 50 - {{player}}
- {% endfor %} -
-
- - {% for output in data.outputs %} - Set Channel 0 Set Channel 1 Set Channel 2 - {{output.name}}
- {% endfor %} -
- {% endif %} +{% extends 'base.html' %} +{% block head %} + +{% endblock %} +{% block content %} - - - +
+ +
+
+
+
+
+

Welcome to
BAPSicle!

+

The next gen Broadcast and Presenting Suite server!

+
+
+

Wanted the actual playout controller?

+ + Open WebStudio + +
+

Version: X | Server Name: Studio X

+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/status.html b/templates/status.html new file mode 100644 index 0000000..5c66adf --- /dev/null +++ b/templates/status.html @@ -0,0 +1,37 @@ +{% extends 'base.html' %} +{% block head %} + +{% endblock %} +{% block content %} + +
+ +
+
+
+
+

Status

+
+
+ {% if data %} + + {% for player in data.channels %} + Play + Stop + Seek 50 + {{player}}
+ {% endfor %} +
+
+ + {% for output in data.outputs %} + Set Channel 0 Set Channel 1 Set Channel 2 - {{output.name}}
+ {% endfor %} +
+ {% endif %} +
+
+
+
+ +{% endblock %} \ No newline at end of file