From b490344632f4a57b297f7223c39e58d635e40aee Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 29 Mar 2020 13:47:22 +0200 Subject: [PATCH] Fixed missing static_folder issue on settings page and JS document race condition --- platypush/backend/http/app/routes/settings.py | 5 +++-- platypush/backend/http/static/js/settings/index.js | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/platypush/backend/http/app/routes/settings.py b/platypush/backend/http/app/routes/settings.py index c6fa0c3a5..7ba7c7a89 100644 --- a/platypush/backend/http/app/routes/settings.py +++ b/platypush/backend/http/app/routes/settings.py @@ -1,6 +1,6 @@ from flask import Blueprint, request, render_template -from platypush.backend.http.app import template_folder +from platypush.backend.http.app import template_folder, static_folder from platypush.backend.http.app.utils import authenticate from platypush.backend.http.utils import HttpUtils from platypush.config import Config @@ -20,7 +20,8 @@ def settings(): """ Settings page """ user_manager = UserManager() users = user_manager.get_users() - return render_template('settings/index.html', utils=HttpUtils, users=users, token=Config.get('token')) + return render_template('settings/index.html', utils=HttpUtils, users=users, + static_folder=static_folder, token=Config.get('token')) # vim:sw=4:ts=4:et: diff --git a/platypush/backend/http/static/js/settings/index.js b/platypush/backend/http/static/js/settings/index.js index 4d4d03cfe..b6f906d6d 100644 --- a/platypush/backend/http/static/js/settings/index.js +++ b/platypush/backend/http/static/js/settings/index.js @@ -3,6 +3,7 @@ window.vm = new Vue({ data: function() { return { config: window.config, + document: undefined, sessionToken: undefined, selectedTab: 'users', selectedUser: undefined, @@ -103,7 +104,7 @@ window.vm = new Vue({ onTokenFocus: function(event) { event.target.select(); - document.execCommand('copy'); + this.document.execCommand('copy'); event.target.setAttribute('disabled', true); createNotification({ @@ -116,7 +117,7 @@ window.vm = new Vue({ onTokenBlur: function(event) { event.target.select(); - document.execCommand('copy'); + this.document.execCommand('copy'); event.target.removeAttribute('disabled'); createNotification({ @@ -177,7 +178,8 @@ window.vm = new Vue({ }, created: function() { - let cookies = Object.fromEntries(document.cookie.split('; ').map(x => x.split('='))); + this.document = document; + let cookies = Object.fromEntries(this.document.cookie.split('; ').map(x => x.split('='))); this.sessionToken = cookies.session_token; }, });