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"
|
2020-02-05 05:57:22 +00:00
|
|
|
:class="thumbnailClass"
|
2019-10-29 18:06:21 +00:00
|
|
|
@error="onImgError()"
|
|
|
|
/>
|
|
|
|
<Avatar
|
|
|
|
v-else
|
|
|
|
:username="username"
|
2020-02-05 05:57:22 +00:00
|
|
|
:class="thumbnailClass"
|
2019-10-29 18:06:21 +00:00
|
|
|
color="white"
|
2019-11-14 08:16:43 +00:00
|
|
|
:size="avatarSize"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2021-10-05 09:05:32 +00:00
|
|
|
<img
|
|
|
|
v-if="badge === 'instagram_direct_message'"
|
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/instagram_direct.png"
|
|
|
|
/>
|
2019-10-29 18:06:21 +00:00
|
|
|
<img
|
2020-02-09 10:17:48 +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"
|
2021-10-05 09:05:32 +00:00
|
|
|
src="~dashboard/assets/images/messenger_direct.png"
|
2019-10-29 18:06:21 +00:00
|
|
|
/>
|
2020-02-02 19:09:00 +00:00
|
|
|
<img
|
2021-09-29 07:26:45 +00:00
|
|
|
v-if="badge === 'twitter-tweet'"
|
2020-02-02 19:09:00 +00:00
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/twitter-badge.png"
|
|
|
|
/>
|
2020-04-29 20:11:13 +00:00
|
|
|
<img
|
2021-09-29 07:26:45 +00:00
|
|
|
v-if="badge === 'twitter-chat'"
|
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/twitter-chat-badge.png"
|
|
|
|
/>
|
|
|
|
<img
|
|
|
|
v-if="badge === 'whatsapp'"
|
2020-04-29 20:11:13 +00:00
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/channels/whatsapp.png"
|
|
|
|
/>
|
2021-09-29 07:26:45 +00:00
|
|
|
<img
|
|
|
|
v-if="badge === 'sms'"
|
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/channels/sms.png"
|
|
|
|
/>
|
2021-09-10 20:01:17 +00:00
|
|
|
<img
|
|
|
|
v-if="badge === 'Channel::Line'"
|
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/channels/line.png"
|
|
|
|
/>
|
2021-09-09 18:30:52 +00:00
|
|
|
<img
|
|
|
|
v-if="badge === 'Channel::Telegram'"
|
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/channels/telegram.png"
|
|
|
|
/>
|
2020-07-04 06:12:47 +00:00
|
|
|
<div
|
|
|
|
v-if="showStatusIndicator"
|
|
|
|
:class="`source-badge user-online-status user-online-status--${status}`"
|
|
|
|
:style="statusStyle"
|
|
|
|
/>
|
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,
|
2020-02-02 17:04:16 +00:00
|
|
|
default: '',
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: '40px',
|
|
|
|
},
|
|
|
|
badge: {
|
|
|
|
type: String,
|
|
|
|
default: 'fb',
|
|
|
|
},
|
2019-10-29 18:06:21 +00:00
|
|
|
username: {
|
|
|
|
type: String,
|
2020-02-02 17:04:16 +00:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
status: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
2019-10-29 18:06:21 +00:00
|
|
|
},
|
2020-02-05 05:57:22 +00:00
|
|
|
hasBorder: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-10-29 18:06:21 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
imgError: false,
|
|
|
|
};
|
|
|
|
},
|
2019-11-14 08:16:43 +00:00
|
|
|
computed: {
|
2020-07-04 06:12:47 +00:00
|
|
|
showStatusIndicator() {
|
|
|
|
return this.status === 'online' || this.status === 'busy';
|
|
|
|
},
|
2019-11-14 08:16:43 +00:00
|
|
|
avatarSize() {
|
|
|
|
return Number(this.size.replace(/\D+/g, ''));
|
|
|
|
},
|
|
|
|
badgeStyle() {
|
|
|
|
const badgeSize = `${this.avatarSize / 3}px`;
|
|
|
|
return { width: badgeSize, height: badgeSize };
|
|
|
|
},
|
2020-02-02 17:04:16 +00:00
|
|
|
statusStyle() {
|
|
|
|
const statusSize = `${this.avatarSize / 4}px`;
|
|
|
|
return { width: statusSize, height: statusSize };
|
|
|
|
},
|
2020-02-05 05:57:22 +00:00
|
|
|
thumbnailClass() {
|
|
|
|
const classname = this.hasBorder ? 'border' : '';
|
|
|
|
return `user-thumbnail ${classname}`;
|
|
|
|
},
|
2019-11-14 08:16:43 +00:00
|
|
|
},
|
2020-05-31 10:46:22 +00:00
|
|
|
watch: {
|
|
|
|
src: {
|
|
|
|
handler(value, oldValue) {
|
|
|
|
if (value !== oldValue && this.imgError) {
|
|
|
|
this.imgError = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
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>
|
2019-12-15 18:23:04 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
2020-02-02 17:04:16 +00:00
|
|
|
@import '~dashboard/assets/scss/foundation-settings';
|
2019-12-15 18:23:04 +00:00
|
|
|
@import '~dashboard/assets/scss/mixins';
|
|
|
|
|
|
|
|
.user-thumbnail-box {
|
|
|
|
@include flex-shrink;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
.user-thumbnail {
|
|
|
|
border-radius: 50%;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
2020-02-05 05:57:22 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
&.border {
|
|
|
|
border: 1px solid white;
|
|
|
|
}
|
2019-12-15 18:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.source-badge {
|
2020-02-02 17:04:16 +00:00
|
|
|
bottom: -$space-micro;
|
2019-12-15 18:23:04 +00:00
|
|
|
height: $space-slab;
|
|
|
|
position: absolute;
|
|
|
|
right: $zero;
|
|
|
|
width: $space-slab;
|
|
|
|
}
|
2020-02-02 17:04:16 +00:00
|
|
|
|
2020-07-04 06:12:47 +00:00
|
|
|
.user-online-status {
|
2020-02-02 17:04:16 +00:00
|
|
|
border-radius: 50%;
|
|
|
|
bottom: $space-micro;
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: ' ';
|
|
|
|
}
|
|
|
|
}
|
2020-07-04 06:12:47 +00:00
|
|
|
|
|
|
|
.user-online-status--online {
|
|
|
|
background: $success-color;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-online-status--busy {
|
|
|
|
background: $warning-color;
|
|
|
|
}
|
2019-12-15 18:23:04 +00:00
|
|
|
}
|
|
|
|
</style>
|