diff --git a/src/app/components/navbar/navbar.component.ts b/src/app/components/navbar/navbar.component.ts index feeb3e1fe9bb..8ba7af4110d1 100755 --- a/src/app/components/navbar/navbar.component.ts +++ b/src/app/components/navbar/navbar.component.ts @@ -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() } }); } diff --git a/src/app/home-components/home-cds/home-cds.component.html b/src/app/home-components/home-cds/home-cds.component.html index da17ef4b9564..e0bf4023d0de 100644 --- a/src/app/home-components/home-cds/home-cds.component.html +++ b/src/app/home-components/home-cds/home-cds.component.html @@ -29,20 +29,26 @@ -
+
YOUR CURRENT CHATBOT DESIGN
-
+
Open the Studio to start editing {{ chatbotName }} chatbot
+
+ You don't have any chatbot yet +
diff --git a/src/app/home-components/home-cds/home-cds.component.ts b/src/app/home-components/home-cds/home-cds.component.ts index cb41c35e0805..3f2261f6ee63 100644 --- a/src/app/home-components/home-cds/home-cds.component.ts +++ b/src/app/home-components/home-cds/home-cds.component.ts @@ -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'; @@ -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 = new Subject(); USER_ROLE: string; projectId: string; @@ -26,6 +26,7 @@ export class HomeCdsComponent implements OnInit { chatbots: Array = []; chatbotName: string; lastUpdatedChatbot: Chatbot; + constructor( public appConfigService: AppConfigService, @@ -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); @@ -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() + } } } diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index edf320f5d539..22cc06c74dc4 100755 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -426,7 +426,7 @@

- +
@@ -499,8 +499,10 @@