From ff182b2d04ab4c6e9019e778aa777fee5954a7e1 Mon Sep 17 00:00:00 2001 From: Nicola Lanzilotto Date: Mon, 4 Mar 2024 16:16:45 +0100 Subject: [PATCH] Improvements and bug fixing --- .../bots/bots-list/bots-list.component.html | 6 +- .../components/sidebar/sidebar.component.html | 4 +- .../components/sidebar/sidebar.component.ts | 37 ++++++----- .../knowledge-base-table.component.ts | 64 ++++++++++--------- 4 files changed, 60 insertions(+), 51 deletions(-) diff --git a/src/app/bots/bots-list/bots-list.component.html b/src/app/bots/bots-list/bots-list.component.html index f23f69632102..469da2fd43bb 100755 --- a/src/app/bots/bots-list/bots-list.component.html +++ b/src/app/bots/bots-list/bots-list.component.html @@ -179,13 +179,15 @@
-
+ +
{{ faqkb.name }} + (click)="$event.stopPropagation()" + (keypress)="onPressEnterUpdateChatBotName($event);$event.stopPropagation() ">
diff --git a/src/app/components/sidebar/sidebar.component.html b/src/app/components/sidebar/sidebar.component.html index 77a520bf34c5..bd55ac113eeb 100755 --- a/src/app/components/sidebar/sidebar.component.html +++ b/src/app/components/sidebar/sidebar.component.html @@ -117,7 +117,7 @@ TMPLT_CMNT_ROUTE_IS_ACTIVE || TMPLT_IS_ROUTE_IS_ACTIVE || TMPLT_CS_ROUTE_IS_ACTIVE || - NEW_KB_ROUTE_IS_ACTIVE} "> + KB_ROUTE_IS_ACTIVE} "> @@ -307,7 +307,7 @@ INSTALLATION_ROUTE_IS_ACTIVE || EMAIL_TICKETING_ROUTE_IS_ACTIVE || AUTOMATIONS_ROUTE_IS_ACTIVE || - KB_ROUTE_IS_ACTIVE || + OLD_KB_ROUTE_IS_ACTIVE || INTEGRATIONS_ROUTE_IS_ACTIVE}" (click)="goToWidgetSetUpOrToCannedResponses()" style="cursor:pointer; height: 50px !important;" matTooltipClass="sb-mat-tooltip" diff --git a/src/app/components/sidebar/sidebar.component.ts b/src/app/components/sidebar/sidebar.component.ts index be96d0a4beb5..5e5999acda99 100755 --- a/src/app/components/sidebar/sidebar.component.ts +++ b/src/app/components/sidebar/sidebar.component.ts @@ -191,7 +191,6 @@ export class SidebarComponent implements OnInit, AfterViewInit { INSTALLATION_ROUTE_IS_ACTIVE: boolean; EMAIL_TICKETING_ROUTE_IS_ACTIVE: boolean; AUTOMATIONS_ROUTE_IS_ACTIVE: boolean; - KB_ROUTE_IS_ACTIVE: boolean; IS_REQUEST_FOR_PANEL_ROUTE: boolean; IS_UNSERVEDREQUEST_FOR_PANEL_ROUTE: boolean; // Chatbot sidebar @@ -202,7 +201,9 @@ export class SidebarComponent implements OnInit, AfterViewInit { TMPLT_CMNT_ROUTE_IS_ACTIVE: boolean; TMPLT_IS_ROUTE_IS_ACTIVE: boolean; TMPLT_CS_ROUTE_IS_ACTIVE: boolean; - NEW_KB_ROUTE_IS_ACTIVE: boolean; + OLD_KB_ROUTE_IS_ACTIVE: boolean; + KB_ROUTE_IS_ACTIVE: boolean; + prjct_profile_name: string; prjct_trial_expired: boolean; @@ -649,6 +650,7 @@ export class SidebarComponent implements OnInit, AfterViewInit { getCurrentRoute() { this.router.events.subscribe((event: NavigationEvent) => { if (event instanceof NavigationEnd) { + this.logger.log('[SIDEBAR] NavigationEnd event.url' , event.url.substring(event.url.lastIndexOf('/') + 1)) if (event.url.indexOf('/request-for-panel') !== -1) { this.IS_REQUEST_FOR_PANEL_ROUTE = true; // this.logger.log('[NAVBAR] NavigationEnd - IS_REQUEST_FOR_PANEL_ROUTE ', this.IS_REQUEST_FOR_PANEL_ROUTE); @@ -894,16 +896,6 @@ export class SidebarComponent implements OnInit, AfterViewInit { this.logger.log('[SIDEBAR] NavigationEnd - TMPLT_CS_ROUTE_IS_ACTIVE ', this.TMPLT_CS_ROUTE_IS_ACTIVE); } - if (event.url.indexOf('/knowledge-bases') !== -1 ) { - this.NEW_KB_ROUTE_IS_ACTIVE = true; - this.logger.log('[SIDEBAR] NavigationEnd - NEW_KB_ROUTE_IS_ACTIVE ', this.NEW_KB_ROUTE_IS_ACTIVE); - } else { - this.NEW_KB_ROUTE_IS_ACTIVE = false; - this.logger.log('[SIDEBAR] NavigationEnd - NEW_KB_ROUTE_IS_ACTIVE ', this.NEW_KB_ROUTE_IS_ACTIVE); - } - - - if (event.url.indexOf('/createfaq') !== -1) { this.CREATE_FAQ_ROUTE_IS_ACTIVE = true; // this.logger.log('[SIDEBAR] NavigationEnd - CREATE_FAQ_ROUTE_IS_ACTIVE ', this.CREATE_FAQ_ROUTE_IS_ACTIVE); @@ -1049,7 +1041,18 @@ export class SidebarComponent implements OnInit, AfterViewInit { this.logger.log('[SIDEBAR] NavigationEnd - AUTOMATIONS_ROUTE_IS_ACTIVE ', this.AUTOMATIONS_ROUTE_IS_ACTIVE); } - if (event.url.indexOf('/knowledge-bases-pre') !== -1) { + // if (event.url.indexOf('/knowledge-bases-pre') ) { + if(event.url.substring(event.url.lastIndexOf('/') + 1) === 'knowledge-bases-pre' ) { + this.OLD_KB_ROUTE_IS_ACTIVE = true; + this.logger.log('[SIDEBAR] NavigationEnd - OLD_KB_ROUTE_IS_ACTIVE ', this.OLD_KB_ROUTE_IS_ACTIVE); + } else { + this.OLD_KB_ROUTE_IS_ACTIVE = false; + this.logger.log('[SIDEBAR] NavigationEnd - OLD_KB_ROUTE_IS_ACTIVE ', this.OLD_KB_ROUTE_IS_ACTIVE); + } + + + // if (event.url.match('/knowledge-bases')) { + if (event.url.substring(event.url.lastIndexOf('/') + 1) === 'knowledge-bases') { this.KB_ROUTE_IS_ACTIVE = true; this.logger.log('[SIDEBAR] NavigationEnd - KB_ROUTE_IS_ACTIVE ', this.KB_ROUTE_IS_ACTIVE); } else { @@ -1201,7 +1204,7 @@ export class SidebarComponent implements OnInit, AfterViewInit { getUserAvailability() { this.usersService.user_is_available_bs.subscribe((user_available) => { this.IS_AVAILABLE = user_available; - // console.log('[SIDEBAR] - USER IS AVAILABLE ', this.IS_AVAILABLE); + // this.logger.log('[SIDEBAR] - USER IS AVAILABLE ', this.IS_AVAILABLE); }); } @@ -1210,7 +1213,7 @@ export class SidebarComponent implements OnInit, AfterViewInit { this.IS_BUSY = user_isbusy; // THE VALUE OS IS_BUSY IS THEN UPDATED WITH THE VALUE RETURNED FROM THE WEBSOCKET getWsCurrentUserIsBusy$() // WHEN, FOR EXAMPLE IN PROJECT-SETTINGS > ADVANCED THE NUM OF MAX CHAT IS 3 AND THE - // console.log('[SIDEBAR] - USER IS BUSY (from db)', this.IS_BUSY); + // this.logger.log('[SIDEBAR] - USER IS BUSY (from db)', this.IS_BUSY); }); } @@ -1365,10 +1368,10 @@ export class SidebarComponent implements OnInit, AfterViewInit { takeUntil(this.unsubscribe$) ) .subscribe((currentuser_isbusy) => { - // console.log('[SIDEBAR] - GET WS CURRENT-USER - currentuser_isbusy? ', currentuser_isbusy); + // this.logger.log('[SIDEBAR] - GET WS CURRENT-USER - currentuser_isbusy? ', currentuser_isbusy); if (currentuser_isbusy !== null) { this.IS_BUSY = currentuser_isbusy; - // console.log('[SIDEBAR] - GET WS CURRENT-USER (from ws)- this.IS_BUSY? ', this.IS_BUSY); + // this.logger.log('[SIDEBAR] - GET WS CURRENT-USER (from ws)- this.IS_BUSY? ', this.IS_BUSY); } }, error => { this.logger.error('[SIDEBAR] - GET WS CURRENT-USER IS BUSY * error * ', error) diff --git a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts index 8685daf481f1..e8e93b2fe1e4 100644 --- a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts +++ b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts @@ -3,7 +3,7 @@ import { MatTableDataSource } from '@angular/material/table'; import { MatSort, Sort } from '@angular/material/sort'; import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator'; import { KB, KbSettings } from 'app/models/kbsettings-model'; -import {LiveAnnouncer} from '@angular/cdk/a11y'; +import { LiveAnnouncer } from '@angular/cdk/a11y'; @Component({ @@ -23,11 +23,11 @@ export class KnowledgeBaseTableComponent implements OnInit { @Output() openBaseModalPreview = new EventEmitter(); @Output() runIndexing = new EventEmitter(); @Output() reloadKbs = new EventEmitter(); - + kbsList: KB[] = []; kbsListfilterTypeFilter: KB[] = []; dataSource: MatTableDataSource; - displayedColumns: string[] = ['type','status','createdAt','name','actions']; + displayedColumns: string[] = ['type', 'status', 'createdAt', 'name', 'actions']; filterType: string; // filterText: string; pagConfig: any; @@ -60,11 +60,11 @@ export class KnowledgeBaseTableComponent implements OnInit { direction: -1, sortField: 'updatedAt' } - + } - ngOnChanges(changes: SimpleChanges){ - if(this.kbs){ + ngOnChanges(changes: SimpleChanges) { + if (this.kbs) { this.kbsList = this.kbs.kbs; this.pagConfig = { length: this.kbs.count, @@ -76,14 +76,14 @@ export class KnowledgeBaseTableComponent implements OnInit { sortField: 'updatedAt' } } - + this.dataSource = new MatTableDataSource(this.kbsList); - if(this.kbsList) { + if (this.kbsList) { this.dataSource = new MatTableDataSource(this.kbsList); // this.dataSource.sort = this.sort; // this.dataSource.paginator = this.paginator; } - if(this.pagConfig && this.kbs){ + if (this.pagConfig && this.kbs) { this.pagConfig.length = this.kbs.count; } // Math.ceil(this.kbs.count/this.pagConfig.pageSize); @@ -91,8 +91,12 @@ export class KnowledgeBaseTableComponent implements OnInit { ngAfterViewInit() { //console.log('ngAfterViewInit!!!-->', this.kbsList); - this.kbsList = this.kbs.kbs; + this.kbsList = []; + if (this.kbs && this.kbs.kbs) { + this.kbsList = this.kbs.kbs; + } this.dataSource = new MatTableDataSource(this.kbsList); + this.dataSource.sort = this.sort; this.sort.active = "updatedAt"; this.sort.direction = "desc" @@ -106,10 +110,10 @@ export class KnowledgeBaseTableComponent implements OnInit { applyFilter(filterValue: string, column: string) { //let params = "?limit="+this.pageSize+"&page="+this.pageIndex; - if( column == 'type'){ + if (column == 'type') { // this.filterType = filterValue; this.pagConfig.status = filterValue; - } else if(column == 'name'){ + } else if (column == 'name') { // this.filterText= filterValue; this.pagConfig.search = filterValue; } @@ -126,7 +130,7 @@ export class KnowledgeBaseTableComponent implements OnInit { // return data.status.toString() === this.filterType; // } // return true; - + // } // this.dataSource.filter = filterValue; // if (this.dataSource.paginator) { @@ -144,38 +148,38 @@ export class KnowledgeBaseTableComponent implements OnInit { // } // } - onShortBy(type){ - if(type == 'createdAt'){ + onShortBy(type) { + if (type == 'createdAt') { this.pagConfig.sortField = type; - } else if(type == 'name'){ + } else if (type == 'name') { this.pagConfig.sortField = type; } - this.pagConfig.direction = this.pagConfig.direction*-1; + this.pagConfig.direction = this.pagConfig.direction * -1; this.onReloadKbs(); } - onRunIndexing(kb){ + onRunIndexing(kb) { // console.log('onRunIndexing:: ', kb); this.runIndexing.emit(kb); } - onOpenBaseModalPreview(){ + onOpenBaseModalPreview() { this.openBaseModalPreview.emit(); } - onOpenBaseModalDelete(kb){ + onOpenBaseModalDelete(kb) { // kb.deleting = true; this.openBaseModalDelete.emit(kb); } - onOpenBaseModalDetail(kb){ + onOpenBaseModalDetail(kb) { // console.log("OPEN DETAIL:: ",kb); this.openBaseModalDetail.emit(kb); } - getSubtitle(kb){ + getSubtitle(kb) { let subtitle = kb.source; - if(kb.type !== 'url'){ + if (kb.type !== 'url') { subtitle = kb.content; // const maxLength = 100; // if (kb.content.length > maxLength) { @@ -193,29 +197,29 @@ export class KnowledgeBaseTableComponent implements OnInit { // console.log('Page change event:', event); this.pagConfig.pageSize = event.pageSize; this.pagConfig.pageIndex = event.pageIndex, - this.onReloadKbs(); + this.onReloadKbs(); } - onReloadKbs(){ - let params = "?limit="+this.pagConfig.pageSize+"&page="+this.pagConfig.pageIndex+"&direction="+this.pagConfig.direction+"&sortField="+this.pagConfig.sortField+"&status="+this.pagConfig.status+"&search="+this.pagConfig.search; + onReloadKbs() { + let params = "?limit=" + this.pagConfig.pageSize + "&page=" + this.pagConfig.pageIndex + "&direction=" + this.pagConfig.direction + "&sortField=" + this.pagConfig.sortField + "&status=" + this.pagConfig.status + "&search=" + this.pagConfig.search; this.reloadKbs.emit(params); } // handlePageSizeChange(event: any) { // console.log('Page size change event:', event);n // } - + // handlePageSizeOptionsChange(event: any) { // console.log('Page size options change event:', event); // } - + // handleLengthChange(event: any) { // console.log('Length change event:', event); // } - + // handlePageIndexChange(event: any) { // console.log('Page index change event:', event); // } - + // handlePageEvent(event: any) { // console.log('Generic page event:', event); // }