Skip to content

Commit

Permalink
Merge branch 'master-pre' into features/slug-PRE
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Panico committed Jan 8, 2025
2 parents c950d7e + f042266 commit 3a1b3c3
Show file tree
Hide file tree
Showing 22 changed files with 620 additions and 35 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
### **Copyrigth**:
*Tiledesk SRL*


# 1.25.0-rc.3
- **added**: intent and chatbot only agents visibility

# 1.25.0-rc.2
- **changed**: action-record translations and default values

# 1.25.1

# 1.25.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,59 @@ <h3 class="card_title__underlined">
</div>
</div>

<!-- <div class="row"> -->
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8">
<span style="color: #9aa0a6;font-size: 12px;font-weight: 400;">
{{'ManageTheBotIn' | translate}}
<span class="custom-link" (click)="goToRoutingAndDepts()">
{{'RoutingAndDepts' | translate}}
</span>
</span>
</div>
<!-- </div> -->

</div>
<div class="row">



<!-- ---------------------------------------------------------- -->
<!-- Agents available -->
<!-- ---------------------------------------------------------- -->
<div *ngIf="isVisibleDEP === true" class="row" style="margin-bottom: 4px; margin-top: 30px;">

<div class="col-sm-10 col-md-10">
<h3 class="card_title__underlined">
<span class="card_title__underline">
{{ 'Agents available' | translate }}
</span>
</h3>
</div>

<div class="col-sm-10 col-md-10">
<div class="section-subtitle"></div>
</div>

<div class="col-sm-10 col-md-10 nw-onoffswitch-wrapper" style="clear: both; display: inline-block;">
<div class="nw-onoffswitch">
<input type="checkbox" name="agents_available_switch"
class="nw-onoffswitch-checkbox" id="agents_available_switch"
[(ngModel)]="selectedChatbot.agents_available"
(change)="onAgentsAvailableChange($event)">
<label class="nw-onoffswitch-label" for="agents_available_switch"></label>
</div>
<span class="checkmark" style="line-height: 25px; margin: 20px 20px 10px; float: left;">
{{ 'Available to agents' | translate }}
</span>
</div>

<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8">
<span style="color: #9aa0a6;font-size: 12px;font-weight: 400;">
{{'ManageTheBotIn' | translate}}
<span class="custom-link" (click)="goToRoutingAndDepts()">
{{'RoutingAndDepts' | translate}}
</span>
{{'A chatbot with this option is visible to agents for the purpose to be put back in the conversation' | translate}}
</span>
</div>

</div>



</div> <!-- ./ bot details -->
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,64 @@ input[type="file"] {
margin-left: 8px;
}



.custom-link {
color: #0f62ff;
cursor: pointer;
}




// --------------------
// SWITCH BTN
// --------------------
// --------- start new on-off btn logo ---------
.nw-onoffswitch {
position: relative;
width: 45px;
margin-top: 20px;
display: block;
float: left;
}
.nw-onoffswitch-checkbox {
position: absolute;
opacity: 0;
pointer-events: none;
}
.nw-onoffswitch-label {
display: block;
overflow: hidden;
cursor: pointer;
height: 25px;
padding: 0;
line-height: 25px;
border: 2px solid #e3e3e3;
border-radius: 25px;
background-color: #ffffff;
transition: background-color 0.3s ease-in;
}
.nw-onoffswitch-label:before {
content: "";
display: block;
width: 25px;
margin: 0px;
background: #ffffff;
position: absolute;
top: 0;
bottom: 0;
right: 20px;
border: 2px solid #e3e3e3;
border-radius: 25px;
transition: all 0.3s ease-in 0s;
}
.nw-onoffswitch-checkbox:checked + .nw-onoffswitch-label {
background-color: var(--blu);
}
.nw-onoffswitch-checkbox:checked + .nw-onoffswitch-label,
.nw-onoffswitch-checkbox:checked + .nw-onoffswitch-label:before {
border-color: var(--blu);
}
.nw-onoffswitch-checkbox:checked + .nw-onoffswitch-label:before {
right: 0px;
}
// --------- ./end new on-off btn logo ---------
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
dept_id: string;
selected_dept_id: string;
selected_dept_name: string;

user: UserModel
imageURL: string;

Expand Down Expand Up @@ -96,9 +95,18 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
ngOnChanges() {
this.logger.log('[CDS-CHATBOT-DTLS] (OnChanges) selectedChatbot ', this.selectedChatbot)
this.destructureSelectedChatbot(this.selectedChatbot)
this.patchAgensAvailable();
}


private patchAgensAvailable(){
if(this.selectedChatbot && this.selectedChatbot.agents_available != false){
this.selectedChatbot.agents_available = true;
}
}



