Move story state to recordings and allow remote connection to interface

This commit is contained in:
Ruben van de Ven 2019-11-12 11:01:56 +01:00
parent 1422ade597
commit 76d440fd8f
3 changed files with 8 additions and 6 deletions

View file

@ -28,7 +28,7 @@ web_dir = os.path.join(os.path.split(__file__)[0], '..', 'www')
def getWebSocketHandler(central_command): def getWebSocketHandler(central_command):
class WebSocketHandler(tornado.websocket.WebSocketHandler): class WebSocketHandler(tornado.websocket.WebSocketHandler):
CORS_ORIGINS = ['localhost', 'hugveycmd.local'] CORS_ORIGINS = ['localhost', 'hugveycmd.local', 'r3.local']
connections = set() connections = set()
selections = {} selections = {}

View file

@ -1999,7 +1999,8 @@ class Story(object):
@classmethod @classmethod
def getStateDir(self): def getStateDir(self):
return "/tmp" # return "/tmp"
return "./recordings"
# day = time.strftime("%Y%m%d") # day = time.strftime("%Y%m%d")
# t = time.strftime("%H:%M:%S") # t = time.strftime("%H:%M:%S")
# #
@ -2010,7 +2011,7 @@ class Story(object):
@classmethod @classmethod
def getStateFilename(cls, hv_id): 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): def storeState(self):
# TODO: stop stopwatch # TODO: stop stopwatch

View file

@ -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) { if(this.hasGraph) {
this.graph = new Graph(); this.graph = new Graph();
@ -377,7 +378,7 @@ class Graph {
getAudioUrlForMsg(msg) { getAudioUrlForMsg(msg) {
let isVariable = msg['text'].includes('$') ? '1' : '0'; let isVariable = msg['text'].includes('$') ? '1' : '0';
let lang = panopticon.graph.language_code; 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() { getConfig() {
@ -2169,7 +2170,7 @@ class Graph {
formData.append( "json", blob ); formData.append( "json", blob );
console.info("Save json", formData ); console.info("Save json", formData );
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.open( "POST", "http://localhost:8888/upload" ); request.open( "POST", window.location.origin + "/upload" );
if(callback) { if(callback) {
request.addEventListener( "load", callback); request.addEventListener( "load", callback);