stash
This commit is contained in:
parent
4b11264dfe
commit
b050c4870f
1 changed files with 38 additions and 38 deletions
|
@ -33,7 +33,7 @@ export default {
|
|||
}),
|
||||
methods: {
|
||||
...mapMutations(['removeToast', 'createToast']),
|
||||
...mapActions(['loadItems', 'loadTickets']),
|
||||
...mapActions(['loadEventItems', 'loadTickets']),
|
||||
openAddModal() {
|
||||
this.addModalOpen = true;
|
||||
},
|
||||
|
@ -42,62 +42,62 @@ export default {
|
|||
},
|
||||
tryConnect() {
|
||||
if (!this.notify_socket || this.notify_socket.readyState !== WebSocket.OPEN) {
|
||||
if (this.socket_toast) {
|
||||
this.removeToast(this.socket_toast.key);
|
||||
this.socket_toast = null;
|
||||
}
|
||||
this.socket_toast = this.createToast({
|
||||
title: "Connecting...",
|
||||
message: "Connecting to websocket...",
|
||||
color: "warning"
|
||||
});
|
||||
//if (this.socket_toast) {
|
||||
// this.removeToast(this.socket_toast.key);
|
||||
// this.socket_toast = null;
|
||||
//}
|
||||
//this.socket_toast = this.createToast({
|
||||
// title: "Connecting...",
|
||||
// message: "Connecting to websocket...",
|
||||
// color: "warning"
|
||||
//});
|
||||
const scheme = window.location.protocol === "https:" ? "wss" : "ws";
|
||||
this.notify_socket = new WebSocket(scheme + '://' + window.location.host + '/ws/2/notify/');
|
||||
this.notify_socket.onopen = (e) => {
|
||||
if (this.socket_toast) {
|
||||
this.removeToast(this.socket_toast.key);
|
||||
this.socket_toast = null;
|
||||
}
|
||||
//if (this.socket_toast) {
|
||||
// this.removeToast(this.socket_toast.key);
|
||||
// this.socket_toast = null;
|
||||
//}
|
||||
//this.socket_toast = this.createToast({
|
||||
// title: "Connection established",
|
||||
// message: JSON.stringify(e),
|
||||
// color: "success"
|
||||
//});
|
||||
console.log(e);
|
||||
this.socket_toast = this.createToast({
|
||||
title: "Connection established",
|
||||
message: JSON.stringify(e),
|
||||
color: "success"
|
||||
});
|
||||
};
|
||||
this.notify_socket.onclose = (e) => {
|
||||
if (this.socket_toast) {
|
||||
this.removeToast(this.socket_toast.key);
|
||||
this.socket_toast = null;
|
||||
}
|
||||
//if (this.socket_toast) {
|
||||
// this.removeToast(this.socket_toast.key);
|
||||
// this.socket_toast = null;
|
||||
//}
|
||||
//this.socket_toast = this.createToast({
|
||||
// title: "Connection closed",
|
||||
// message: JSON.stringify(e),
|
||||
// color: "danger"
|
||||
//});
|
||||
console.log(e);
|
||||
this.socket_toast = this.createToast({
|
||||
title: "Connection closed",
|
||||
message: JSON.stringify(e),
|
||||
color: "danger"
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.tryConnect();
|
||||
}, 1000);
|
||||
};
|
||||
this.notify_socket.onerror = (e) => {
|
||||
if (this.socket_toast) {
|
||||
this.removeToast(this.socket_toast.key);
|
||||
this.socket_toast = null;
|
||||
}
|
||||
//if (this.socket_toast) {
|
||||
// this.removeToast(this.socket_toast.key);
|
||||
// this.socket_toast = null;
|
||||
//}
|
||||
//this.socket_toast = this.createToast({
|
||||
// title: "Connection error",
|
||||
// message: JSON.stringify(e),
|
||||
// color: "danger"
|
||||
//});
|
||||
console.log(e);
|
||||
this.socket_toast = this.createToast({
|
||||
title: "Connection error",
|
||||
message: JSON.stringify(e),
|
||||
color: "danger"
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.tryConnect();
|
||||
}, 1000);
|
||||
};
|
||||
this.notify_socket.onmessage = (e) => {
|
||||
let data = JSON.parse(e.data);
|
||||
//this.loadItems()
|
||||
this.loadEventItems()
|
||||
this.loadTickets()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue