Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Panico committed Oct 31, 2023
1 parent 4645553 commit b6f3253
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
19 changes: 12 additions & 7 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}

Expand Down Expand Up @@ -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'));
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
4 changes: 2 additions & 2 deletions src/app/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/app/guards/role.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/knowledge-base.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/openai.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down

0 comments on commit b6f3253

Please sign in to comment.