From 74db319a7c3738baa62c395640fc18ce63d84a7f Mon Sep 17 00:00:00 2001 From: Sanju Date: Mon, 25 Oct 2021 19:46:37 +0530 Subject: [PATCH] feat: Add video preview & player in conversation (#3201) --- .../scss/widgets/_conversation-view.scss | 20 ++++++++- .../widgets/conversation/Message.vue | 43 +++++++++++++------ .../widgets/conversation/bubble/Actions.vue | 6 ++- .../widgets/conversation/bubble/Video.vue | 32 ++++++++++++++ 4 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 app/javascript/dashboard/components/widgets/conversation/bubble/Video.vue diff --git a/app/javascript/dashboard/assets/scss/widgets/_conversation-view.scss b/app/javascript/dashboard/assets/scss/widgets/_conversation-view.scss index f6965c493..8c65b92e0 100644 --- a/app/javascript/dashboard/assets/scss/widgets/_conversation-view.scss +++ b/app/javascript/dashboard/assets/scss/widgets/_conversation-view.scss @@ -17,7 +17,8 @@ } } - .image { + .image, + .video { cursor: pointer; position: relative; @@ -29,17 +30,32 @@ max-width: 85%; } + .modal-video { + max-height: 75vh; + max-width: 100%; + } + &::before { background-image: linear-gradient(-180deg, transparent 3%, $color-heading 130%); bottom: 0; content: ''; height: 20%; left: 0; - opacity: .8; + opacity: 0.8; position: absolute; width: 100%; } } + + .video { + .modal-container { + width: auto; + + .modal--close { + z-index: var(--z-index-low); + } + } + } } .conversations-list-wrap { diff --git a/app/javascript/dashboard/components/widgets/conversation/Message.vue b/app/javascript/dashboard/components/widgets/conversation/Message.vue index b3674681a..bd832f4ba 100644 --- a/app/javascript/dashboard/components/widgets/conversation/Message.vue +++ b/app/javascript/dashboard/components/widgets/conversation/Message.vue @@ -31,6 +31,11 @@ + 0) { - const { attachments = [{}] } = this.data; - const { file_type: fileType } = attachments[0]; - return fileType === 'image'; - } - return false; - }, hasText() { return !!this.data.content; }, @@ -270,7 +269,8 @@ export default { return { bubble: this.isBubble, 'is-private': this.data.private, - 'is-image': this.hasImageAttachment, + 'is-image': this.hasMediaAttachment('image'), + 'is-video': this.hasMediaAttachment('video'), 'is-text': this.hasText, 'is-from-bot': this.isSentByBot, }; @@ -288,6 +288,14 @@ export default { }, }, methods: { + hasMediaAttachment(type) { + if (this.hasAttachments && this.data.attachments.length > 0) { + const { attachments = [{}] } = this.data; + const { file_type: fileType } = attachments[0]; + return fileType === type; + } + return false; + }, handleContextMenuClick() { this.showContextMenu = !this.showContextMenu; }, @@ -315,17 +323,28 @@ export default {