fix and friends

This commit is contained in:
Bytetrex 2021-04-09 15:49:59 +08:00
parent 73fca4ff51
commit ac76d704cb
10 changed files with 288 additions and 293 deletions

View file

@ -23,8 +23,8 @@ export default {
const jwt = localStorage.getItem("token"); const jwt = localStorage.getItem("token");
const wind = localStorage.getItem("wind404"); const wind = localStorage.getItem("wind404");
if (token) { if (jwt) {
this.$store.commit("setToken", token); this.$store.commit("setToken", jwt);
} }
if (wind) { if (wind) {
@ -33,6 +33,10 @@ export default {
this.$store.commit("setWind", wind); this.$store.commit("setWind", wind);
} }
Object.assign(axios.defaults, {
headers: { Authorization: this.$store.state.user.token },
});
if (this.$store.state.debug) { if (this.$store.state.debug) {
this.$buefy.snackbar.open({ this.$buefy.snackbar.open({
message: this.$t("errors.devBuild"), message: this.$t("errors.devBuild"),

View file

@ -29,10 +29,6 @@ Vue.use(VMdEditor);
Vue.use(VueAxios, axios); Vue.use(VueAxios, axios);
Vue.use(Buefy); Vue.use(Buefy);
// Axios Headers
const jwtToken = localStorage.getItem("token");
axios.defaults.headers.common["Authorization"] = jwtToken;
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.prototype.$snackbar = Snackbar; Vue.prototype.$snackbar = Snackbar;

View file

@ -183,7 +183,7 @@ const routes = [{
redirect: "/settings/general", redirect: "/settings/general",
children: [ children: [
{ path: 'general', component: route('SettingsGeneral') }, { path: 'general', component: route('SettingsGeneral') },
{ path: 'account', component: route('SettingsAccount') }, { path: 'security', component: route('SettingsSecurity') },
{ path: 'about', component: route('SettingsAbout') }, { path: 'about', component: route('SettingsAbout') },
] ]
}, },

View file

@ -1,19 +1,43 @@
<template> <template>
<main> <div id="debug">
<section class="section">
<div class="container" v-if="!$store.state.debug">
<div class="columns is-centered">
<div class="column"> <div class="column">
<div class="box"> <div class="box">
{{$t('debug.title')}}: {{$store.state.debug}} <div class="title">
<br> {{ $t("debug.title") }}: {{ store.state.debug }}
<div v-if="$store.state.debug"> {{$t('debug.authUser')}}: {{$store.state.user.username}}<br>
{{$t('debug.userState')}}: {{$store.state.user}}<br>
{{$t('debug.state')}}: {{$store.state}}<br>
{{$t('debug.token')}}: {{$store.state.user.token}}
</div> </div>
<b-button v-if="$store.state.debug" @click="authTest">{{$t('debug.auth')}}</b-button> <hr>
<b-button v-if="$store.state.debug" @click="turnOffDebug">{{$t('debug.disable')}}</b-button> <p>If you'd like to re-enable debug mode refresh.</p>
</div> </div>
</div> </div>
</main> </div>
</div>
<div class="container" v-else>
<div class="columns is-centered">
<div class="column is-7">
<div class="box">
<div class="title">
{{ $t("debug.title") }}: {{ $store.state.debug }}
</div>
<hr />
{{ $t("debug.authUser") }}: {{ $store.state.user.username }}<br />
{{ $t("debug.userState") }}: {{ $store.state.user }}<br />
{{ $t("debug.state") }}: {{ $store.state }}<br />
{{ $t("debug.token") }}: {{ $store.state.user.token }}
</div>
<b-button v-if="$store.state.debug" @click="authTest">{{
$t("debug.auth")
}}</b-button>
<b-button v-if="$store.state.debug" @click="turnOffDebug">{{
$t("debug.disable")
}}</b-button>
</div>
</div>
</div>
</section>
</div>
</template> </template>
<script> <script>
@ -21,17 +45,28 @@ export default {
name: "Debug", name: "Debug",
methods: { methods: {
turnOffDebug() { turnOffDebug() {
this.$store.commit('turnOffDebug') this.$store.commit("turnOffDebug");
this.$buefy.snackbar.open({message:this.$t('errors.disableDebug'), type: 'is-warning'}) this.$buefy.snackbar.open({
message: this.$t("errors.disableDebug"),
type: "is-warning",
});
}, },
authTest() { authTest() {
this.axios.get('/api/v1/userinfo/auth' this.axios
).then(() => { .get("/api/v1/userinfo/auth")
this.$buefy.snackbar.open({message:this.$t('errors.authSuccess'), type: 'is-warning'}) .then(() => {
}).catch(() => { this.$buefy.snackbar.open({
this.$buefy.snackbar.open({message:this.$t('errors.authFail'), type: 'is-warning'}) message: this.$t("errors.authSuccess"),
type: "is-warning",
});
}) })
} .catch(() => {
} this.$buefy.snackbar.open({
} message: this.$t("errors.authFail"),
type: "is-warning",
});
});
},
},
};
</script> </script>

View file

@ -1,54 +1,51 @@
<template> <template>
<main> <div id="friends">
<div class="section"> <section class="section">
<h1 class="title has-text-centered">{{name}} ({{count}})</h1> <div class="columns is-centered">
<div class="column is-7 has-text-centered">
<div class="title">{{ name }} ({{ count }})</div>
<div class="tabs is-centered"> <div class="tabs is-centered">
<ul> <ul>
<router-link tag="li" :to="'/friends/pendingCanAccept'" exact><a>{{ $t('friends.pendingCanAccept') }}</a></router-link> <router-link tag="li" :to="'/friends/pendingCanAccept'" exact><a>{{ $t('friends.pendingCanAccept') }}</a>
<router-link tag="li" :to="'/friends/accepted'" exact><a>{{ $t('friends.accepted') }}</a></router-link> </router-link>
<router-link tag="li" :to="'/friends/pending'" exact><a>{{ $t('friends.pending') }}</a></router-link> <router-link tag="li" :to="'/friends/pending'" exact><a>{{ $t('friends.pending') }}</a></router-link>
<router-link tag="li" :to="'/friends/accepted'" exact><a>{{ $t('friends.accepted') }}</a></router-link>
</ul> </ul>
</div> </div>
<div class="columns is-multiline" v-if="friends.length && !loading"> <div class="columns is-multiline" v-if="friends.length && !loading">
<div class="column is-3 has-text-centered" v-for='(friend) in friends' :key='"friend-" + friend.id'> <div class="column is-3 has-text-centered" v-for='(friend) in friends' :key='"friend-" + friend.id'>
<h1 class="title has-text-centered">{{ friend.friend2.username }}</h1> <h1 class="title has-text-centered">{{ friend.friend2.username }}</h1>
<div class="box"> <div class="box">
<img :src="'https://cdn.kaverti.com/user/avatars/full/' + friend.friend2.picture + '.png'"><br> <img :src="'https://cdn.kaverti.com/user/avatars/full/' + friend.friend2.picture + '.png'" alt="Avatar"><br>
<div class="buttons"> <div class="buttons">
<b-button @click="removeFriend(friend)" class="is-warning has-text-centered is-centered is-center" v-if="friend.type === 'pending'"><i class="fas fa-minus"></i>&nbsp;Cancel Friend Request</b-button> <b-button @click="removeFriend(friend)" class="is-warning has-text-centered is-centered is-center"
<b-button @click="removeFriend(friend)" class="is-warning has-text-centered is-centered is-center" v-if="friend.type === 'pendingCanAccept'"><i class="fas fa-minus"></i>&nbsp;Deny Friend Request</b-button> v-if="friend.type === 'pending'"><i class="fas fa-minus"></i>&nbsp;Cancel Friend Request
<b-button @click="doRelationshipAccept(friend)" class="is-success has-text-centered is-centered is-center" v-if="friend.type === 'pendingCanAccept'"><i class="fas fa-plus"></i>&nbsp;Accept Friend Request</b-button> </b-button>
<b-button @click="removeFriend(friend)" class="is-danger has-text-centered is-centered is-center" v-if="friend.type === 'accepted'"><i class="fas fa-minus"></i>&nbsp;Remove Friend</b-button> <b-button @click="removeFriend(friend)" class="is-warning has-text-centered is-centered is-center"
v-if="friend.type === 'pendingCanAccept'"><i class="fas fa-minus"></i>&nbsp;Deny Friend
Request
</b-button>
<b-button @click="doRelationshipAccept(friend)"
class="is-success has-text-centered is-centered is-center"
v-if="friend.type === 'pendingCanAccept'"><i class="fas fa-plus"></i>&nbsp;Accept Friend
Request
</b-button>
<b-button @click="removeFriend(friend)" class="is-danger has-text-centered is-centered is-center"
v-if="friend.type === 'accepted'"><i class="fas fa-minus"></i>&nbsp;Remove Friend
</b-button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="section" v-if="!friends.length && !loading">
<NoItems type="friends"></NoItems>
</div>
<div class="section columns" v-if="loading">
<div class="column">
<div class="box">
<b-skeleton></b-skeleton>
</div> </div>
</div> </div>
<div class="column"> </section>
<div class="box">
<b-skeleton></b-skeleton>
</div> </div>
</div>
<div class="column">
<div class="box">
<b-skeleton></b-skeleton>
</div>
</div>
</div>
</div>
</main>
</template> </template>
<script> <script>
import AjaxErrorHandler from ".././assets/js/errorHandler"; import AjaxErrorHandler from ".././assets/js/errorHandler";
import NoItems from "../components/NoItems" import NoItems from "../components/NoItems"
export default { export default {
name: 'Friends', name: 'Friends',
components: { components: {
@ -65,20 +62,20 @@ export default {
}, },
watch: { watch: {
$route() { $route() {
this.loading = true this.loading = true;
this.friends = [] this.friends = [];
this.offset = 0 this.offset = 0;
this.category = this.$route.params.category this.category = this.$route.params.category;
if (this.category === 'pendingCanAccept') { if (this.category === 'pendingCanAccept') {
this.name = "Requests to you" this.name = "Requests to you";
} else if (this.category === 'pending') { } else if (this.category === 'pending') {
this.name = "Requests from you" this.name = "Requests from you";
} else if (this.category === 'accepted') { } else if (this.category === 'accepted') {
this.name = "Accepted Requests" this.name = "Accepted Requests";
} else { } else {
this.name = "Unknown" this.name = "Unknown";
} }
this.getItems() this.getItems();
} }
}, },
methods: { methods: {
@ -88,13 +85,13 @@ export default {
friend: user.friend2.username friend: user.friend2.username
}) })
.then(() => { .then(() => {
this.getItems() this.getItems();
}) })
.catch(e => { .catch(e => {
this.getItems() this.getItems();
AjaxErrorHandler(this.$store)(e) AjaxErrorHandler(this.$store)(e);
}) });
}, },
doRelationshipAccept(user) { doRelationshipAccept(user) {
this.axios this.axios
@ -102,44 +99,48 @@ export default {
friend: user.friend2.username friend: user.friend2.username
}) })
.then(() => { .then(() => {
this.getItems() this.getItems();
}) })
.catch(e => { .catch(e => {
this.getItems() this.getItems();
AjaxErrorHandler(this.$store)(e) AjaxErrorHandler(this.$store)(e);
}) });
}, },
getItems() { getItems() {
this.loading = true this.loading = true;
this.axios this.axios
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/getAll/' + this.category) .get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/getAll/' + this.category)
.then(res => { .then(res => {
this.friends = res.data.rows this.friends = res.data.rows;
this.count = res.data.count this.count = res.data.count;
this.loading = false this.loading = false;
}) })
.catch((e) => { .catch((e) => {
this.loading = false this.loading = false;
AjaxErrorHandler(this.$store)(e)
AjaxErrorHandler(this.$store)(e);
}) })
}, },
}, },
mounted() { mounted() {
this.loading = true if (this.$store.state.user.username) {
this.friends = [] this.loading = true;
this.offset = 0 this.friends = [];
this.category = this.$route.params.category this.offset = 0;
this.category = this.$route.params.category;
if (this.category === 'pendingCanAccept') { if (this.category === 'pendingCanAccept') {
this.name = "Requests to you" this.name = "Requests to you";
} else if (this.category === 'pending') { } else if (this.category === 'pending') {
this.name = "Requests from you" this.name = "Requests from you";
} else if (this.category === 'accepted') { } else if (this.category === 'accepted') {
this.name = "Accepted Requests" this.name = "Accepted Requests";
} else { } else {
this.name = "Unknown" this.name = "Unknown";
}
this.getItems();
} }
this.getItems()
} }
} }
</script> </script>

