2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2019-10-29 18:06:21 +00:00
|
|
|
<div class="user-thumbnail-box" :style="{ height: size, width: size }">
|
|
|
|
<img
|
|
|
|
v-if="!imgError && Boolean(src)"
|
|
|
|
id="image"
|
|
|
|
:src="src"
|
|
|
|
class="user-thumbnail"
|
|
|
|
@error="onImgError()"
|
|
|
|
/>
|
|
|
|
<Avatar
|
|
|
|
v-else
|
|
|
|
:username="username"
|
|
|
|
class="user-thumbnail"
|
|
|
|
background-color="#1f93ff"
|
|
|
|
color="white"
|
2019-11-14 08:16:43 +00:00
|
|
|
:size="avatarSize"
|
2019-10-29 18:06:21 +00:00
|
|
|
>
|
|
|
|
</Avatar>
|
|
|
|
<img
|
2019-11-17 08:45:05 +00:00
|
|
|
v-if="badge === 'Channel::FacebookPage'"
|
2019-10-29 18:06:21 +00:00
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
2019-11-14 08:16:43 +00:00
|
|
|
:style="badgeStyle"
|
2019-10-29 18:06:21 +00:00
|
|
|
src="~dashboard/assets/images/fb-badge.png"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
/**
|
|
|
|
* Thumbnail Component
|
|
|
|
* Src - source for round image
|
|
|
|
* Size - Size of the thumbnail
|
|
|
|
* Badge - Chat source indication { fb / telegram }
|
2019-10-29 18:06:21 +00:00
|
|
|
* Username - User name for avatar
|
2019-08-14 09:48:44 +00:00
|
|
|
*/
|
2019-10-29 18:06:21 +00:00
|
|
|
import Avatar from './Avatar';
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2019-10-29 18:06:21 +00:00
|
|
|
components: {
|
|
|
|
Avatar,
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
props: {
|
|
|
|
src: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: '40px',
|
|
|
|
},
|
|
|
|
badge: {
|
|
|
|
type: String,
|
|
|
|
default: 'fb',
|
|
|
|
},
|
2019-10-29 18:06:21 +00:00
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
imgError: false,
|
|
|
|
};
|
|
|
|
},
|
2019-11-14 08:16:43 +00:00
|
|
|
computed: {
|
|
|
|
avatarSize() {
|
|
|
|
return Number(this.size.replace(/\D+/g, ''));
|
|
|
|
},
|
|
|
|
badgeStyle() {
|
|
|
|
const badgeSize = `${this.avatarSize / 3}px`;
|
|
|
|
return { width: badgeSize, height: badgeSize };
|
|
|
|
},
|
|
|
|
},
|
2019-10-29 18:06:21 +00:00
|
|
|
methods: {
|
|
|
|
onImgError() {
|
|
|
|
this.imgError = true;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
2019-10-16 09:06:17 +00:00
|
|
|
</script>
|