Skip to content

Commit

Permalink
Inital Code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Warren committed Nov 9, 2018
1 parent 3a913c7 commit 74dec7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
>
Connection Closed
</v-alert>
<v-alert v-if="error"
:value="true"
type="error"
>
Connection Error
</v-alert>

<v-layout v-if="!token">
<v-flex xs12 sm6 offset-sm3>
Expand Down Expand Up @@ -98,17 +104,22 @@ export default {
token: null,
socket: null,
connected: false,
error: false
}
},
sockets: {
onopen () {
this.error = false
this.connected = true
this.messages.push({ 'title': 'System', 'message': 'Connection open' })
},
onclose () {
this.error = false
this.connected = false
},
onerror (err) {
this.connected = false
this.error = true
console.log (err)
},
onmessage (msg) {
Expand All @@ -128,6 +139,8 @@ export default {
this.token = token
this.newMessage = "Hi, I am "+ this.auth.username
this.$connect('ws://localhost:8080/stream?token=' + token)
// TODO Show Logged in
Expand All @@ -141,6 +154,7 @@ export default {
logout () {
this.token = null
this.$disconnect()
this.messages = []
},
send () {
this.axios({
Expand All @@ -151,12 +165,11 @@ export default {
'X-Gotify-Key': this.gotifyKey
},
}).then((resp) => {
this.newMessage = ''
// this.messages.push(resp.data)
}).catch((err) => {
console.log(err)
})
this.newMessage = ''
}
},
destroy () {
Expand Down
2 changes: 1 addition & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
logLevel: 'debug'
},
'/stream*': {
target: 'ws://' + process.env.VUE_APP_GOTIFY_URL + '',
target: 'ws://' + process.env.VUE_APP_GOTIFY_URL,
ws: true,
secure: false,
logLevel: 'debug',
Expand Down

0 comments on commit 74dec7a

Please sign in to comment.