mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-14 12:18:01 +00:00
Add sample support, re-organize repo
This commit is contained in:
51
src/components/appbar.js
Normal file
51
src/components/appbar.js
Normal file
@@ -0,0 +1,51 @@
|
||||
export default {
|
||||
name: 'AppBar',
|
||||
|
||||
data: () => ({
|
||||
drawyer: false,
|
||||
isAdmin: false
|
||||
}),
|
||||
created () {
|
||||
this.getCurrentUser()
|
||||
},
|
||||
methods: {
|
||||
home () {
|
||||
this.$router.push('/')
|
||||
},
|
||||
admin () {
|
||||
this.$router.push('/admin')
|
||||
},
|
||||
logout () {
|
||||
this.$http.get('/logout')
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
this.$router.push('/login')
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error.response)
|
||||
})
|
||||
},
|
||||
getCurrentUser () {
|
||||
this.$http.get('/users/current')
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
this.isAdmin = response.data.user.isAdmin
|
||||
this.$vuetify.theme.dark = response.data.user.darkMode
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error.response)
|
||||
this.isAdmin = false
|
||||
})
|
||||
},
|
||||
toggleDarkMode () {
|
||||
this.$http.patch('/users/dark-mode', {
|
||||
darkMode: this.$vuetify.theme.dark
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error.response)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user