diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index 6e139a1d..77506231 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -136,11 +136,11 @@ login_manager.init_app(app) @login_manager.user_loader def load_user(session_id): # TODO USE Alternative ID - print(session) + # print(session) user_id = get_session_user(session_id) if user_id: user = AILUser.get(user_id) - print(user) + # print(user) return user return None diff --git a/var/www/modules/dashboard/Flask_dashboard.py b/var/www/modules/dashboard/Flask_dashboard.py index 64b842fe..5ee4428c 100644 --- a/var/www/modules/dashboard/Flask_dashboard.py +++ b/var/www/modules/dashboard/Flask_dashboard.py @@ -56,6 +56,16 @@ def event_stream(): if msg['type'] == 'pmessage' and level != "DEBUG": yield 'data: %s\n\n' % json.dumps(msg) +def event_stream_dashboard(): + try: + while True: + # jsonify(row1=get_queues()) + data = {'queues': get_queues()} + yield f'data: {json.dumps(data)}\n\n' + time.sleep(1) + except GeneratorExit: + print("Generator Exited") + def get_queues(): # We may want to put the llen in a pipeline to do only one query. return ail_queues.get_modules_queues_stats() @@ -103,6 +113,12 @@ def datetime_from_utc_to_local(utc_str): def logs(): return flask.Response(event_stream(), mimetype="text/event-stream") +@dashboard.route("/_dashboard") +@login_required +@login_read_only +def _dashboard(): + return flask.Response(event_stream_dashboard(), content_type="text/event-stream") + @dashboard.route("/_get_last_logs_json") @login_required @login_read_only diff --git a/var/www/modules/dashboard/templates/index.html b/var/www/modules/dashboard/templates/index.html index 1ac1577b..c823236e 100644 --- a/var/www/modules/dashboard/templates/index.html +++ b/var/www/modules/dashboard/templates/index.html @@ -94,17 +94,17 @@