Skip to content

Commit

Permalink
Rajout de la route API dans le webchat service 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlaine committed Feb 1, 2024
1 parent caa49e8 commit 3a950e1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions projects/webchat/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="chatbot" *ngIf="configService.config && !configService.config.maintenanceMode">
<app-chat-widget [socketUrl]="chatbotSocket"
[chatbotUrl]="chatbotUrl"
[botAvatar]="chatbotUrl + '/media/' + configService.config.icon"
[companyLogo]="configService.config.embeddedIcon ? chatbotUrl + '/media/' + configService.config.embeddedIcon : null"
[botName]="configService.config.name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class ChatMessagesComponent implements OnInit, OnDestroy {
@Input() isMobileSize: boolean;
@Input() storage: string;
@Input() socketUrl: string;
@Input() chatbotUrl: string;
@Input() socketPath: string;
@Input() initPayload: string;
@Input() delayBetweenMessages: number;
Expand Down Expand Up @@ -73,7 +74,7 @@ export class ChatMessagesComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this._chatService.setStorage(this.storage);
this.messages = this._chatService.getConversation();
this._chatService.connect(this.socketUrl, this.socketPath, this.initPayload);
this._chatService.connect(this.socketUrl, this.socketPath, this.initPayload, this.chatbotUrl);
this._feedbackService.url = this.socketUrl;

setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h1 id="tchat-title" class="sr-only">Fenêtre de chat</h1>
[isMobileSize]="isMobileSize"
[storage]="storage"
[socketUrl]="socketUrl"
[chatbotUrl]="chatbotUrl"
[socketPath]="socketPath"
[initPayload]="initPayload"
[delayBetweenMessages]="delayBetweenMessages"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class ChatWidgetComponent implements OnInit {
@Input() public companyLogo = `https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Logo_Minist%C3%A8re_des_Arm%C3%A9es_%282020%29.svg/520px-Logo_Minist%C3%A8re_des_Arm%C3%A9es_%282020%29.svg.png`;
@Input() public userAvatar = null;
@Input() public socketUrl = 'http://localhost:5500';
@Input() public chatbotUrl: string;
@Input() public socketPath = environment.socketUrl;
@Input() public initPayload = '/phrase_presentation';
@Input() public feedbackPayload = '/phrase_feedback';
Expand Down
6 changes: 4 additions & 2 deletions projects/webchat/src/app/core/services/webchat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const ACCESSIBILITY_NAME = 'chat_accessibility';
export class WebchatService {

private _url;
private _apiUrl;
private _initPayload: string;

private _socket: any;
Expand All @@ -28,8 +29,9 @@ export class WebchatService {
constructor(private _http: HttpClient) {
}

public connect(url: string, path: string, initPayload: string) {
public connect(url: string, path: string, initPayload: string, apiUrl: string) {
this._url = url;
this._apiUrl = apiUrl;
this._initPayload = initPayload;
if (this._socket) {
this._socket.disconnect();
Expand Down Expand Up @@ -159,7 +161,7 @@ export class WebchatService {
params = params.append('getResponses', getResponses.toString());
}

return this._http.get(`${this._url}/api/public/intents`, {params});
return this._http.get(`${this._apiUrl}/api/public/intents`, {params});
}

public getSessionId() {
Expand Down

0 comments on commit 3a950e1

Please sign in to comment.