Compare commits
No commits in common. "63999a9e74fc3015b1641b5aa2b4a85dd5a7503e" and "3b2ff65054c63a7bee3628be403473ef5e9a0b21" have entirely different histories.
63999a9e74
...
3b2ff65054
10 changed files with 72 additions and 202 deletions
|
|
@ -45,7 +45,7 @@
|
||||||
<v-icon>edit</v-icon>
|
<v-icon>edit</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
|
||||||
<v-dialog v-model="deleting">
|
<v-dialog v-model="deleting" persistent>
|
||||||
<template v-slot:activator="{ on }">
|
<template v-slot:activator="{ on }">
|
||||||
<v-btn fab absolute bottom left v-on="on">
|
<v-btn fab absolute bottom left v-on="on">
|
||||||
<v-icon>delete</v-icon>
|
<v-icon>delete</v-icon>
|
||||||
|
|
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
<template>
|
|
||||||
<Header v-if="user">
|
|
||||||
<v-btn flat :to="{ name: 'deckcp' }">
|
|
||||||
<v-icon>view_carousel</v-icon> Decks
|
|
||||||
</v-btn>
|
|
||||||
|
|
||||||
<v-btn flat>
|
|
||||||
<v-icon>play_arrow</v-icon> Play
|
|
||||||
</v-btn>
|
|
||||||
|
|
||||||
<v-btn flat :to="{ name: 'usercp' }">
|
|
||||||
<v-icon>person</v-icon> {{ user.login }}
|
|
||||||
</v-btn>
|
|
||||||
|
|
||||||
<v-dialog v-model="logging_out">
|
|
||||||
<template v-slot:activator="{ on }">
|
|
||||||
<v-btn flat v-on="on"> <v-icon>power_off</v-icon> Logout </v-btn>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<v-card>
|
|
||||||
<v-card-title class="headline">
|
|
||||||
Log Out?
|
|
||||||
</v-card-title>
|
|
||||||
|
|
||||||
<v-card-text>
|
|
||||||
Are you sure you want to log out?
|
|
||||||
</v-card-text>
|
|
||||||
|
|
||||||
<v-card-actions>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
|
|
||||||
<v-btn color="error" @click.native="logging_out = false">
|
|
||||||
Cancel
|
|
||||||
</v-btn>
|
|
||||||
|
|
||||||
<v-btn color="success" @click.native="logout">
|
|
||||||
Confirm
|
|
||||||
</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-dialog>
|
|
||||||
</Header>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import * as Cookies from 'js-cookie'
|
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
import Header from './Header'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'HeaderIntern',
|
|
||||||
|
|
||||||
components: {
|
|
||||||
Header
|
|
||||||
},
|
|
||||||
|
|
||||||
data: () => ({
|
|
||||||
logging_out: false
|
|
||||||
}),
|
|
||||||
|
|
||||||
props: {
|
|
||||||
value: String
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
goHome() {
|
|
||||||
this.$emit('input', '')
|
|
||||||
Cookies.remove('session')
|
|
||||||
this.$router.push({ name: 'home' })
|
|
||||||
},
|
|
||||||
|
|
||||||
logout() {
|
|
||||||
axios
|
|
||||||
.post('/user/logout', {
|
|
||||||
session: this.value
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (response.data.success) {
|
|
||||||
this.goHome()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
session: () => Cookies.get('session')
|
|
||||||
},
|
|
||||||
|
|
||||||
asyncComputed: {
|
|
||||||
user: {
|
|
||||||
get() {
|
|
||||||
return axios
|
|
||||||
.post('/user/info', {
|
|
||||||
session: this.session
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (response.data.success) {
|
|
||||||
this.$emit('input', this.session)
|
|
||||||
this.$emit('user', response.data.user)
|
|
||||||
return response.data.user
|
|
||||||
} else {
|
|
||||||
this.goHome()
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
default: {
|
|
||||||
user: 0,
|
|
||||||
login: '',
|
|
||||||
settings: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
{{ user.login }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'UserInfo',
|
|
||||||
|
|
||||||
props: {
|
|
||||||
session: String,
|
|
||||||
user: Object
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<v-dialog v-model="dialog">
|
<v-dialog v-model="dialog">
|
||||||
<template v-slot:activator="{ on }">
|
<template v-slot:activator="{ on }">
|
||||||
<v-btn flat v-on="on">
|
<v-btn flat v-on="on">
|
||||||
<v-icon>{{ icon }}</v-icon> {{ buttonText }}
|
{{ buttonText }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -60,8 +60,7 @@ export default {
|
||||||
}),
|
}),
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
buttonText: String,
|
buttonText: String
|
||||||
icon: String
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<FormDialog ref="main" buttonText="Login" icon="power" @validated="doLogin">
|
<FormDialog ref="main" buttonText="Login" @validated="doLogin">
|
||||||
<v-card-title class="headline">
|
<v-card-title class="headline">
|
||||||
Log In
|
Log In
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
@ -64,7 +64,7 @@ export default {
|
||||||
let cookie_data = JSON.parse(response.data.message)
|
let cookie_data = JSON.parse(response.data.message)
|
||||||
Cookies.set('session', cookie_data.value, cookie_data.properties)
|
Cookies.set('session', cookie_data.value, cookie_data.properties)
|
||||||
this.$refs.main.showSnackbar('Login successful!', 'success')
|
this.$refs.main.showSnackbar('Login successful!', 'success')
|
||||||
this.$router.push('deckcp')
|
this.$router.push('usercp')
|
||||||
} else {
|
} else {
|
||||||
this.$refs.main.showSnackbar(response.data.message, 'error')
|
this.$refs.main.showSnackbar(response.data.message, 'error')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<FormDialog
|
<FormDialog ref="main" buttonText="Register" @validated="doRegister">
|
||||||
ref="main"
|
|
||||||
buttonText="Register"
|
|
||||||
icon="book"
|
|
||||||
@validated="doRegister"
|
|
||||||
>
|
|
||||||
<v-card-title class="headline">
|
<v-card-title class="headline">
|
||||||
Register
|
Register
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,6 @@ export default new Router({
|
||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "usercp" */ './views/UserCP.vue')
|
import(/* webpackChunkName: "usercp" */ './views/UserCP.vue')
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/deckcp',
|
|
||||||
name: 'deckcp',
|
|
||||||
component: () =>
|
|
||||||
import(/* webpackChunkName: "deckcp" */ './views/DeckCP.vue')
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/game',
|
path: '/game',
|
||||||
name: 'game',
|
name: 'game',
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
<template>
|
|
||||||
<v-content>
|
|
||||||
<HeaderIntern v-model="session" @user="user = $event" />
|
|
||||||
|
|
||||||
<v-container v-if="user">
|
|
||||||
<h2 class="headline">Your Decks</h2>
|
|
||||||
<DeckList :session="session" />
|
|
||||||
</v-container>
|
|
||||||
</v-content>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import HeaderIntern from '@/components/HeaderIntern.vue'
|
|
||||||
import DeckList from '@/components/DeckList.vue'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'DeckCP',
|
|
||||||
|
|
||||||
components: {
|
|
||||||
HeaderIntern,
|
|
||||||
DeckList
|
|
||||||
},
|
|
||||||
|
|
||||||
data: () => ({
|
|
||||||
session: null,
|
|
||||||
user: null
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -36,17 +36,15 @@ export default {
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.session) {
|
axios
|
||||||
axios
|
.post('/user/login', {
|
||||||
.post('/user/login', {
|
session: this.session
|
||||||
session: this.session
|
})
|
||||||
})
|
.then(response => {
|
||||||
.then(response => {
|
if (response.data.success) {
|
||||||
if (response.data.success) {
|
this.$router.push({ name: 'usercp' })
|
||||||
this.$router.push({ name: 'deckcp' })
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,74 @@
|
||||||
<template>
|
<template>
|
||||||
<v-content>
|
<v-content>
|
||||||
<HeaderIntern v-model="session" @user="user = $event" />
|
<v-container>
|
||||||
|
<Header>
|
||||||
|
<v-btn flat @click.native="logout">Logout</v-btn>
|
||||||
|
</Header>
|
||||||
|
|
||||||
<v-container v-if="user">
|
<template v-if="user">
|
||||||
<h2 class="headline">User Info</h2>
|
<p>user logged in: {{ user.login }}</p>
|
||||||
<UserInfo :session="session" :user="user" />
|
</template>
|
||||||
|
|
||||||
|
<DeckList :session="session" />
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-content>
|
</v-content>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HeaderIntern from '@/components/HeaderIntern.vue'
|
import * as Cookies from 'js-cookie'
|
||||||
import UserInfo from '@/components/UserInfo.vue'
|
import axios from '@/plugins/axios'
|
||||||
|
|
||||||
|
import Header from '@/components/Header.vue'
|
||||||
|
import DeckList from '@/components/DeckList.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UserCP',
|
name: 'UserCP',
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
HeaderIntern,
|
Header,
|
||||||
UserInfo
|
DeckList
|
||||||
},
|
},
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({}),
|
||||||
session: null,
|
|
||||||
user: null
|
methods: {
|
||||||
})
|
goHome() {
|
||||||
|
Cookies.remove('session')
|
||||||
|
this.$router.push({ name: 'home' })
|
||||||
|
},
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
axios
|
||||||
|
.post('/user/logout', {
|
||||||
|
session: this.session
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.data.success) {
|
||||||
|
this.goHome()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
session: () => Cookies.get('session')
|
||||||
|
},
|
||||||
|
|
||||||
|
asyncComputed: {
|
||||||
|
user() {
|
||||||
|
return axios
|
||||||
|
.post('/user/info', {
|
||||||
|
session: this.session
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.data.success) {
|
||||||
|
return response.data.user
|
||||||
|
} else {
|
||||||
|
this.goHome()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Reference in a new issue