Colubrina/frontend/src/components/UserDialog.vue

210 lines
6.1 KiB
Vue
Raw Normal View History

2022-07-29 19:04:37 +10:00
<template>
<v-dialog v-model="user.value" max-width="650px">
<v-card v-if="user.item" class="user-popout" height="600px">
<v-toolbar color="toolbar" height="100">
<v-avatar size="64" class="mr-3 mb-2 mt-2">
<v-img
:src="$store.state.baseURL + '/usercontent/' + user.item.avatar"
v-if="user.item.avatar"
class="elevation-1"
/>
<v-icon v-else class="elevation-1"> mdi-account </v-icon>
</v-avatar>
<v-toolbar-title>
{{ getName(user.item) }}
<v-tooltip top v-if="user.item.admin">
<template v-slot:activator="{ on }">
<v-btn icon v-on="on" small>
<v-icon> mdi-crown </v-icon>
</v-btn>
</template>
<span>Colubrina Instance Administrator</span>
</v-tooltip>
<v-tooltip top v-if="user.item.id < 35">
<template v-slot:activator="{ on }">
<v-btn icon v-on="on" small>
<v-icon> mdi-alpha-a-circle </v-icon>
</v-btn>
</template>
<span>Early User</span>
</v-tooltip>
<v-tooltip top v-if="user.item.bot">
<template v-slot:activator="{ on }">
<v-btn icon v-on="on" small>
<v-icon> mdi-robot </v-icon>
</v-btn>
</template>
<span>Bot</span>
</v-tooltip>
<div class="subheading subtitle-1 text--lighten-2">
2022-10-02 17:12:25 +11:00
<template v-if="user.item.nickname">{{
user.item.username
}}</template>
2022-07-29 19:04:37 +10:00
</div>
</v-toolbar-title>
</v-toolbar>
<v-tabs :show-arrows="false" fixed-tabs background-color="card">
<v-tab>
<v-icon>mdi-account-multiple</v-icon>&nbsp; Mutual Friends
</v-tab>
<v-tab> <v-icon>mdi-account-group</v-icon>&nbsp; Mutual Groups </v-tab>
<v-tab-item
:style="
'background-color: ' +
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].card
"
>
<v-list
:height="400"
:style="
'background-color: ' +
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].card
"
>
<v-overlay :value="loading.mutualFriends" absolute>
<v-progress-circular
indeterminate
size="64"
></v-progress-circular>
</v-overlay>
<v-list-item
v-for="item in mutualFriends"
:key="item.id"
@click="openUserPanel(item)"
>
<v-list-item-title>
<v-avatar size="24">
<v-img
:src="$store.state.baseURL + '/usercontent/' + item.avatar"
v-if="item.avatar"
class="elevation-1"
/>
<v-icon v-else class="elevation-1"> mdi-account </v-icon>
</v-avatar>
{{ getName(item) }}
</v-list-item-title>
</v-list-item>
</v-list>
</v-tab-item>
<v-tab-item
:style="
'background-color: ' +
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].card
"
>
<v-list
:height="400"
:style="
'background-color: ' +
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].card
"
>
<v-overlay :value="loading.mutualFriends" absolute>
<v-progress-circular
indeterminate
size="64"
></v-progress-circular>
</v-overlay>
<v-list-item
v-for="item in mutualGroups"
:key="item.id"
2022-10-02 17:12:25 +11:00
@click="
$router.push('/communications/' + item.associationId)
user.value = false
"
2022-07-29 19:04:37 +10:00
>
<v-list-item-title>
{{ item.name }}
</v-list-item-title>
</v-list-item>
</v-list>
</v-tab-item>
</v-tabs>
<v-card-actions
:style="
'background-color: ' +
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].card
"
>
<v-spacer></v-spacer>
<v-btn color="primary" text @click="user.value = false"> Close </v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
2022-11-03 18:30:37 +11:00
import AjaxErrorHandler from "@/lib/errorHandler.js"
2022-07-29 19:04:37 +10:00
export default {
name: "UserDialog",
props: ["user"],
data() {
return {
mutualGroups: [],
mutualFriends: [],
loading: {
mutualFriends: true,
mutualGroups: true
}
}
},
methods: {
2022-10-02 17:12:25 +11:00
openUserPanel(user) {
this.user.item = user
this.onMounted()
},
2022-07-29 19:04:37 +10:00
getName(user) {
if (user.nickname?.nickname) {
return user.nickname.nickname
} else {
return user.username
}
2022-10-02 17:12:25 +11:00
},
onMounted() {
if (this.user?.item?.id) {
this.mutualGroups = []
this.mutualFriends = []
this.loading = {
mutualGroups: true,
mutualFriends: true
}
this.axios
2022-07-29 21:26:18 +10:00
.get(
2022-10-02 17:12:25 +11:00
process.env.VUE_APP_BASE_URL +
2022-07-29 21:26:18 +10:00
"/api/v1/communications/mutual/" +
this.user.item.id +
"/groups"
)
.then((res) => {
this.mutualGroups = res.data
this.loading.mutualGroups = false
})
.catch((e) => {
AjaxErrorHandler(this.$store)(e)
})
2022-10-02 17:12:25 +11:00
this.axios
2022-07-29 21:26:18 +10:00
.get(
2022-10-02 17:12:25 +11:00
process.env.VUE_APP_BASE_URL +
2022-07-29 21:26:18 +10:00
"/api/v1/communications/mutual/" +
this.user.item.id +
"/friends"
)
.then((res) => {
this.mutualFriends = res.data
this.loading.mutualFriends = false
})
.catch((e) => {
AjaxErrorHandler(this.$store)(e)
})
2022-10-02 17:12:25 +11:00
}
2022-07-29 19:04:37 +10:00
}
2022-10-02 17:12:25 +11:00
},
mounted() {
this.onMounted()
2022-07-29 19:04:37 +10:00
}
}
</script>
<style scoped></style>