From edaef13a4d4a33683bd9d97f994f22f58bf9164a Mon Sep 17 00:00:00 2001 From: topilski Date: Tue, 4 Jun 2019 22:49:53 -0400 Subject: [PATCH] Start/Stop/Restart multy stream --- app/stream/view.py | 25 +++++++++++++++++-------- app/templates/user/dashboard.html | 18 +++++++++--------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/app/stream/view.py b/app/stream/view.py index 079257c..0946445 100644 --- a/app/stream/view.py +++ b/app/stream/view.py @@ -25,8 +25,10 @@ class StreamView(FlaskView): def start(self): server = current_user.get_current_server() if server: - sid = request.form['sid'] - server.start_stream(sid) + data = request.get_json() + sids = data['sids'] + for sid in sids: + server.start_stream(sid) return jsonify(status='ok'), 200 return jsonify(status='failed'), 404 @@ -35,8 +37,10 @@ class StreamView(FlaskView): def stop(self): server = current_user.get_current_server() if server: - sid = request.form['sid'] - server.stop_stream(sid) + data = request.get_json() + sids = data['sids'] + for sid in sids: + server.start_stream(sid) return jsonify(status='ok'), 200 return jsonify(status='failed'), 404 @@ -45,8 +49,10 @@ class StreamView(FlaskView): def restart(self): server = current_user.get_current_server() if server: - sid = request.form['sid'] - server.restart_stream(sid) + data = request.get_json() + sids = data['sids'] + for sid in sids: + server.start_stream(sid) return jsonify(status='ok'), 200 return jsonify(status='failed'), 404 @@ -318,8 +324,11 @@ class StreamView(FlaskView): def remove(self): server = current_user.get_current_server() if server: - sid = request.form['sid'] - server.remove_stream(sid) + data = request.get_json() + sids = data['sids'] + for sid in sids: + server.stop_stream(sid) + server.remove_stream(sid) return jsonify(status='ok'), 200 return jsonify(status='failed'), 404 diff --git a/app/templates/user/dashboard.html b/app/templates/user/dashboard.html index 6c0af67..f4992cc 100644 --- a/app/templates/user/dashboard.html +++ b/app/templates/user/dashboard.html @@ -46,6 +46,7 @@ Dashboard | {{ config['PUBLIC_CONFIG'].site.title }} } + {{super()}} {% endblock %} @@ -711,8 +712,8 @@ Dashboard | {{ config['PUBLIC_CONFIG'].site.title }} $.ajax({ url: "{{ url_for('StreamView:remove') }}", type: "POST", - dataType: 'json', - data: {"sid":sid}, + contentType : 'application/json', + data: JSON.stringify({sids: [sid]}), success: function (response) { console.log(response); window.location.reload(); @@ -757,8 +758,8 @@ Dashboard | {{ config['PUBLIC_CONFIG'].site.title }} $.ajax({ url: "{{ url_for('StreamView:start') }}", type: "POST", - dataType: 'json', - data: {"sid":sid}, + contentType : 'application/json', + data: JSON.stringify({sids: [sid]}), success: function (response) { console.log(response); // window.location.reload(); @@ -773,8 +774,8 @@ Dashboard | {{ config['PUBLIC_CONFIG'].site.title }} $.ajax({ url: "{{ url_for('StreamView:stop') }}", type: "POST", - dataType: 'json', - data: {"sid":sid}, + contentType : 'application/json', + data: JSON.stringify({sids: [sid]}), success: function (response) { console.log(response); // window.location.reload(); @@ -789,8 +790,8 @@ Dashboard | {{ config['PUBLIC_CONFIG'].site.title }} $.ajax({ url: "{{ url_for('StreamView:restart') }}", type: "POST", - dataType: 'json', - data: {"sid":sid}, + contentType : 'application/json', + data: JSON.stringify({sids: [sid]}), success: function (response) { console.log(response); // window.location.reload(); @@ -801,6 +802,5 @@ Dashboard | {{ config['PUBLIC_CONFIG'].site.title }} }); } - {% endblock %}