Fixed missing static_folder issue on settings page and JS document race condition

This commit is contained in:
Fabio Manganiello 2020-03-29 13:47:22 +02:00
parent 13c25f94d5
commit b490344632
2 changed files with 8 additions and 5 deletions

View file

@ -1,6 +1,6 @@
from flask import Blueprint, request, render_template 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.app.utils import authenticate
from platypush.backend.http.utils import HttpUtils from platypush.backend.http.utils import HttpUtils
from platypush.config import Config from platypush.config import Config
@ -20,7 +20,8 @@ def settings():
""" Settings page """ """ Settings page """
user_manager = UserManager() user_manager = UserManager()
users = user_manager.get_users() 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: # vim:sw=4:ts=4:et:

View file

@ -3,6 +3,7 @@ window.vm = new Vue({
data: function() { data: function() {
return { return {
config: window.config, config: window.config,
document: undefined,
sessionToken: undefined, sessionToken: undefined,
selectedTab: 'users', selectedTab: 'users',
selectedUser: undefined, selectedUser: undefined,
@ -103,7 +104,7 @@ window.vm = new Vue({
onTokenFocus: function(event) { onTokenFocus: function(event) {
event.target.select(); event.target.select();
document.execCommand('copy'); this.document.execCommand('copy');
event.target.setAttribute('disabled', true); event.target.setAttribute('disabled', true);
createNotification({ createNotification({
@ -116,7 +117,7 @@ window.vm = new Vue({
onTokenBlur: function(event) { onTokenBlur: function(event) {
event.target.select(); event.target.select();
document.execCommand('copy'); this.document.execCommand('copy');
event.target.removeAttribute('disabled'); event.target.removeAttribute('disabled');
createNotification({ createNotification({
@ -177,7 +178,8 @@ window.vm = new Vue({
}, },
created: function() { 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; this.sessionToken = cookies.session_token;
}, },
}); });