getDeptsByProjectId() {
this.departmentService.getDeptsByProjectId().subscribe({ next: (departments: any) => {
this.logger.log('[CDS-CHATBOT-DTLS] - DEPT GET DEPTS ', departments);
Expand Down Expand Up @@ -528,7 +536,6 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
editBot() {
// RESOLVE THE BUG 'edit button remains focused after clicking'
this.elementRef.nativeElement.blur();

// this.logger.log('[CDS-CHATBOT-DTLS] FAQ KB NAME TO UPDATE ', this.faqKb_name);
this.faqKbService.updateFaqKb(this.selectedChatbot).subscribe({next:(faqKb) => {
this.logger.log('[CDS-CHATBOT-DTLS] EDIT BOT - FAQ KB UPDATED ', faqKb);
Expand All @@ -549,14 +556,37 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
}
// =========== NOTIFY ERROR ===========
this.notify.showWidgetStyleUpdateNotification(this.translationsMap.get('CDSSetting.UpdateBotError'), 4, 'report_problem');
}, complete: () => {
this.logger.log('[CDS-CHATBOT-DTLS] EDIT BOT - * COMPLETE *');
// =========== NOTIFY SUCCESS===========
this.notify.showWidgetStyleUpdateNotification(this.translationsMap.get('CDSSetting.UpdateBotSuccess'), 2, 'done');
}});
}


editBotAgentsAvailable() {
// RESOLVE THE BUG 'edit button remains focused after clicking'
this.elementRef.nativeElement.blur();
// this.logger.log('[CDS-CHATBOT-DTLS] FAQ KB NAME TO UPDATE ', this.faqKb_name);
this.faqKbService.updateFaqKbAgentsAvailable(this.selectedChatbot._id, this.selectedChatbot.agents_available).subscribe({next:(faqKb) => {
this.logger.log('[CDS-CHATBOT-DTLS] EDIT BOT - FAQ KB UPDATED ', faqKb);
if (faqKb) {
this.selectedChatbot.name = faqKb['name']
this.selectedChatbot.description = faqKb['description']
}
}, error: (error) => {
this.logger.error('[CDS-CHATBOT-DTLS] EDIT BOT - ERROR ', error);
// =========== NOTIFY ERROR ===========
this.notify.showWidgetStyleUpdateNotification(this.translationsMap.get('CDSSetting.UpdateBotError'), 4, 'report_problem');
}, complete: () => {
this.logger.log('[CDS-CHATBOT-DTLS] EDIT BOT - * COMPLETE *');
// =========== NOTIFY SUCCESS===========
this.notify.showWidgetStyleUpdateNotification(this.translationsMap.get('CDSSetting.UpdateBotSuccess'), 2, 'done');
this.selectedChatbot.name
}});
}


goToRoutingAndDepts() {
let redirecturl = this.appConfigService.getConfig().dashboardBaseUrl + '#/project/'+ this.project._id + '/departments'
window.open(redirecturl, '_blank')
Expand All @@ -567,4 +597,14 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
window.open(redirecturl, '_blank')
}


onAgentsAvailableChange(event: Event): void {
const checkbox = event.target as HTMLInputElement;
const isAgentsAvailable = checkbox.checked;
this.logger.log('[CDS-CHATBOT-DTLS] isAgentsAvailable: ',isAgentsAvailable);
this.selectedChatbot.agents_available = isAgentsAvailable;
this.editBotAgentsAvailable();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
(deleteIntent)="onDeleteIntent($event)">
</cds-intent>



<cds-event *ngFor="let intent of listOfEvents"
[id]="intent.intent_id"
Expand Down Expand Up @@ -102,6 +101,15 @@
(saveButton)=onSaveButton($event)>
</cds-panel-button-configuration>

<cds-panel-intent-detail *ngIf="IS_OPEN_PANEL_INTENT_DETAIL"
id="intent-detail"
class="cds-generic-panel"
[project_id]="projectID"
[intentSelected]="elementIntentSelected"
(closePanel)="closeAllPanels()"
(savePanelIntentDetail)="onSavePanelIntentDetail($event)">
</cds-panel-intent-detail>


<cds-panel-action-detail *ngIf="IS_OPEN_PANEL_ACTION_DETAIL"
id="action-detail"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { LOGOS_ITEMS } from './../../utils-resources';
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';

import { TYPE_ACTION } from 'src/app/chatbot-design-studio/utils-actions';

// const swal = require('sweetalert');

@Component({
Expand Down Expand Up @@ -116,6 +118,9 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{
private logger: LoggerService = LoggerInstance.getInstance()


IS_OPEN_PANEL_INTENT_DETAIL: boolean = false;
startDraggingPosition: any = null;

constructor(
private intentService: IntentService,
private stageService: StageService,
Expand Down Expand Up @@ -345,6 +350,18 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{

});

/** SUBSCRIBE TO THE STATE INTENT DETAIL PANEL */
// this.subscriptionOpenDetailPanel = this.controllerService.isOpenIntentDetailPanel$.subscribe((element: Intent) => {
// if (element) {
// this.closeAllPanels();
// this.IS_OPEN_PANEL_ACTION_DETAIL = true;
// this.removeConnectorDraftAndCloseFloatMenu();
// } else {
// this.IS_OPEN_PANEL_ACTION_DETAIL = false;
// }
// this.logger.log('[CDS-CANVAS] isOpenActionDetailPanel ', element, this.IS_OPEN_PANEL_ACTION_DETAIL);
// });

/** SUBSCRIBE TO THE STATE ACTION DETAIL PANEL */
this.subscriptionOpenDetailPanel = this.controllerService.isOpenActionDetailPanel$.subscribe((element: { type: TYPE_INTENT_ELEMENT, element: Action | string | Form }) => {
this.elementIntentSelected = element;
Expand Down Expand Up @@ -424,10 +441,10 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{
private closeAllPanels(){
this.IS_OPEN_PANEL_WIDGET = false;
// this.IS_OPEN_PANEL_ACTION_DETAIL = false;
this.IS_OPEN_PANEL_INTENT_DETAIL = false;
this.IS_OPEN_PANEL_BUTTON_CONFIG = false;
this.IS_OPEN_PANEL_CONNECTOR_MENU = false;
this.IS_OPEN_CONTEXT_MENU = false;
// this.closePanelWidget.next();
}
private closeActionDetailPanel(){
this.IS_OPEN_PANEL_ACTION_DETAIL = false;
Expand Down Expand Up @@ -491,7 +508,7 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{
this.logger.log('[CDS-CANVAS] start-dragging ', el);
this.removeConnectorDraftAndCloseFloatMenu();
this.intentService.setIntentSelectedById(el.id);
//this.intentSelected = this.listOfIntents.find((intent) => intent.intent_id === el.id);
this.startDraggingPosition = { x: el.offsetLeft, y: el.offsetTop };
el.style.zIndex = 2;
};
document.addEventListener("start-dragging", this.listnerStartDragging, false);
Expand All @@ -516,6 +533,12 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{
const el = e.detail.element;
this.logger.log('[CDS-CANVAS] end-dragging ', el);
el.style.zIndex = 1;
this.logger.log('[CDS-CANVAS] end-dragging ', this.intentService.intentSelected.attributes.position);
this.logger.log('[CDS-CANVAS] end-dragging ', this.startDraggingPosition);
let position = this.intentService.intentSelected.attributes.position;
if(this.startDraggingPosition.x === position.x && this.startDraggingPosition.y === position.y){
this.onIntentSelected(this.intentService.intentSelected);
}
this.intentService.updateIntentSelected();
};
document.addEventListener("end-dragging", this.listnerEndDragging, false);
Expand Down Expand Up @@ -989,11 +1012,10 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{
// --------------------------------------------------------- //
/** onSelectIntent */
onSelectIntent(intent: Intent) {
// this.logger.log('[CDS-CANVAS] onSelectIntent::: ', intent);
this.logger.log('[CDS-CANVAS] onSelectIntent::: ', intent);
if (!this.hasClickedAddAction) {
this.removeConnectorDraftAndCloseFloatMenu();
}
// this.intentSelected = intent;
this.intentService.setIntentSelected(intent.intent_id);
this.posCenterIntentSelected(intent);
this.closeAllPanels();
Expand Down Expand Up @@ -1028,6 +1050,27 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{
// --------------------------------------------------------- //
// START EVENT > INTENT
// --------------------------------------------------------- //



onIntentSelected(intent){
if (intent.intent_display_name === 'start' || intent.intent_display_name === 'defaultFallback') {
return;
}
this.logger.log('[CDS-CANVAS] onIntentSelected ', intent.intent_id);
this.closeAllPanels();
this.removeConnectorDraftAndCloseFloatMenu();
this.intentService.setIntentSelectedById(intent.intent_id);
this.closeActionDetailPanel();
setTimeout(() => {
this.elementIntentSelected = intent;
if(this.elementIntentSelected){

}
this.IS_OPEN_PANEL_INTENT_DETAIL = true;
}, 0);
}

/** onActionSelected **
* @ Close WHEN AN ACTION IS SELECTED FROM AN INTENT
* - actions context menu (static & float)
Expand Down Expand Up @@ -1121,15 +1164,13 @@ export class CdsCanvasComponent implements OnInit, AfterViewInit{
// } else {
// this.IS_OPEN_PANEL_WIDGET = !this.IS_OPEN_PANEL_WIDGET;
// }

if(this.IS_OPEN_PANEL_WIDGET){
this.controllerService.closeActionDetailPanel();
this.controllerService.closeButtonPanel();
// this.intentService.setLiveActiveIntent(null);
this.controllerService.closeAddActionMenu();
this.connectorService.removeConnectorDraft();
}

if(intent){
// this.intentSelected = intent;
this.intentService.setIntentSelectedById(intent.intent_id);
Expand Down
Loading

0 comments on commit 3a1b3c3

Please sign in to comment.