Skip to content

Commit

Permalink
Added snackbar to message, show error on login. Fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
rudmanmrrod committed Jul 18, 2019
1 parent b7f37e7 commit 4fd6d11
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
8 changes: 7 additions & 1 deletion frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@
<span class="font-weight-light">SGE</span>
</v-toolbar-title>
</v-toolbar>

<v-snackbar
v-model="$store.state.snackbar.value"
:color="$store.state.snackbar.type"
top="true"
>
{{ $store.state.snackbar.text }}
</v-snackbar>
<v-content>
<router-view/>
</v-content>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/UserManagement/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export default{
this.$router.push('/')
})
.catch(error => {
console.log(error)
let message = {
'text': error.response.data.detail,
'type': 'error',
'value':true
}
this.$store.dispatch('setMessage',message)
})
}
})
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/UserManagement/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
name="username"
v-validate="'required'"
:error-messages="errors.collect('username')"
:label="email"
:data-vv-as="email"
label="email"
></v-text-field>
</v-flex>
<v-flex xs12>
Expand All @@ -19,7 +18,7 @@
name="password"
v-validate="'required|min:8'"
:error-messages="errors.collect('password')"
:label="password"
label="password"
type="password"
></v-text-field>
</v-flex>
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ export default new Vuex.Store({
users: users
},
state: {

snackbar:{
value: false,
type: '',
text: ''
}
},
mutations: {

['SET_MSG'] (state,payload){
state.snackbar = payload
}
},
actions: {

setMessage({commit},obj){
commit('SET_MSG',obj)
}
}
})
5 changes: 3 additions & 2 deletions frontend/src/store/users.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export default{
state: {
user: localStorage.getItem('user')
user: localStorage.getItem('user') ? JSON.parse(localStorage.getItem('user')):null
},
mutations: {
['LOGIN'] (state,payload){
state.user = payload
localStorage.setItem('user',JSON.stringify(payload))
state.user = JSON.stringify(payload)
}
},
actions: {
Expand Down

0 comments on commit 4fd6d11

Please sign in to comment.