From 76d440fd8f2ba4e02f9ace8cfabecf0dac58d5fb Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Tue, 12 Nov 2019 11:01:56 +0100 Subject: [PATCH] Move story state to recordings and allow remote connection to interface --- hugvey/panopticon.py | 2 +- hugvey/story.py | 5 +++-- www/js/hugvey_console.js | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hugvey/panopticon.py b/hugvey/panopticon.py index 0ef6549..10f6665 100644 --- a/hugvey/panopticon.py +++ b/hugvey/panopticon.py @@ -28,7 +28,7 @@ web_dir = os.path.join(os.path.split(__file__)[0], '..', 'www') def getWebSocketHandler(central_command): class WebSocketHandler(tornado.websocket.WebSocketHandler): - CORS_ORIGINS = ['localhost', 'hugveycmd.local'] + CORS_ORIGINS = ['localhost', 'hugveycmd.local', 'r3.local'] connections = set() selections = {} diff --git a/hugvey/story.py b/hugvey/story.py index 8ed7dc7..99cbce1 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -1999,7 +1999,8 @@ class Story(object): @classmethod def getStateDir(self): - return "/tmp" +# return "/tmp" + return "./recordings" # day = time.strftime("%Y%m%d") # t = time.strftime("%H:%M:%S") # @@ -2010,7 +2011,7 @@ class Story(object): @classmethod def getStateFilename(cls, hv_id): - return os.path.join(cls.getStateDir(), f"hugvey{hv_id}") + return os.path.join(cls.getStateDir(), f"state_hugvey{hv_id}") def storeState(self): # TODO: stop stopwatch diff --git a/www/js/hugvey_console.js b/www/js/hugvey_console.js index d9f315e..11ce8df 100644 --- a/www/js/hugvey_console.js +++ b/www/js/hugvey_console.js @@ -92,7 +92,8 @@ class Panopticon { - this.socket = new ReconnectingWebSocket( "ws://localhost:8888/ws", null, { debug: false, reconnectInterval: 3000 } ); +// this.socket = new ReconnectingWebSocket( "ws://localhost:8888/ws", null, { debug: false, reconnectInterval: 3000 } ); + this.socket = new ReconnectingWebSocket( window.location.origin.replace('http', 'ws') +'/ws', null, { debug: false, reconnectInterval: 3000 } ); if(this.hasGraph) { this.graph = new Graph(); @@ -377,7 +378,7 @@ class Graph { getAudioUrlForMsg(msg) { let isVariable = msg['text'].includes('$') ? '1' : '0'; let lang = panopticon.graph.language_code; - return `http://localhost:8888/voice?text=${encodeURIComponent(msg['text'])}&variable=${isVariable}&lang=${lang}&filename=0`; + return `${window.location.origin}/voice?text=${encodeURIComponent(msg['text'])}&variable=${isVariable}&lang=${lang}&filename=0`; } getConfig() { @@ -2169,7 +2170,7 @@ class Graph { formData.append( "json", blob ); console.info("Save json", formData ); var request = new XMLHttpRequest(); - request.open( "POST", "http://localhost:8888/upload" ); + request.open( "POST", window.location.origin + "/upload" ); if(callback) { request.addEventListener( "load", callback);