2018-10-23 13:38:03 +00:00
|
|
|
<!--
|
|
|
|
- @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
|
|
|
|
-
|
|
|
|
- @author Julius Härtl <jus@bitgrid.net>
|
|
|
|
-
|
|
|
|
- @license GNU AGPL version 3 or any later version
|
|
|
|
-
|
|
|
|
- This program is free software: you can redistribute it and/or modify
|
|
|
|
- it under the terms of the GNU Affero General Public License as
|
|
|
|
- published by the Free Software Foundation, either version 3 of the
|
|
|
|
- License, or (at your option) any later version.
|
|
|
|
-
|
|
|
|
- This program is distributed in the hope that it will be useful,
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
- GNU Affero General Public License for more details.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the GNU Affero General Public License
|
|
|
|
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-
|
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
2019-10-07 09:10:16 +00:00
|
|
|
<div v-if="profileAccount(uid) && accountInfo(uid)" class="user-profile">
|
2019-08-22 07:24:32 +00:00
|
|
|
<div>
|
2019-10-07 09:10:16 +00:00
|
|
|
<avatar v-if="accountInfo(uid).local" :user="localUid" :disable-tooltip="true"
|
2019-01-09 14:59:59 +00:00
|
|
|
:size="128" />
|
2018-12-21 16:33:29 +00:00
|
|
|
<avatar v-else :url="avatarUrl" :disable-tooltip="true"
|
2019-01-09 14:59:59 +00:00
|
|
|
:size="128" />
|
2018-10-23 14:20:38 +00:00
|
|
|
<h2>{{ displayName }}</h2>
|
2019-10-07 09:10:16 +00:00
|
|
|
<p>@{{ accountInfo(uid).account }}</p>
|
|
|
|
<p v-if="accountInfo(uid).website">
|
|
|
|
Website: <a :href="accountInfo(uid).website.value">
|
|
|
|
{{ accountInfo(uid).website.value }}
|
2019-01-02 23:25:44 +00:00
|
|
|
</a>
|
|
|
|
</p>
|
2019-10-07 09:10:16 +00:00
|
|
|
<follow-button :account="accountInfo(uid).account" />
|
2019-02-06 10:48:46 +00:00
|
|
|
<button v-if="serverData.public" class="primary" @click="followRemote">
|
|
|
|
{{ t('social', 'Follow') }}
|
|
|
|
</button>
|
2018-10-23 13:38:03 +00:00
|
|
|
</div>
|
2018-12-21 16:33:29 +00:00
|
|
|
<!-- TODO: we have no details, timeline and follower list for non-local accounts for now -->
|
2019-10-07 09:10:16 +00:00
|
|
|
<ul v-if="accountInfo(uid).details && accountInfo(uid).local" class="user-profile--sections">
|
2018-10-23 14:20:38 +00:00
|
|
|
<li>
|
2019-01-02 23:25:44 +00:00
|
|
|
<router-link :to="{ name: 'profile', params: { account: uid } }" class="icon-category-monitoring">
|
|
|
|
{{ getCount('post') }} {{ t('social', 'posts') }}
|
|
|
|
</router-link>
|
2018-10-23 13:38:03 +00:00
|
|
|
</li>
|
2018-10-23 14:20:38 +00:00
|
|
|
<li>
|
2019-01-02 23:25:44 +00:00
|
|
|
<router-link :to="{ name: 'profile.following', params: { account: uid } }" class="icon-category-social">
|
|
|
|
{{ getCount('following') }} {{ t('social', 'following') }}
|
|
|
|
</router-link>
|
2018-10-23 13:38:03 +00:00
|
|
|
</li>
|
2018-10-23 14:20:38 +00:00
|
|
|
<li>
|
2019-01-02 23:25:44 +00:00
|
|
|
<router-link :to="{ name: 'profile.followers', params: { account: uid } }" class="icon-category-social">
|
|
|
|
{{ getCount('followers') }} {{ t('social', 'followers') }}
|
|
|
|
</router-link>
|
2018-10-23 13:38:03 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
.user-profile {
|
|
|
|
display: flex;
|
2019-08-22 07:24:32 +00:00
|
|
|
flex-wrap: wrap;
|
|
|
|
justify-content: space-between;
|
2018-10-23 13:38:03 +00:00
|
|
|
width: 100%;
|
|
|
|
text-align: center;
|
|
|
|
padding-top: 20px;
|
|
|
|
align-items: flex-end;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
h2 {
|
|
|
|
margin-bottom: 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-profile--sections {
|
|
|
|
display: flex;
|
|
|
|
margin-bottom: 30px;
|
|
|
|
}
|
|
|
|
.user-profile--sections li {
|
|
|
|
flex-grow: 1;
|
|
|
|
}
|
|
|
|
.user-profile--sections li a {
|
2018-12-03 11:39:18 +00:00
|
|
|
padding: 10px;
|
2018-10-23 13:38:03 +00:00
|
|
|
padding-left: 24px;
|
2018-12-03 11:39:18 +00:00
|
|
|
display: inline-block;
|
2018-10-23 14:20:38 +00:00
|
|
|
background-position: 0 center;
|
2018-10-23 13:38:03 +00:00
|
|
|
height: 40px;
|
2018-10-23 20:07:46 +00:00
|
|
|
opacity: .6;
|
|
|
|
}
|
2018-12-03 11:39:18 +00:00
|
|
|
.user-profile--sections li a.router-link-exact-active,
|
|
|
|
.user-profile--sections li a:focus{
|
2018-10-23 20:07:46 +00:00
|
|
|
opacity: 1;
|
2018-12-03 11:39:18 +00:00
|
|
|
border-bottom: 1px solid var(--color-main-text);
|
2018-10-23 13:38:03 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
2019-11-05 15:41:02 +00:00
|
|
|
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
|
2019-10-07 09:10:16 +00:00
|
|
|
import accountMixins from '../mixins/accountMixins'
|
2018-11-29 10:50:59 +00:00
|
|
|
import serverData from '../mixins/serverData'
|
2018-12-03 09:02:46 +00:00
|
|
|
import currentUser from '../mixins/currentUserMixin'
|
|
|
|
import follow from '../mixins/follow'
|
2019-09-09 14:16:40 +00:00
|
|
|
import FollowButton from './FollowButton.vue'
|
2020-10-09 16:16:40 +00:00
|
|
|
import { generateUrl } from '@nextcloud/router'
|
2018-10-23 13:38:03 +00:00
|
|
|
|
2018-10-26 08:33:27 +00:00
|
|
|
export default {
|
|
|
|
name: 'ProfileInfo',
|
|
|
|
components: {
|
2018-12-21 16:33:29 +00:00
|
|
|
FollowButton,
|
2018-10-26 08:33:27 +00:00
|
|
|
Avatar
|
|
|
|
},
|
2018-12-05 08:48:02 +00:00
|
|
|
mixins: [
|
2019-10-07 09:10:16 +00:00
|
|
|
accountMixins,
|
2018-12-05 08:48:02 +00:00
|
|
|
currentUser,
|
2019-10-07 09:10:16 +00:00
|
|
|
serverData,
|
2018-12-05 08:48:02 +00:00
|
|
|
follow
|
|
|
|
],
|
2018-10-26 08:33:27 +00:00
|
|
|
props: {
|
|
|
|
uid: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
},
|
2018-12-03 10:40:44 +00:00
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
followingText: t('social', 'Following')
|
|
|
|
}
|
|
|
|
},
|
2018-10-26 08:33:27 +00:00
|
|
|
computed: {
|
2019-09-19 08:45:44 +00:00
|
|
|
localUid() {
|
|
|
|
// Returns only the local part of a username
|
|
|
|
return (this.uid.indexOf('@') === -1) ? this.uid : this.uid.substr(0, this.uid.indexOf('@'))
|
|
|
|
},
|
2018-10-26 08:33:27 +00:00
|
|
|
displayName() {
|
2019-10-07 09:10:16 +00:00
|
|
|
if (typeof this.accountInfo(this.uid).name !== 'undefined' && this.accountInfo(this.uid).name !== '') {
|
|
|
|
return this.accountInfo(this.uid).name
|
2018-12-03 09:02:46 +00:00
|
|
|
}
|
2020-10-12 15:48:36 +00:00
|
|
|
if (typeof this.accountInfo.preferredUsername !== 'undefined' && this.accountInfo.preferredUsername !== '') {
|
|
|
|
return this.accountInfo.preferredUsername
|
|
|
|
}
|
2019-10-07 09:10:16 +00:00
|
|
|
return this.profileAccount(this.uid)
|
2018-12-21 16:33:29 +00:00
|
|
|
},
|
|
|
|
getCount() {
|
2019-10-07 09:10:16 +00:00
|
|
|
let account = this.accountInfo(this.uid)
|
|
|
|
return (field) => account.details.count ? account.details.count[field] : ''
|
2018-12-21 16:33:29 +00:00
|
|
|
},
|
|
|
|
avatarUrl() {
|
2019-10-07 09:10:16 +00:00
|
|
|
return generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.accountInfo(this.uid).id)
|
2018-10-26 08:33:27 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2019-02-06 10:48:46 +00:00
|
|
|
followRemote() {
|
2020-10-09 16:16:40 +00:00
|
|
|
window.open(generateUrl('/apps/social/api/v1/ostatus/followRemote/' + encodeURI(this.localUid)), 'followRemote', 'width=433,height=600toolbar=no,menubar=no,scrollbars=yes,resizable=yes')
|
2019-02-06 10:48:46 +00:00
|
|
|
}
|
2018-10-23 13:38:03 +00:00
|
|
|
}
|
2018-10-26 08:33:27 +00:00
|
|
|
}
|
2018-10-23 13:38:03 +00:00
|
|
|
|
|
|
|
</script>
|