Skip to content

Commit

Permalink
connection status
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoragrega committed Oct 19, 2021
1 parent 837a5df commit 9388092
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
14 changes: 14 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<template>
<v-app>
<v-progress-linear
:active=!connected
dark
absolute
top
indeterminate
color="yellow darken-2"
></v-progress-linear>
<!--v-app-bar app color="primary" dark>
<div class="d-flex align-center">
<v-img
Expand Down Expand Up @@ -36,15 +44,21 @@
<v-main>
<router-view />
</v-main>
<v-overlay :value="!connected"></v-overlay>
</v-app>
</template>

<script lang="ts">
import Vue from "vue";
import {mapState} from "vuex";
export default Vue.extend({
name: "App",
computed: mapState({
connected: state => state.socket.isConnected
}),
data: () => ({
//
}),
Expand Down
3 changes: 2 additions & 1 deletion client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import vuetify from "./plugins/vuetify";
import './assets/css/styles.scss';
import VueNativeSock from "vue-native-websocket";

//Vue.use(VueNativeSock, 'ws://192.168.1.101:3001/v1/ws', {
Vue.use(VueNativeSock, 'ws://127.0.0.1:3000/v1/ws', {
store: store,
format: 'json',
reconnection: true, // (Boolean) whether to reconnect automatically (false)
reconnectionAttempts: 5, // (Number) number of reconnection attempts before giving up (Infinity),
//reconnectionAttempts: 5, // (Number) number of reconnection attempts before giving up (Infinity),
reconnectionDelay: 3000,
})

Expand Down
9 changes: 4 additions & 5 deletions client/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ export default new Vuex.Store({
modules: {},
mutations: {
close_notification(state, id) {
console.log("deleting notification with ID", id)
console.log("current count", state.notifications.length)
state.notifications = state.notifications.filter(n => n.id !== id);
console.log("count after deletion", state.notifications.length)
},
SOCKET_ONOPEN (state, event) {
Vue.prototype.$socket = event.currentTarget
state.socket.isConnected = true
},
SOCKET_ONCLOSE (state, event) {
SOCKET_ONCLOSE (state) {
state.socket.isConnected = false
},
SOCKET_ONERROR (state, event) {
Expand All @@ -55,7 +52,9 @@ export default new Vuex.Store({
break;
case "SYSTEM-NOTIFICATION":
console.log("received system notification", message.data)
window.ipc.send('synchronous-message', message.data);
if (window.ipc !== undefined) {
window.ipc.send('synchronous-message', message.data);
}
break;
}
},
Expand Down

0 comments on commit 9388092

Please sign in to comment.