From c9a933926ba9de55f3503a0c5f324a7f54a7661a Mon Sep 17 00:00:00 2001 From: jedi Date: Thu, 25 Jan 2024 01:02:27 +0100 Subject: [PATCH] stash --- deploy/nginx-ws-proxy.conf | 27 +++++++++++ web/public/js/worker.js | 50 --------------------- web/src/views/admin/Debug.vue | 84 ++++++++++++++++++++++------------- web/vue.config.js | 39 ---------------- 4 files changed, 81 insertions(+), 119 deletions(-) create mode 100644 deploy/nginx-ws-proxy.conf delete mode 100644 web/public/js/worker.js diff --git a/deploy/nginx-ws-proxy.conf b/deploy/nginx-ws-proxy.conf new file mode 100644 index 0000000..7b55d7c --- /dev/null +++ b/deploy/nginx-ws-proxy.conf @@ -0,0 +1,27 @@ +http { + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + upstream websocket { + server staging.c3lf.de:443; + } + + server { + listen 8082; + access_log /home/jedi/Projects/c3lf-system-3/deploy/foo.log; + location / { + proxy_pass https://websocket; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Origin "https://staging.c3lf.de/"; + proxy_set_header Host $host; + } + } +} + +events {} + +pid /home/jedi/Projects/c3lf-system-3/deploy/nginx.pid; \ No newline at end of file diff --git a/web/public/js/worker.js b/web/public/js/worker.js deleted file mode 100644 index 19f4203..0000000 --- a/web/public/js/worker.js +++ /dev/null @@ -1,50 +0,0 @@ -let state = 0; -let ports = []; -let notify_socket; - -function tryConnect(){ - if(self.WebSocket === undefined){ - console.log("no websocket support"); - return; - } - if (!notify_socket || notify_socket.readyState !== WebSocket.OPEN) { - const scheme = location.protocol === "https:" ? "wss" : "ws"; - notify_socket = new WebSocket(scheme + '://' + location.host + '/ws/2/notify/'); - notify_socket.onopen = (e) => { - console.log("open", JSON.stringify(e)); - }; - notify_socket.onclose = (e) => { - console.log("close", JSON.stringify(e)); - setTimeout(() => { - tryConnect(); - }, 1000); - }; - notify_socket.onerror = (e) => { - console.log("error", JSON.stringify(e)); - setTimeout(() => { - tryConnect(); - }, 1000); - }; - notify_socket.onmessage = (e) => { - let data = JSON.parse(e.data); - console.log("message", data); - //this.loadEventItems() - //this.loadTickets() - } - } -} - -onconnect = function (e) { - const port = e.ports[0]; - ports.push(port); - port.onmessage = function (e) { - state = state + 1; - for (let i = 0; i < ports.length; i++) { - ports[i].postMessage({d: e.data, s: state, n: ports.length}); - } - } - port.start(); - console.log("worker connected", JSON.stringify(e)); - tryConnect(); -} - diff --git a/web/src/views/admin/Debug.vue b/web/src/views/admin/Debug.vue index 1acde81..683525c 100644 --- a/web/src/views/admin/Debug.vue +++ b/web/src/views/admin/Debug.vue @@ -1,39 +1,50 @@