From 7ac2a47ae64ef6953f3df27bc1b138c8804c8873 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Fri, 17 Apr 2020 21:53:25 +0530 Subject: [PATCH 01/35] Add all the features --- app/livechat/client/ui.js | 2 +- .../views/app/tabbar/customerChatHistory.html | 89 ++++ .../views/app/tabbar/customerChatHistory.js | 230 ++++++++++ .../tabbar/customerChatHistoryMessages.html | 62 +++ .../app/tabbar/customerChatHistoryMessages.js | 101 +++++ app/livechat/client/views/regular.js | 3 +- app/theme/client/main.css | 411 ++++++++++++++++++ package-lock.json | 5 + packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- 9 files changed, 902 insertions(+), 3 deletions(-) create mode 100644 app/livechat/client/views/app/tabbar/customerChatHistory.html create mode 100644 app/livechat/client/views/app/tabbar/customerChatHistory.js create mode 100644 app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html create mode 100644 app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js diff --git a/app/livechat/client/ui.js b/app/livechat/client/ui.js index 3a4d3fb73f2be..4491c2009d6dc 100644 --- a/app/livechat/client/ui.js +++ b/app/livechat/client/ui.js @@ -35,7 +35,7 @@ TabBar.addButton({ id: 'visitor-history', i18nTitle: 'Past_Chats', icon: 'clock', - template: 'visitorHistory', + template: 'customerChatHistory', order: 11, }); diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html new file mode 100644 index 0000000000000..963765402280e --- /dev/null +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -0,0 +1,89 @@ + \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.js b/app/livechat/client/views/app/tabbar/customerChatHistory.js new file mode 100644 index 0000000000000..94a6172e367ae --- /dev/null +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.js @@ -0,0 +1,230 @@ +import { ReactiveVar } from 'meteor/reactive-var'; +import { Template } from 'meteor/templating'; +import moment from 'moment'; +import _ from 'underscore'; +import './customerChatHistory.html'; +import { APIClient, t } from '../../../../../utils/client'; +import { AccountBox, TabBar, MessageTypes } from '../../../../../ui-utils'; +import {Mongo ,MongoInternals} from 'meteor/mongo'; +import { Tracker } from 'meteor/tracker'; +import { ReactiveDict } from 'meteor/reactive-dict'; +import { Session } from 'meteor/session'; + +const ITEMS_COUNT = 50; +let historyResult +let len, msgs +let allHistoryChat ; + +Template.customerChatHistory.helpers({ + + isAllChat:function(){ + // will return is have to load all chat + return Template.instance().isAllChat.get(); + }, + isChatClicked:function(){ + // will return that if you have clicked in a single chatHistory + return Template.instance().isChatClicked.get(); + }, + isfound:function() { + // will return if find any search result + var isfound= Session.get('found'); + + return isfound; + }, + isLoading() { + return Template.instance().isLoading.get(); + }, + searchResults(){ + // will return search result + var r = Session.get('searchResult'); + return Template.instance().searchResult.get(); + }, + + previousChats() { + // will return pervious chats list + let history = Template.instance().history.get(); + let newHisTory = [] + for(i=1; i { + const { room } = await APIClient.v1.get(`rooms.info?roomId=${ currentData.rid }`); + if (room && room.v) { + this.visitorId.set(room.v._id); + } + }); + + this.autorun(async () => { + + if (!this.visitorId.get() || !currentData || !currentData.rid) { + return; + } + + const offset = this.offset.get(); + + this.isLoading.set(true); + const { history, total } = await APIClient.v1.get(`livechat/visitors.chatHistory/room/${ currentData.rid }/visitor/${ this.visitorId.get() }?count=${ ITEMS_COUNT }&offset=${ offset }`); + + this.isLoading.set(false); + this.total.set(total); + this.history.set(this.history.get().concat(history)); + // this will load all the chat history chat messages + allHistoryChat = []; + var limit = 100; + let count = this.history.get(); + if(allHistoryChat.length>0){ + return + } + for(i=0;i= (e.target.scrollHeight - e.target.clientHeight)) { + const history = instance.history.get(); + if (instance.total.get() <= history.length) { + return; + } + return instance.offset.set(instance.offset.get() + ITEMS_COUNT); + } + }, 200), + 'keyup #searchInput': async function(event,template){ + + searchResults = []; + let text = event.target.value; + template.isChatClicked.set(false); + + Session.set('found',false); + if(event.target.value == ''){ + template.isAllChat.set(true); + }else{ + template.isAllChat.set(false); + Template.instance().searchResult = new ReactiveVar([]); + + for(var i=0; i 0){ + Session.set('found',true); + + } + + }}, + 'click .list-chat': async function(event,template){ + event.preventDefault(); + template.isAllChat.set(false); + template.isChatClicked.set(true); + let id = event.currentTarget.id + let token = event.currentTarget.attributes.aria.value; + Session.set('FetchID',id); + Session.set('FetchToken',token) + } + +}); + +Template.customerChatHistory.onDestroyed(function(){ + var header = document.getElementsByClassName('Contextualheading'); + if(header[0]){ + header[0].innerText = '' + header[0].className = 'contextual-bar__header-title'; + } +}) +function getTime(newTs){ + var hr = newTs.slice(0,2); + var min = newTs.slice(3,5); + if(hr > 12 && hr < 24){ + hr = hr-12; + return time = `${hr}:${min} PM`; + }else if(hr == 24){ + hr = 00; + return time = `${hr}:${min} AM`; + }else if(hr < 12 ){ + return time = `${hr}:${min} AM`; + }else if(hr == 12){ + return time = `${hr}:${min} PM`; + } +} +function getDay(obj){ + var d = Date.parse(obj.ts); + var D = new Date(); + D.setTime(d); + var day = D.getDay(); + switch(day){ + case 1 : return 'Monday'; + case 2 : return 'Tuesday'; + case 3 : return 'Wednesday'; + case 4 : return 'Thursday'; + case 5 : return 'Friday'; + case 6 : return 'Saturday'; + case 7 : return 'Sunday'; + } +} \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html new file mode 100644 index 0000000000000..5204f3cf7965f --- /dev/null +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html @@ -0,0 +1,62 @@ + \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js new file mode 100644 index 0000000000000..5cd29b63a4ccd --- /dev/null +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -0,0 +1,101 @@ +import { ReactiveVar } from 'meteor/reactive-var'; +import { Template } from 'meteor/templating'; +import moment from 'moment'; +import _ from 'underscore'; +import './customerChatHistoryMessages.html'; +import { APIClient, t } from '../../../../../utils/client'; +import { AccountBox, TabBar, MessageTypes } from '../../../../../ui-utils'; +import {Mongo ,MongoInternals} from 'meteor/mongo'; +import { Tracker } from 'meteor/tracker'; +import { ReactiveDict } from 'meteor/reactive-dict'; +import { Session } from 'meteor/session'; + +let historyResult +let len, msgs +let allHistoryChat ; + +Template.customerChatHistoryMessages.helpers({ + + historyResult(){ + // will return all the messages in history room + + return Template.instance().historyResu.get().reverse(); + }, + len(){ + // will return length of total messages in room + len = Template.instance().historyResu.get(); + return len = len.length-2; + }, +}) + +Template.customerChatHistoryMessages.onCreated(function() { + this.historyResu = new ReactiveVar([]); + var id = Session.get('FetchID'); + var token = Session.get('FetchToken') + this.autorun(async () => { + historyResult = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`); + // will return pervious chats list + let history = historyResult.messages; + let newHisTory = [] + for(i=1; i 12 && hr < 24){ + hr = hr-12; + return time = `${hr}:${min} PM`; + }else if(hr == 24){ + hr = 00; + return time = `${hr}:${min} AM`; + }else if(hr < 12 ){ + return time = `${hr}:${min} AM`; + }else if(hr == 12){ + return time = `${hr}:${min} PM`; + } +} +function getDay(obj){ + var d = Date.parse(obj.ts); + var D = new Date(); + D.setTime(d); + var day = D.getDay(); + switch(day){ + case 1 : return 'Monday'; + case 2 : return 'Tuesday'; + case 3 : return 'Wednesday'; + case 4 : return 'Thursday'; + case 5 : return 'Friday'; + case 6 : return 'Saturday'; + case 7 : return 'Sunday'; + } +} \ No newline at end of file diff --git a/app/livechat/client/views/regular.js b/app/livechat/client/views/regular.js index 1fc7ddf9441ab..b134606917ab0 100644 --- a/app/livechat/client/views/regular.js +++ b/app/livechat/client/views/regular.js @@ -8,6 +8,7 @@ import './app/tabbar/agentInfo'; import './app/tabbar/externalSearch'; import './app/tabbar/visitorEdit'; import './app/tabbar/visitorForward'; -import './app/tabbar/visitorHistory'; +import './app/tabbar/customerChatHistory'; +import './app/tabbar/customerChatHistoryMessages'; import './app/tabbar/visitorInfo'; import './app/tabbar/visitorNavigation'; diff --git a/app/theme/client/main.css b/app/theme/client/main.css index 56d02e89df83e..8c0aa732cd6f3 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -58,3 +58,414 @@ /* RTL */ @import 'imports/general/rtl.css'; + +/* customerChat History CSS */ +.inner-addon { + position: relative; + left: 24px; + width: 345px; + height: 40px; + border: 2px solid #cbced1; + background: #ffffff; + + box-sizing: border-box; + border-radius: 2px; +} + +.inner-addon .glyphicon { + position: absolute; + bottom: 0.5%; + color: #2F343D; + + padding: 10px; + + pointer-events: none; + +} + +.searchresults { + margin-top: 7%; +} + +.search-li { + display: block; + padding-bottom: 3%; + position: relative; + + height: 65px; + + background-color: #ffffff; +} + +.search-li :hover { + cursor: default; +} + +.closed-div { + position: relative; + top: 20px; +} + +.closed-div-p { + background: #f5455c; + border-radius: 2px; + width: 100%; + text-align: center; + line-height: 0.15em; + font-size: 10px; + + margin: 10px 0 15px; +} + +.closed-div-p span { + width: 101px; + height: 12px; + + right: 138px; + top: 3px; + font-family: Inter; + font-style: normal; + font-weight: 600; + text-align: center; + + color: #f5455c; + background: white; + padding-left: 8px; + padding-right: 8px; +} + +.closed-h1 h1 { + color: #6c727a !important; + + font-size: 14px !important; + + line-height: 20px !important; + + font-weight: 600px !important; + font-style: italic !important; + text-transform: none !important; +} + +.closed-p p { + color: #9ea2a8 !important; + font-style: italic !important; + font-weight: 500 !important; + top: 25px !important; +} + +.belldiv { + position: absolute; + width: 36px; + height: 36px; + top: 12px; + left: 24px; + background: #e4e7ea; +} + +.belldiv i { + position: relative; + left: 22.31%; + top: 15.79%; +} + +.history-main { + display: flex; + position: relative; + + width: 100%; + height: 68px; + left: 2px; + background: #ffffff; +} + +.history-img img { + position: absolute; + + width: 36px; + height: 36px; + top: 12px; + left: 24px; +} + +.history-detail-main { + display: inline-block; + position: relative; + left: 68px; + top: 8px; + +} + +.detail-main-upper { + display: flex; +} + +.detail-main-upper h1 { + position: static; + height: 22px; + left: 0px; + top: 0px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 16px; + line-height: 22px; + text-transform: lowercase; + color: #2f343d; + flex: none; + order: 0; + align-self: center; + margin: 4px 0px; + margin-right: 4px; +} + +.detail-main-upper p { + position: static; + height: 16px; + top: 6px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; + flex: none; + order: 1; + align-self: flex-end; + margin: 4px 0px; +} + +.detail-main-lower p { + position: absolute; + width: 625px; + height: 20px; + top: 29px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 20px; + color: #2f343d; +} + +.chatHistory { + position: relative; + left: 24px; + width: 345px; + top: 27px; +} + +.chatHistory ul li { + display: block; +} + +.msgcount p { + background: #cbced1; + border-radius: 2px; + width: 100%; + text-align: center; + line-height: 0.15em; + font-size: 10px; + margin: 10px 0 20px; +} + +.msgcount p span { + width: 65px; + height: 12px; + right: 156px; + top: 3px; + font-family: Inter; + font-style: normal; + font-weight: 600; + text-align: center; + color: #6c727a; + background: white; + padding-left: 8px; + padding-right: 8px; +} + +.noresult { + font-weight: 700; + position: relative; + top: 30px; + left: 6%; +} + +#searchInput { + font-family: Inter; + font-style: normal; + font-weight: 500; + font-size: 14px; + line-height: 20px; + color: #9ea2a8; + position: absolute; + left: 16px; + right: 46px; + top: 10px; + bottom: 10px; + border: none; + width: 92%; +} + +.right-addon .glyphicon { + right: 0px; +} + +.right-addon input { + padding-right: 30px; +} + +.vistior-history-block { + margin-top: 10%; +} + +.vistior-history-block ul li { + border-bottom: 2px solid #f2f3f5; + display: block; + padding-bottom: 5%; + cursor: pointer; + width: 390px; + background-color: #ffffff; +} + +.vistior-history-block ul a { + text-decoration: none; + color: black; +} + +#allist li:hover { + background-color: rgba(15,34,0,.05) !important; +} + +.history-div { + display: flex; +} + +.visitor-img { + display: contents; +} + +.visitor-img img { + position: relative; + width: 36px; + height: 36px; + left: 24px; + top: 16px; + border-radius: 1.75px; +} + +.visitor-history-details { + margin-left: 2%; +} + +.visitor-details { + display: -webkit-inline-box; +} + +.visitor-details h1 { + position: relative; + height: 22px; + left: 25px; + top: 16px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 16px; + line-height: 22px; + text-transform: lowercase; + color: #2f343d; +} + +.contextual-bar__content { + padding-left: 0px !important; + padding-right: 0px !important; +} + +.visitor-details p { + position: relative; + height: 16px; + left: 29px; + top: 21px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; +} + +.total-messages { + font-size: 0.8rem; + color: grey; +} + +.total-messages p { + position: relative; + height: 16px; + left: 25px; + right: 84px; + top: 16px; + font-family: Inter; + font-style: normal; + font-weight: bold; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; +} + +.agent-comment { + margin-top: 3%; + font-size: 0.8rem; +} + +.comment-heading { + position: relative; + height: 16px; + left: 25px; + right: 84px; + top: 15px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 10px; + line-height: 12px; + color: #6c727a; +} + +.comment-text { + position: relative; + width: 268px; + left: 25px; + right: 24px; + top: 15px; + font-family: Inter; + font-style: italic; + font-weight: 500; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; +} + +.open { + padding-left: 4% !important; +} + +.loding { + text-align: center; + font-family: Inter; +} + +.Contextualheading { + position: absolute; + width: 249px; + height: 22px; + left: 57px; + top: 25px; + font-family: Inter; + font-style: normal; + font-weight: 500; + font-size: 16px; + line-height: 22px; + display: flex; + align-items: center; + color: #2f344d; +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2ace3c2d27024..e569b926cb76b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2862,6 +2862,11 @@ "uuid": "^3.2.1" }, "dependencies": { + "adm-zip": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.14.tgz", + "integrity": "sha512-/9aQCnQHF+0IiCl0qhXoK7qs//SwYE7zX8lsr/DNk1BRAHYxeLZPL4pguwK29gUEqasYQjqPtEpDRSWEkdHn9g==" + }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index d0854c8776ab1..d6fb2977f861d 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2609,7 +2609,7 @@ "Password_changed_successfully": "Password changed successfully", "Passwords_do_not_match": "Passwords do not match", "Password_Policy": "Password Policy", - "Past_Chats": "Past Chats", + "Past_Chats": "Customer Chat History", "Paste_here": "Paste here...", "Payload": "Payload", "Peer_Password": "Peer Password", From 428c0471d9b69afc8cdbcce6ea4acdf9cd296d1b Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Fri, 17 Apr 2020 22:00:16 +0530 Subject: [PATCH 02/35] css improved --- app/theme/client/main.css | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/theme/client/main.css b/app/theme/client/main.css index 8c0aa732cd6f3..b2184939f9ca1 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -62,19 +62,22 @@ /* customerChat History CSS */ .inner-addon { position: relative; - left: 24px; - width: 345px; - height: 40px; + left: 24px; + + width: 345px; + height: 40px; + border: 2px solid #cbced1; + + box-sizing: border-box; background: #ffffff; - - box-sizing: border-box; + border-radius: 2px; } .inner-addon .glyphicon { position: absolute; - bottom: 0.5%; + bottom: 0.5%; color: #2F343D; padding: 10px; From cf714877d3759a3d6d8d8abb9f6ae0d61009870a Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Fri, 17 Apr 2020 22:03:25 +0530 Subject: [PATCH 03/35] changed some css --- app/theme/client/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/theme/client/main.css b/app/theme/client/main.css index b2184939f9ca1..b51a3804abb30 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -62,7 +62,7 @@ /* customerChat History CSS */ .inner-addon { position: relative; - left: 24px; + left: 24px; width: 345px; height: 40px; From 1dd9fae9d72d32aa131fc5e9acda37c294a20d9a Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 22 Apr 2020 18:01:25 +0530 Subject: [PATCH 04/35] Code and CSS Improvement --- .../views/app/tabbar/customerChatHistory.html | 74 ++++----- .../views/app/tabbar/customerChatHistory.js | 149 ++++-------------- .../tabbar/customerChatHistoryMessages.html | 8 +- .../app/tabbar/customerChatHistoryMessages.js | 77 ++------- .../views/app/tabbar/visitorHistory.html | 22 --- .../client/views/app/tabbar/visitorHistory.js | 70 -------- app/theme/client/main.css | 73 +++++---- 7 files changed, 114 insertions(+), 359 deletions(-) delete mode 100644 app/livechat/client/views/app/tabbar/visitorHistory.html delete mode 100644 app/livechat/client/views/app/tabbar/visitorHistory.js diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html index 963765402280e..ddb472fcb2584 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -9,11 +9,33 @@ {{#if isAllChat}}
-
    + {{#if isSearching}} + {{#if isfound }} + {{#each searchResults}} +
  • +
    +
    + +
    +
    +
    +

    {{u.name}}

    +

    {{time}}

    +
    +
    +

    {{msg}}

    +
    +
    +
    +
  • + {{/each}} + {{else}} +

    No result found

    + {{/if}} + {{else}} {{#each previousChats}} -
  • - +
  • @@ -28,62 +50,24 @@

    {{responseBy.username}}

    {{/if}}
    -

    {{count}} messages

    +

    {{room.msgs}} messages

    Agent comment:

    "{{lastMessage.msg}}"

    -
- {{/each}} + {{/if}} - {{else}} + {{else}} {{#if isChatClicked}} {{> customerChatHistoryMessages}} - {{else}} -
- {{#if isfound }} -
    - - {{#each searchResults}} - -
  • -
    -
    - -
    -
    -
    -

    {{u.name}}

    -

    {{time}}

    -
    -
    -

    {{msg}}

    -
    -
    -
    - -
  • - {{/each}} - -
- {{else}} -

No result found

- {{/if}} -
- {{/if}} - - {{/if}} - + {{/if}} - - - \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.js b/app/livechat/client/views/app/tabbar/customerChatHistory.js index 94a6172e367ae..8039faab93de4 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.js @@ -1,66 +1,45 @@ -import { ReactiveVar } from 'meteor/reactive-var'; import { Template } from 'meteor/templating'; import moment from 'moment'; -import _ from 'underscore'; +import { ReactiveVar } from 'meteor/reactive-var'; import './customerChatHistory.html'; import { APIClient, t } from '../../../../../utils/client'; -import { AccountBox, TabBar, MessageTypes } from '../../../../../ui-utils'; -import {Mongo ,MongoInternals} from 'meteor/mongo'; -import { Tracker } from 'meteor/tracker'; -import { ReactiveDict } from 'meteor/reactive-dict'; import { Session } from 'meteor/session'; const ITEMS_COUNT = 50; let historyResult let len, msgs let allHistoryChat ; - Template.customerChatHistory.helpers({ - - isAllChat:function(){ + isSearching(){ + return Template.instance().isSearching.get() + }, + isAllChat() { // will return is have to load all chat return Template.instance().isAllChat.get(); }, - isChatClicked:function(){ + isChatClicked() { // will return that if you have clicked in a single chatHistory return Template.instance().isChatClicked.get(); }, - isfound:function() { + isfound() { // will return if find any search result - var isfound= Session.get('found'); - - return isfound; - }, - isLoading() { - return Template.instance().isLoading.get(); + return Session.get('found'); }, searchResults(){ // will return search result var r = Session.get('searchResult'); return Template.instance().searchResult.get(); }, - previousChats() { // will return pervious chats list let history = Template.instance().history.get(); let newHisTory = [] for(i=1; i { const { room } = await APIClient.v1.get(`rooms.info?roomId=${ currentData.rid }`); @@ -95,40 +73,10 @@ Template.customerChatHistory.onCreated(function() { if (!this.visitorId.get() || !currentData || !currentData.rid) { return; } - const offset = this.offset.get(); - - this.isLoading.set(true); const { history, total } = await APIClient.v1.get(`livechat/visitors.chatHistory/room/${ currentData.rid }/visitor/${ this.visitorId.get() }?count=${ ITEMS_COUNT }&offset=${ offset }`); - - this.isLoading.set(false); this.total.set(total); - this.history.set(this.history.get().concat(history)); - // this will load all the chat history chat messages - allHistoryChat = []; - var limit = 100; - let count = this.history.get(); - if(allHistoryChat.length>0){ - return - } - for(i=0;i 0){ - Session.set('found',true); - - } - + if(array.length >0){ + Session.set('found',true); + Session.set('searchResult',array); + template.searchResult.set(array) + } }}, 'click .list-chat': async function(event,template){ event.preventDefault(); @@ -198,33 +137,3 @@ Template.customerChatHistory.onDestroyed(function(){ header[0].className = 'contextual-bar__header-title'; } }) -function getTime(newTs){ - var hr = newTs.slice(0,2); - var min = newTs.slice(3,5); - if(hr > 12 && hr < 24){ - hr = hr-12; - return time = `${hr}:${min} PM`; - }else if(hr == 24){ - hr = 00; - return time = `${hr}:${min} AM`; - }else if(hr < 12 ){ - return time = `${hr}:${min} AM`; - }else if(hr == 12){ - return time = `${hr}:${min} PM`; - } -} -function getDay(obj){ - var d = Date.parse(obj.ts); - var D = new Date(); - D.setTime(d); - var day = D.getDay(); - switch(day){ - case 1 : return 'Monday'; - case 2 : return 'Tuesday'; - case 3 : return 'Wednesday'; - case 4 : return 'Thursday'; - case 5 : return 'Friday'; - case 6 : return 'Saturday'; - case 7 : return 'Sunday'; - } -} \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html index 5204f3cf7965f..a51d40f46e7d0 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html @@ -4,18 +4,13 @@

{{_ "Loading..."}}

{{else}} -
-

{{len}} messages

-
-
    - +
      {{#each historyResult}} {{#unless t}} -
    • @@ -57,6 +52,5 @@

      Agent comment:

      {{/each}}
- {{/if}} \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js index 5cd29b63a4ccd..fed8f39335af9 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -1,49 +1,36 @@ -import { ReactiveVar } from 'meteor/reactive-var'; import { Template } from 'meteor/templating'; import moment from 'moment'; -import _ from 'underscore'; import './customerChatHistoryMessages.html'; import { APIClient, t } from '../../../../../utils/client'; -import { AccountBox, TabBar, MessageTypes } from '../../../../../ui-utils'; -import {Mongo ,MongoInternals} from 'meteor/mongo'; -import { Tracker } from 'meteor/tracker'; -import { ReactiveDict } from 'meteor/reactive-dict'; import { Session } from 'meteor/session'; -let historyResult +let Messages let len, msgs let allHistoryChat ; Template.customerChatHistoryMessages.helpers({ - - historyResult(){ + historyResult() { // will return all the messages in history room - - return Template.instance().historyResu.get().reverse(); + return Template.instance().historyResult.get().reverse(); }, - len(){ + len() { // will return length of total messages in room - len = Template.instance().historyResu.get(); - return len = len.length-2; + len = Template.instance().historyResult.get(); + return len = len.length-1; }, }) Template.customerChatHistoryMessages.onCreated(function() { - this.historyResu = new ReactiveVar([]); + this.historyResult = new ReactiveVar([]); var id = Session.get('FetchID'); var token = Session.get('FetchToken') this.autorun(async () => { - historyResult = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`); + Messages = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`); // will return pervious chats list - let history = historyResult.messages; + let history = Messages.messages; let newHisTory = [] for(i=1; i 12 && hr < 24){ - hr = hr-12; - return time = `${hr}:${min} PM`; - }else if(hr == 24){ - hr = 00; - return time = `${hr}:${min} AM`; - }else if(hr < 12 ){ - return time = `${hr}:${min} AM`; - }else if(hr == 12){ - return time = `${hr}:${min} PM`; - } -} -function getDay(obj){ - var d = Date.parse(obj.ts); - var D = new Date(); - D.setTime(d); - var day = D.getDay(); - switch(day){ - case 1 : return 'Monday'; - case 2 : return 'Tuesday'; - case 3 : return 'Wednesday'; - case 4 : return 'Thursday'; - case 5 : return 'Friday'; - case 6 : return 'Saturday'; - case 7 : return 'Sunday'; - } -} \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/visitorHistory.html b/app/livechat/client/views/app/tabbar/visitorHistory.html deleted file mode 100644 index 25b744f51cc4e..0000000000000 --- a/app/livechat/client/views/app/tabbar/visitorHistory.html +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/app/livechat/client/views/app/tabbar/visitorHistory.js b/app/livechat/client/views/app/tabbar/visitorHistory.js deleted file mode 100644 index 84d3c00b447c3..0000000000000 --- a/app/livechat/client/views/app/tabbar/visitorHistory.js +++ /dev/null @@ -1,70 +0,0 @@ -import { ReactiveVar } from 'meteor/reactive-var'; -import { Template } from 'meteor/templating'; -import moment from 'moment'; -import _ from 'underscore'; - -import './visitorHistory.html'; -import { APIClient } from '../../../../../utils/client'; - -const ITEMS_COUNT = 50; - -Template.visitorHistory.helpers({ - isLoading() { - return Template.instance().isLoading.get(); - }, - - previousChats() { - return Template.instance().history.get(); - }, - - title() { - let title = moment(this.ts).format('L LTS'); - - if (this.label) { - title += ` - ${ this.label }`; - } - - return title; - }, -}); - -Template.visitorHistory.onCreated(function() { - const currentData = Template.currentData(); - this.visitorId = new ReactiveVar(); - this.isLoading = new ReactiveVar(false); - this.history = new ReactiveVar([]); - this.offset = new ReactiveVar(0); - this.total = new ReactiveVar(0); - - this.autorun(async () => { - const { room } = await APIClient.v1.get(`rooms.info?roomId=${ currentData.rid }`); - if (room && room.v) { - this.visitorId.set(room.v._id); - } - }); - - this.autorun(async () => { - if (!this.visitorId.get() || !currentData || !currentData.rid) { - return; - } - - const offset = this.offset.get(); - this.isLoading.set(true); - const { history, total } = await APIClient.v1.get(`livechat/visitors.chatHistory/room/${ currentData.rid }/visitor/${ this.visitorId.get() }?count=${ ITEMS_COUNT }&offset=${ offset }`); - this.isLoading.set(false); - this.total.set(total); - this.history.set(this.history.get().concat(history)); - }); -}); - -Template.visitorHistory.events({ - 'scroll .visitor-scroll': _.throttle(function(e, instance) { - if (e.target.scrollTop >= (e.target.scrollHeight - e.target.clientHeight)) { - const history = instance.history.get(); - if (instance.total.get() <= history.length) { - return; - } - return instance.offset.set(instance.offset.get() + ITEMS_COUNT); - } - }, 200), -}); diff --git a/app/theme/client/main.css b/app/theme/client/main.css index b51a3804abb30..92f26cf4f29e3 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -65,11 +65,11 @@ left: 24px; width: 345px; - height: 40px; + height: 40px; - border: 2px solid #cbced1; + border: 2px solid #cbced1; - box-sizing: border-box; + box-sizing: border-box; background: #ffffff; border-radius: 2px; @@ -77,83 +77,89 @@ .inner-addon .glyphicon { position: absolute; - bottom: 0.5%; - color: #2F343D; + bottom: 0.5%; + + color: #2f343d; padding: 10px; - pointer-events: none; + pointer-events: none; } .searchresults { - margin-top: 7%; + margin-top: 7%; } .search-li { display: block; - padding-bottom: 3%; + + padding-bottom: 3%; position: relative; - height: 65px; + height: 65px; background-color: #ffffff; } -.search-li :hover { - cursor: default; +.search-li :hover { + + cursor: default; } .closed-div { position: relative; - top: 20px; + top: 20px; } .closed-div-p { - background: #f5455c; + background: #f5455c; border-radius: 2px; width: 100%; text-align: center; line-height: 0.15em; font-size: 10px; - margin: 10px 0 15px; + margin: 10px 0 15px; } .closed-div-p span { - width: 101px; + width: 101px; height: 12px; - right: 138px; + right: 138px; top: 3px; font-family: Inter; font-style: normal; font-weight: 600; text-align: center; - color: #f5455c; + color: #f5455c; background: white; padding-left: 8px; padding-right: 8px; } .closed-h1 h1 { - color: #6c727a !important; - - font-size: 14px !important; + color: #6c727a !important; - line-height: 20px !important; - - font-weight: 600px !important; + font-size: 14px !important; + font-weight: 600px !important; + + line-height: 20px !important; + font-style: italic !important; + text-transform: none !important; } .closed-p p { - color: #9ea2a8 !important; - font-style: italic !important; + color: #9ea2a8 !important; font-weight: 500 !important; - top: 25px !important; + + font-style: italic !important; + + top: 25px !important; } .belldiv { @@ -162,13 +168,14 @@ height: 36px; top: 12px; left: 24px; - background: #e4e7ea; + + background: #e4e7ea; } .belldiv i { position: relative; - left: 22.31%; - top: 15.79%; + top: 15.79%; + left: 22.31%; } .history-main { @@ -176,9 +183,11 @@ position: relative; width: 100%; - height: 68px; - left: 2px; - background: #ffffff; + height: 68px; + + left: 2px; + + background: #ffffff; } .history-img img { From 19d618437a5519fd536955951923bd25266068ef Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 22 Apr 2020 18:06:36 +0530 Subject: [PATCH 05/35] Code and CSS Improvement --- app/theme/client/main.css | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/theme/client/main.css b/app/theme/client/main.css index 92f26cf4f29e3..a6b24bd185166 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -62,15 +62,16 @@ /* customerChat History CSS */ .inner-addon { position: relative; - left: 24px; - - width: 345px; - height: 40px; - - border: 2px solid #cbced1; + left: 24px; + + width: 345px; + height: 40px; - box-sizing: border-box; - background: #ffffff; + box-sizing: border-box; + + border: 2px solid #cbced1; + + background: #ffffff; border-radius: 2px; } From 8388d6e77a0490d70c89f04723fc6c2006d74855 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 22 Apr 2020 18:24:08 +0530 Subject: [PATCH 06/35] some changes --- package-lock.json | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 66d78df54d407..44cad480c2c43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6900,8 +6900,8 @@ "integrity": "sha1-WYc/Nej89sc2HBAjkmHXbhU0i7I=" }, "adm-zip": { - "version": "0.4.12", - "resolved": "github:RocketChat/adm-zip#34ac787ce7f45c6cea99df049deb17d0c476a3b5" + "version": "github:RocketChat/adm-zip#34ac787ce7f45c6cea99df049deb17d0c476a3b5", + "from": "github:RocketChat/adm-zip" }, "aggregate-error": { "version": "3.0.1", diff --git a/package.json b/package.json index 84992469d2da8..e8981c0ff6ec7 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "@rocket.chat/ui-kit": "^0.7.1", "@slack/client": "^4.8.0", "adm-zip": "RocketChat/adm-zip", - "apn": "2.2.0", + "apn": "^2.2.0", "archiver": "^3.0.0", "arraybuffer-to-string": "^1.0.2", "atlassian-crowd": "^0.5.0", @@ -205,7 +205,7 @@ "moment-timezone": "^0.5.27", "mongodb": "^3.5.6", "node-dogstatsd": "^0.0.7", - "node-gcm": "0.14.4", + "node-gcm": "^0.14.4", "node-rsa": "^1.0.5", "object-path": "^0.11.4", "pdfjs-dist": "^2.0.943", From 6ec867f22dcb5428aeb0830f79b3968320b38890 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 22 Apr 2020 18:28:01 +0530 Subject: [PATCH 07/35] changes made --- app/livechat/client/views/app/tabbar/customerChatHistory.html | 2 +- app/livechat/client/views/app/tabbar/customerChatHistory.js | 1 - .../client/views/app/tabbar/customerChatHistoryMessages.html | 2 +- .../client/views/app/tabbar/customerChatHistoryMessages.js | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html index ddb472fcb2584..e744ff0547dec 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -31,7 +31,7 @@

{{u.name}}

{{/each}} {{else}} -

No result found

+

No result found

{{/if}} {{else}} {{#each previousChats}} diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.js b/app/livechat/client/views/app/tabbar/customerChatHistory.js index 8039faab93de4..bdefca91e2062 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.js @@ -67,7 +67,6 @@ Template.customerChatHistory.onCreated(function() { this.visitorId.set(room.v._id); } }); - this.autorun(async () => { if (!this.visitorId.get() || !currentData || !currentData.rid) { diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html index a51d40f46e7d0..033b838acdcc1 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html @@ -30,7 +30,7 @@

{{u.name}}

{{else}} {{#if u.name}}
-

Conversation closed

+

Conversation closed

diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js index fed8f39335af9..f3d3988ce8302 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -19,7 +19,6 @@ Template.customerChatHistoryMessages.helpers({ return len = len.length-1; }, }) - Template.customerChatHistoryMessages.onCreated(function() { this.historyResult = new ReactiveVar([]); var id = Session.get('FetchID'); From 65d03ae19aba8b15d8254f34bd67e9dff3af51f9 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Mon, 27 Apr 2020 17:57:12 +0530 Subject: [PATCH 08/35] Api modified --- .../views/app/tabbar/chatRoomHistoryItem.html | 26 +++++ .../views/app/tabbar/customerChatHistory.html | 104 ++++++++---------- .../views/app/tabbar/customerChatHistory.js | 93 ++++++++++------ .../tabbar/customerChatHistoryMessages.html | 104 +++++++++--------- .../app/tabbar/customerChatHistoryMessages.js | 41 +++---- app/livechat/imports/server/rest/visitors.js | 4 +- app/livechat/server/api/lib/visitors.js | 48 ++++++-- app/theme/client/main.css | 4 +- 8 files changed, 243 insertions(+), 181 deletions(-) create mode 100644 app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html diff --git a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html new file mode 100644 index 0000000000000..54e37f407ed40 --- /dev/null +++ b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html index e744ff0547dec..cb88ffe50f014 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -2,72 +2,54 @@
-
- - +
+ + +
-
- {{#if isAllChat}} -
-
    - {{#if isSearching}} - {{#if isfound }} - {{#each searchResults}} -
  • -
    -
    - -
    -
    -
    -

    {{u.name}}

    -

    {{time}}

    -
    -
    -

    {{msg}}

    -
    -
    -
    -
  • - {{/each}} + {{#if hasChatHistory}} + {{#if isAllChat}} +
    +
      + {{#if isSearching}} + {{#if isfound }} + {{#each searchResults}} +
    • +
      +
      + +
      +
      +
      +

      {{u.name}}

      +

      {{time}}

      +
      +
      +

      {{msg}}

      +
      +
      +
      +
    • + {{/each}} + {{else}} +

      No result found

      + {{/if}} {{else}} -

      No result found

      + {{#each room in previousChats}} + {{> chatRoomHistoryItem room}} + {{/each}} {{/if}} +
    +
    {{else}} - {{#each previousChats}} -
  • -
    -
    - -
    -
    -
    -

    {{responseBy.username}}

    - {{#if open}} -

    Open

    - {{else}} -

    Close at time {{time}}

    - {{/if}} -
    -
    -

    {{room.msgs}} messages

    -
    -
    -

    Agent comment:

    -

    "{{lastMessage.msg}}"

    -
    -
    -
    -
  • - {{/each}} + {{#if isChatClicked}} + {{> customerChatHistoryMessages}} + {{/if}} {{/if}} -
-
- {{else}} - {{#if isChatClicked}} - {{> customerChatHistoryMessages}} + {{else}} +

No Previous Chats found

{{/if}} - {{/if}}
- \ No newline at end of file + + diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.js b/app/livechat/client/views/app/tabbar/customerChatHistory.js index bdefca91e2062..02b65e30c2671 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.js @@ -2,15 +2,19 @@ import { Template } from 'meteor/templating'; import moment from 'moment'; import { ReactiveVar } from 'meteor/reactive-var'; import './customerChatHistory.html'; +import './chatRoomHistoryItem.html'; import { APIClient, t } from '../../../../../utils/client'; import { Session } from 'meteor/session'; - +import _ from 'underscore'; const ITEMS_COUNT = 50; -let historyResult -let len, msgs -let allHistoryChat ; +let isChanged; Template.customerChatHistory.helpers({ - isSearching(){ + + hasChatHistory() { + // will return if user has any chatHistory or not + return Template.instance().hasHistory.get() + }, + isSearching() { return Template.instance().isSearching.get() }, isAllChat() { @@ -27,19 +31,11 @@ Template.customerChatHistory.helpers({ }, searchResults(){ // will return search result - var r = Session.get('searchResult'); return Template.instance().searchResult.get(); }, previousChats() { // will return pervious chats list - let history = Template.instance().history.get(); - let newHisTory = [] - for(i=1; i { - + const filter = this.filter.get() if (!this.visitorId.get() || !currentData || !currentData.rid) { return; } const offset = this.offset.get(); - const { history, total } = await APIClient.v1.get(`livechat/visitors.chatHistory/room/${ currentData.rid }/visitor/${ this.visitorId.get() }?count=${ ITEMS_COUNT }&offset=${ offset }`); + const searchText='null'; + let baseUrl = `livechat/visitors.chatHistory/room/${ currentData.rid}/visitor/${ this.visitorId.get() }?searchText=${searchText}&count=${ ITEMS_COUNT }&offset=${ offset }` + const { history, total,resultArray } = await APIClient.v1.get(baseUrl); + if(history.length > 0){ + for(var i=0 ;i0){ + Template.instance().searchResult = new ReactiveVar([]); + var result = loadRoom(event.target.value ,Template.currentData().rid,template.visitorId.get(),offset) + result.then(function(v){ + if(v != null){ Session.set('found',true); - Session.set('searchResult',array); - template.searchResult.set(array) - } + Session.set('searchResult',v); + template.searchResult.set(v); + } + }) }}, 'click .list-chat': async function(event,template){ event.preventDefault(); @@ -136,3 +136,26 @@ Template.customerChatHistory.onDestroyed(function(){ header[0].className = 'contextual-bar__header-title'; } }) + +loadRoom = async (searchTerm,rid,visitorId,offset) =>{ + let baseUrl = `livechat/visitors.chatHistory/room/${ rid}/visitor/${ visitorId }?searchText=${searchTerm}&count=${ ITEMS_COUNT }&offset=${ offset }` + const { resultArray } = await APIClient.v1.get(baseUrl); + if(resultArray.length==0){ + return null; + }else{ + return addTime(resultArray); + } +} + +addTime = (array,value='false') => { + if(value=='true'){ + if(!isChanged){ + array.shift(); + isChanged = true; + } + } + for(var i=0; i {{#if isLoading}} -

- {{_ "Loading..."}} -

- {{else}} -
-
-

{{len}} messages

-
-
    - {{#each historyResult}} - {{#unless t}} -
  • -
    -
    - -
    -
    -
    -

    {{u.name}}

    -

    {{time}}

    -
    -
    -

    {{msg}}

    -
    -
    -
    -
  • - {{else}} - {{#if u.name}} -
    -

    Conversation closed

    -
    -
    -
    - -
    -
    -
    -
    -

    Agent comment:

    -
    -
    -

    "{{msg}}".

    -
    -
    -
    +

    + {{_ "Loading..."}} +

    + {{else}} +
    +
    +

    {{len}} messages

    - {{/if}} - {{/unless}} - {{/each}} -
-
- {{/if}} +
    + {{#each historyResult}} + {{#unless t}} +
  • +
    +
    + +
    +
    +
    +

    {{u.name}}

    +

    {{time}}

    +
    +
    +

    {{msg}}

    +
    +
    +
    +
  • + {{else}} + {{#if u.name}} +
    +

    Conversation closed

    +
    +
    +
    + +
    +
    +
    +
    +

    Agent comment:

    +
    +
    +

    "{{msg}}".

    +
    +
    +
    +
    + {{/if}} + {{/unless}} + {{/each}} +
+
+ {{/if}} \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js index f3d3988ce8302..2b78bcb9c8e5c 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -3,49 +3,52 @@ import moment from 'moment'; import './customerChatHistoryMessages.html'; import { APIClient, t } from '../../../../../utils/client'; import { Session } from 'meteor/session'; - -let Messages -let len, msgs -let allHistoryChat ; +import { ReactiveVar } from 'meteor/reactive-var'; Template.customerChatHistoryMessages.helpers({ historyResult() { // will return all the messages in history room - return Template.instance().historyResult.get().reverse(); + return Template.instance().historyResult.get(); }, len() { // will return length of total messages in room - len = Template.instance().historyResult.get(); - return len = len.length-1; + let len = Template.instance().historyResult.get(); + return len = len.length; }, }) Template.customerChatHistoryMessages.onCreated(function() { this.historyResult = new ReactiveVar([]); + this.history = new ReactiveVar([]); var id = Session.get('FetchID'); var token = Session.get('FetchToken') this.autorun(async () => { - Messages = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`); + const{ messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`); // will return pervious chats list - let history = Messages.messages; - let newHisTory = [] - for(i=1; i { + let newArray = []; + for(var j=array.length-2; j>=1;j--){ + array[j].time = moment(array[j].ts).format('LT'); + newArray.push(array[j]) + }; + return newArray; + +} diff --git a/app/livechat/imports/server/rest/visitors.js b/app/livechat/imports/server/rest/visitors.js index 42b5a20b25d71..1013429c3bfda 100644 --- a/app/livechat/imports/server/rest/visitors.js +++ b/app/livechat/imports/server/rest/visitors.js @@ -3,6 +3,7 @@ import { check } from 'meteor/check'; import { API } from '../../../../api'; import { findVisitorInfo, findVisitedPages, findChatHistory } from '../../../server/api/lib/visitors'; +import { normalizeMessagesForUser } from '/app/utils/server/lib/normalizeMessagesForUser'; API.v1.addRoute('livechat/visitors.info', { authRequired: true }, { get() { @@ -47,18 +48,17 @@ API.v1.addRoute('livechat/visitors.chatHistory/room/:roomId/visitor/:visitorId', }); const { offset, count } = this.getPaginationItems(); const { sort } = this.parseJsonQuery(); - const history = Promise.await(findChatHistory({ userId: this.userId, roomId: this.urlParams.roomId, visitorId: this.urlParams.visitorId, + text : this.queryParams.searchText, pagination: { offset, count, sort, }, })); - return API.v1.success(history); }, }); diff --git a/app/livechat/server/api/lib/visitors.js b/app/livechat/server/api/lib/visitors.js index ad7cb3da93e51..8c1ce3bc66b35 100644 --- a/app/livechat/server/api/lib/visitors.js +++ b/app/livechat/server/api/lib/visitors.js @@ -1,6 +1,7 @@ import { hasPermissionAsync } from '../../../../authorization/server/functions/hasPermission'; import { LivechatVisitors, Messages, LivechatRooms } from '../../../../models/server/raw'; import { canAccessRoomAsync } from '../../../../authorization/server/functions/canAccessRoom'; +import { Meteor } from 'meteor/meteor'; export async function findVisitorInfo({ userId, visitorId }) { if (!await hasPermissionAsync(userId, 'view-l-room')) { @@ -30,7 +31,7 @@ export async function findVisitedPages({ userId, roomId, pagination: { offset, c skip: offset, limit: count, }); - + const total = await cursor.count(); const pages = await cursor.toArray(); @@ -43,7 +44,7 @@ export async function findVisitedPages({ userId, roomId, pagination: { offset, c }; } -export async function findChatHistory({ userId, roomId, visitorId, pagination: { offset, count, sort } }) { +export async function findChatHistory({ userId, roomId, visitorId,text, pagination: { offset, count, sort } }) { if (!await hasPermissionAsync(userId, 'view-l-room')) { throw new Error('error-not-authorized'); } @@ -62,13 +63,40 @@ export async function findChatHistory({ userId, roomId, visitorId, pagination: { }); const total = await cursor.count(); - const history = await cursor.toArray(); - - return { - history, - count: history.length, - offset, - total, - }; + if(text == 'null'){ + return { + history, + count: history.length, + offset, + total, + + }; + + }else{ + let resultArray=[]; + Meteor.runAsUser(userId,()=>{ + for(var i=0; i0){ + for(var j=0; j Date: Mon, 27 Apr 2020 18:14:18 +0530 Subject: [PATCH 09/35] css changes with Api modification --- app/theme/client/main.css | 71 ++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/app/theme/client/main.css b/app/theme/client/main.css index d8712876c8bad..238edd0fecbb1 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -64,12 +64,12 @@ position: relative; left: 24px; - width: 345px; - height: 40px; + width: 345px; + height: 40px; - box-sizing: border-box; - - border: 2px solid #cbced1; + box-sizing: border-box; + + border: 2px solid #cbced1; background: #ffffff; @@ -96,9 +96,9 @@ display: block; padding-bottom: 3%; - position: relative; + position: relative; - height: 65px; + height: 65px; background-color: #ffffff; } @@ -114,7 +114,7 @@ } .closed-div-p { - background: #f5455c; + background: #f5455c; border-radius: 2px; width: 100%; text-align: center; @@ -126,7 +126,7 @@ .closed-div-p span { width: 101px; - height: 12px; + height: 12px; right: 138px; top: 3px; @@ -142,12 +142,12 @@ } .closed-h1 h1 { - color: #6c727a !important; - - font-size: 14px !important; - font-weight: 600px !important; + color: #6c727a !important; + + font-size: 14px !important; + font-weight: 600px !important; - line-height: 20px !important; + line-height: 20px !important; font-style: italic !important; @@ -156,11 +156,11 @@ .closed-p p { color: #9ea2a8 !important; - font-weight: 500 !important; + font-weight: 500 !important; - font-style: italic !important; - - top: 25px !important; + font-style: italic !important; + + top: 25px !important; } .belldiv { @@ -174,37 +174,38 @@ } .belldiv i { - position: relative; + position: relative; top: 15.79%; left: 22.31%; + } .history-main { - display: flex; - position: relative; + display: flex; + position: relative; + + width: 100%; + height: 68px; - width: 100%; - height: 68px; - - left: 2px; - - background: #ffffff; + left: 2px; + + background: #ffffff; } .history-img img { position: absolute; - width: 36px; - height: 36px; - top: 12px; - left: 24px; + width: 36px; + height: 36px; + top: 12px; + left: 24px; } .history-detail-main { - display: inline-block; - position: relative; - left: 68px; - top: 8px; + display: inline-block; + position: relative; + left: 68px; + top: 8px; } From 4a7e476b035a3c28ec61e5fde8d1af9d368957f5 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Tue, 28 Apr 2020 18:46:36 +0530 Subject: [PATCH 10/35] chnages made on 28April --- .../views/app/tabbar/chatRoomHistoryItem.js | 8 + .../views/app/tabbar/chatRoomSearchItem.html | 18 +++ .../views/app/tabbar/chatRoomSearchItem.js | 8 + .../views/app/tabbar/customerChatHistory.html | 21 +-- .../views/app/tabbar/customerChatHistory.js | 146 +++++++++--------- .../tabbar/customerChatHistoryMessages.html | 2 +- .../app/tabbar/customerChatHistoryMessages.js | 73 ++++----- app/livechat/client/views/regular.js | 2 + app/livechat/imports/server/rest/visitors.js | 3 +- app/livechat/server/api/lib/visitors.js | 67 ++++---- app/theme/client/main.css | 63 ++++---- package.json | 4 +- 12 files changed, 208 insertions(+), 207 deletions(-) create mode 100644 app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js create mode 100644 app/livechat/client/views/app/tabbar/chatRoomSearchItem.html create mode 100644 app/livechat/client/views/app/tabbar/chatRoomSearchItem.js diff --git a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js new file mode 100644 index 0000000000000..6defc12ae0434 --- /dev/null +++ b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js @@ -0,0 +1,8 @@ +import moment from 'moment'; +import './chatRoomHistoryItem.html'; +import { Template } from 'meteor/templating'; + +Template.chatRoomHistoryItem.onCreated(function() { + const currentData = Template.currentData(); + currentData.time = moment(currentData.ts).format('LT'); +}); diff --git a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.html b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.html new file mode 100644 index 0000000000000..a9a1f9abcccb8 --- /dev/null +++ b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.html @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js new file mode 100644 index 0000000000000..78440462b795a --- /dev/null +++ b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js @@ -0,0 +1,8 @@ +import moment from 'moment'; +import './chatRoomSearchItem.html'; +import { Template } from 'meteor/templating'; + +Template.chatRoomSearchItem.onCreated(function() { + const currentData = Template.currentData(); + currentData.time = moment(currentData.ts).format('LT'); +}); diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html index cb88ffe50f014..00f54acb08f4c 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -13,23 +13,8 @@
    {{#if isSearching}} {{#if isfound }} - {{#each searchResults}} -
  • -
    -
    - -
    -
    -
    -

    {{u.name}}

    -

    {{time}}

    -
    -
    -

    {{msg}}

    -
    -
    -
    -
  • + {{#each chat in searchResults}} + {{> chatRoomSearchItem chat}} {{/each}} {{else}}

    No result found

    @@ -43,7 +28,7 @@

    No result found

{{else}} {{#if isChatClicked}} - {{> customerChatHistoryMessages}} + {{> customerChatHistoryMessages clickRid=clickRid clickToken=clickToken}} {{/if}} {{/if}} {{else}} diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.js b/app/livechat/client/views/app/tabbar/customerChatHistory.js index 02b65e30c2671..bdc4a97de7e89 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.js @@ -3,22 +3,23 @@ import moment from 'moment'; import { ReactiveVar } from 'meteor/reactive-var'; import './customerChatHistory.html'; import './chatRoomHistoryItem.html'; -import { APIClient, t } from '../../../../../utils/client'; -import { Session } from 'meteor/session'; +import './chatRoomSearchItem.html'; import _ from 'underscore'; + +import { APIClient } from '../../../../../utils/client'; + const ITEMS_COUNT = 50; -let isChanged; Template.customerChatHistory.helpers({ - + hasChatHistory() { // will return if user has any chatHistory or not - return Template.instance().hasHistory.get() + return Template.instance().hasHistory.get(); }, isSearching() { - return Template.instance().isSearching.get() + return Template.instance().isSearching.get(); }, isAllChat() { - // will return is have to load all chat + // will return is have to load all chat return Template.instance().isAllChat.get(); }, isChatClicked() { @@ -27,18 +28,23 @@ Template.customerChatHistory.helpers({ }, isfound() { // will return if find any search result - return Session.get('found'); + return Template.instance().isFound.get(); }, - searchResults(){ + searchResults() { // will return search result return Template.instance().searchResult.get(); }, previousChats() { // will return pervious chats list - return addTime(Template.instance().history.get(),'true'); + return Template.instance().history.get(); + }, + clickRid() { + return Template.instance().clickRid.get(); + }, + clickToken() { + return Template.instance().clickToken.get(); }, title() { - let title = moment(this.ts).format('L LTS'); if (this.label) { @@ -50,10 +56,12 @@ Template.customerChatHistory.helpers({ const DEBOUNCE_TIME_FOR_SEARCH_DEPARTMENTS_IN_MS = 300; Template.customerChatHistory.onCreated(function() { - isChanged = false; const currentData = Template.currentData(); + this.rid = new ReactiveVar(currentData.rid); this.filter = new ReactiveVar(''); + this.isKeyUp = new ReactiveVar(false); this.hasHistory = new ReactiveVar(false); + this.isFound = new ReactiveVar(); this.visitorId = new ReactiveVar(); this.history = new ReactiveVar([]); this.offset = new ReactiveVar(0); @@ -61,31 +69,49 @@ Template.customerChatHistory.onCreated(function() { this.isAllChat = new ReactiveVar(true); this.isSearching = new ReactiveVar(false); this.isChatClicked = new ReactiveVar(true); + this.clickRid = new ReactiveVar(); + this.clickToken = new ReactiveVar(); this.autorun(async () => { const { room } = await APIClient.v1.get(`rooms.info?roomId=${ currentData.rid }`); if (room && room.v) { this.visitorId.set(room.v._id); } + this.loadRoom(); }); - this.autorun(async () => { - const filter = this.filter.get() - if (!this.visitorId.get() || !currentData || !currentData.rid) { + this.loadRoom = async (searchTerm) => { + if (!this.visitorId.get()) { return; } const offset = this.offset.get(); - const searchText='null'; - let baseUrl = `livechat/visitors.chatHistory/room/${ currentData.rid}/visitor/${ this.visitorId.get() }?searchText=${searchText}&count=${ ITEMS_COUNT }&offset=${ offset }` - const { history, total,resultArray } = await APIClient.v1.get(baseUrl); - if(history.length > 0){ - for(var i=0 ;i 0) { + this.hasHistory.set(true); + } + } else { + if (searchTerm === '') { + this.isFound.set(false); + this.isSearching.set(false); + return; + } + if (resultArray.length !== 0) { + result = resultArray; + this.isFound.set(true); + this.searchResult.set(result); + } + } + }; }); Template.customerChatHistory.events({ @@ -98,64 +124,32 @@ Template.customerChatHistory.events({ return instance.offset.set(instance.offset.get() + ITEMS_COUNT); } }, 200), - 'keyup #searchInput': async function(event,template){ - const offset = template.offset.get(); + 'keyup #searchInput': _.debounce((event, template) => { + event.preventDefault(); + event.stopPropagation(); template.isSearching.set(true); template.isChatClicked.set(false); template.isAllChat.set(true); - Session.set('found',false); - if(event.target.value == ''){ - template.isSearching.set(false); - }else{ - Template.instance().searchResult = new ReactiveVar([]); - var result = loadRoom(event.target.value ,Template.currentData().rid,template.visitorId.get(),offset) - result.then(function(v){ - if(v != null){ - Session.set('found',true); - Session.set('searchResult',v); - template.searchResult.set(v); - } - }) - }}, - 'click .list-chat': async function(event,template){ + template.isFound.set(false); + template.isKeyUp.set(true); + template.loadRoom(event.target.value); + }, DEBOUNCE_TIME_FOR_SEARCH_DEPARTMENTS_IN_MS), + async 'click .list-chat'(event, template) { event.preventDefault(); template.isAllChat.set(false); template.isChatClicked.set(true); - let id = event.currentTarget.id - let token = event.currentTarget.attributes.aria.value; - Session.set('FetchID',id); - Session.set('FetchToken',token) - } + const { id } = event.currentTarget; + const token = event.currentTarget.attributes.aria.value; + template.clickRid.set(id); + template.clickToken.set(token); + }, }); -Template.customerChatHistory.onDestroyed(function(){ - var header = document.getElementsByClassName('Contextualheading'); - if(header[0]){ - header[0].innerText = '' +Template.customerChatHistory.onDestroyed(function() { + const header = document.getElementsByClassName('Contextualheading'); + if (header[0]) { + header[0].innerText = ''; header[0].className = 'contextual-bar__header-title'; } -}) - -loadRoom = async (searchTerm,rid,visitorId,offset) =>{ - let baseUrl = `livechat/visitors.chatHistory/room/${ rid}/visitor/${ visitorId }?searchText=${searchTerm}&count=${ ITEMS_COUNT }&offset=${ offset }` - const { resultArray } = await APIClient.v1.get(baseUrl); - if(resultArray.length==0){ - return null; - }else{ - return addTime(resultArray); - } -} - -addTime = (array,value='false') => { - if(value=='true'){ - if(!isChanged){ - array.shift(); - isChanged = true; - } - } - for(var i=0; i {{else}}
-

{{len}} messages

+

{{historyResult.length}} messages

    {{#each historyResult}} diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js index 2b78bcb9c8e5c..7b88c87682676 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -1,54 +1,43 @@ import { Template } from 'meteor/templating'; import moment from 'moment'; import './customerChatHistoryMessages.html'; -import { APIClient, t } from '../../../../../utils/client'; -import { Session } from 'meteor/session'; import { ReactiveVar } from 'meteor/reactive-var'; +import { APIClient } from '../../../../../utils/client'; + Template.customerChatHistoryMessages.helpers({ historyResult() { // will return all the messages in history room return Template.instance().historyResult.get(); - }, - len() { - // will return length of total messages in room - let len = Template.instance().historyResult.get(); - return len = len.length; }, -}) +}); Template.customerChatHistoryMessages.onCreated(function() { - this.historyResult = new ReactiveVar([]); - this.history = new ReactiveVar([]); - var id = Session.get('FetchID'); - var token = Session.get('FetchToken') - this.autorun(async () => { - const{ messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${token}`); - // will return pervious chats list - this.history.set(messages); - let allMessages = addTIME(this.history.get()); - var header = document.getElementsByClassName('contextual-bar__header-title'); - var day,agentName; - - if(allMessages.length !== 0){ - var len = allMessages.length-1; - agentName = allMessages[len].u.username; - day = moment(allMessages[len].ts).format('dddd'); - } - if(header[0]){ - header[0].innerText= `${agentName}, closed at ${day}` - header[0].className = 'Contextualheading'; + const currentData = Template.currentData(); + this.historyResult = new ReactiveVar([]); + this.history = new ReactiveVar([]); + const id = currentData.clickRid; + const token = currentData.clickToken; + let closingDay; + let agentName; + this.autorun(async () => { + const { messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${ token }`); + // will return pervious chats list + this.history.set(messages); + const allMessages = []; + for (let j = messages.length - 2; j >= 1; j--) { + messages[j].time = moment(messages[j].ts).format('LT'); + allMessages.push(messages[j]); } - this.historyResult.set(allMessages); - }) -}) -addTIME = (array) => { - let newArray = []; - for(var j=array.length-2; j>=1;j--){ - array[j].time = moment(array[j].ts).format('LT'); - newArray.push(array[j]) - }; - return newArray; - -} - - + const header = document.getElementsByClassName('contextual-bar__header-title'); + if (allMessages.length !== 0) { + const len = allMessages.length - 1; + agentName = allMessages[len].u.username; + closingDay = moment(allMessages[len].ts).format('dddd'); + } + if (header[0]) { + header[0].innerText = `${ agentName }, closed at ${ closingDay }`; + header[0].className = 'Contextualheading'; + } + this.historyResult.set(allMessages); + }); +}); diff --git a/app/livechat/client/views/regular.js b/app/livechat/client/views/regular.js index b134606917ab0..f817b74e86808 100644 --- a/app/livechat/client/views/regular.js +++ b/app/livechat/client/views/regular.js @@ -10,5 +10,7 @@ import './app/tabbar/visitorEdit'; import './app/tabbar/visitorForward'; import './app/tabbar/customerChatHistory'; import './app/tabbar/customerChatHistoryMessages'; +import './app/tabbar/chatRoomHistoryItem'; +import './app/tabbar/chatRoomSearchItem'; import './app/tabbar/visitorInfo'; import './app/tabbar/visitorNavigation'; diff --git a/app/livechat/imports/server/rest/visitors.js b/app/livechat/imports/server/rest/visitors.js index 1013429c3bfda..15d3760defa11 100644 --- a/app/livechat/imports/server/rest/visitors.js +++ b/app/livechat/imports/server/rest/visitors.js @@ -52,7 +52,8 @@ API.v1.addRoute('livechat/visitors.chatHistory/room/:roomId/visitor/:visitorId', userId: this.userId, roomId: this.urlParams.roomId, visitorId: this.urlParams.visitorId, - text : this.queryParams.searchText, + text: this.queryParams.searchText, + closedChatsOnly: this.queryParams.closedChatsOnly, pagination: { offset, count, diff --git a/app/livechat/server/api/lib/visitors.js b/app/livechat/server/api/lib/visitors.js index 8c1ce3bc66b35..aa5b08e043029 100644 --- a/app/livechat/server/api/lib/visitors.js +++ b/app/livechat/server/api/lib/visitors.js @@ -1,7 +1,8 @@ +import { Meteor } from 'meteor/meteor'; + import { hasPermissionAsync } from '../../../../authorization/server/functions/hasPermission'; import { LivechatVisitors, Messages, LivechatRooms } from '../../../../models/server/raw'; import { canAccessRoomAsync } from '../../../../authorization/server/functions/canAccessRoom'; -import { Meteor } from 'meteor/meteor'; export async function findVisitorInfo({ userId, visitorId }) { if (!await hasPermissionAsync(userId, 'view-l-room')) { @@ -31,7 +32,7 @@ export async function findVisitedPages({ userId, roomId, pagination: { offset, c skip: offset, limit: count, }); - + const total = await cursor.count(); const pages = await cursor.toArray(); @@ -44,7 +45,7 @@ export async function findVisitedPages({ userId, roomId, pagination: { offset, c }; } -export async function findChatHistory({ userId, roomId, visitorId,text, pagination: { offset, count, sort } }) { +export async function findChatHistory({ userId, roomId, visitorId, text, closedChatsOnly, pagination: { offset, count, sort } }) { if (!await hasPermissionAsync(userId, 'view-l-room')) { throw new Error('error-not-authorized'); } @@ -61,42 +62,36 @@ export async function findChatHistory({ userId, roomId, visitorId,text, paginati skip: offset, limit: count, }); - const total = await cursor.count(); const history = await cursor.toArray(); - if(text == 'null'){ - return { - history, - count: history.length, - offset, - total, - - }; - - }else{ - let resultArray=[]; - Meteor.runAsUser(userId,()=>{ - for(var i=0; i0){ - for(var j=0; j { + history.map(function(val) { + const roomId = val._id; + const count = 1; + const result = Meteor.call('messageSearch', text, roomId, count).message.docs; + if (result.length > 0) { + result.map(function(e) { + resultArray.push(e); + }); } + }); + }); + } + if (closedChatsOnly) { + history.map(function(e, index) { + if (e.open) { + history.splice(index, 1); } - }) - - return { - history, - count: history.length, - offset, - total, - resultArray, - - }; - + }); } - + return { + history, + count: history.length, + offset, + total, + resultArray, + }; } diff --git a/app/theme/client/main.css b/app/theme/client/main.css index 238edd0fecbb1..f60ad46643551 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -65,11 +65,11 @@ left: 24px; width: 345px; - height: 40px; + height: 40px; - box-sizing: border-box; + box-sizing: border-box; - border: 2px solid #cbced1; + border: 2px solid #cbced1; background: #ffffff; @@ -78,57 +78,57 @@ .inner-addon .glyphicon { position: absolute; - bottom: 0.5%; + bottom: 0.5%; color: #2f343d; padding: 10px; - pointer-events: none; + pointer-events: none; } .searchresults { - margin-top: 7%; + margin-top: 7%; } .search-li { display: block; - padding-bottom: 3%; + padding-bottom: 3%; position: relative; - height: 65px; + height: 65px; background-color: #ffffff; } .search-li :hover { - cursor: default; + cursor: default; } .closed-div { position: relative; - top: 20px; + top: 20px; } .closed-div-p { - background: #f5455c; + background: #f5455c; border-radius: 2px; width: 100%; text-align: center; line-height: 0.15em; font-size: 10px; - margin: 10px 0 15px; + margin: 10px 0 15px; } .closed-div-p span { width: 101px; height: 12px; - right: 138px; + right: 138px; top: 3px; font-family: Inter; font-style: normal; @@ -142,25 +142,25 @@ } .closed-h1 h1 { - color: #6c727a !important; + color: #6c727a !important; - font-size: 14px !important; - font-weight: 600px !important; + font-size: 14px !important; + font-weight: 600px !important; - line-height: 20px !important; + line-height: 20px !important; font-style: italic !important; - text-transform: none !important; + text-transform: none !important; } .closed-p p { color: #9ea2a8 !important; font-weight: 500 !important; - font-style: italic !important; + font-style: italic !important; - top: 25px !important; + top: 25px !important; } .belldiv { @@ -175,9 +175,8 @@ .belldiv i { position: relative; - top: 15.79%; - left: 22.31%; - + top: 15.79%; + left: 22.31%; } .history-main { @@ -185,11 +184,11 @@ position: relative; width: 100%; - height: 68px; - - left: 2px; + height: 68px; - background: #ffffff; + left: 2px; + + background: #ffffff; } .history-img img { @@ -197,15 +196,16 @@ width: 36px; height: 36px; - top: 12px; + + top: 12px; left: 24px; } .history-detail-main { - display: inline-block; + display: inline-block; position: relative; - left: 68px; - top: 8px; + left: 68px; + top: 8px; } @@ -338,6 +338,7 @@ padding-bottom: 5%; cursor: pointer; width: 390px; + background-color: #ffffff; } diff --git a/package.json b/package.json index e8981c0ff6ec7..84992469d2da8 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "@rocket.chat/ui-kit": "^0.7.1", "@slack/client": "^4.8.0", "adm-zip": "RocketChat/adm-zip", - "apn": "^2.2.0", + "apn": "2.2.0", "archiver": "^3.0.0", "arraybuffer-to-string": "^1.0.2", "atlassian-crowd": "^0.5.0", @@ -205,7 +205,7 @@ "moment-timezone": "^0.5.27", "mongodb": "^3.5.6", "node-dogstatsd": "^0.0.7", - "node-gcm": "^0.14.4", + "node-gcm": "0.14.4", "node-rsa": "^1.0.5", "object-path": "^0.11.4", "pdfjs-dist": "^2.0.943", From 2996e428f9a18411607b7e0ba30bb6dfde1cdf81 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Fri, 1 May 2020 23:16:58 +0530 Subject: [PATCH 11/35] changes made on 1may --- .../views/app/tabbar/chatRoomHistoryItem.html | 12 +++--- .../views/app/tabbar/chatRoomHistoryItem.js | 27 +++++++++++- .../views/app/tabbar/chatRoomSearchItem.js | 14 ++++++- .../views/app/tabbar/customerChatHistory.html | 8 ++-- .../views/app/tabbar/customerChatHistory.js | 7 ---- .../tabbar/customerChatHistoryMessages.html | 42 +------------------ .../app/tabbar/customerChatHistoryMessages.js | 7 +--- .../customerChatHistoryMessagesItem.html | 41 ++++++++++++++++++ .../tabbar/customerChatHistoryMessagesItem.js | 18 ++++++++ app/livechat/client/views/regular.js | 1 + app/livechat/imports/server/rest/visitors.js | 1 - app/livechat/server/api/lib/visitors.js | 17 +++----- app/models/server/raw/LivechatRooms.js | 10 +++++ packages/rocketchat-i18n/i18n/en.i18n.json | 1 + 14 files changed, 125 insertions(+), 81 deletions(-) create mode 100644 app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html create mode 100644 app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js diff --git a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html index 54e37f407ed40..10e07b85ac99e 100644 --- a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html +++ b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html @@ -7,19 +7,17 @@

    {{responseBy.username}}

    - {{#if open}} -

    Open

    - {{else}} -

    Close at time {{time}}

    - {{/if}} +

    Close at time {{closedAt}}

    -

    {{room.msgs}} messages

    +

    {{msgs}} messages

    + {{#if hasClosingRoomMessage }}

    Agent comment:

    -

    "{{lastMessage.msg}}"

    +

    "{{closingRoomMessage}}"

    + {{/if}}
diff --git a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js index 6defc12ae0434..b550d37ffb081 100644 --- a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js +++ b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js @@ -1,8 +1,31 @@ import moment from 'moment'; import './chatRoomHistoryItem.html'; import { Template } from 'meteor/templating'; +import { ReactiveVar } from 'meteor/reactive-var'; + +Template.chatRoomHistoryItem.helpers({ + closedAt() { + const { closedAt } = Template.instance().room.get(); + return moment(closedAt).format('LT'); + }, + hasClosingRoomMessage() { + const { lastMessage } = Template.instance().room.get(); + if (lastMessage.t === 'livechat-close') { + Template.instance().closingRoomMessage.set(lastMessage); + return true; + } + return false; + }, + closingRoomMessage() { + const closingObj = Template.instance().closingRoomMessage.get(); + return closingObj.msg; + }, +}); Template.chatRoomHistoryItem.onCreated(function() { - const currentData = Template.currentData(); - currentData.time = moment(currentData.ts).format('LT'); + this.room = new ReactiveVar(); + this.closingRoomMessage = new ReactiveVar(); + this.autorun(() => { + this.room.set(Template.currentData()); + }); }); diff --git a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js index 78440462b795a..5ab611443a996 100644 --- a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js +++ b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js @@ -1,8 +1,18 @@ import moment from 'moment'; import './chatRoomSearchItem.html'; import { Template } from 'meteor/templating'; +import { ReactiveVar } from 'meteor/reactive-var'; + +Template.chatRoomSearchItem.helpers({ + time() { + const { ts } = Template.instance().room.get(); + return moment(ts).format('LT'); + }, +}); Template.chatRoomSearchItem.onCreated(function() { - const currentData = Template.currentData(); - currentData.time = moment(currentData.ts).format('LT'); + this.room = new ReactiveVar(); + this.autorun(() => { + this.room.set(Template.currentData()); + }); }); diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html index 00f54acb08f4c..eda3133c347eb 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -13,11 +13,11 @@
    {{#if isSearching}} {{#if isfound }} - {{#each chat in searchResults}} - {{> chatRoomSearchItem chat}} + {{#each room in searchResults}} + {{> chatRoomSearchItem room}} {{/each}} {{else}} -

    No result found

    +

    {{_ "No_results_found"}}

    {{/if}} {{else}} {{#each room in previousChats}} @@ -32,7 +32,7 @@

    No result found

    {{/if}} {{/if}} {{else}} -

    No Previous Chats found

    +

    {{_ "No_Previous_Chats_Found"}}

    {{/if}}
diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.js b/app/livechat/client/views/app/tabbar/customerChatHistory.js index bdc4a97de7e89..0e48e97af680b 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.js @@ -12,30 +12,24 @@ const ITEMS_COUNT = 50; Template.customerChatHistory.helpers({ hasChatHistory() { - // will return if user has any chatHistory or not return Template.instance().hasHistory.get(); }, isSearching() { return Template.instance().isSearching.get(); }, isAllChat() { - // will return is have to load all chat return Template.instance().isAllChat.get(); }, isChatClicked() { - // will return that if you have clicked in a single chatHistory return Template.instance().isChatClicked.get(); }, isfound() { - // will return if find any search result return Template.instance().isFound.get(); }, searchResults() { - // will return search result return Template.instance().searchResult.get(); }, previousChats() { - // will return pervious chats list return Template.instance().history.get(); }, clickRid() { @@ -58,7 +52,6 @@ const DEBOUNCE_TIME_FOR_SEARCH_DEPARTMENTS_IN_MS = 300; Template.customerChatHistory.onCreated(function() { const currentData = Template.currentData(); this.rid = new ReactiveVar(currentData.rid); - this.filter = new ReactiveVar(''); this.isKeyUp = new ReactiveVar(false); this.hasHistory = new ReactiveVar(false); this.isFound = new ReactiveVar(); diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html index dbce97ec1e655..1921b0aa2ed0e 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html @@ -9,46 +9,8 @@

{{historyResult.length}} messages

    - {{#each historyResult}} - {{#unless t}} -
  • -
    -
    - -
    -
    -
    -

    {{u.name}}

    -

    {{time}}

    -
    -
    -

    {{msg}}

    -
    -
    -
    -
  • - {{else}} - {{#if u.name}} -
    -

    Conversation closed

    -
    -
    -
    - -
    -
    -
    -
    -

    Agent comment:

    -
    -
    -

    "{{msg}}".

    -
    -
    -
    -
    - {{/if}} - {{/unless}} + {{#each room in historyResult}} + {{>customerChatHistoryMessagesItem room}} {{/each}}
diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js index 7b88c87682676..cca6db21c05b5 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -7,7 +7,6 @@ import { APIClient } from '../../../../../utils/client'; Template.customerChatHistoryMessages.helpers({ historyResult() { - // will return all the messages in history room return Template.instance().historyResult.get(); }, }); @@ -23,11 +22,7 @@ Template.customerChatHistoryMessages.onCreated(function() { const { messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${ token }`); // will return pervious chats list this.history.set(messages); - const allMessages = []; - for (let j = messages.length - 2; j >= 1; j--) { - messages[j].time = moment(messages[j].ts).format('LT'); - allMessages.push(messages[j]); - } + const allMessages = this.history.get().reverse(); const header = document.getElementsByClassName('contextual-bar__header-title'); if (allMessages.length !== 0) { const len = allMessages.length - 1; diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html new file mode 100644 index 0000000000000..c6bae2ce7bd3a --- /dev/null +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js new file mode 100644 index 0000000000000..bd1e21155344e --- /dev/null +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js @@ -0,0 +1,18 @@ +import moment from 'moment'; +import './customerChatHistoryMessagesItem.html'; +import { Template } from 'meteor/templating'; +import { ReactiveVar } from 'meteor/reactive-var'; + +Template.customerChatHistoryMessagesItem.helpers({ + time() { + const { closedAt } = Template.instance().room.get(); + return moment(closedAt).format('LT'); + }, +}); + +Template.customerChatHistoryMessagesItem.onCreated(function() { + this.room = new ReactiveVar(); + this.autorun(() => { + this.room.set(Template.currentData()); + }); +}); diff --git a/app/livechat/client/views/regular.js b/app/livechat/client/views/regular.js index f817b74e86808..90d49bc90bb6f 100644 --- a/app/livechat/client/views/regular.js +++ b/app/livechat/client/views/regular.js @@ -12,5 +12,6 @@ import './app/tabbar/customerChatHistory'; import './app/tabbar/customerChatHistoryMessages'; import './app/tabbar/chatRoomHistoryItem'; import './app/tabbar/chatRoomSearchItem'; +import './app/tabbar/customerChatHistoryMessagesItem'; import './app/tabbar/visitorInfo'; import './app/tabbar/visitorNavigation'; diff --git a/app/livechat/imports/server/rest/visitors.js b/app/livechat/imports/server/rest/visitors.js index 15d3760defa11..e1507c3018ec2 100644 --- a/app/livechat/imports/server/rest/visitors.js +++ b/app/livechat/imports/server/rest/visitors.js @@ -3,7 +3,6 @@ import { check } from 'meteor/check'; import { API } from '../../../../api'; import { findVisitorInfo, findVisitedPages, findChatHistory } from '../../../server/api/lib/visitors'; -import { normalizeMessagesForUser } from '/app/utils/server/lib/normalizeMessagesForUser'; API.v1.addRoute('livechat/visitors.info', { authRequired: true }, { get() { diff --git a/app/livechat/server/api/lib/visitors.js b/app/livechat/server/api/lib/visitors.js index aa5b08e043029..67da095288951 100644 --- a/app/livechat/server/api/lib/visitors.js +++ b/app/livechat/server/api/lib/visitors.js @@ -57,36 +57,29 @@ export async function findChatHistory({ userId, roomId, visitorId, text, closedC throw new Error('error-not-allowed'); } - const cursor = LivechatRooms.findByVisitorId(visitorId, { + const options = { sort: sort || { ts: -1 }, skip: offset, limit: count, - }); + }; + const cursor = closedChatsOnly ? LivechatRooms.findClosedByVisitorId(visitorId, options) : LivechatRooms.findByVisitorId(visitorId,options); const total = await cursor.count(); const history = await cursor.toArray(); - const resultArray = []; if (text !== undefined) { Meteor.runAsUser(userId, () => { - history.map(function(val) { + history.map((val) => { const roomId = val._id; const count = 1; const result = Meteor.call('messageSearch', text, roomId, count).message.docs; if (result.length > 0) { - result.map(function(e) { + result.map((e) => { resultArray.push(e); }); } }); }); } - if (closedChatsOnly) { - history.map(function(e, index) { - if (e.open) { - history.splice(index, 1); - } - }); - } return { history, count: history.length, diff --git a/app/models/server/raw/LivechatRooms.js b/app/models/server/raw/LivechatRooms.js index e996eac6e3681..2f93a8e100843 100644 --- a/app/models/server/raw/LivechatRooms.js +++ b/app/models/server/raw/LivechatRooms.js @@ -834,7 +834,17 @@ export class LivechatRoomsRaw extends BaseRaw { t: 'l', 'v._id': visitorId, }; + return this.find(query, options); + } + findClosedByVisitorId(visitorId, options) { + const query = { + t: 'l', + 'v._id': visitorId, + closedAt: { + $exists: true, + }, + }; return this.find(query, options); } diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 4700368768f30..90f449ac24bf2 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2486,6 +2486,7 @@ "No_messages_yet": "No messages yet", "No_pages_yet_Try_hitting_Reload_Pages_button": "No pages yet. Try hitting \"Reload Pages\" button.", "No_pinned_messages": "No pinned messages", + "No_Previous_Chats_Found": "No Previous Chats Found", "No_results_found": "No results found", "No_results_found_for": "No results found for:", "No_snippet_messages": "No snippet", From 63ee3757c07c8b4f81feda0559eb45ab5dc2c7e9 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 15:40:58 +0530 Subject: [PATCH 12/35] changes made on 6th may --- app/lib/server/functions/index.js | 1 + .../server/functions/loadClosingMessage.js | 34 ++ .../views/app/tabbar/chatRoomHistoryItem.js | 31 -- .../views/app/tabbar/chatRoomSearchItem.html | 18 - .../views/app/tabbar/chatRoomSearchItem.js | 18 - .../views/app/tabbar/customerChatHistory.html | 22 +- .../views/app/tabbar/customerChatHistory.js | 70 ++- .../tabbar/customerChatHistoryMessages.html | 24 +- .../app/tabbar/customerChatHistoryMessages.js | 49 +- .../customerChatHistoryMessagesItem.html | 2 +- .../tabbar/customerChatHistoryMessagesItem.js | 8 + ....html => customerChatRoomHistoryItem.html} | 2 +- .../app/tabbar/customerChatRoomHistoryItem.js | 36 ++ app/livechat/client/views/regular.js | 3 +- app/livechat/server/api/lib/visitors.js | 3 + app/livechat/server/api/v1/message.js | 40 +- app/models/server/models/Messages.js | 15 + app/models/server/models/Rooms.js | 2 - app/theme/client/index.js | 1 + app/theme/client/livechat.css | 399 ++++++++++++++++ app/theme/client/main.css | 425 ------------------ 21 files changed, 649 insertions(+), 554 deletions(-) create mode 100644 app/lib/server/functions/loadClosingMessage.js delete mode 100644 app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js delete mode 100644 app/livechat/client/views/app/tabbar/chatRoomSearchItem.html delete mode 100644 app/livechat/client/views/app/tabbar/chatRoomSearchItem.js rename app/livechat/client/views/app/tabbar/{chatRoomHistoryItem.html => customerChatRoomHistoryItem.html} (94%) create mode 100644 app/livechat/client/views/app/tabbar/customerChatRoomHistoryItem.js create mode 100644 app/theme/client/livechat.css diff --git a/app/lib/server/functions/index.js b/app/lib/server/functions/index.js index 7685736716489..85f55376d3fbc 100644 --- a/app/lib/server/functions/index.js +++ b/app/lib/server/functions/index.js @@ -16,6 +16,7 @@ export { generateUsernameSuggestion } from './getUsernameSuggestion'; export { insertMessage } from './insertMessage'; export { isTheLastMessage } from './isTheLastMessage'; export { loadMessageHistory } from './loadMessageHistory'; +export { loadClosingMessage } from './loadClosingMessage'; export { processWebhookMessage } from './processWebhookMessage'; export { removeUserFromRoom } from './removeUserFromRoom'; export { saveCustomFields } from './saveCustomFields'; diff --git a/app/lib/server/functions/loadClosingMessage.js b/app/lib/server/functions/loadClosingMessage.js new file mode 100644 index 0000000000000..3d89aa28806f4 --- /dev/null +++ b/app/lib/server/functions/loadClosingMessage.js @@ -0,0 +1,34 @@ +import { settings } from '../../../settings'; +import { Messages, Rooms } from '../../../models'; +import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser'; + +const hideMessagesOfTypeServer = new Set(); + +settings.get('Hide_System_Messages', function(key, values) { + const hiddenTypes = values.reduce((array, value) => [...array, ...value === 'mute_unmute' ? ['user-muted', 'user-unmuted'] : [value]], []); + hideMessagesOfTypeServer.clear(); + hiddenTypes.forEach((item) => hideMessagesOfTypeServer.add(item)); +}); + +export const loadClosingMessage = function loadClosingMessage({ userId, rid, limit = 20 }) { + const room = Rooms.findOne(rid, { fields: { sysMes: 1 } }); + const hiddenMessageTypes = Array.isArray(room && room.sysMes) ? room.sysMes : Array.from(hideMessagesOfTypeServer.values()); // TODO probably remove on chained event system + const options = { + sort: { + ts: -1, + }, + limit, + }; + + if (!settings.get('Message_ShowEditedStatus')) { + options.fields = { + editedAt: 0, + }; + } + + const records = Messages.findVisibleByRoomIdWithClosingMessages(rid, hiddenMessageTypes, options).fetch(); + const messages = normalizeMessagesForUser(records, userId); + return { + messages, + }; +}; diff --git a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js b/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js deleted file mode 100644 index b550d37ffb081..0000000000000 --- a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.js +++ /dev/null @@ -1,31 +0,0 @@ -import moment from 'moment'; -import './chatRoomHistoryItem.html'; -import { Template } from 'meteor/templating'; -import { ReactiveVar } from 'meteor/reactive-var'; - -Template.chatRoomHistoryItem.helpers({ - closedAt() { - const { closedAt } = Template.instance().room.get(); - return moment(closedAt).format('LT'); - }, - hasClosingRoomMessage() { - const { lastMessage } = Template.instance().room.get(); - if (lastMessage.t === 'livechat-close') { - Template.instance().closingRoomMessage.set(lastMessage); - return true; - } - return false; - }, - closingRoomMessage() { - const closingObj = Template.instance().closingRoomMessage.get(); - return closingObj.msg; - }, -}); - -Template.chatRoomHistoryItem.onCreated(function() { - this.room = new ReactiveVar(); - this.closingRoomMessage = new ReactiveVar(); - this.autorun(() => { - this.room.set(Template.currentData()); - }); -}); diff --git a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.html b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.html deleted file mode 100644 index a9a1f9abcccb8..0000000000000 --- a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.html +++ /dev/null @@ -1,18 +0,0 @@ - \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js b/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js deleted file mode 100644 index 5ab611443a996..0000000000000 --- a/app/livechat/client/views/app/tabbar/chatRoomSearchItem.js +++ /dev/null @@ -1,18 +0,0 @@ -import moment from 'moment'; -import './chatRoomSearchItem.html'; -import { Template } from 'meteor/templating'; -import { ReactiveVar } from 'meteor/reactive-var'; - -Template.chatRoomSearchItem.helpers({ - time() { - const { ts } = Template.instance().room.get(); - return moment(ts).format('LT'); - }, -}); - -Template.chatRoomSearchItem.onCreated(function() { - this.room = new ReactiveVar(); - this.autorun(() => { - this.room.set(Template.currentData()); - }); -}); diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html index eda3133c347eb..2789ce44c4ebd 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js index cca6db21c05b5..cc7f7d5ea0cb7 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -9,30 +9,45 @@ Template.customerChatHistoryMessages.helpers({ historyResult() { return Template.instance().historyResult.get(); }, + isSearchResults() { + return Template.instance().isSearchResults.get(); + }, + searchResult() { + return Template.instance().searchResult.get(); + }, }); Template.customerChatHistoryMessages.onCreated(function() { const currentData = Template.currentData(); this.historyResult = new ReactiveVar([]); this.history = new ReactiveVar([]); + this.isSearchResults = new ReactiveVar(false); + this.searchResult = new ReactiveVar([]); const id = currentData.clickRid; const token = currentData.clickToken; let closingDay; let agentName; - this.autorun(async () => { - const { messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${ token }`); - // will return pervious chats list - this.history.set(messages); - const allMessages = this.history.get().reverse(); - const header = document.getElementsByClassName('contextual-bar__header-title'); - if (allMessages.length !== 0) { - const len = allMessages.length - 1; - agentName = allMessages[len].u.username; - closingDay = moment(allMessages[len].ts).format('dddd'); - } - if (header[0]) { - header[0].innerText = `${ agentName }, closed at ${ closingDay }`; - header[0].className = 'Contextualheading'; - } - this.historyResult.set(allMessages); - }); + if (id || token) { + this.autorun(async () => { + const { messages } = await APIClient.v1.get(`livechat/messages.history/${ id }?token=${ token }`); + // will return pervious chats list + this.history.set(messages); + const allMessages = this.history.get().reverse(); + const header = document.getElementsByClassName('contextual-bar__header-title'); + if (allMessages.length !== 0) { + const len = allMessages.length - 1; + agentName = allMessages[len].u.username; + closingDay = moment(allMessages[len].ts).format('dddd'); + } + if (header[0]) { + header[0].innerText = `${ agentName }, closed at ${ closingDay }`; + header[0].className = 'Contextualheading'; + } + this.historyResult.set(allMessages); + }); + } else { + this.isSearchResults.set(true); + const array = []; + array.push(currentData); + this.searchResult.set(array); + } }); diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html index c6bae2ce7bd3a..de0ff1a838e9f 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html @@ -17,7 +17,7 @@

{{u.name}}

{{else}} - {{#if u.name}} + {{#if hasClosingMessage}}

Conversation closed

diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js index bd1e21155344e..dfd5d91118456 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.js @@ -8,11 +8,19 @@ Template.customerChatHistoryMessagesItem.helpers({ const { closedAt } = Template.instance().room.get(); return moment(closedAt).format('LT'); }, + hasClosingMessage() { + return Template.instance().hasClosingMessage.get(); + }, }); Template.customerChatHistoryMessagesItem.onCreated(function() { this.room = new ReactiveVar(); + this.hasClosingMessage = new ReactiveVar(false); + const currentData = Template.currentData(); this.autorun(() => { this.room.set(Template.currentData()); + if (currentData.t === 'livechat-close') { + this.hasClosingMessage.set(true); + } }); }); diff --git a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html b/app/livechat/client/views/app/tabbar/customerChatRoomHistoryItem.html similarity index 94% rename from app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html rename to app/livechat/client/views/app/tabbar/customerChatRoomHistoryItem.html index 10e07b85ac99e..8490a0eda0d11 100644 --- a/app/livechat/client/views/app/tabbar/chatRoomHistoryItem.html +++ b/app/livechat/client/views/app/tabbar/customerChatRoomHistoryItem.html @@ -7,7 +7,7 @@

{{responseBy.username}}

-

Close at time {{closedAt}}

+

Close at {{closedAt}}

{{msgs}} messages

diff --git a/app/livechat/client/views/app/tabbar/customerChatRoomHistoryItem.js b/app/livechat/client/views/app/tabbar/customerChatRoomHistoryItem.js new file mode 100644 index 0000000000000..bf2299f2a3637 --- /dev/null +++ b/app/livechat/client/views/app/tabbar/customerChatRoomHistoryItem.js @@ -0,0 +1,36 @@ +import moment from 'moment'; +import './customerChatRoomHistoryItem.html'; +import { Template } from 'meteor/templating'; +import { ReactiveVar } from 'meteor/reactive-var'; + +import { APIClient } from '../../../../../utils/client'; + +Template.chatRoomHistoryItem.helpers({ + closedAt() { + const { closedAt } = Template.instance().room.get(); + return moment(closedAt).format('LT'); + }, + hasClosingRoomMessage() { + return Template.instance().hasClosingRoomMessage.get(); + }, + closingRoomMessage() { + const closingObj = Template.instance().closingRoomMessage.get(); + return closingObj.msg; + }, +}); + +Template.chatRoomHistoryItem.onCreated(function() { + this.room = new ReactiveVar(); + this.hasClosingRoomMessage = new ReactiveVar(false); + this.closingRoomMessage = new ReactiveVar(); + this.autorun(async () => { + const currentData = Template.currentData(); + this.room.set(currentData); + const { token } = currentData.v; + const { messages } = await APIClient.v1.get(`livechat/messages.closingMessage/${ currentData._id }?token=${ token }`); + if (messages.length > 0) { + this.closingRoomMessage.set(messages[0]); + this.hasClosingRoomMessage.set(true); + } + }); +}); diff --git a/app/livechat/client/views/regular.js b/app/livechat/client/views/regular.js index 90d49bc90bb6f..827f0956a51bf 100644 --- a/app/livechat/client/views/regular.js +++ b/app/livechat/client/views/regular.js @@ -10,8 +10,7 @@ import './app/tabbar/visitorEdit'; import './app/tabbar/visitorForward'; import './app/tabbar/customerChatHistory'; import './app/tabbar/customerChatHistoryMessages'; -import './app/tabbar/chatRoomHistoryItem'; -import './app/tabbar/chatRoomSearchItem'; +import './app/tabbar/customerChatRoomHistoryItem'; import './app/tabbar/customerChatHistoryMessagesItem'; import './app/tabbar/visitorInfo'; import './app/tabbar/visitorNavigation'; diff --git a/app/livechat/server/api/lib/visitors.js b/app/livechat/server/api/lib/visitors.js index 67da095288951..7ba8d486e3209 100644 --- a/app/livechat/server/api/lib/visitors.js +++ b/app/livechat/server/api/lib/visitors.js @@ -66,6 +66,7 @@ export async function findChatHistory({ userId, roomId, visitorId, text, closedC const total = await cursor.count(); const history = await cursor.toArray(); const resultArray = []; + const searchResultRooms = []; if (text !== undefined) { Meteor.runAsUser(userId, () => { history.map((val) => { @@ -76,6 +77,7 @@ export async function findChatHistory({ userId, roomId, visitorId, text, closedC result.map((e) => { resultArray.push(e); }); + searchResultRooms.push(val); } }); }); @@ -86,5 +88,6 @@ export async function findChatHistory({ userId, roomId, visitorId, text, closedC offset, total, resultArray, + searchResultRooms, }; } diff --git a/app/livechat/server/api/v1/message.js b/app/livechat/server/api/v1/message.js index e2362baf6d32e..254bf488875b3 100644 --- a/app/livechat/server/api/v1/message.js +++ b/app/livechat/server/api/v1/message.js @@ -5,7 +5,7 @@ import { Random } from 'meteor/random'; import { Messages, LivechatRooms, LivechatVisitors } from '../../../../models'; import { hasPermission } from '../../../../authorization'; import { API } from '../../../../api'; -import { loadMessageHistory } from '../../../../lib'; +import { loadMessageHistory, loadClosingMessage } from '../../../../lib'; import { findGuest, findRoom, normalizeHttpHeaderData } from '../lib/livechat'; import { Livechat } from '../../lib/Livechat'; import { normalizeMessageFileUpload } from '../../../../utils/server/functions/normalizeMessageFileUpload'; @@ -246,6 +246,44 @@ API.v1.addRoute('livechat/messages.history/:rid', { }, }); +API.v1.addRoute('livechat/messages.closingMessage/:rid', { + get() { + try { + check(this.urlParams, { + rid: String, + }); + + const { rid } = this.urlParams; + const { token } = this.queryParams; + if (!token) { + throw new Meteor.Error('error-token-param-not-provided', 'The required "token" query param is missing.'); + } + + const guest = findGuest(token); + if (!guest) { + throw new Meteor.Error('invalid-token'); + } + + const room = findRoom(token, rid); + if (!room) { + throw new Meteor.Error('invalid-room'); + } + + let limit = 20; + if (this.queryParams.limit) { + limit = parseInt(this.queryParams.limit); + } + const messages = loadClosingMessage({ userId: guest._id, rid, limit }) + .messages + .map(normalizeMessageFileUpload); + return API.v1.success({ messages }); + } catch (e) { + return API.v1.failure(e); + } + }, +}); + + API.v1.addRoute('livechat/messages', { authRequired: true }, { post() { if (!hasPermission(this.userId, 'view-livechat-manager')) { diff --git a/app/models/server/models/Messages.js b/app/models/server/models/Messages.js index ca29fe391eaa3..e3cd35f875564 100644 --- a/app/models/server/models/Messages.js +++ b/app/models/server/models/Messages.js @@ -251,7 +251,22 @@ export class Messages extends Base { _hidden: { $ne: true, }, + rid: roomId, + }; + if (Match.test(types, [String]) && (types.length > 0)) { + query.t = { $nin: types }; + } + + return this.find(query, options); + } + + findVisibleByRoomIdWithClosingMessages(roomId, types, options) { + const query = { + _hidden: { + $ne: true, + }, + t: 'livechat-close', rid: roomId, }; diff --git a/app/models/server/models/Rooms.js b/app/models/server/models/Rooms.js index 0492a899c9cec..2dbde015415aa 100644 --- a/app/models/server/models/Rooms.js +++ b/app/models/server/models/Rooms.js @@ -34,11 +34,9 @@ export class Rooms extends Base { name: _idOrName, }], }; - return this.findOne(query, options); } - setJitsiTimeout(_id, time) { const query = { _id, diff --git a/app/theme/client/index.js b/app/theme/client/index.js index 2dc7ee1fe082c..220f786f0bb69 100644 --- a/app/theme/client/index.js +++ b/app/theme/client/index.js @@ -2,3 +2,4 @@ import './main.css'; import './vendor/photoswipe.css'; import './vendor/fontello/css/fontello.css'; import './rocketchat.font.css'; +import './livechat.css'; diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css new file mode 100644 index 0000000000000..6836e4e186671 --- /dev/null +++ b/app/theme/client/livechat.css @@ -0,0 +1,399 @@ +/* customerChat History CSS */ +.inner-addon { + position: relative; + left: 24px; + width: 345px; + height: 40px; + box-sizing: border-box; + border: 2px solid #cbced1; + background: #ffffff; + border-radius: 2px; +} + +.inner-addon .glyphicon { + position: absolute; + bottom: 0.5%; + color: #2f343d; + padding: 10px; + pointer-events: none; +} + +.searchresults { + margin-top: 7%; +} + +.search-li { + display: block; + padding-bottom: 3%; + position: relative; + height: 65px; + background-color: #ffffff; +} + +.search-li :hover { + cursor: default; +} + +.closed-div { + position: relative; + top: 20px; +} + +.closed-div-p { + background: #f5455c; + border-radius: 2px; + width: 100%; + text-align: center; + line-height: 0.15em; + font-size: 10px; + margin: 10px 0 15px; +} + +.closed-div-p span { + width: 101px; + height: 12px; + right: 138px; + top: 3px; + font-family: Inter; + font-style: normal; + font-weight: 600; + text-align: center; + color: #f5455c; + background: white; + padding-left: 8px; + padding-right: 8px; +} + +.closed-h1 h1 { + color: #6c727a !important; + font-size: 14px !important; + font-weight: 600px !important; + line-height: 20px !important; + font-style: italic !important; + text-transform: none !important; +} + +.closed-p p { + color: #9ea2a8 !important; + font-weight: 500 !important; + font-style: italic !important; + top: 25px !important; +} + +.belldiv { + position: absolute; + width: 36px; + height: 36px; + top: 12px; + left: 24px; + background: #e4e7ea; +} + +.belldiv i { + position: relative; + top: 15.79%; + left: 22.31%; +} + +.history-main { + display: flex; + position: relative; + width: 100%; + height: 68px; + left: 2px; + background: #ffffff; +} + +.history-img img { + position: absolute; + width: 36px; + height: 36px; + top: 12px; + left: 24px; +} + +.history-detail-main { + display: inline-block; + position: relative; + left: 68px; + top: 8px; +} + +.detail-main-upper { + display: flex; +} + +.detail-main-upper h1 { + position: static; + height: 22px; + left: 0px; + top: 0px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 16px; + line-height: 22px; + text-transform: lowercase; + color: #2f343d; + flex: none; + order: 0; + align-self: center; + margin: 4px 0px; + margin-right: 4px; +} + +.detail-main-upper p { + position: static; + height: 16px; + top: 6px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; + flex: none; + order: 1; + align-self: flex-end; + margin: 4px 0px; +} + +.detail-main-lower p { + position: absolute; + width: 625px; + height: 20px; + top: 29px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 20px; + color: #2f343d; +} + +.chatHistory { + position: relative; + left: 24px; + width: 345px; + top: 27px; +} + +.chatHistory ul li { + display: block; +} + +.msgcount p { + background: #cbced1; + border-radius: 2px; + width: 100%; + text-align: center; + line-height: 0.15em; + font-size: 10px; + margin: 10px 0 20px; +} + +.msgcount p span { + width: 65px; + height: 12px; + right: 156px; + top: 3px; + font-family: Inter; + font-style: normal; + font-weight: 600; + text-align: center; + color: #6c727a; + background: white; + padding-left: 8px; + padding-right: 8px; +} + +.noresult { + font-weight: 700; + position: relative; + top: 30px; + left: 6%; +} + +#searchInput { + font-family: Inter; + font-style: normal; + font-weight: 500; + font-size: 14px; + line-height: 20px; + color: #9ea2a8; + position: absolute; + left: 16px; + right: 46px; + top: 10px; + bottom: 10px; + border: none; + width: 92%; +} + +.right-addon .glyphicon { + right: 0px; +} + +.right-addon input { + padding-right: 30px; +} + +.vistior-history-block { + margin-top: 10%; +} + +.vistior-history-block ul li { + border-bottom: 2px solid #f2f3f5; + display: block; + padding-bottom: 5%; + cursor: pointer; + width: 390px; + + background-color: #ffffff; +} + +.vistior-history-block ul a { + text-decoration: none; + color: black; +} + +#allist li:hover { + background-color: rgba(15,34,0,.05) !important; +} + +.history-div { + display: flex; +} + +.visitor-img { + display: contents; +} + +.visitor-img img { + position: relative; + width: 36px; + height: 36px; + left: 24px; + top: 16px; + border-radius: 1.75px; +} + +.visitor-history-details { + margin-left: 2%; +} + +.visitor-details { + display: -webkit-inline-box; +} + +.visitor-details h1 { + position: relative; + height: 22px; + left: 25px; + top: 16px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 16px; + line-height: 22px; + text-transform: lowercase; + color: #2f343d; +} + +#conten { + position: absolute; + left: 0px; + right: 0px; + padding-left: 0px !important; + padding-right: 0px !important; +} + +.visitor-details p { + position: relative; + height: 16px; + left: 29px; + top: 21px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; +} + +.total-messages { + font-size: 0.8rem; + color: grey; +} + +.total-messages p { + position: relative; + height: 16px; + left: 25px; + right: 84px; + top: 16px; + font-family: Inter; + font-style: normal; + font-weight: bold; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; +} + +.agent-comment { + margin-top: 3%; + font-size: 0.8rem; +} + +.comment-heading { + position: relative; + height: 16px; + left: 25px; + right: 84px; + top: 15px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 10px; + line-height: 12px; + color: #6c727a; +} + +.comment-text { + position: relative; + width: 268px; + left: 25px; + right: 24px; + top: 15px; + font-family: Inter; + font-style: italic; + font-weight: 500; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; +} + +.open { + padding-left: 4% !important; +} + +.loding { + text-align: center; + font-family: Inter; +} + +.Contextualheading { + position: absolute; + width: 249px; + height: 22px; + left: 57px; + top: 25px; + font-family: Inter; + font-style: normal; + font-weight: 500; + font-size: 16px; + line-height: 22px; + display: flex; + align-items: center; + color: #2f344d; +} \ No newline at end of file diff --git a/app/theme/client/main.css b/app/theme/client/main.css index f60ad46643551..a774c8e118831 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -59,428 +59,3 @@ /* RTL */ @import 'imports/general/rtl.css'; -/* customerChat History CSS */ -.inner-addon { - position: relative; - left: 24px; - - width: 345px; - height: 40px; - - box-sizing: border-box; - - border: 2px solid #cbced1; - - background: #ffffff; - - border-radius: 2px; -} - -.inner-addon .glyphicon { - position: absolute; - bottom: 0.5%; - - color: #2f343d; - - padding: 10px; - - pointer-events: none; - -} - -.searchresults { - margin-top: 7%; -} - -.search-li { - display: block; - - padding-bottom: 3%; - position: relative; - - height: 65px; - - background-color: #ffffff; -} - -.search-li :hover { - - cursor: default; -} - -.closed-div { - position: relative; - top: 20px; -} - -.closed-div-p { - background: #f5455c; - border-radius: 2px; - width: 100%; - text-align: center; - line-height: 0.15em; - font-size: 10px; - - margin: 10px 0 15px; -} - -.closed-div-p span { - width: 101px; - height: 12px; - - right: 138px; - top: 3px; - font-family: Inter; - font-style: normal; - font-weight: 600; - text-align: center; - - color: #f5455c; - background: white; - padding-left: 8px; - padding-right: 8px; -} - -.closed-h1 h1 { - color: #6c727a !important; - - font-size: 14px !important; - font-weight: 600px !important; - - line-height: 20px !important; - - font-style: italic !important; - - text-transform: none !important; -} - -.closed-p p { - color: #9ea2a8 !important; - font-weight: 500 !important; - - font-style: italic !important; - - top: 25px !important; -} - -.belldiv { - position: absolute; - width: 36px; - height: 36px; - top: 12px; - left: 24px; - - background: #e4e7ea; -} - -.belldiv i { - position: relative; - top: 15.79%; - left: 22.31%; -} - -.history-main { - display: flex; - position: relative; - - width: 100%; - height: 68px; - - left: 2px; - - background: #ffffff; -} - -.history-img img { - position: absolute; - - width: 36px; - height: 36px; - - top: 12px; - left: 24px; -} - -.history-detail-main { - display: inline-block; - position: relative; - left: 68px; - top: 8px; - -} - -.detail-main-upper { - display: flex; -} - -.detail-main-upper h1 { - position: static; - height: 22px; - left: 0px; - top: 0px; - font-family: Inter; - font-style: normal; - font-weight: 600; - font-size: 16px; - line-height: 22px; - text-transform: lowercase; - color: #2f343d; - flex: none; - order: 0; - align-self: center; - margin: 4px 0px; - margin-right: 4px; -} - -.detail-main-upper p { - position: static; - height: 16px; - top: 6px; - font-family: Inter; - font-style: normal; - font-weight: normal; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; - flex: none; - order: 1; - align-self: flex-end; - margin: 4px 0px; -} - -.detail-main-lower p { - position: absolute; - width: 625px; - height: 20px; - top: 29px; - font-family: Inter; - font-style: normal; - font-weight: normal; - font-size: 14px; - line-height: 20px; - color: #2f343d; -} - -.chatHistory { - position: relative; - left: 24px; - width: 345px; - top: 27px; -} - -.chatHistory ul li { - display: block; -} - -.msgcount p { - background: #cbced1; - border-radius: 2px; - width: 100%; - text-align: center; - line-height: 0.15em; - font-size: 10px; - margin: 10px 0 20px; -} - -.msgcount p span { - width: 65px; - height: 12px; - right: 156px; - top: 3px; - font-family: Inter; - font-style: normal; - font-weight: 600; - text-align: center; - color: #6c727a; - background: white; - padding-left: 8px; - padding-right: 8px; -} - -.noresult { - font-weight: 700; - position: relative; - top: 30px; - left: 6%; -} - -#searchInput { - font-family: Inter; - font-style: normal; - font-weight: 500; - font-size: 14px; - line-height: 20px; - color: #9ea2a8; - position: absolute; - left: 16px; - right: 46px; - top: 10px; - bottom: 10px; - border: none; - width: 92%; -} - -.right-addon .glyphicon { - right: 0px; -} - -.right-addon input { - padding-right: 30px; -} - -.vistior-history-block { - margin-top: 10%; -} - -.vistior-history-block ul li { - border-bottom: 2px solid #f2f3f5; - display: block; - padding-bottom: 5%; - cursor: pointer; - width: 390px; - - background-color: #ffffff; -} - -.vistior-history-block ul a { - text-decoration: none; - color: black; -} - -#allist li:hover { - background-color: rgba(15,34,0,.05) !important; -} - -.history-div { - display: flex; -} - -.visitor-img { - display: contents; -} - -.visitor-img img { - position: relative; - width: 36px; - height: 36px; - left: 24px; - top: 16px; - border-radius: 1.75px; -} - -.visitor-history-details { - margin-left: 2%; -} - -.visitor-details { - display: -webkit-inline-box; -} - -.visitor-details h1 { - position: relative; - height: 22px; - left: 25px; - top: 16px; - font-family: Inter; - font-style: normal; - font-weight: 600; - font-size: 16px; - line-height: 22px; - text-transform: lowercase; - color: #2f343d; -} - -.contextual-bar__content { - padding-left: 0px !important; - padding-right: 0px !important; -} - -.visitor-details p { - position: relative; - height: 16px; - left: 29px; - top: 21px; - font-family: Inter; - font-style: normal; - font-weight: normal; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; -} - -.total-messages { - font-size: 0.8rem; - color: grey; -} - -.total-messages p { - position: relative; - height: 16px; - left: 25px; - right: 84px; - top: 16px; - font-family: Inter; - font-style: normal; - font-weight: bold; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; -} - -.agent-comment { - margin-top: 3%; - font-size: 0.8rem; -} - -.comment-heading { - position: relative; - height: 16px; - left: 25px; - right: 84px; - top: 15px; - font-family: Inter; - font-style: normal; - font-weight: 600; - font-size: 10px; - line-height: 12px; - color: #6c727a; -} - -.comment-text { - position: relative; - width: 268px; - left: 25px; - right: 24px; - top: 15px; - font-family: Inter; - font-style: italic; - font-weight: 500; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; -} - -.open { - padding-left: 4% !important; -} - -.loding { - text-align: center; - font-family: Inter; -} - -.Contextualheading { - position: absolute; - width: 249px; - height: 22px; - left: 57px; - top: 25px; - font-family: Inter; - font-style: normal; - font-weight: 500; - font-size: 16px; - line-height: 22px; - display: flex; - align-items: center; - color: #2f344d; -} \ No newline at end of file From 1450021c2b3b075c349b3167017fda2c9a8949ea Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 15:45:49 +0530 Subject: [PATCH 13/35] css chang --- app/theme/client/livechat.css | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index 6836e4e186671..344422e29e622 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,13 +1,15 @@ /* customerChat History CSS */ .inner-addon { - position: relative; - left: 24px; - width: 345px; - height: 40px; - box-sizing: border-box; - border: 2px solid #cbced1; - background: #ffffff; - border-radius: 2px; + position: relative; + left: 24px; + + width: 345px; + box-sizing: border-box; + height: 40px; + + border: 2px solid #cbced1; + border-radius: 2px; + background: #ffffff; } .inner-addon .glyphicon { From 866130c1ec3af9de05607e18a02ed170d759e15b Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 15:47:39 +0530 Subject: [PATCH 14/35] css chang --- app/theme/client/livechat.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index 344422e29e622..a65ca86232dd1 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,12 +1,12 @@ /* customerChat History CSS */ .inner-addon { - position: relative; - left: 24px; - + position: relative; + left: 24px; + box-sizing: border-box; + width: 345px; - box-sizing: border-box; height: 40px; - + border: 2px solid #cbced1; border-radius: 2px; background: #ffffff; From ff89afcbcd81e1dde8e3ab030b9d49df159c2c19 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 15:48:53 +0530 Subject: [PATCH 15/35] css chang --- app/theme/client/livechat.css | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index a65ca86232dd1..258ab3f205bcb 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,9 +1,10 @@ /* customerChat History CSS */ .inner-addon { - position: relative; - left: 24px; - box-sizing: border-box; - + position: relative; + left: 24px; + + box-sizing: border-box; + width: 345px; height: 40px; From 74e51a61a6a86400f624f0d2706d43a8ac13db54 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 15:50:38 +0530 Subject: [PATCH 16/35] css chang --- app/theme/client/livechat.css | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index 258ab3f205bcb..a035df4bd614b 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,16 +1,16 @@ /* customerChat History CSS */ .inner-addon { - position: relative; - left: 24px; - - box-sizing: border-box; + position: relative; + left: 24px; - width: 345px; - height: 40px; + box-sizing: border-box; - border: 2px solid #cbced1; - border-radius: 2px; - background: #ffffff; + width: 345px; + height: 40px; + + border: 2px solid #cbced1; + border-radius: 2px; + background: #ffffff; } .inner-addon .glyphicon { From efee1207154a3243ebfd3b404d10e48c46feb937 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 15:52:12 +0530 Subject: [PATCH 17/35] css chang --- app/theme/client/livechat.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index a035df4bd614b..9777201c1a1d5 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,12 +1,12 @@ /* customerChat History CSS */ .inner-addon { - position: relative; - left: 24px; + position: relative; + left: 24px; - box-sizing: border-box; + box-sizing: border-box; - width: 345px; - height: 40px; + width: 345px; + height: 40px; border: 2px solid #cbced1; border-radius: 2px; From 3cf7fa962e11b642ce91de70d3ddd77c0300de4d Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 15:53:35 +0530 Subject: [PATCH 18/35] css chang --- app/theme/client/livechat.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index 9777201c1a1d5..30c709505049d 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,7 +1,7 @@ /* customerChat History CSS */ .inner-addon { - position: relative; - left: 24px; + position: relative; + left: 24px; box-sizing: border-box; From 845b7e9359a03d2948603a2775751a3bb7da9495 Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Wed, 6 May 2020 16:44:36 +0530 Subject: [PATCH 19/35] css chang --- app/theme/client/livechat.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index 30c709505049d..3afd6306b03e6 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,7 +1,6 @@ -/* customerChat History CSS */ .inner-addon { - position: relative; - left: 24px; + position: relative; + left: 24px; box-sizing: border-box; From 36e5ad7a20266a945a7f4453473985ec74796f3d Mon Sep 17 00:00:00 2001 From: nitinkumartiwari Date: Thu, 7 May 2020 12:07:58 +0530 Subject: [PATCH 20/35] changes made on 7th may --- app/theme/client/livechat.css | 11 ++++------- app/theme/client/main.css | 3 +-- package-lock.json | 8 ++++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index 3afd6306b03e6..86d22e15e7fdd 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,15 +1,12 @@ -.inner-addon { +.inner-addon { position: relative; left: 24px; - box-sizing: border-box; - width: 345px; height: 40px; - - border: 2px solid #cbced1; - border-radius: 2px; - background: #ffffff; + border: 2px solid #cbced1; + border-radius: 2px; + background: #ffffff; } .inner-addon .glyphicon { diff --git a/app/theme/client/main.css b/app/theme/client/main.css index a774c8e118831..8842415790c99 100644 --- a/app/theme/client/main.css +++ b/app/theme/client/main.css @@ -57,5 +57,4 @@ @import 'imports/components/userInfo.css'; /* RTL */ -@import 'imports/general/rtl.css'; - +@import 'imports/general/rtl.css'; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 44cad480c2c43..c56746ae21c63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2928,9 +2928,9 @@ } }, "@rocket.chat/apps-engine": { - "version": "1.14.0-beta.3119", - "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.14.0-beta.3119.tgz", - "integrity": "sha512-SoQicHOGkQD6wwcnMzc1qETbNoMwQ2ei5j5krzh0/dachCbHG+C1rBO8yYbK2TQwuSjxR0wLM20ZbM57iHaYKw==", + "version": "1.15.0-beta.3262", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.15.0-beta.3262.tgz", + "integrity": "sha512-Rh8aVd8L5d8RWf6i2nk+vUuTIz6rJLBux0Px8gdC+7uO8r5C7ZKxhs7TaeEqxPBAq05KLhor120sMjkIGN8xGA==", "requires": { "adm-zip": "^0.4.9", "cryptiles": "^4.1.3", @@ -2952,7 +2952,7 @@ "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" } } - }, + }, "@rocket.chat/css-in-js": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/@rocket.chat/css-in-js/-/css-in-js-0.7.1.tgz", From 587cd3d0d920ec25b8a7a784d226180c9a8a03b6 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Mon, 1 Jun 2020 15:08:46 -0300 Subject: [PATCH 21/35] Update visitors.js --- app/livechat/server/api/lib/visitors.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/livechat/server/api/lib/visitors.js b/app/livechat/server/api/lib/visitors.js index 3d4349fa59733..a1d48cfa0a817 100644 --- a/app/livechat/server/api/lib/visitors.js +++ b/app/livechat/server/api/lib/visitors.js @@ -62,19 +62,19 @@ export async function findChatHistory({ userId, roomId, visitorId, text, closedC skip: offset, limit: count, }; - const cursor = closedChatsOnly ? LivechatRooms.findClosedByVisitorId(visitorId, options) : LivechatRooms.findByVisitorId(visitorId,options); + const cursor = closedChatsOnly ? LivechatRooms.findClosedByVisitorId(visitorId, options) : LivechatRooms.findByVisitorId(visitorId, options); const total = await cursor.count(); const history = await cursor.toArray(); const resultArray = []; const searchResultRooms = []; if (text !== undefined) { Meteor.runAsUser(userId, () => { - history.map((val) => { + history.forEach((val) => { const roomId = val._id; const count = 1; const result = Meteor.call('messageSearch', text, roomId, count).message.docs; if (result.length > 0) { - result.map((e) => { + result.forEach((e) => { resultArray.push(e); }); searchResultRooms.push(val); From 048c1d4889d6f8282a503b4b59d73a6fe3007a74 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Mon, 1 Jun 2020 15:13:46 -0300 Subject: [PATCH 22/35] Fix indentations. --- app/theme/client/livechat.css | 516 +++++++++++++++++----------------- 1 file changed, 258 insertions(+), 258 deletions(-) diff --git a/app/theme/client/livechat.css b/app/theme/client/livechat.css index 86d22e15e7fdd..2955436cc131d 100644 --- a/app/theme/client/livechat.css +++ b/app/theme/client/livechat.css @@ -1,398 +1,398 @@ -.inner-addon { - position: relative; - left: 24px; - box-sizing: border-box; - width: 345px; - height: 40px; - border: 2px solid #cbced1; - border-radius: 2px; - background: #ffffff; +.inner-addon { + position: relative; + left: 24px; + box-sizing: border-box; + width: 345px; + height: 40px; + border: 2px solid #cbced1; + border-radius: 2px; + background: #ffffff; } .inner-addon .glyphicon { - position: absolute; - bottom: 0.5%; - color: #2f343d; - padding: 10px; - pointer-events: none; + position: absolute; + bottom: 0.5%; + color: #2f343d; + padding: 10px; + pointer-events: none; } .searchresults { - margin-top: 7%; + margin-top: 7%; } .search-li { - display: block; - padding-bottom: 3%; - position: relative; - height: 65px; - background-color: #ffffff; + display: block; + padding-bottom: 3%; + position: relative; + height: 65px; + background-color: #ffffff; } .search-li :hover { - cursor: default; + cursor: default; } .closed-div { - position: relative; - top: 20px; + position: relative; + top: 20px; } .closed-div-p { - background: #f5455c; - border-radius: 2px; - width: 100%; - text-align: center; - line-height: 0.15em; - font-size: 10px; - margin: 10px 0 15px; + background: #f5455c; + border-radius: 2px; + width: 100%; + text-align: center; + line-height: 0.15em; + font-size: 10px; + margin: 10px 0 15px; } .closed-div-p span { - width: 101px; - height: 12px; - right: 138px; - top: 3px; - font-family: Inter; - font-style: normal; - font-weight: 600; - text-align: center; - color: #f5455c; - background: white; - padding-left: 8px; - padding-right: 8px; + width: 101px; + height: 12px; + right: 138px; + top: 3px; + font-family: Inter; + font-style: normal; + font-weight: 600; + text-align: center; + color: #f5455c; + background: white; + padding-left: 8px; + padding-right: 8px; } .closed-h1 h1 { - color: #6c727a !important; - font-size: 14px !important; - font-weight: 600px !important; - line-height: 20px !important; - font-style: italic !important; - text-transform: none !important; + color: #6c727a !important; + font-size: 14px !important; + font-weight: 600px !important; + line-height: 20px !important; + font-style: italic !important; + text-transform: none !important; } .closed-p p { - color: #9ea2a8 !important; - font-weight: 500 !important; - font-style: italic !important; - top: 25px !important; + color: #9ea2a8 !important; + font-weight: 500 !important; + font-style: italic !important; + top: 25px !important; } .belldiv { - position: absolute; - width: 36px; - height: 36px; - top: 12px; - left: 24px; - background: #e4e7ea; + position: absolute; + width: 36px; + height: 36px; + top: 12px; + left: 24px; + background: #e4e7ea; } .belldiv i { - position: relative; - top: 15.79%; - left: 22.31%; + position: relative; + top: 15.79%; + left: 22.31%; } .history-main { - display: flex; - position: relative; - width: 100%; - height: 68px; - left: 2px; - background: #ffffff; + display: flex; + position: relative; + width: 100%; + height: 68px; + left: 2px; + background: #ffffff; } .history-img img { - position: absolute; - width: 36px; - height: 36px; - top: 12px; - left: 24px; + position: absolute; + width: 36px; + height: 36px; + top: 12px; + left: 24px; } .history-detail-main { - display: inline-block; - position: relative; - left: 68px; - top: 8px; + display: inline-block; + position: relative; + left: 68px; + top: 8px; } .detail-main-upper { - display: flex; + display: flex; } .detail-main-upper h1 { - position: static; - height: 22px; - left: 0px; - top: 0px; - font-family: Inter; - font-style: normal; - font-weight: 600; - font-size: 16px; - line-height: 22px; - text-transform: lowercase; - color: #2f343d; - flex: none; - order: 0; - align-self: center; - margin: 4px 0px; - margin-right: 4px; + position: static; + height: 22px; + left: 0px; + top: 0px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 16px; + line-height: 22px; + text-transform: lowercase; + color: #2f343d; + flex: none; + order: 0; + align-self: center; + margin: 4px 0px; + margin-right: 4px; } .detail-main-upper p { - position: static; - height: 16px; - top: 6px; - font-family: Inter; - font-style: normal; - font-weight: normal; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; - flex: none; - order: 1; - align-self: flex-end; - margin: 4px 0px; + position: static; + height: 16px; + top: 6px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; + flex: none; + order: 1; + align-self: flex-end; + margin: 4px 0px; } .detail-main-lower p { - position: absolute; - width: 625px; - height: 20px; - top: 29px; - font-family: Inter; - font-style: normal; - font-weight: normal; - font-size: 14px; - line-height: 20px; - color: #2f343d; + position: absolute; + width: 625px; + height: 20px; + top: 29px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 20px; + color: #2f343d; } .chatHistory { - position: relative; - left: 24px; - width: 345px; - top: 27px; + position: relative; + left: 24px; + width: 345px; + top: 27px; } .chatHistory ul li { - display: block; + display: block; } .msgcount p { - background: #cbced1; - border-radius: 2px; - width: 100%; - text-align: center; - line-height: 0.15em; - font-size: 10px; - margin: 10px 0 20px; + background: #cbced1; + border-radius: 2px; + width: 100%; + text-align: center; + line-height: 0.15em; + font-size: 10px; + margin: 10px 0 20px; } .msgcount p span { - width: 65px; - height: 12px; - right: 156px; - top: 3px; - font-family: Inter; - font-style: normal; - font-weight: 600; - text-align: center; - color: #6c727a; - background: white; - padding-left: 8px; - padding-right: 8px; + width: 65px; + height: 12px; + right: 156px; + top: 3px; + font-family: Inter; + font-style: normal; + font-weight: 600; + text-align: center; + color: #6c727a; + background: white; + padding-left: 8px; + padding-right: 8px; } .noresult { - font-weight: 700; - position: relative; - top: 30px; - left: 6%; + font-weight: 700; + position: relative; + top: 30px; + left: 6%; } #searchInput { - font-family: Inter; - font-style: normal; - font-weight: 500; - font-size: 14px; - line-height: 20px; - color: #9ea2a8; - position: absolute; - left: 16px; - right: 46px; - top: 10px; - bottom: 10px; - border: none; - width: 92%; + font-family: Inter; + font-style: normal; + font-weight: 500; + font-size: 14px; + line-height: 20px; + color: #9ea2a8; + position: absolute; + left: 16px; + right: 46px; + top: 10px; + bottom: 10px; + border: none; + width: 92%; } .right-addon .glyphicon { - right: 0px; + right: 0px; } .right-addon input { - padding-right: 30px; + padding-right: 30px; } .vistior-history-block { - margin-top: 10%; + margin-top: 10%; } .vistior-history-block ul li { - border-bottom: 2px solid #f2f3f5; - display: block; - padding-bottom: 5%; - cursor: pointer; - width: 390px; + border-bottom: 2px solid #f2f3f5; + display: block; + padding-bottom: 5%; + cursor: pointer; + width: 390px; - background-color: #ffffff; + background-color: #ffffff; } .vistior-history-block ul a { - text-decoration: none; - color: black; + text-decoration: none; + color: black; } #allist li:hover { - background-color: rgba(15,34,0,.05) !important; + background-color: rgba(15,34,0,.05) !important; } .history-div { - display: flex; + display: flex; } .visitor-img { - display: contents; + display: contents; } .visitor-img img { - position: relative; - width: 36px; - height: 36px; - left: 24px; - top: 16px; - border-radius: 1.75px; + position: relative; + width: 36px; + height: 36px; + left: 24px; + top: 16px; + border-radius: 1.75px; } .visitor-history-details { - margin-left: 2%; + margin-left: 2%; } .visitor-details { - display: -webkit-inline-box; + display: -webkit-inline-box; } .visitor-details h1 { - position: relative; - height: 22px; - left: 25px; - top: 16px; - font-family: Inter; - font-style: normal; - font-weight: 600; - font-size: 16px; - line-height: 22px; - text-transform: lowercase; - color: #2f343d; + position: relative; + height: 22px; + left: 25px; + top: 16px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 16px; + line-height: 22px; + text-transform: lowercase; + color: #2f343d; } #conten { - position: absolute; - left: 0px; - right: 0px; - padding-left: 0px !important; - padding-right: 0px !important; + position: absolute; + left: 0px; + right: 0px; + padding-left: 0px !important; + padding-right: 0px !important; } .visitor-details p { - position: relative; - height: 16px; - left: 29px; - top: 21px; - font-family: Inter; - font-style: normal; - font-weight: normal; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; + position: relative; + height: 16px; + left: 29px; + top: 21px; + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; } .total-messages { - font-size: 0.8rem; - color: grey; + font-size: 0.8rem; + color: grey; } .total-messages p { - position: relative; - height: 16px; - left: 25px; - right: 84px; - top: 16px; - font-family: Inter; - font-style: normal; - font-weight: bold; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; + position: relative; + height: 16px; + left: 25px; + right: 84px; + top: 16px; + font-family: Inter; + font-style: normal; + font-weight: bold; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; } .agent-comment { - margin-top: 3%; - font-size: 0.8rem; + margin-top: 3%; + font-size: 0.8rem; } .comment-heading { - position: relative; - height: 16px; - left: 25px; - right: 84px; - top: 15px; - font-family: Inter; - font-style: normal; - font-weight: 600; - font-size: 10px; - line-height: 12px; - color: #6c727a; + position: relative; + height: 16px; + left: 25px; + right: 84px; + top: 15px; + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 10px; + line-height: 12px; + color: #6c727a; } .comment-text { - position: relative; - width: 268px; - left: 25px; - right: 24px; - top: 15px; - font-family: Inter; - font-style: italic; - font-weight: 500; - font-size: 12px; - line-height: 16px; - color: #9ea2a8; + position: relative; + width: 268px; + left: 25px; + right: 24px; + top: 15px; + font-family: Inter; + font-style: italic; + font-weight: 500; + font-size: 12px; + line-height: 16px; + color: #9ea2a8; } .open { - padding-left: 4% !important; + padding-left: 4% !important; } .loding { - text-align: center; - font-family: Inter; + text-align: center; + font-family: Inter; } .Contextualheading { - position: absolute; - width: 249px; - height: 22px; - left: 57px; - top: 25px; - font-family: Inter; - font-style: normal; - font-weight: 500; - font-size: 16px; - line-height: 22px; - display: flex; - align-items: center; - color: #2f344d; + position: absolute; + width: 249px; + height: 22px; + left: 57px; + top: 25px; + font-family: Inter; + font-style: normal; + font-weight: 500; + font-size: 16px; + line-height: 22px; + display: flex; + align-items: center; + color: #2f344d; } \ No newline at end of file From 6e14f3206769134875ca51ac73cdc421b72cc658 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Tue, 2 Jun 2020 18:13:33 -0300 Subject: [PATCH 23/35] Fix css/style issues. --- .../views/app/tabbar/customerChatHistory.html | 16 +- .../views/app/tabbar/customerChatHistory.js | 4 +- .../tabbar/customerChatHistoryMessages.html | 14 +- .../app/tabbar/customerChatHistoryMessages.js | 2 +- .../customerChatHistoryMessagesItem.html | 20 +- app/theme/client/livechat.css | 380 ++++++++++++------ 6 files changed, 273 insertions(+), 163 deletions(-) diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.html b/app/livechat/client/views/app/tabbar/customerChatHistory.html index 2789ce44c4ebd..ebf77bc4cc37e 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.html @@ -4,37 +4,37 @@
- +
{{#if hasChatHistory}} {{#if isAllChat}} -
+
    {{#if isSearchingRoom}} {{#if isfoundRoom }} - {{#each room in searchResultsRoom}} + {{#each room in searchResultsRoom}} {{> chatRoomHistoryItem room}} {{/each}} {{else}} -

    {{_ "No_results_found"}}

    +

    {{_ "No_results_found"}}

    {{/if}} {{else}} {{#each room in previousChats}} {{> chatRoomHistoryItem room}} {{/each}} {{/if}} -
+
{{else}} {{#if isChatClicked}} {{#if isSearching}} {{#if isfound }} - {{#each room in searchResults}} + {{#each room in searchResults}} {{> customerChatHistoryMessages room}} {{/each}} {{else}} -

{{_ "No_results_found"}}

+

{{_ "No_results_found"}}

{{/if}} {{else}} {{> customerChatHistoryMessages clickRid=clickRid clickToken=clickToken}} @@ -42,7 +42,7 @@

{{_ "No_results_found"}}

{{/if}} {{/if}} {{else}} -

{{_ "No_Previous_Chats_Found"}}

+

{{_ "No_Previous_Chats_Found"}}

{{/if}}
diff --git a/app/livechat/client/views/app/tabbar/customerChatHistory.js b/app/livechat/client/views/app/tabbar/customerChatHistory.js index 59806773a93eb..f917ff08ab917 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistory.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistory.js @@ -138,7 +138,7 @@ Template.customerChatHistory.events({ return instance.offset.set(instance.offset.get() + ITEMS_COUNT); } }, 200), - 'keyup #searchInput': _.debounce((event, template) => { + 'keyup #visitor-history-search-input': _.debounce((event, template) => { event.preventDefault(); event.stopPropagation(); template.isKeyUp.set(true); @@ -162,7 +162,7 @@ Template.customerChatHistory.events({ }); Template.customerChatHistory.onDestroyed(function() { - const header = document.getElementsByClassName('Contextualheading'); + const header = document.getElementsByClassName('contextual-heading'); if (header[0]) { header[0].innerText = ''; header[0].className = 'contextual-bar__header-title'; diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html index f91b966e4aaf6..60bea6bfd9e79 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.html @@ -1,26 +1,24 @@ \ No newline at end of file diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js index cc7f7d5ea0cb7..738d7d2611fb7 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessages.js @@ -40,7 +40,7 @@ Template.customerChatHistoryMessages.onCreated(function() { } if (header[0]) { header[0].innerText = `${ agentName }, closed at ${ closingDay }`; - header[0].className = 'Contextualheading'; + header[0].className = 'contextual-heading'; } this.historyResult.set(allMessages); }); diff --git a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html index de0ff1a838e9f..4f1d191dc4a73 100644 --- a/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html +++ b/app/livechat/client/views/app/tabbar/customerChatHistoryMessagesItem.html @@ -1,16 +1,16 @@ \ No newline at end of file + diff --git a/app/livechat/imports/server/rest/visitors.js b/app/livechat/imports/server/rest/visitors.js index 1d7b4176d2e0d..e4707f48cdf00 100644 --- a/app/livechat/imports/server/rest/visitors.js +++ b/app/livechat/imports/server/rest/visitors.js @@ -46,14 +46,14 @@ API.v1.addRoute('livechat/visitors.chatHistory/room/:roomId/visitor/:visitorId', roomId: String, }); const { roomId, visitorId } = this.urlParams; - const { searchText: text, closedChatsOnly, servedChatsOnly } = this.queryParams; + const { searchText, closedChatsOnly, servedChatsOnly } = this.queryParams; const { offset, count } = this.getPaginationItems(); const { sort } = this.parseJsonQuery(); const history = Promise.await(findChatHistory({ userId: this.userId, roomId, visitorId, - text, + searchText, closedChatsOnly, servedChatsOnly, pagination: { diff --git a/app/livechat/server/api/lib/visitors.js b/app/livechat/server/api/lib/visitors.js index 15b04a733f897..7bca7a0dcf00b 100644 --- a/app/livechat/server/api/lib/visitors.js +++ b/app/livechat/server/api/lib/visitors.js @@ -43,7 +43,7 @@ export async function findVisitedPages({ userId, roomId, pagination: { offset, c }; } -export async function findChatHistory({ userId, roomId, visitorId /* , text */, closedChatsOnly, servedChatsOnly: served, pagination: { offset, count, sort } }) { +export async function findChatHistory({ userId, roomId, visitorId, searchText, closedChatsOnly, servedChatsOnly: served, pagination: { offset, count, sort } }) { if (!await hasPermissionAsync(userId, 'view-l-room')) { throw new Error('error-not-authorized'); } @@ -61,8 +61,9 @@ export async function findChatHistory({ userId, roomId, visitorId /* , text */, limit: count, }; - // const roomIds = text && text !== '' & Messages.findDistinctLivechatRoomIdsByTextMessage(); - const cursor = LivechatRooms.findRoomsWithCriteria({ visitorId, open: !closedChatsOnly, served, options }); + const roomIds = searchText && searchText !== '' && (await LivechatRooms.findRoomIdsByVisitorIdAndMessage({ visitorId, open: !closedChatsOnly, served, searchText }).toArray()).map((r) => r._id); + + const cursor = LivechatRooms.findRoomsWithCriteria({ visitorId, open: !closedChatsOnly, served, roomIds, options }); const total = await cursor.count(); diff --git a/app/models/server/models/LivechatRooms.js b/app/models/server/models/LivechatRooms.js index 06707539e47f2..1ff1886caa031 100644 --- a/app/models/server/models/LivechatRooms.js +++ b/app/models/server/models/LivechatRooms.js @@ -19,6 +19,7 @@ export class LivechatRooms extends Base { this.tryEnsureIndex({ closedAt: 1 }, { sparse: true }); this.tryEnsureIndex({ servedBy: 1 }, { sparse: true }); this.tryEnsureIndex({ 'v.token': 1 }, { sparse: true }); + this.tryEnsureIndex({ 'v._id': 1 }, { sparse: true }); } findLivechat(filter = {}, offset = 0, limit = 20) { diff --git a/app/models/server/raw/LivechatRooms.js b/app/models/server/raw/LivechatRooms.js index e8c2738d60f28..2b77193825a0b 100644 --- a/app/models/server/raw/LivechatRooms.js +++ b/app/models/server/raw/LivechatRooms.js @@ -837,7 +837,33 @@ export class LivechatRoomsRaw extends BaseRaw { return this.find(query, options); } - findRoomsWithCriteria({ agents, roomName, departmentId, open, served, createdAt, closedAt, tags, customFields, visitorId, options = {} }) { + findRoomIdsByVisitorIdAndMessage({ visitorId, searchText, open, served, options = {} }) { + const match = { + $match: { + 'v._id': visitorId, + ...open !== undefined && { open: { $exists: open } }, + ...served !== undefined && { servedBy: { $exists: served } }, + }, + }; + const lookup = { $lookup: { from: 'rocketchat_message', localField: '_id', foreignField: 'rid', as: 'messages' } }; + const unwind = { $unwind: { path: '$messages' } }; + const matchMessages = { $match: { 'messages.msg': { $regex: `.*${ searchText }.*` } } }; + const group = { $group: { _id: '$_id' } }; + const sort = { $sort: options.sort || { ts: -1 } }; + const params = [match, lookup, unwind, matchMessages, group, sort]; + + if (options.offset) { + params.push({ $skip: options.offset }); + } + + if (options.count) { + params.push({ $limit: options.count }); + } + + return this.col.aggregate(params); + } + + findRoomsWithCriteria({ agents, roomName, departmentId, open, served, createdAt, closedAt, tags, customFields, visitorId, roomIds, options = {} }) { const query = { t: 'l', }; @@ -883,6 +909,11 @@ export class LivechatRoomsRaw extends BaseRaw { if (customFields) { query.$and = Object.keys(customFields).map((key) => ({ [`livechatData.${ key }`]: new RegExp(customFields[key], 'i') })); } + + if (roomIds) { + query._id = { $in: roomIds }; + } + console.log(query); return this.find(query, { sort: options.sort || { name: 1 }, skip: options.offset, limit: options.count }); } From 1e983436709b42057b8e60cc749924f65b5af41f Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Wed, 17 Jun 2020 00:23:23 -0300 Subject: [PATCH 28/35] Remove unnecessary console log. --- app/models/server/raw/LivechatRooms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/server/raw/LivechatRooms.js b/app/models/server/raw/LivechatRooms.js index 2b77193825a0b..b7d859ce81932 100644 --- a/app/models/server/raw/LivechatRooms.js +++ b/app/models/server/raw/LivechatRooms.js @@ -913,7 +913,7 @@ export class LivechatRoomsRaw extends BaseRaw { if (roomIds) { query._id = { $in: roomIds }; } - console.log(query); + return this.find(query, { sort: options.sort || { name: 1 }, skip: options.offset, limit: options.count }); } From 0e4bc407102771f4a00b3582a82be3c30b44b22b Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Thu, 18 Jun 2020 13:23:28 -0300 Subject: [PATCH 29/35] UI-UX improvements. --- app/livechat/client/stylesheets/livechat.css | 520 ++++-------------- .../views/app/tabbar/contactChatHistory.html | 49 +- .../views/app/tabbar/contactChatHistory.js | 4 +- .../app/tabbar/contactChatHistoryItem.html | 28 +- .../app/tabbar/contactChatHistoryItem.js | 18 +- app/livechat/imports/server/rest/visitors.js | 27 +- app/livechat/server/api/lib/visitors.js | 40 +- app/models/server/raw/LivechatRooms.js | 38 +- 8 files changed, 244 insertions(+), 480 deletions(-) diff --git a/app/livechat/client/stylesheets/livechat.css b/app/livechat/client/stylesheets/livechat.css index ee172e214e48a..7ff6d926c692e 100644 --- a/app/livechat/client/stylesheets/livechat.css +++ b/app/livechat/client/stylesheets/livechat.css @@ -641,148 +641,6 @@ height: 100%; } -/* - beginning of the past chat styling -*/ - -.inner-addon { - position: relative; - left: 24px; - - box-sizing: border-box; - width: 345px; - height: 40px; - - border: 2px solid #cbced1; - border-radius: 2px; - background: #ffffff; -} - -.inner-addon .glyphicon { - position: absolute; - bottom: 0.5%; - - padding: 10px; - - pointer-events: none; - - color: #2f343d; -} - -.searchresults { - margin-top: 7%; -} - -.search-li { - position: relative; - - display: block; - - height: 65px; - - padding-bottom: 3%; - - background-color: #ffffff; -} - -.search-li :hover { - cursor: default; -} - -.closed-div { - position: relative; - - top: 20px; -} - -.closed-div-p { - width: 100%; - - margin: 10px 0 15px; - - text-align: center; - - border-radius: 2px; - - background: #f5455c; - - font-size: 10px; - - line-height: 0.15em; -} - -.closed-div-p span { - top: 3px; - right: 138px; - - width: 101px; - height: 12px; - - padding-right: 8px; - padding-left: 8px; - - text-align: center; - - color: #f5455c; - - background: white; - - font-family: Inter; - font-weight: 600; - font-style: normal; -} - -.closed-h1 h1 { - text-transform: none !important; - - color: #6c727a !important; - - font-size: 14px !important; - font-weight: 600px !important; - font-style: italic !important; - line-height: 20px !important; -} - -.closed-p p { - top: 25px !important; - - color: #9ea2a8 !important; - - font-weight: 500 !important; - font-style: italic !important; -} - -.belldiv { - position: absolute; - - top: 12px; - left: 24px; - - width: 36px; - height: 36px; - - background: #e4e7ea; -} - -.belldiv i { - position: relative; - top: 15.79%; - left: 22.31%; -} - -.chat-history-main { - position: relative; - - left: 2px; - - display: flex; - - width: 100%; - height: 68px; - - background: #ffffff; -} - .chat-history-img img { position: absolute; @@ -802,78 +660,6 @@ display: inline-block; } -.chat-history-detail-main-upper { - display: flex; -} - -.chat-history-detail-main-upper h1 { - position: static; - - top: 0; - left: 0; - - flex: none; - - height: 22px; - - margin: 4px px; - margin-right: 4px; - - text-transform: lowercase; - - color: #2f343d; - - font-family: Inter; - font-size: 16px; - font-weight: 600; - font-style: normal; - line-height: 22px; - - align-self: center; - - order: 0; -} - -.chat-history-detail-main-upper p { - position: static; - top: 6px; - - flex: none; - - height: 16px; - - margin: 4px 0; - - color: #9ea2a8; - - font-family: Inter; - font-size: 12px; - font-weight: normal; - font-style: normal; - line-height: 16px; - - align-self: flex-end; - - order: 1; -} - -.chat-history-detail-main-lower p { - position: absolute; - - top: 29px; - - width: 625px; - height: 20px; - - color: #2f343d; - - font-family: Inter; - font-size: 14px; - font-weight: normal; - font-style: normal; - line-height: 20px; -} - .chat-history-container { position: relative; @@ -881,111 +667,34 @@ left: 24px; width: 345px; -} - -.chat-history-container ul li { - display: block; -} - -.chat-history-msg-count p { - width: 100%; - - margin: 10px 0 20px; - - text-align: center; - - border-radius: 2px; - - background: #cbced1; - - font-size: 10px; - - line-height: 0.15em; -} - -.chat-history-msg-count p span { - top: 3px; - right: 156px; - - width: 65px; - height: 12px; - - padding-right: 8px; - padding-left: 8px; - - text-align: center; - - color: #6c727a; - - background: white; - - font-family: Inter; - font-weight: 600; - font-style: normal; -} - -.visitor-history-no-result { - position: relative; - - top: 30px; - left: 6%; - - font-weight: 700; -} - -#visitor-history-search-input { - position: absolute; - - top: 10px; - right: 46px; - bottom: 10px; - left: 16px; - - width: 92%; - - color: #9ea2a8; - border: none; - - font-family: Inter; - font-size: 14px; - font-weight: 500; - font-style: normal; - line-height: 20px; -} - -.right-addon .glyphicon { - right: 0; -} - -.right-addon input { - padding-right: 30px; + & ul { + & li { + display: block; + } + } } -.visitor-history-block ul li { - display: block; - - padding-bottom: 5%; +.contact-chat-history-container { + & ul { + & li { + display: block; - cursor: pointer; + padding-bottom: 8%; - border-bottom: 2px solid #f2f3f5; + cursor: pointer; - background-color: #ffffff; -} + border-bottom: 2px solid #f2f3f5; -.visitor-history-block ul a { - text-decoration: none; - - color: black; -} + background-color: #ffffff; + } -#allist li:hover { - background-color: rgba(15, 34, 0, 0.05) !important; -} + & a { + text-decoration: none; -.history-div { - display: flex; + color: black; + } + } } .visitor-img { @@ -1004,34 +713,50 @@ border-radius: 1.75px; } -.visitor-history-details { +.contact-chat-history-item-details { margin-left: 2%; } -.visitor-details { +.contact-chat-history-item-header { display: -webkit-inline-box; -} -.visitor-details h1 { - position: relative; + & h1 { + position: relative; - top: 16px; - left: 25px; + top: 16px; + left: 25px; - height: 22px; + height: 22px; - text-transform: lowercase; + text-transform: lowercase; - color: var(--primary-font-color); + color: var(--primary-font-color); - font-family: inherit; - font-size: 0.875rem; - font-weight: 600; - font-style: normal; - line-height: inherit; + font-family: inherit; + font-size: 0.875rem; + font-weight: 600; + font-style: normal; + line-height: inherit; + } + + & p { + position: relative; + + top: 16px; + left: 29px; + + height: 22px; + + color: var(--color-gray); + + font-family: Inter; + font-size: 12px; + font-weight: normal; + font-style: normal; + line-height: 16px; + } } -/* #conten { position: absolute; left: 0px; @@ -1039,56 +764,78 @@ padding-right: 0px !important; padding-left: 0px !important; } -*/ -.visitor-details p { - position: relative; +.open { + padding-left: 4% !important; +} - top: 16px; - left: 29px; +/* new design */ - height: 22px; +.chat-history-messages-main { + padding-top: var(--default-padding); + padding-bottom: var(--default-padding); - color: var(--color-gray); + border-bottom: 1px solid var(--color-gray-light); +} - font-family: Inter; - font-size: 12px; - font-weight: normal; - font-style: normal; - line-height: 16px; +.contact-chat-history-list { + overflow: auto; + + word-wrap: break-word; + flex-shrink: 1; +} + +.contact-chat-history-list li:hover { + background-color: rgba(15, 34, 0, 0.05) !important; +} + +.message.contact-chat-history-message { + padding-top: 16px; + padding-bottom: 8px; } -.total-messages { +.contact-chat-history-message + .contact-chat-history-message { + border-top: 1px solid var(--color-gray-light); +} + +.contact-chat-history-messages-list .message-actions { + visibility: hidden; +} + +.contact-chat-history-item-content { + display: flex; +} + +.contact-chat-history-item-total-messages { color: grey; font-size: 0.8rem; -} -.total-messages p { - position: relative; + & p { + position: relative; - top: 16px; - right: 84px; - left: 25px; + top: 16px; + left: 25px; - height: 16px; + height: 16px; - color: #9ea2a8; + color: #9ea2a8; - font-family: Inter; - font-size: 12px; - font-weight: bold; - font-style: normal; - line-height: 16px; + font-family: Inter; + font-size: 12px; + font-weight: bold; + font-style: normal; + line-height: 16px; + } } -.agent-comment { +.contact-chat-history-item-agent-comment { margin-top: 3%; font-size: 0.8rem; } -.comment-heading { +.contact-chat-history-item-comment-heading { position: relative; top: 15px; @@ -1100,16 +847,16 @@ color: #6c727a; font-family: Inter; - font-size: 10px; - font-weight: 600; + font-size: 12px; /*10px;*/ + font-weight: bold; /*600;*/ font-style: normal; - line-height: 12px; + line-height: 16px; /*12px;*/ } -.comment-text { +.contact-chat-history-item-comment-text { position: relative; - top: 15px; + top: 20px; right: 24px; left: 25px; @@ -1123,58 +870,3 @@ font-style: italic; line-height: 16px; } - -.open { - padding-left: 4% !important; -} - -.contextual-heading { - position: absolute; - top: 25px; - left: 57px; - - display: flex; - - width: 249px; - - height: 22px; - - color: #2f344d; - - font-family: Inter; - font-size: 16px; - font-weight: 500; - font-style: normal; - line-height: 22px; - - align-items: center; -} - -/* new design */ - -.chat-history-messages-main { - padding-top: var(--default-padding); - padding-bottom: var(--default-padding); - - border-bottom: 1px solid var(--color-gray-light); -} - -.contact-chat-history-list { - overflow: auto; - - word-wrap: break-word; - flex-shrink: 1; -} - -.message.contact-chat-history-message { - padding-top: 16px; - padding-bottom: 8px; -} - -.contact-chat-history-message + .contact-chat-history-message { - border-top: 1px solid var(--color-gray-light); -} - -.contact-chat-history-messages-list .message-actions { - visibility: hidden; -} diff --git a/app/livechat/client/views/app/tabbar/contactChatHistory.html b/app/livechat/client/views/app/tabbar/contactChatHistory.html index 814d76620f0f8..1037e28640114 100644 --- a/app/livechat/client/views/app/tabbar/contactChatHistory.html +++ b/app/livechat/client/views/app/tabbar/contactChatHistory.html @@ -1,37 +1,32 @@ - diff --git a/app/livechat/client/views/app/tabbar/contactChatHistory.js b/app/livechat/client/views/app/tabbar/contactChatHistory.js index f27270b00ed05..a0559304890bc 100644 --- a/app/livechat/client/views/app/tabbar/contactChatHistory.js +++ b/app/livechat/client/views/app/tabbar/contactChatHistory.js @@ -64,7 +64,7 @@ Template.contactChatHistory.onCreated(async function() { const offset = this.offset.get(); const searchTerm = this.searchTerm.get(); - let baseUrl = `livechat/visitors.chatHistory/room/${ currentData.rid }/visitor/${ this.visitorId.get() }?count=${ HISTORY_COUNT }&offset=${ offset }&closedChatsOnly=true&servedChatsOnly=true`; + let baseUrl = `livechat/visitors.searchHistory/room/${ currentData.rid }/visitor/${ this.visitorId.get() }?count=${ HISTORY_COUNT }&offset=${ offset }&closedChatsOnly=true&servedChatsOnly=true`; if (searchTerm) { baseUrl += `&searchText=${ searchTerm }`; } @@ -90,7 +90,7 @@ Template.contactChatHistory.events({ instance.offset.set(instance.offset.get() + HISTORY_COUNT); } }, 200), - 'click .list-chat-item'(event, instance) { + 'click .contact-chat-history-item'(event, instance) { event.preventDefault(); event.stopPropagation(); diff --git a/app/livechat/client/views/app/tabbar/contactChatHistoryItem.html b/app/livechat/client/views/app/tabbar/contactChatHistoryItem.html index bc0f01ed6a7b0..41305aece2b55 100644 --- a/app/livechat/client/views/app/tabbar/contactChatHistoryItem.html +++ b/app/livechat/client/views/app/tabbar/contactChatHistoryItem.html @@ -1,23 +1,27 @@