Skip to content

Commit

Permalink
Manages the home section "YOUR CURRENT CHATBOT DESIGN" when no chatbo…
Browse files Browse the repository at this point in the history
…t has been created yet
  • Loading branch information
Nicola Lanzilotto committed Jan 2, 2024
1 parent 9e09729 commit 6dfc3c0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 42 deletions.
16 changes: 2 additions & 14 deletions src/app/components/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,20 +751,8 @@ export class NavbarComponent implements OnInit, AfterViewInit, AfterContentCheck

this.logger.log('[NAVBAR] -> OPERATING_HOURS_ACTIVE ', this.OPERATING_HOURS_ACTIVE);
}
// this.prjct_profile_name = this.project.profile_name;
// this.prjct_trial_expired = this.project.trial_expired;
// this.prjc_trial_days_left = this.project.trial_days_left;
// // this.prjc_trial_days_left_percentage = ((this.prjc_trial_days_left *= -1) * 100) / 30
// this.prjc_trial_days_left_percentage = (this.prjc_trial_days_left * 100) / 30;

// // this.prjc_trial_days_left_percentage IT IS
// // A NEGATIVE NUMBER AND SO TO DETERMINE THE PERCENT IS MADE AN ADDITION
// const perc = 100 + this.prjc_trial_days_left_percentage
// this.logger.log('SIDEBAR project perc ', perc)


// this.prjc_trial_days_left_percentage = this.round5(perc)
// this.logger.log('SIDEBAR project trial days left % rounded', this.prjc_trial_days_left_percentage);

this.getProjects()
}
});
}
Expand Down
12 changes: 9 additions & 3 deletions src/app/home-components/home-cds/home-cds.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,26 @@
</div>
</div>

<div class="title-container">
<div class="title-container">
<div class="home-cds-section-title">
YOUR CURRENT CHATBOT DESIGN
</div>
<div class="home-cds-section-subtitle">
<div *ngIf="chatbots?.length > 0" class="home-cds-section-subtitle">
Open the Studio to start editing <b> {{ chatbotName }} </b> chatbot
</div>
<div *ngIf="chatbots?.length === 0" class="home-cds-section-subtitle">
You don't have any chatbot yet
</div>
</div>

<div class="button-container">
<button class="btn btn-size-xl btn-p btn-p-ripple" style="background: #2196f3;" (click)="goToBotProfile()">
<span>
<span *ngIf="chatbots?.length > 0">
Edit chatbot
</span>
<span *ngIf="chatbots?.length === 0">
Create your first chatbot
</span>
</button>
</div>

Expand Down
52 changes: 30 additions & 22 deletions src/app/home-components/home-cds/home-cds.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from 'app/core/auth.service';
import { Chatbot } from 'app/models/faq_kb-model';
Expand All @@ -16,7 +16,7 @@ import { takeUntil } from 'rxjs/operators'
styleUrls: ['./home-cds.component.scss']
})
export class HomeCdsComponent implements OnInit {

@Output() goToCreateChatbot = new EventEmitter();
private unsubscribe$: Subject<any> = new Subject<any>();
USER_ROLE: string;
projectId: string;
Expand All @@ -26,6 +26,7 @@ export class HomeCdsComponent implements OnInit {
chatbots: Array<Chatbot> = [];
chatbotName: string;
lastUpdatedChatbot: Chatbot;


constructor(
public appConfigService: AppConfigService,
Expand Down Expand Up @@ -106,23 +107,26 @@ export class HomeCdsComponent implements OnInit {

getProjectBots(storage, uploadEngineIsFirebase) {
this.faqKbService.getFaqKbByProjectId().subscribe((faqKb: any) => {

faqKb.sort(function compare(a: Chatbot, b: Chatbot) {
if (a['updatedAt'] > b['updatedAt']) {
return -1;
}
if (a['updatedAt'] < b['updatedAt']) {
return 1;
}
return 0;
});

this.logger.log('[HOME-CDS] - GET FAQKB RES (sorted)', faqKb);

this.chatbotName = faqKb[0].name
this.lastUpdatedChatbot = faqKb[0]
this.logger.log('[HOME-CDS] - GET FAQKB lastUpdatedChatbot', this.lastUpdatedChatbot);

this.chatbots = faqKb
if (this.chatbots && this.chatbots.length > 0) {

this.chatbots.sort(function compare(a: Chatbot, b: Chatbot) {
if (a['updatedAt'] > b['updatedAt']) {
return -1;
}
if (a['updatedAt'] < b['updatedAt']) {
return 1;
}
return 0;
});

this.logger.log('[HOME-CDS] - GET FAQKB RES (sorted)', this.chatbots);

this.chatbotName = this.chatbots[0].name;
this.lastUpdatedChatbot = this.chatbots[0];
this.logger.log('[HOME-CDS] - lastUpdatedChatbot ', this.lastUpdatedChatbot);
this.logger.log('[HOME-CDS] - GET FAQKB lastUpdatedChatbot', this.lastUpdatedChatbot);
}

}, (error) => {
this.logger.error('[HOME-CDS] - GET FAQKB - ERROR ', error);
Expand All @@ -134,9 +138,13 @@ export class HomeCdsComponent implements OnInit {

goToBotProfile() {
if (this.USER_ROLE !== 'agent') {
// this.router.navigate(['project/' + this.project._id + '/tilebot/intents/', bot_id, botType]);
// this.router.navigate(['project/' + this.projectId + '/cds/', bot._id, 'intent', '0', 'h']);
goToCDSVersion(this.router, this.lastUpdatedChatbot, this.projectId, this.appConfigService.getConfig().cdsBaseUrl)
if (this.chatbots?.length > 0) {
// this.router.navigate(['project/' + this.project._id + '/tilebot/intents/', bot_id, botType]);
// this.router.navigate(['project/' + this.projectId + '/cds/', bot._id, 'intent', '0', 'h']);
goToCDSVersion(this.router, this.lastUpdatedChatbot, this.projectId, this.appConfigService.getConfig().cdsBaseUrl)
} else if (this.chatbots?.length === 0) {
this.goToCreateChatbot.emit()
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ <h2></h2>
<ng-container *ngIf="!showskeleton ">
<span *ngIf="USER_ROLE !== 'agent'">

<home-cds> </home-cds>
<home-cds (goToCreateChatbot)="goToCreateChatbot()"> </home-cds>

<div class="home--blocks" id="homeBlocks" *ngFor="let item of child_list_order">

Expand Down Expand Up @@ -499,8 +499,10 @@ <h2></h2>
<!-- ----------------------- -->
<ng-container *ngIf="item.type === 'child5'">
<appdashboard-home-create-chatbot #childCreateChatbot *ngIf="displayCreateChatbot"
[use_case_for_child]="use_case_for_child" [solution_channel_for_child]="solution_channel_for_child"
[waBotId]="waBotId" [wadepartmentName]="wadepartmentName"
[use_case_for_child]="use_case_for_child"
[solution_channel_for_child]="solution_channel_for_child"
[waBotId]="waBotId"
[wadepartmentName]="wadepartmentName"
[chatbotConnectedWithWA]="chatbotConnectedWithWA"
(botHookedToDefaultDept)="botHookedToDefaultDept($event)"
(trackUserAction)="trackUserAction($event)">
Expand Down

0 comments on commit 6dfc3c0

Please sign in to comment.