View file

@ -8,13 +8,22 @@
<div class="title"> <div class="title">
{{ $store.state.user.username }} {{ $store.state.user.username }}
</div> </div>
<img :src="'https://cdn.kaverti.com/user/avatars/full/' + $store.state.user.avatar + '.png'" alt="Avatar" class="is-centered" width="50%"> <img
:src="
'https://cdn.kaverti.com/user/avatars/full/' +
$store.state.user.avatar +
'.png'
"
alt="Avatar"
class="is-centered"
width="50%"
/>
</div> </div>
<div class="title"> <div class="title">
{{ $t('home.news') }} {{ $t("home.news") }}
</div> </div>
<div v-if="blogs.length"> <div v-if="blogs.length">
<div class="box" v-for='(blog) in blogs' :key='"blog-" + blog.id'> <div class="box" v-for="blog in blogs" :key="'blog-' + blog.id">
<div class="subtitle"> <div class="subtitle">
{{ blog.name }} {{ blog.name }}
</div> </div>
@ -30,28 +39,52 @@
<div class="column is-8" v-if="!loading"> <div class="column is-8" v-if="!loading">
<div class="box"> <div class="box">
<div class="title"> <div class="title">
{{ $t('home.globalWall') }} {{ $t("home.globalWall") }}
</div> </div>
<b-input type="textarea" maxlength="256" placeholder="How's it going?" v-model="wallText"></b-input> <b-input
type="textarea"
maxlength="256"
placeholder="How's it going?"
v-model="wallText"
></b-input>
<b-tag type="is-info" class="is-pulled-right"> <b-tag type="is-info" class="is-pulled-right">
Markdown is no longer available on wall posts. Markdown is no longer available on wall posts.
</b-tag> </b-tag>
<b-button type="is-info" ckass="is-pulled-left" :loading="loadingWallButton" @click="postWall">Post</b-button> <b-button
type="is-info"
ckass="is-pulled-left"
:loading="loadingWallButton"
@click="postWall"
>Post</b-button
>
</div> </div>
<hr> <hr />
<div class="box" v-for='(post) in wallPosts' :key='"wallPosts-" + post.id'> <div
class="box"
v-for="post in wallPosts"
:key="'wallPosts-' + post.id"
>
<article class="media"> <article class="media">
<figure class="media-left"> <figure class="media-left">
<figure class="image is-64x64 is-rounded"> <figure class="image is-64x64 is-rounded">
<img :src="'https://cdn.kaverti.com/user/avatars/headshot/' + post.fromUser.picture + '.png'" alt="Avatar" class="is-rounded"> <img
:src="
'https://cdn.kaverti.com/user/avatars/headshot/' +
post.fromUser.picture +
'.png'
"
alt="Avatar"
class="is-rounded"
/>
</figure> </figure>
</figure> </figure>
<div class="media-content"> <div class="media-content">
<div class="content"> <div class="content">
<p> <p>
<strong>{{ post.fromUser.username }}</strong>&nbsp; <strong>{{ post.fromUser.username }}</strong
>&nbsp;
<small>{{ post.createdAt | formatDate() }}</small> <small>{{ post.createdAt | formatDate() }}</small>
<br> <br />
{{ post.plainText }} {{ post.plainText }}
</p> </p>
</div> </div>
@ -67,105 +100,24 @@
</div> </div>
</div> </div>
</section> </section>
<section class="hero is-info is-large is-fullheight-with-navbar" v-if="!$store.state.user.username"> <section
class="hero is-info is-large is-fullheight-with-navbar"
v-if="!$store.state.user.username"
>
<div class="hero-body"> <div class="hero-body">
<div class="container has-text-centered"> <div class="container has-text-centered">
<div class="title"> <div class="title">Kaverti</div>
Kaverti
</div>
<div class="subtitle"> <div class="subtitle">
Kaverti is a new 3D sandbox gaming platform, and avatar social website. Kaverti is a new 3D sandbox gaming platform, and avatar social
<br> website.
<br />
Kaverti is home to hundreds of users who enjoy using it Kaverti is home to hundreds of users who enjoy using it
<br> <br />
So why not sign up today! So why not sign up today!
</div> </div>
</div> </div>
</div> </div>
</section> </section>
<section class="section hero is-white is-medium" v-if="!$store.state.user.username">
<div class="hero-body">
<div class="container has-text-centered">
<div class="title">
Statistics
</div>
<div class="columns is-centered">
<div class="column has-text-centered">
<div class="title">{{ $t('stats.users') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ users }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
<div class="column has-text-centered">
<div class="title">{{ $t('stats.users') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ users }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
<div class="column has-text-centered">
<div class="title">{{ $t('stats.posts') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ posts }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
<div class="column has-text-centered">
<div class="title">{{ $t('stats.users') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ users }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
<div class="column has-text-centered">
<div class="title">{{ $t('stats.purchased') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ inventory }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
<div class="column has-text-centered">
<div class="title">{{ $t('stats.items') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ items }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
<div class="column has-text-centered">
<div class="title">{{ $t('stats.teams') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ teams }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
<div class="column has-text-centered">
<div class="title">{{ $t('stats.threads') }}</div>
<div class="box">
<div class="title" v-if="!loading">
{{ threads }}
</div>
<b-skeleton size="is-large" :active="loading" :count="2"></b-skeleton>
</div>
</div>
</div>
</div>
</div>
</section>
</div> </div>
</template> </template>
@ -174,83 +126,86 @@ import NoItems from "@/components/NoItems";
import AjaxErrorHandler from ".././assets/js/errorHandler"; import AjaxErrorHandler from ".././assets/js/errorHandler";
export default { export default {
name: 'Home', name: "Home",
components: { components: {
NoItems NoItems,
}, },
data() { data() {
return { return {
blogs: [], blogs: [],
wallOffset: 0, wallOffset: 0,
wallPosts: [], wallPosts: [],
wallText: '', wallText: "",
mentions: '', mentions: "",
loadingWallButton: false, loadingWallButton: false,
loadingWall: true, loadingWall: true,
users: 0, };
posts: 0,
inventory: 0,
teams: 0,
threads: 0,
items: 0,
loading: false
}
}, },
methods: { methods: {
postWall() { postWall() {
this.loadingWallButton = true this.loadingWallButton = true;
this.axios.post(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `wall/post`, { this.axios
.post(
process.env.VUE_APP_APIENDPOINT +
process.env.VUE_APP_APIVERSION +
`/` +
`wall/post`,
{
username: "GlobalWall", username: "GlobalWall",
content: this.wallText content: this.wallText,
}).then(() => { }
this.loadingWallButton = false )
this.getWall(true) .then(() => {
}).catch(e => { this.loadingWallButton = false;
this.loadingWallButton = false this.getWall(true);
AjaxErrorHandler(this.$store)(e)
}) })
.catch((e) => {
this.loadingWallButton = false;
AjaxErrorHandler(this.$store)(e);
});
}, },
getWall(initial) { getWall(initial) {
this.loadingWall = true this.loadingWall = true;
if (initial) { if (initial) {
this.wallOffset = 0 this.wallOffset = 0;
} }
this.axios this.axios
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `user/GlobalWall?wall=true&offset=` + this.wallOffset) .get(
.then(res => { process.env.VUE_APP_APIENDPOINT +
this.loadingPosts = false process.env.VUE_APP_APIVERSION +
this.loadingWall = false `/` +
`user/GlobalWall?wall=true&offset=` +
this.wallOffset
)
.then((res) => {
this.loadingPosts = false;
this.loadingWall = false;
if (initial) { if (initial) {
this.wallPosts = res.data.userWalls this.wallPosts = res.data.userWalls;
} else { } else {
this.wallPosts.push(...res.data.userWalls) this.wallPosts.push(...res.data.userWalls);
}
})
} }
});
},
}, },
mounted() { mounted() {
this.axios.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'kaverti/stats') if (this.$store.state.user.username) {
.then(res => {
this.users = res.data.users
this.posts = res.data.posts
this.inventory = res.data.inventory
this.items = res.data.items
this.teams = res.data.teams
this.threads = res.data.threads
this.loading = false
}).catch(() => {
this.$buefy.snackbar.open({message:this.$t('errors.authFail'), type: 'is-warning'})
})
this.axios this.axios
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `blog/posts`) .get(
.then(res => { process.env.VUE_APP_APIENDPOINT +
this.blogs = res.data process.env.VUE_APP_APIVERSION +
`/` +
`blog/posts`
)
.then((res) => {
this.blogs = res.data;
}) })
.catch(e => { .catch((e) => {
AjaxErrorHandler(this.$store)(e) AjaxErrorHandler(this.$store)(e);
}) });
this.getWall(true) this.getWall(true);
}
} }
},
};
</script> </script>

View file

@ -46,8 +46,8 @@ export default {
route: "general", route: "general",
}, },
{ {
name: "Account", name: "Security",
route: "account", route: "security",
}, },
{ {
name: "About", name: "About",

View file

@ -1,10 +1,10 @@
<template> <template>
<div id="settings-about"> <div id="settings-about">
<div class="box"> <div class="box">
<div class="title">About</div> <div class="title">{{ $t("settings.about.title") }}</div>
<hr /> <hr />
<div class="has-text-centered"> <div class="has-text-centered">
<img src="https://cdn.kaverti.com/icon.png" width="10%" /> <img src="https://cdn.kaverti.com/icon.png" alt="Logo" width="10%" />
<p>Kaverti v{{ this.$store.state.client.clientVersion }}</p> <p>Kaverti v{{ this.$store.state.client.clientVersion }}</p>
<p> <p>
Latest Client Version: v{{ Latest Client Version: v{{

View file

@ -1,11 +0,0 @@
<template>
<div id="settings-account">
</div>
</template>
<script>
export default {
name: "SettingsAccount"
}
</script>

View file

@ -0,0 +1,15 @@
<template>
<div id="settings-account">
<div class="box">
<div class="title">{{ $t("settings.security.title") }}</div>
<hr>
<p>We're still working on this mate.</p>
</div>
</div>
</template>
<script>
export default {
name: "SettingsAccount"
}
</script>