Skip to content

Commit

Permalink
Improvements and bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Lanzilotto committed Mar 4, 2024
1 parent 794fb37 commit ff182b2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 51 deletions.
6 changes: 4 additions & 2 deletions src/app/bots/bots-list/bots-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,15 @@
<div class="bot-card-info-wpr">
<span class="bot-card-bot-name-wpr">

<div class="bot-card-bot-name" (click)="$event.stopPropagation()">
<!-- (click)="$event.stopPropagation()" -->
<div class="bot-card-bot-name" >
<!-- {{ faqkb.name }} -->
<!-- (click)="edit()" -->
<span *ngIf="botIdToRename !== faqkb._id">{{ faqkb.name }}</span>
<input *ngIf="botIdToRename === faqkb._id" type="text" [(ngModel)]="faqkb.name"
(ngModelChange)="changeChatBotName($event)"
(keypress)="onPressEnterUpdateChatBotName($event)">
(click)="$event.stopPropagation()"
(keypress)="onPressEnterUpdateChatBotName($event);$event.stopPropagation() ">


</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/sidebar/sidebar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -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} ">
<a id="bot-anchor" #botbtn class="customAncor" (click)="goToAllMyChatbot()"
style="height: 40px;">
<span class="bot-icon-wpr">
Expand Down Expand Up @@ -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"
Expand Down
37 changes: 20 additions & 17 deletions src/app/components/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
});
}

Expand All @@ -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);
});
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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<KB>;
displayedColumns: string[] = ['type','status','createdAt','name','actions'];
displayedColumns: string[] = ['type', 'status', 'createdAt', 'name', 'actions'];
filterType: string;
// filterText: string;
pagConfig: any;
Expand Down Expand Up @@ -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,
Expand All @@ -76,23 +76,27 @@ 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);
}

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"
Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
// }
Expand Down

0 comments on commit ff182b2

Please sign in to comment.