Add sample support, re-organize repo

This commit is contained in:
Kevin Thomas
2021-09-24 00:35:18 -07:00
parent b9e340c26a
commit f2d1b80673
23 changed files with 703 additions and 524 deletions

77
src/components/admin.js Normal file
View File

@@ -0,0 +1,77 @@
export default {
name: 'Admin',
data: () => ({
currentUser: {},
users: [],
snackbar: false,
updateText: ''
}),
created () {
this.getCurrentUser()
this.getUsers()
},
methods: {
getUsers () {
this.$http.get('/users')
.then(response => {
if (response.status === 200) {
this.users = response.data.users
}
})
.catch((error) => {
console.error(error.response)
})
},
getCurrentUser () {
this.$http.get('/users/current')
.then(response => {
if (response.status === 200) {
this.currentUser = response.data.user
}
})
.catch((error) => {
console.error(error.response)
})
},
updateUserAdmin (id, isAdmin) {
this.$http.patch('/users/admin/'.concat(id), {
isAdmin: isAdmin
})
.then(response => {
if (response.status === 200) {
this.updateText = 'User updated'
}
})
.catch(function (error) {
console.error(error.response)
this.updateText = 'Error updating user'
})
},
updateUserUpload (id, canUpload) {
this.$http.patch('/users/upload/'.concat(id), {
canUpload: canUpload
})
.then(response => {
if (response.status === 200) {
this.updateText = 'User updated'
}
})
.catch(function (error) {
console.error(error.response)
this.updateText = 'Error updating user'
})
},
deleteUser (id) {
this.$http.delete('/users/'.concat(id))
.then(response => {
if (response.status === 200) {
this.getUsers()
}
})
.catch((error) => {
console.error(error.response)
})
}
}
}