From eeb1c69368c202b6a7b79de0d17a2f6acdab8a03 Mon Sep 17 00:00:00 2001 From: Nicola Lanzilotto Date: Thu, 30 Jan 2025 11:47:12 +0100 Subject: [PATCH 01/11] Available to agents in progress --- .../bots/bots-list/bots-list.component.html | 3 + src/app/bots/bots-list/bots-list.component.ts | 2 +- .../ws-requests-msgs.component.ts | 140 ++++++++++-------- 3 files changed, 80 insertions(+), 65 deletions(-) diff --git a/src/app/bots/bots-list/bots-list.component.html b/src/app/bots/bots-list/bots-list.component.html index 7ac235f2c979..f74259a108ee 100755 --- a/src/app/bots/bots-list/bots-list.component.html +++ b/src/app/bots/bots-list/bots-list.component.html @@ -244,6 +244,9 @@
+
+ boy +
diff --git a/src/app/bots/bots-list/bots-list.component.ts b/src/app/bots/bots-list/bots-list.component.ts index f22d59621f62..c512509399bd 100755 --- a/src/app/bots/bots-list/bots-list.component.ts +++ b/src/app/bots/bots-list/bots-list.component.ts @@ -592,7 +592,7 @@ export class BotListComponent extends PricingBaseComponent implements OnInit, On this.showSpinner = true // this.faqKbService.getAllBotByProjectId().subscribe((faqKb: any) => { this.faqKbService.getFaqKbByProjectId().subscribe((faqKb: any) => { - this.logger.log('[BOTS-LIST] - GET BOTS BY PROJECT ID', faqKb); + console.log('[BOTS-LIST] - GET BOTS BY PROJECT ID', faqKb); if (faqKb) { this.faqkbList = faqKb; diff --git a/src/app/ws_requests/ws-requests-msgs/ws-requests-msgs.component.ts b/src/app/ws_requests/ws-requests-msgs/ws-requests-msgs.component.ts index d6246b12ed68..394bdcd68b57 100755 --- a/src/app/ws_requests/ws-requests-msgs/ws-requests-msgs.component.ts +++ b/src/app/ws_requests/ws-requests-msgs/ws-requests-msgs.component.ts @@ -283,7 +283,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit CURRENT_USER_IS_A_FOLLOWER: boolean = false; displayModalTranscript: string = 'none' transcriptDwnldPreference: string; - + resolutionBotCount: number; previousUrl: string; hasSearchedBy: string; @@ -424,7 +424,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit public dialog: MatDialog, public brandService: BrandService, private faqService: FaqService, - private cacheService: CacheService + private cacheService: CacheService ) { super(botLocalDbService, usersLocalDbService, router, wsRequestsService, faqKbService, usersService, notify, logger, translate) this.jira_issue_types = [ @@ -646,7 +646,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit presentModalOnlyOwnerCanManageTheAccountPlan() { // https://github.com/t4t5/sweetalert/issues/845 this.notify.presentModalOnlyOwnerCanManageTheAccountPlan( - this.translationMap.get('OnlyUsersWithTheOwnerRoleCanManageTheAccountPlan'), + this.translationMap.get('OnlyUsersWithTheOwnerRoleCanManageTheAccountPlan'), this.translationMap.get('LearnMoreAboutDefaultRoles') ) } @@ -1696,10 +1696,10 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit else return days + " " + this.translate.instant('Analytics.Days'); } - - async getWsRequestById$() { + + async getWsRequestById$() { this.wsRequestsService.wsRequest$ .pipe( takeUntil(this.unsubscribe$) @@ -1708,7 +1708,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit this.logger.log('[WS-REQUESTS-MSGS] - getWsRequestById$ *** wsrequest *** NIKO 2 ', wsrequest) this.request = wsrequest; - + if (this.request) { this.getfromStorageIsOpenAppSidebar() @@ -1935,13 +1935,13 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit this.logger.log('[WS-REQUESTS-MSGS] - *** id_project ', this.request.id_project); - - // if (!this.CURRENT_USER_ROLE) { - // this.CURRENT_USER_ROLE = await this.getProjectUserInProject(this.currentUserID, this.request.id_project) - // this.logger.log('[WS-REQUESTS-MSGS] - *** CURRENT_USER_ROLE 2 ', this.CURRENT_USER_ROLE); - // } - if(!this.CURRENT_USER_ROLE) { - this.CURRENT_USER_ROLE = await this.getProjectUserInProject(this.currentUserID, this.request.id_project) + + // if (!this.CURRENT_USER_ROLE) { + // this.CURRENT_USER_ROLE = await this.getProjectUserInProject(this.currentUserID, this.request.id_project) + // this.logger.log('[WS-REQUESTS-MSGS] - *** CURRENT_USER_ROLE 2 ', this.CURRENT_USER_ROLE); + // } + if (!this.CURRENT_USER_ROLE) { + this.CURRENT_USER_ROLE = await this.getProjectUserInProject(this.currentUserID, this.request.id_project) this.logger.log('[WS-REQUESTS-MSGS] - *** CURRENT_USER_ROLE 2 ', this.CURRENT_USER_ROLE); } @@ -2684,7 +2684,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit const foundtag = this.tagsList.filter((obj: any) => { return obj._id === this.tag; }); - + this.logger.log('[WS-REQUESTS-MSGS] - ADD TAG - foundtag: ', foundtag); // No more used @@ -2716,9 +2716,9 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit } - manageRequestTags(id_request, tag, fromaction) { - this.logger.log('[WS-REQUESTS-MSGS] - UPDATE REQUEST TAGS fromaction: ', fromaction); - this.logger.log('[WS-REQUESTS-MSGS] - UPDATE REQUEST TAGS tag: ', tag); + manageRequestTags(id_request, tag, fromaction) { + this.logger.log('[WS-REQUESTS-MSGS] - UPDATE REQUEST TAGS fromaction: ', fromaction); + this.logger.log('[WS-REQUESTS-MSGS] - UPDATE REQUEST TAGS tag: ', tag); this.wsRequestsService.updateRequestTags(id_request, tag) .subscribe((data: any) => { this.logger.log('[WS-REQUESTS-MSGS] - ADD TAG - RES: ', data); @@ -2850,7 +2850,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit // const tagObject = { tag: tag.tag, color: tag.color } // no more used // self.tagsArray.push(tagObject); // no more used const newTagArray = [{ tag: tag.tag, color: tag.color }] - + self.manageRequestTags(this.id_request, newTagArray, 'create') @@ -2901,7 +2901,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit }, 0); // this.getTag(); - + // this.wsRequestsService.updateRequestsById_UpdateTag(this.id_request, this.tagsArray) this.wsRequestsService.deleteRequestTags(this.id_request, tag['_id']) .subscribe((data: any) => { @@ -2952,7 +2952,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit this.ngSelect.blur() } - + onPressEnterInIputTypeNewTag() { this.logger.log('[WS-REQUESTS-MSGS] - ON PRESS ENTER IN INPUT TYPE NEW TAG'); @@ -3068,24 +3068,24 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit addNote() { // this.disableMainPanelScroll(); if (this.DISABLE_ADD_NOTE_AND_TAGS === false) { - this.showSpinnerInAddNoteBtn = true; - this.wsRequestsService.createNote(this.new_note, this.id_request) - .subscribe((responses: any) => { - this.logger.log('[WS-REQUESTS-MSGS] - CREATE NOTE - RES ', responses); - }, (error) => { - this.logger.error('[WS-REQUESTS-MSGS] - CREATE NOTE - ERROR ', error); - this.notify.showWidgetStyleUpdateNotification(this.translationMap.get('Notes.NotificationMsgs')['CreateNoteError'], 4, 'report_problem'); - this.showSpinnerInAddNoteBtn = false; - }, () => { - this.logger.error('[WS-REQUESTS-MSGS] - CREATE NOTE * COMPLETE *'); - this.new_note = '' - // var panel = document.querySelector('.note-panel') - // panel.scrollTop = panel.scrollHeight; - // this.logger.log('% Ws-REQUESTS-Msgs - note-wf - CREATE NOTE * COMPLETE *'); + this.showSpinnerInAddNoteBtn = true; + this.wsRequestsService.createNote(this.new_note, this.id_request) + .subscribe((responses: any) => { + this.logger.log('[WS-REQUESTS-MSGS] - CREATE NOTE - RES ', responses); + }, (error) => { + this.logger.error('[WS-REQUESTS-MSGS] - CREATE NOTE - ERROR ', error); + this.notify.showWidgetStyleUpdateNotification(this.translationMap.get('Notes.NotificationMsgs')['CreateNoteError'], 4, 'report_problem'); + this.showSpinnerInAddNoteBtn = false; + }, () => { + this.logger.error('[WS-REQUESTS-MSGS] - CREATE NOTE * COMPLETE *'); + this.new_note = '' + // var panel = document.querySelector('.note-panel') + // panel.scrollTop = panel.scrollHeight; + // this.logger.log('% Ws-REQUESTS-Msgs - note-wf - CREATE NOTE * COMPLETE *'); - this.notify.showWidgetStyleUpdateNotification(this.translationMap.get('Notes.NotificationMsgs')['CreateNoteSuccess'], 2, 'done'); - this.showSpinnerInAddNoteBtn = false; - // this.enableMainPanelScroll() + this.notify.showWidgetStyleUpdateNotification(this.translationMap.get('Notes.NotificationMsgs')['CreateNoteSuccess'], 2, 'done'); + this.showSpinnerInAddNoteBtn = false; + // this.enableMainPanelScroll() }); } @@ -3770,7 +3770,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit Swal.fire({ title: this.translate.instant('Oops') + '!', - text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), + text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), icon: "error", showCloseButton: false, showCancelButton: false, @@ -3832,9 +3832,9 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit }, (error) => { this.logger.error('[WS-REQUESTS-MSGS] AddAgentToConversation in swal willBeAssigned to User addParticipant - ERROR ', error); - Swal.fire( { + Swal.fire({ title: this.translate.instant('Oops') + '!', - text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), + text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), icon: "error", showCloseButton: false, showCancelButton: false, @@ -3877,24 +3877,34 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit this.displayConfirmReassignmentModal = 'block' let blocks = {} this.faqService.getAllFaqByFaqKbId(botid).subscribe((faqs: any) => { - this.logger.log('[MODAL-CHATBOT-REASSIGNMENT] - GET ALL FAQ BY BOT ID', faqs); + console.log('[MODAL-CHATBOT-REASSIGNMENT] - GET ALL FAQ BY BOT ID', faqs); + console.log('[MODAL-CHATBOT-REASSIGNMENT] - GET ALL FAQ BY BOT ID CURRENT_USER_ROLE', this.CURRENT_USER_ROLE); + // const intent_display_name_array = [] if (faqs) { let processedItems = 0; + if (this.CURRENT_USER_ROLE === 'agent') { + faqs = faqs.filter(faq => faq.agents_available === true); + } faqs.forEach((faq, index) => { processedItems++; blocks[faq.intent_display_name] = faq.intent_display_name // intent_display_name_array.push(block) if (processedItems === faqs.length) { - this.logger.log('loop finished'); + console.log('loop finished'); + console.log('[MODAL-CHATBOT-REASSIGNMENT] - HERE 0 blocks', blocks); + + this.presentSwalModalReassignConversationToBot(this.userid_selected, this.userfirstname_selected, blocks) } }); + + this.logger.log('[MODAL-CHATBOT-REASSIGNMENT] - blocks', blocks); // this.logger.log('[MODAL-CHATBOT-REASSIGNMENT] - intent_display_name_array', intent_display_name_array); // this.intent_display_name_array = this.intent_display_name_array.slice(0) @@ -3913,7 +3923,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit async presentSwalModalReassignConversationToBot(botid, botname, blocks) { this.logger.log('[MODAL-CHATBOT-REASSIGNMENT] - blocks 2', blocks); const { value: block } = await Swal.fire({ - html: this.CHAT_PANEL_MODE === true ? `` : `${this.translationMap.get('VisitorsPage.TheRequestWillBeReassignedTo')} ${botname} ` , + html: this.CHAT_PANEL_MODE === true ? `` : `${this.translationMap.get('VisitorsPage.TheRequestWillBeReassignedTo')} ${botname} `, title: this.translationMap.get('VisitorsPage.ReassignRequest'), // text: this.translationMap.get('VisitorsPage.TheRequestWillBeReassignedTo') + ' ' + botname, // if there is the html this is not diplayed // icon: "info", @@ -4061,9 +4071,9 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit }, (error) => { this.logger.error('[WS-REQUESTS-MSGS] ConfirmReassignToDept in swal joinDept - ERROR ', error); - Swal.fire( { + Swal.fire({ title: this.translate.instant('Oops') + '!', - text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), + text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), icon: "error", showCloseButton: false, showCancelButton: false, @@ -4315,7 +4325,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit reverseButtons: true, // buttons: true, // dangerMode: false, - customClass: this.CHAT_PANEL_MODE === true ? "swal-size-sm" : "" + customClass: this.CHAT_PANEL_MODE === true ? "swal-size-sm" : "" }) .then((result) => { if (result.isConfirmed) { @@ -4327,9 +4337,9 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit }, (err) => { this.logger.error('[WS-REQUESTS-MSGS] - LEAVE THE GROUP - ERROR ', err); - Swal.fire( { + Swal.fire({ title: this.translate.instant('Oops') + '!', - text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), + text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), icon: "error", showCloseButton: false, showCancelButton: false, @@ -4769,14 +4779,14 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit presentModalOnlyOwnerCanManageAdvancedProjectSettings() { this.notify.presentModalOnlyOwnerCanManageAdvancedProjectSettings( - this.translationMap.get('OnlyUserWithOwnerRoleCanManageAdvancedProjectSettings'), + this.translationMap.get('OnlyUserWithOwnerRoleCanManageAdvancedProjectSettings'), this.translationMap.get('LearnMoreAboutDefaultRoles') ) } banVisitors(leadid: string, ipaddress: string) { const index = this.bannedVisitorsArray.findIndex((v) => v.id === leadid); - this.logger.log("displayModalBanVisitor bannedVisitorsArray index" , index) + this.logger.log("displayModalBanVisitor bannedVisitorsArray index", index) this.logger.log("displayModalBanVisitor bannedVisitorsArray", this.bannedVisitorsArray) // if (this.visitorIsBanned === false) { if (index === -1) { @@ -4805,7 +4815,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit }, (error) => { // this.logger.error('[WS-REQUESTS-MSGS] BAN VISITOR in swal - ERROR ', error); - Swal.fire( { + Swal.fire({ title: this.translate.instant('Oops') + '!', text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), icon: "error", @@ -4827,8 +4837,8 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit customClass: this.CHAT_PANEL_MODE === true ? "swal-size-sm" : "" }).then((result) => { if (result.isConfirmed) { - this.cacheService.clearCache() - this.findCurrentProjectAmongAll(this.id_project) + this.cacheService.clearCache() + this.findCurrentProjectAmongAll(this.id_project) } }); @@ -4986,7 +4996,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit presentModalAgentCannotManageAvancedSettings() { this.notify.presentModalOnlyOwnerCanManageTheAccountPlan( - this.translationMap.get('UsersWiththeAgentroleCannotManageTheAdvancedOptionsOfTheProject'), + this.translationMap.get('UsersWiththeAgentroleCannotManageTheAdvancedOptionsOfTheProject'), this.translationMap.get('LearnMoreAboutDefaultRoles') ) } @@ -5266,7 +5276,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit // ----------------------------------------------- translateNotificationMsgs() { - let keys= [ + let keys = [ 'Tags.NotificationMsgs', 'Notes.NotificationMsgs', 'Processing', @@ -5313,11 +5323,13 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit 'SorryFileTypeNotSupported', ] - this.translate.get(keys).subscribe({next: (translation)=>{ - Object.keys(translation).forEach(key => { - this.translationMap.set(key, translation[key]) - }) - }}) + this.translate.get(keys).subscribe({ + next: (translation) => { + Object.keys(translation).forEach(key => { + this.translationMap.set(key, translation[key]) + }) + } + }) this.translate.get('AvailableWithThePlan', { plan_name: PLAN_NAME.F }) @@ -5403,7 +5415,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit // const isAccepted = this.checkAcceptedFile(mimeType) const canUploadFile = checkAcceptedFile(this.uploadedFiles.type, this.fileUploadAccept) - if(!canUploadFile){ + if (!canUploadFile) { this.uploadedFiles = null; this.presenModalAttachmentFileTypeNotSupported(); return; @@ -5868,9 +5880,9 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit }, (error) => { this.logger.error('[WS-REQUESTS-MSGS] ON SMART ASSIGNMENT OFF - ERROR ', error); - Swal.fire( { + Swal.fire({ title: this.translate.instant('Oops') + '!', - text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), + text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), icon: "error", showCloseButton: false, showCancelButton: false, @@ -5931,7 +5943,7 @@ export class WsRequestsMsgsComponent extends WsSharedComponent implements OnInit Swal.fire({ title: this.translate.instant('Oops') + '!', - text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), + text: this.translate.instant('UserEditAddPage.AnErrorHasOccurred'), icon: "error", showCloseButton: false, showCancelButton: false, From 7a2c4dd147718361bd8e3d5324bcfaa25821da5d Mon Sep 17 00:00:00 2001 From: Nicola Lanzilotto Date: Thu, 30 Jan 2025 20:02:20 +0100 Subject: [PATCH 02/11] Removes footer from "get-chatbot" wizard page --- src/app/app.component.ts | 3 ++- .../get-start-chatbot-fork.component.html | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a2837bb6aa79..fcc4ab30fdc0 100755 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1236,7 +1236,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { (this.route.indexOf('/desktop-access') !== -1) || (this.route.indexOf('/desktop--access') !== -1) || (this.route.indexOf('/projects') !== -1) || - (this.route.indexOf('/pricing') !== -1) + (this.route.indexOf('/pricing') !== -1) || + (this.route.indexOf('/get-chatbot') !== -1) ) { elemFooter.setAttribute('style', 'display:none;'); // this.logger.log('DETECT LOGIN PAGE') diff --git a/src/app/create-project-wizard/get-start-chatbot-fork/get-start-chatbot-fork.component.html b/src/app/create-project-wizard/get-start-chatbot-fork/get-start-chatbot-fork.component.html index 9b2b376a4b20..147304b96979 100644 --- a/src/app/create-project-wizard/get-start-chatbot-fork/get-start-chatbot-fork.component.html +++ b/src/app/create-project-wizard/get-start-chatbot-fork/get-start-chatbot-fork.component.html @@ -77,14 +77,20 @@

