stash
This commit is contained in:
parent
b962ff3dbc
commit
e0679e965d
7 changed files with 161 additions and 132 deletions
27
deploy/nginx-ws-proxy.conf
Normal file
27
deploy/nginx-ws-proxy.conf
Normal file
|
@ -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;
|
|
@ -8,14 +8,14 @@
|
||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.5",
|
||||||
"base-64": "^0.1.0",
|
"base-64": "^1.0.0",
|
||||||
"bootstrap": "^4.3.1",
|
"bootstrap": "^4.3.1",
|
||||||
"core-js": "^3.3.2",
|
"core-js": "^3.35.1",
|
||||||
"jquery": "^3.4.1",
|
"jquery": "^3.4.1",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"luxon": "^1.21.3",
|
"luxon": "^1.21.3",
|
||||||
"popper.js": "^1.16.0",
|
"popper.js": "^1.16.1",
|
||||||
"ramda": "^0.26.1",
|
"ramda": "^0.26.1",
|
||||||
"sass": "^1.19.0",
|
"sass": "^1.19.0",
|
||||||
"sass-loader": "^10.4.1",
|
"sass-loader": "^10.4.1",
|
||||||
|
@ -31,8 +31,10 @@
|
||||||
"@vue/cli-plugin-babel": "^5.0.8",
|
"@vue/cli-plugin-babel": "^5.0.8",
|
||||||
"@vue/cli-service": "~5.0.8",
|
"@vue/cli-service": "~5.0.8",
|
||||||
"express-basic-auth": "^1.2.1",
|
"express-basic-auth": "^1.2.1",
|
||||||
|
"http-proxy-middleware": "^2.0.6",
|
||||||
"vue-template-compiler": "^2.6.10",
|
"vue-template-compiler": "^2.6.10",
|
||||||
"webpack": "^5"
|
"webpack": "^5",
|
||||||
|
"webpack-dev-server": "^4.15.1"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,28 +1,99 @@
|
||||||
export default (config) => (store) => ({
|
export default (config) => {
|
||||||
onInit: () => {
|
console.log('plugin created');
|
||||||
console.log('onInit');
|
const worker_fun = function (self, ctx) {
|
||||||
store.dispatch('init');
|
let state = 0;
|
||||||
},
|
let ports = [];
|
||||||
onMutation: (mutation, state) => {
|
let notify_socket;
|
||||||
console.log('onMutation', mutation.type);
|
|
||||||
if (mutation.type === 'updateLastEvent') {
|
function tryConnect() {
|
||||||
console.log('update last event', mutation.payload);
|
if (self.WebSocket === undefined) {
|
||||||
store.dispatch('updateLastEvent', mutation.payload);
|
console.log("no websocket support");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
},
|
if (!notify_socket || notify_socket.readyState !== WebSocket.OPEN) {
|
||||||
onAction: (action, state) => {
|
// global location is not useful in worker loaded from data url
|
||||||
console.log('onAction', action.type);
|
const scheme = ctx.location.protocol === "https:" ? "wss" : "ws";
|
||||||
if (action.type === 'updateLastEvent') {
|
console.log("connecting to", scheme + '://' + ctx.location.host + '/ws/2/notify/');
|
||||||
console.log('update last event', action.payload);
|
notify_socket = new WebSocket(scheme + '://' + ctx.location.host + '/ws/2/notify/');
|
||||||
store.dispatch('updateLastEvent', action.payload);
|
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()
|
||||||
}
|
}
|
||||||
},
|
|
||||||
onSubscription: (mutation, state) => {
|
|
||||||
console.log('onSubscription', mutation.type);
|
|
||||||
if (mutation.type === 'updateLastEvent') {
|
|
||||||
console.log('update last event', mutation.payload);
|
|
||||||
store.dispatch('updateLastEvent', mutation.payload);
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
// other hooks...
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("worker loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
const worker_context = {
|
||||||
|
location: { ...location },
|
||||||
|
}
|
||||||
|
const worker_code = '(' + worker_fun.toString() + ')(self,' + JSON.stringify(worker_context) + ')';
|
||||||
|
const worker_url = 'data:application/javascript;base64,' + btoa(worker_code);
|
||||||
|
|
||||||
|
const worker = new SharedWorker(worker_url, 'vuex-shared-state-plugin');
|
||||||
|
worker.port.start();
|
||||||
|
worker.port.onmessage = function (e) {
|
||||||
|
console.log('worker result', e.data);
|
||||||
|
};
|
||||||
|
worker.port.postMessage([2, 3]);
|
||||||
|
console.log('worker started');
|
||||||
|
|
||||||
|
return (store) => {
|
||||||
|
console.log('plugin started');
|
||||||
|
if ('mutations' in config) {
|
||||||
|
store.subscribe((mutation, state) => {
|
||||||
|
if (mutation.type in config.mutations) {
|
||||||
|
console.log(mutation.type, mutation.payload);
|
||||||
|
console.log(state);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if ('actions' in config) {
|
||||||
|
store.subscribeAction((action, state) => {
|
||||||
|
if (action.type in config.actions) {
|
||||||
|
console.log(action.type, action.payload);
|
||||||
|
console.log(state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if ('state' in config) {
|
||||||
|
config.state.forEach((member) => {
|
||||||
|
store.watch((state, getters) => state[member], (newValue, oldValue) => {
|
||||||
|
console.log('watch', member, newValue, oldValue);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -18,13 +18,7 @@ import sharedStatePlugin from "@/shared-state-plugin";
|
||||||
|
|
||||||
//Vue.use(worker);
|
//Vue.use(worker);
|
||||||
|
|
||||||
const worker = new SharedWorker('/js/worker.js');
|
|
||||||
worker.port.start();
|
|
||||||
worker.port.onmessage = function (e) {
|
|
||||||
console.log('worker result', e.data);
|
|
||||||
};
|
|
||||||
worker.port.postMessage([2, 3]);
|
|
||||||
console.log('worker started');
|
|
||||||
|
|
||||||
|
|
||||||
const axios = AxiosBootstrap.create({
|
const axios = AxiosBootstrap.create({
|
||||||
|
@ -244,7 +238,10 @@ const store = createStore({
|
||||||
localStorage.removeItem('token_expiry');
|
localStorage.removeItem('token_expiry');
|
||||||
if (router.currentRoute.name !== 'login')
|
if (router.currentRoute.name !== 'login')
|
||||||
router.push('/login');
|
router.push('/login');
|
||||||
}
|
},
|
||||||
|
setTest(state, test) {
|
||||||
|
state.test = test;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async login({commit, dispatch, state}, {username, password, remember}) {
|
async login({commit, dispatch, state}, {username, password, remember}) {
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<div>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<button class="btn btn-primary" @click="addTest('test')">+</button>
|
||||||
|
</li>
|
||||||
|
<li v-for="(t, index) in test" :key="index">
|
||||||
|
{{ t }}
|
||||||
|
<button class="btn btn-link" @click="removeTest(index)">-</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<!--qr-code :text="qr_url" color="#000" bg-color="#fff" error-level="H" class="qr-code"></qr-code-->
|
<!--qr-code :text="qr_url" color="#000" bg-color="#fff" error-level="H" class="qr-code"></qr-code-->
|
||||||
<h3 class="text-center">Events</h3>
|
<h3 class="text-center">Events</h3>
|
||||||
<!--p>{{ events }}</p-->
|
<!--p>{{ events }}</p-->
|
||||||
|
@ -47,7 +58,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapActions, mapState} from 'vuex';
|
import {mapActions, mapMutations, mapState} from 'vuex';
|
||||||
import Table from '@/components/Table';
|
import Table from '@/components/Table';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -60,13 +71,23 @@ export default {
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['events', 'loadedItems', 'loadedBoxes']),//, 'mails', 'issues', 'systemEvents']),
|
...mapState(['events', 'loadedItems', 'loadedBoxes']),//, 'mails', 'issues', 'systemEvents']),
|
||||||
|
...mapState(['test']),
|
||||||
qr_url() {
|
qr_url() {
|
||||||
return window.location.href;
|
return window.location.href;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['changeEvent'])//, 'loadMails', 'loadIssues', 'loadSystemEvents']),
|
...mapActions(['changeEvent']),//, 'loadMails', 'loadIssues', 'loadSystemEvents']),
|
||||||
|
...mapMutations(['setTest']),
|
||||||
|
addTest(test) {
|
||||||
|
const tests = [...this.test, test];
|
||||||
|
this.setTest(tests);
|
||||||
|
},
|
||||||
|
removeTest(index) {
|
||||||
|
const tests = [...this.test];
|
||||||
|
tests.splice(index, 1);
|
||||||
|
this.setTest(tests);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
//this.loadMails();
|
//this.loadMails();
|
||||||
|
|
|
@ -7,45 +7,6 @@ module.exports = {
|
||||||
"Access-Control-Allow-Headers": "*",
|
"Access-Control-Allow-Headers": "*",
|
||||||
"Access-Control-Allow-Methods": "*"
|
"Access-Control-Allow-Methods": "*"
|
||||||
},
|
},
|
||||||
//devMiddleware: {
|
|
||||||
// //location /redirect_media/ {
|
|
||||||
// // internal;
|
|
||||||
// // alias /var/www/c3lf-sys3/userfiles/;
|
|
||||||
// //}
|
|
||||||
// //
|
|
||||||
// //location /redirect_thumbnail/ {
|
|
||||||
// // internal;
|
|
||||||
// // alias /var/www/c3lf-sys3/userfiles/thumbnails/;
|
|
||||||
// //}
|
|
||||||
// modifyResponse: function (res) {
|
|
||||||
// path = res.headers['x-accel-redirect'];
|
|
||||||
// let re_path;
|
|
||||||
// if (path && path.includes('/redirect_thumbnail/')) {
|
|
||||||
// re_path = path.replace('/redirect_thumbnail/', '../userfiles/thumbnails/');
|
|
||||||
// }else if (path && path.includes('/redirect_media/')) {
|
|
||||||
// re_path = path.replace('/redirect_media/', '../userfiles/');
|
|
||||||
// }
|
|
||||||
// const body = require(re_path);
|
|
||||||
// res.headers['content-type'] = 'image/jpeg';
|
|
||||||
// res.headers['content-length'] = body.length;
|
|
||||||
// res.body = body;
|
|
||||||
// return res;
|
|
||||||
// },
|
|
||||||
//},
|
|
||||||
/*setupMiddlewares: (middlewares, devServer) => {
|
|
||||||
devServer.app.use(basicAuth({
|
|
||||||
users: {
|
|
||||||
'c3lf': 'findetalles'
|
|
||||||
},
|
|
||||||
challenge: true
|
|
||||||
}));
|
|
||||||
|
|
||||||
return middlewares;
|
|
||||||
},*/
|
|
||||||
/*watchOptions: {
|
|
||||||
poll: true,
|
|
||||||
ignored: /node_modules/,
|
|
||||||
},*/
|
|
||||||
proxy: {
|
proxy: {
|
||||||
'^/media/2': {
|
'^/media/2': {
|
||||||
target: 'https://staging.c3lf.de/',
|
target: 'https://staging.c3lf.de/',
|
||||||
|
@ -60,8 +21,8 @@ module.exports = {
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'^/ws/2': {
|
'^/ws/2': {
|
||||||
target: 'https://staging.c3lf.de/',
|
target: 'http://127.0.0.1:8082/',
|
||||||
changeOrigin: true,
|
//changeOrigin: true,
|
||||||
ws: true,
|
ws: true,
|
||||||
logLevel: 'debug',
|
logLevel: 'debug',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue