Skip to content

Commit

Permalink
Merge branch 'master-pre-prod'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Lanzilotto committed Mar 27, 2024
2 parents 201d9db + 0b5250a commit 75f4ba8
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# tiledesk-dashboard

### 2.6.5
- Deploys in production
- Improvements and bug fixing

### 2.6.4
- Deploys in production
- Improves performance
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tiledesk/tiledesk-dashboard",
"version": "2.6.4",
"version": "2.6.5",
"scripts": {
"ng": "ng",
"start": "ng serve --aot",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app-store/app-store.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ <h5 class="card-title" style="min-height: 48px;margin-bottom: 5px;">



<div class="col-xs-6 app-store-right-col-btn" (click)="goToCreateBot('external')">
<div class="col-xs-6 app-store-right-col-btn" (click)="createExternalBot('external')">
<a style="cursor: pointer;">
{{'Create' | translate}}
</a>
Expand Down
82 changes: 80 additions & 2 deletions src/app/app-store/app-store.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { takeUntil } from 'rxjs/operators'
import { Subject } from 'rxjs';
import { AppConfigService } from 'app/services/app-config.service';
import { PricingBaseComponent } from 'app/pricing/pricing-base/pricing-base.component';
import { FaqKbService } from 'app/services/faq-kb.service';
import { ChatbotModalComponent } from 'app/bots/bots-list/chatbot-modal/chatbot-modal.component';
import { MatDialog } from '@angular/material/dialog';
const swal = require('sweetalert');
const Swal = require('sweetalert2')
@Component({
Expand Down Expand Up @@ -53,6 +56,7 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
areVisiblePaidApps: boolean;
agentCannotManageAdvancedOptions: string;
learnMoreAboutDefaultRoles: string;
agentsCannotManageChatbots: string;
tPlanParams: any;
appIsAvailable: boolean = true;
appSumoProfile: string;
Expand All @@ -61,7 +65,7 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
project: any;
callingPage: string;
onlyOwnerCanManageTheAccountPlanMsg: string;

public chatBotCount: any;
constructor(
public appStoreService: AppStoreService,
private router: Router,
Expand All @@ -74,6 +78,8 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
public usersService: UsersService,
public appConfigService: AppConfigService,
public route: ActivatedRoute,
private faqKbService: FaqKbService,
public dialog: MatDialog,
) {
super(prjctPlanService, notify);
const brand = brandService.getBrand();
Expand All @@ -94,6 +100,7 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
this.getLoggedUser();
this.getRouteParams();
this.listenToParentPostMessage()
this.getFaqKbByProjectId()
}


Expand Down Expand Up @@ -278,7 +285,9 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
});

this.logger.log('sendTranscriptAppIndex ', sendTranscriptAppIndex);
this.apps.splice(sendTranscriptAppIndex, 1);
if (sendTranscriptAppIndex > -1) {
this.apps.splice(sendTranscriptAppIndex, 1);
}

this.apps.forEach(app => {
this.logger.log('APP-STORE - getApps APPS app ', app )
Expand Down Expand Up @@ -673,6 +682,47 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
window.open(url, '_blank');
}

getFaqKbByProjectId() {
this.showSpinner = true
// this.faqKbService.getAllBotByProjectId().subscribe((faqKb: any) => {
this.faqKbService.getFaqKbByProjectId().subscribe((faqKb: any) => {
this.logger.log('[APP-STORE] - GET BOTS BY PROJECT ID', faqKb);
if (faqKb) {
this.chatBotCount = faqKb.length;
}

}, (error) => {
this.logger.error('[APP-STORE] GET BOTS ERROR ', error);
this.showSpinner = false;
}, () => {
this.logger.log('[APP-STORE] GET BOTS COMPLETE');

});
}


createExternalBot(type: string) {
console.log('[APP-STORE] createExternalBot ', type)
if (this.USER_ROLE !== 'agent') {
if (this.chatBotLimit) {
if (this.chatBotCount < this.chatBotLimit) {
this.logger.log('[APP-STORE] USECASE chatBotCount < chatBotLimit')
this.goToCreateBot(type)
} else if (this.chatBotCount >= this.chatBotLimit) {
this.logger.log('[APP-STORE] USECASE chatBotCount >= chatBotLimit DISPLAY MODAL')
this.presentDialogReachedChatbotLimit()
}
} else if (!this.chatBotLimit) {
this.logger.log('[APP-STORE] USECASE NO chatBotLimit: RUN PRJCTS')
this.goToCreateBot(type)
}
} else if (this.USER_ROLE === 'agent') {
this.presentModalAgentCannotManageChatbot()
}
}



goToCreateBot(type: string) {
// this.logger.log('[BOT-TYPE-SELECT] Bot Type Selected type ', type)
if (type !== 'native' && type !== 'tilebot') {
Expand All @@ -687,6 +737,28 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
}
}

presentDialogReachedChatbotLimit() {
this.logger.log('[BOTS-LIST] openDialog presentDialogReachedChatbotLimit prjct_profile_name ', this.prjct_profile_name)
const dialogRef = this.dialog.open(ChatbotModalComponent, {
backdropClass: 'cdk-overlay-transparent-backdrop',
hasBackdrop: true,
data: {
projectProfile: this.prjct_profile_name,
subscriptionIsActive: this.subscription_is_active,
prjctProfileType: this.prjct_profile_type,
trialExpired: this.trial_expired
},
});

dialogRef.afterClosed().subscribe(result => {
this.logger.log(`[BOTS-LIST] Dialog result: ${result}`);
});
}

presentModalAgentCannotManageChatbot() {
this.notify.presentModalAgentCannotManageChatbot(this.agentsCannotManageChatbots, this.learnMoreAboutDefaultRoles)
}

goToCreateRasaBot() {
this.router.navigate(['project/' + this.projectId + '/bot/rasa/create']);
}
Expand Down Expand Up @@ -865,6 +937,12 @@ export class AppStoreComponent extends PricingBaseComponent implements OnInit, O
this.onlyOwnerCanManageTheAccountPlanMsg = translation
})

