From b6f32533a20111d8fe99addaf9c5be8f4c71c4d8 Mon Sep 17 00:00:00 2001 From: Gabriele Panico Date: Tue, 31 Oct 2023 09:14:25 +0100 Subject: [PATCH] minor improvements --- src/app/app.component.ts | 19 ++++++++++++------- .../textarea/textarea.component.ts | 2 +- src/app/guards/auth.guard.ts | 4 ++-- src/app/guards/role.guard.ts | 6 ++++-- src/app/services/knowledge-base.service.ts | 2 +- src/app/services/openai.service.ts | 2 +- src/app/services/projects.service.ts | 2 +- src/app/services/users.service.ts | 2 +- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 845992de..de4c8322 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -91,24 +91,22 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { let serverBaseURL = this.appConfigService.getConfig().apiUrl this.tiledeskAuthService.initialize(serverBaseURL); - this.projectService.initialize(serverBaseURL); - this.uploadService.initialize(); + // this.departmentService.initialize(serverBaseURL, this.project._id); // this.faqKbService.initialize(serverBaseURL, this.project._id) // this.faqService.initialize(serverBaseURL, this.project._id) // this.kbService.initialize(serverBaseURL, this.project._id) // this.openaiService.initialize(serverBaseURL, this.project._id) // this.whatsappService.initialize(serverBaseURL, this.project._id) - this.multiChannelService.initialize(serverBaseURL) - this.userService.initialize(serverBaseURL) - - - // const getUrlParams = await this.dashboardService.getUrlParams(); // this.logger.log('[CDS DSHBRD] Risultato 2:', getUrlParams); await this.initAuthentication(); this.setLanguage(null); + // this.projectService.initialize(serverBaseURL); + // this.multiChannelService.initialize(serverBaseURL) + // this.userService.initialize(serverBaseURL) + // this.uploadService.initialize(); } @@ -251,6 +249,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { initAuthentication() { const tiledeskToken = localStorage.getItem('tiledesk_token') + let serverBaseURL = this.appConfigService.getConfig().apiUrl + this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ') this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken) // const currentUser = JSON.parse(this.appStorageService.getItem('currentUser')); @@ -261,6 +261,11 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { this.logger.log('[APP-COMP] >>> initAuthentication user ', user) this.updateStoredCurrentUser() + this.projectService.initialize(serverBaseURL); + this.multiChannelService.initialize(serverBaseURL) + this.userService.initialize(serverBaseURL) + this.uploadService.initialize(); + this.IS_ONLINE = true; }).catch(error => { this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::', error) diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/textarea/textarea.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/textarea/textarea.component.ts index 2db52f7c..4f4d4a65 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/textarea/textarea.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/textarea/textarea.component.ts @@ -100,7 +100,7 @@ export class CDSTextareaComponent implements OnInit { } onChangeTextArea(event) { - // this.logger.log('[CDS-TEXAREA] onChangeTextarea-->', event, this.readonly); + this.logger.log('[CDS-TEXAREA] onChangeTextarea-->', event, this.readonly); this.calculatingleftCharsText(); // console.log('onChangeTextarea!! ',event); if(this.readonly && event){ diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index e68d4804..4a19d4be 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -27,14 +27,14 @@ export class AuthGuard implements CanActivate { // if(!queryParams){ // return false // } - const storedTiledeskoken = this.appStorageService.getItem('tiledeskToken') + const storedTiledeskoken = localStorage.getItem('tiledesk_token') if(!queryParams && !storedTiledeskoken){ //goToSignIn Dashboard return false } var isAuthenticated = await this.tiledeskAuthService.isLoggedIn(); - console.log('isAuthenticated-->', isAuthenticated) + console.log('[AUTH-GUARD] isAuthenticated-->', isAuthenticated) if (!isAuthenticated) { //goToSignIn Dashboard return false diff --git a/src/app/guards/role.guard.ts b/src/app/guards/role.guard.ts index b63af0cd..6d9cc364 100644 --- a/src/app/guards/role.guard.ts +++ b/src/app/guards/role.guard.ts @@ -29,7 +29,9 @@ export class RoleGuard implements CanActivate { /** CHECK USER IS LOGGED IN */ const queryParams = route.queryParams['jwt'] - const storedTiledeskoken = this.appStorageService.getItem('tiledeskToken') + console.log('[ROLE-GUARD] -->', queryParams) + + const storedTiledeskoken = localStorage.getItem('tiledesk_token') if(!queryParams && !storedTiledeskoken){ //goToSignIn Dashboard return false @@ -44,7 +46,7 @@ export class RoleGuard implements CanActivate { const projectId= route.params.projectid const user = this.tiledeskAuthService.getCurrentUser() const userIsInProject = await this.getProjectUserInProject(projectId, user.uid) - console.log('userIsInProject-->', userIsInProject) + console.log('[ROLE-GUARD] userIsInProject-->', userIsInProject) if(!userIsInProject){ this.router.navigate([`project/${projectId}/unauthorized`]); return false diff --git a/src/app/services/knowledge-base.service.ts b/src/app/services/knowledge-base.service.ts index 22671112..07583d92 100644 --- a/src/app/services/knowledge-base.service.ts +++ b/src/app/services/knowledge-base.service.ts @@ -29,7 +29,7 @@ export class KnowledgeBaseService { } initialize(serverBaseUrl: string, project_id: string){ - this.logger.log('[TILEDESK-AUTH-SERV] - initialize serverBaseUrl', serverBaseUrl); + this.logger.log('[KNOWLEDGE BASE SERVICE] - initialize serverBaseUrl', serverBaseUrl); this.project_id = project_id; this.SERVER_BASE_URL = serverBaseUrl; this.URL_TILEDESK_KNB = this.SERVER_BASE_URL + this.project_id diff --git a/src/app/services/openai.service.ts b/src/app/services/openai.service.ts index 0c7c5d24..e79772a3 100644 --- a/src/app/services/openai.service.ts +++ b/src/app/services/openai.service.ts @@ -30,7 +30,7 @@ export class OpenaiService { } initialize(serverBaseUrl: string, project_id: string){ - this.logger.log('[TILEDESK-AUTH-SERV] - initialize serverBaseUrl', serverBaseUrl); + this.logger.log('[OPENAI.SERVICE] - initialize serverBaseUrl', serverBaseUrl); this.project_id = project_id; this.SERVER_BASE_URL = serverBaseUrl; this.URL_TILEDESK_OPENAI = this.SERVER_BASE_URL + this.project_id diff --git a/src/app/services/projects.service.ts b/src/app/services/projects.service.ts index 2afaea35..3db12f8a 100644 --- a/src/app/services/projects.service.ts +++ b/src/app/services/projects.service.ts @@ -36,7 +36,7 @@ export class ProjectService { } initialize(serverBaseUrl: string) { - this.logger.log('[TILEDESK-AUTH-SERV] - initialize serverBaseUrl', serverBaseUrl); + this.logger.log('[TILEDESK-PROJECTS-SERV] - initialize serverBaseUrl', serverBaseUrl); this.SERVER_BASE_URL = serverBaseUrl; this.URL_TILEDESK_PROJECTS = this.SERVER_BASE_URL + 'projects/'; this.tiledeskToken = this.appStorageService.getItem('tiledeskToken') diff --git a/src/app/services/users.service.ts b/src/app/services/users.service.ts index 839df000..c9fc53f8 100755 --- a/src/app/services/users.service.ts +++ b/src/app/services/users.service.ts @@ -87,7 +87,7 @@ export class UsersService { } initialize(serverBaseUrl: string){ - this.logger.log('[TILEDESK-AUTH-SERV] - initialize serverBaseUrl', serverBaseUrl); + this.logger.log('[USER-SERV] - initialize serverBaseUrl', serverBaseUrl); this.SERVER_BASE_URL = serverBaseUrl; this.tiledeskToken = this.appStorageService.getItem('tiledeskToken') }