Add frontend debug messages

This commit is contained in:
Jan Oberhauser 2020-06-08 16:35:08 +02:00
parent a03d5c6e14
commit 6830a6eb93
2 changed files with 18 additions and 6 deletions

View file

@ -29,12 +29,6 @@ export const nodeBase = mixins(nodeIndex).extend({
isMacOs (): boolean { isMacOs (): boolean {
return /(ipad|iphone|ipod|mac)/i.test(navigator.platform); return /(ipad|iphone|ipod|mac)/i.test(navigator.platform);
}, },
isReadOnly (): boolean {
if (['NodeViewExisting', 'NodeViewNew'].includes(this.$route.name as string)) {
return false;
}
return true;
},
nodeName (): string { nodeName (): string {
return NODE_NAME_PREFIX + this.nodeIndex; return NODE_NAME_PREFIX + this.nodeIndex;
}, },

View file

@ -33,11 +33,14 @@ export const pushConnection = mixins(
}, },
methods: { methods: {
pushAutomaticReconnect (): void { pushAutomaticReconnect (): void {
console.log('pushAutomaticReconnect: 1');
if (this.reconnectTimeout !== null) { if (this.reconnectTimeout !== null) {
console.log('pushAutomaticReconnect: 2');
return; return;
} }
this.reconnectTimeout = setTimeout(() => { this.reconnectTimeout = setTimeout(() => {
console.log('pushAutomaticReconnect: 3');
this.pushConnect(); this.pushConnect();
}, 3000); }, 3000);
}, },
@ -46,6 +49,8 @@ export const pushConnection = mixins(
* Connect to server to receive data via EventSource * Connect to server to receive data via EventSource
*/ */
pushConnect (): void { pushConnect (): void {
console.log('pushConnect: 1');
// Make sure existing event-source instances get // Make sure existing event-source instances get
// always removed that we do not end up with multiple ones // always removed that we do not end up with multiple ones
this.pushDisconnect(); this.pushDisconnect();
@ -55,23 +60,32 @@ export const pushConnection = mixins(
this.eventSource = new EventSource(connectionUrl); this.eventSource = new EventSource(connectionUrl);
this.eventSource.addEventListener('message', this.pushMessageReceived, false); this.eventSource.addEventListener('message', this.pushMessageReceived, false);
console.log('pushConnect: 2');
this.eventSource.addEventListener('open', () => { this.eventSource.addEventListener('open', () => {
console.log('pushConnect: 20 - open');
this.$store.commit('setPushConnectionActive', true); this.$store.commit('setPushConnectionActive', true);
console.log('pushConnect: 21');
if (this.reconnectTimeout !== null) { if (this.reconnectTimeout !== null) {
console.log('pushConnect: 22');
clearTimeout(this.reconnectTimeout); clearTimeout(this.reconnectTimeout);
this.reconnectTimeout = null; this.reconnectTimeout = null;
} }
}, false); }, false);
this.eventSource.addEventListener('error', () => { this.eventSource.addEventListener('error', () => {
console.log('pushConnect: 30 - error');
this.pushDisconnect(); this.pushDisconnect();
if (this.reconnectTimeout !== null) { if (this.reconnectTimeout !== null) {
console.log('pushConnect: 31');
clearTimeout(this.reconnectTimeout); clearTimeout(this.reconnectTimeout);
this.reconnectTimeout = null; this.reconnectTimeout = null;
} }
console.log('pushConnect: 32');
this.$store.commit('setPushConnectionActive', false); this.$store.commit('setPushConnectionActive', false);
console.log('pushConnect: 33');
this.pushAutomaticReconnect(); this.pushAutomaticReconnect();
}, false); }, false);
}, },
@ -80,11 +94,15 @@ export const pushConnection = mixins(
* Close connection to server * Close connection to server
*/ */
pushDisconnect (): void { pushDisconnect (): void {
console.log('pushDisconnect: 1');
if (this.eventSource !== null) { if (this.eventSource !== null) {
console.log('pushDisconnect: 2');
this.eventSource.close(); this.eventSource.close();
this.eventSource = null; this.eventSource = null;
this.$store.commit('setPushConnectionActive', false); this.$store.commit('setPushConnectionActive', false);
console.log('pushDisconnect: 3');
} }
}, },