this.translate
.get('AgentsCannotManageChatbots')
.subscribe((translation: any) => {
this.agentsCannotManageChatbots = translation
})

}

translateCancel() {
Expand Down
4 changes: 2 additions & 2 deletions src/app/bots/bots-list/bots-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</div>

<div class="bot-type-logo-wpr" *ngIf="faqkb.type === 'external'">
<div class="bot-type-logo--img-wpr ">
<div class="bot-type-logo--img-wpr" style="top: -39px; left: 14px;">
<img class="bot-type-logo" src="assets/img/external_bot_logo.png" />
</div>
</div>
Expand Down Expand Up @@ -209,7 +209,7 @@
<div class="cl-card-second-column">
<div class="cl-card-stats-wpr">

<div class="cl-card-item-stats">
<div *ngIf="faqkb.type === 'tilebot'" class="cl-card-item-stats">
<div class="cl-card-item-stats-title">
<span *ngIf="faqkb.published"> Published </span>
<span *ngIf="!faqkb.published"> Draft </span>
Expand Down
2 changes: 1 addition & 1 deletion src/app/bots/bots-list/clone-bot/clone-bot.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h4 style="font-weight: 400;"> Choose which project you want to duplicate the ch
style="margin-top: 0px; max-width: 500px;"
[clearable]="false"
[(ngModel)]="selectedProject"
[items]="projects"
[items]="activeProjects"
bindLabel="id_project.name"
bindValue="id_project._id"
placeholder="Choose a project"
Expand Down
8 changes: 7 additions & 1 deletion src/app/bots/bots-list/clone-bot/clone-bot.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { LoggerService } from 'app/services/logger/logger.service';
})
export class CloneBotComponent implements OnInit {
public projects: any;
public activeProjects: any;
public bot_name: string;
public current_project_id: string;
public selectedProjectId: Project;
Expand All @@ -28,9 +29,14 @@ export class CloneBotComponent implements OnInit {
this.bot_name = data.botName;
this.current_project_id = data.currentProjectId
this.logger.log('[CLONE-BOT] data botName ', this.bot_name)
this.logger.log('[CLONE-BOT] data projects ', this.projects)
// console.log('[CLONE-BOT] data projects ', this.projects)
this.logger.log('[CLONE-BOT] data current_project_id ', this.current_project_id)

this.activeProjects = this.projects.filter( (project) => {
return project.id_project.status === 100
});

// console.log('[CLONE-BOT] newArray ', this.activeProjects)
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h4 style="font-weight: 400;"> Choose which project you want to install the cha
<!-- (clear)="onClearSelectedLanguage()" -->
<ng-select class="select-language-in-wizard" id="language_option"
style="margin-top: 0px; max-width: 500px;" [clearable]="false" [(ngModel)]="selectedProject"
[items]="projects" bindLabel="id_project.name" bindValue="id_project._id" groupBy="type"
[items]="activeProjects" bindLabel="id_project.name" bindValue="id_project._id" groupBy="type"
placeholder="Choose a project" (change)="onSelectProject(selectedProject)">
</ng-select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class GetStartChatbotForkComponent implements OnInit {
public templateImg: string;
public templateNameOnSite: string;
public projects: Project[];
public activeProjects : Project[];
public botid: string;
public selectedProjectId: string;
public projectname: string;
Expand Down Expand Up @@ -194,22 +195,26 @@ export class GetStartChatbotForkComponent implements OnInit {
if (projects) {
this.projects = projects;

if (this.projects && this.projects.length === 1) {
this.activeProjects = this.projects.filter( (project) => {
return project.id_project.status === 100
});

if (this.activeProjects && this.activeProjects.length === 1) {
// console.log('[GET START CHATBOT FORK] USE-CASE PROJECTS NO = 1')
this.projectName = this.projects[0].id_project.name
this.selectedProjectId = this.projects[0].id_project._id
this.projectName = this.activeProjects[0].id_project.name
this.selectedProjectId = this.activeProjects[0].id_project._id
// console.log('[GET START CHATBOT FORK] this.project ', this.selectedProjectId)
this.project = this.projects[0].id_project;
this.project = this.activeProjects[0].id_project;
// console.log('[GET START CHATBOT FORK] this.project ', this.project)
this.getProjectBotsByPassingProjectId(this.selectedProjectId);
this.getProjectPlan(this.project)
this.trackGroup(this.selectedProjectId)
}
if (projectid) {
// console.log('[GET START CHATBOT FORK] USE-CASE PROJECTS NO > 1' , projectid)
if (this.projects && this.projects.length > 1) {
if (this.activeProjects && this.activeProjects.length > 1) {
// console.log('[GET START CHATBOT FORK] USE-CASE PROJECTS NO > 1')
projects.forEach(project => {
this.activeProjects.forEach(project => {
if (project.id_project.id === projectid) {
this.project = project.id_project
// console.log('[GET START CHATBOT FORK] this.project ', this.project)
Expand Down

0 comments on commit 75f4ba8

Please sign in to comment.