Choose which project you want to install the cha
- - -
From 9614047fdc19c2940f10a2629fecc296004090c0 Mon Sep 17 00:00:00 2001 From: Nicola Lanzilotto Date: Thu, 30 Jan 2025 20:03:17 +0100 Subject: [PATCH 03/11] Adds an icon on the chatbot cards of the chatbot list page to indicate that the chatbot is available to agents --- .../bots/bots-list/bots-list.component.html | 45 +++++++++++++++---- .../bots/bots-list/bots-list.component.scss | 22 +++++++++ src/app/bots/bots-list/bots-list.component.ts | 21 ++++++++- src/app/bots/bots-list/bots-list.module.ts | 4 +- 4 files changed, 82 insertions(+), 10 deletions(-) diff --git a/src/app/bots/bots-list/bots-list.component.html b/src/app/bots/bots-list/bots-list.component.html index f74259a108ee..dc47340cb06c 100755 --- a/src/app/bots/bots-list/bots-list.component.html +++ b/src/app/bots/bots-list/bots-list.component.html @@ -79,8 +79,7 @@ style="margin-right: 20px"> Create from scratch -
@@ -157,16 +156,38 @@ - +

-

+ + + + + +
+ +
+ Available to agents +
+ +
+ Chatbot visible to agents for the purpose to be put back in the conversation +
+ +
+
+
@@ -243,8 +264,15 @@
+ + +
-
+
boy
@@ -358,6 +386,7 @@
+
@@ -396,7 +425,7 @@