From d4e81b11e0a148e557d4486f72c6f0910dd6cdad Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Wed, 20 May 2020 10:32:39 +0200 Subject: [PATCH] Fix foreign user data transmission for admins --- app/events.py | 2 +- app/static/js/nopaque.js | 23 ++++++++++++----------- app/templates/admin/user.html.j2 | 2 +- app/templates/corpora/corpus.html.j2 | 2 +- app/templates/jobs/job.html.j2 | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/events.py b/app/events.py index 568d7fd6..df716d81 100644 --- a/app/events.py +++ b/app/events.py @@ -47,7 +47,7 @@ def user_data_stream_init(): def foreign_user_data_stream_init(user_id): socketio.start_background_task(user_data_stream, current_app._get_current_object(), - user_id, request.sid, True) + user_id, request.sid, foreign=True) def user_data_stream(app, user_id, session_id, foreign=False): diff --git a/app/static/js/nopaque.js b/app/static/js/nopaque.js index 44287d69..6a88ccbc 100644 --- a/app/static/js/nopaque.js +++ b/app/static/js/nopaque.js @@ -7,20 +7,21 @@ var nopaque = {}; // nopaque ressources nopaque.socket = undefined; -nopaque.corpora = undefined; -nopaque.corporaSubscribers = []; -nopaque.jobs = undefined; -nopaque.jobsSubscribers = []; - -nopaque.foreignCorpora = undefined; -nopaque.foreignCorporaSubscribers = []; -nopaque.foreignJobs = undefined; -nopaque.foreignJobsSubscribers = []; - +// User data nopaque.user = {}; nopaque.user.isAuthenticated = undefined; -nopaque.user.settings = {} +nopaque.user.settings = {}; nopaque.user.settings.darkMode = undefined; +nopaque.corporaSubscribers = []; +nopaque.jobsSubscribers = []; + +// Foreign user (user inspected with admin credentials) data +nopaque.foreignUser = {}; +nopaque.foreignUser.isAuthenticated = undefined; +nopaque.foreignUser.settings = {}; +nopaque.foreignUser.settings.darkMode = undefined; +nopaque.foreignCorporaSubscribers = []; +nopaque.foreignJobsSubscribers = []; nopaque.flashedMessages = undefined; diff --git a/app/templates/admin/user.html.j2 b/app/templates/admin/user.html.j2 index 69bb6c58..5a668726 100644 --- a/app/templates/admin/user.html.j2 +++ b/app/templates/admin/user.html.j2 @@ -104,7 +104,7 @@ var corpusList = new RessourceList("corpora", nopaque.foreignCorporaSubscribers, "corpus"); var jobList = new RessourceList("jobs", nopaque.foreignJobsSubscribers, "job"); document.addEventListener("DOMContentLoaded", () => { - nopaque.socket.emit("foreign_user_ressources_init", {{ user.id }}); + nopaque.socket.emit("foreign_user_data_stream_init", {{ user.id }}); }); {% endblock %} diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2 index f8604b81..c53e32b3 100644 --- a/app/templates/corpora/corpus.html.j2 +++ b/app/templates/corpora/corpus.html.j2 @@ -213,7 +213,7 @@ {% else %} var informationUpdater = new InformationUpdater({{ corpus.id }}, true); document.addEventListener("DOMContentLoaded", () => { - nopaque.socket.emit("subscribe_foreign_user_ressources", {{ corpus.user_id }}); + nopaque.socket.emit("foreign_user_data_stream_init", {{ corpus.user_id }}); }); {% endif %} diff --git a/app/templates/jobs/job.html.j2 b/app/templates/jobs/job.html.j2 index 1f4b5245..ee893d77 100644 --- a/app/templates/jobs/job.html.j2 +++ b/app/templates/jobs/job.html.j2 @@ -254,7 +254,7 @@ {% else %} var informationUpdater = new InformationUpdater({{ job.id }}, true); document.addEventListener("DOMContentLoaded", () => { - nopaque.socket.emit("foreign_user_ressources_init", {{ job.user_id }}); + nopaque.socket.emit("foreign_user_data_stream_init", {{ job.user_id }}); }); {% endif %}