Skip to content

Commit

Permalink
Handles the loading of the Changelog script
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Lanzilotto committed Jan 28, 2025
1 parent 688c261 commit 43cb86e
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 46 deletions.
30 changes: 28 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
private notify: NotifyService,
public usersLocalDbService: LocalDbService,
private projectService: ProjectService,

private sleekplanSsoService: SleekplanSsoService,
private sleekplanService: SleekplanService,
private sleekplanApiService: SleekplanApiService
Expand Down Expand Up @@ -181,6 +180,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.logger.log('[APP-COMPONENT] getConfig chatEngine', appConfigService.getConfig().chatEngine)
this.logger.log('[APP-COMPONENT] getConfig uploadEngine', appConfigService.getConfig().uploadEngine)
this.logger.log('[APP-COMPONENT] getConfig pushEngine', appConfigService.getConfig().pushEngine)


// if (appConfigService.getConfig().chatEngine && appConfigService.getConfig().chatEngine !== 'mqtt') {
if (appConfigService.getConfig().uploadEngine === 'firebase' || appConfigService.getConfig().chatEngine === 'firebase' || appConfigService.getConfig().pushEngine === 'firebase') {
this.logger.log('[APP-COMPONENT] - WORKS WITH FIREBASE ')
Expand Down Expand Up @@ -708,6 +709,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
}

sleekplanSso(user) {
this.logger.log('[APP-COMP] calling sleekplanSso ')

// this.logger.log('APP-COMP sleekplanSso ')
// window['$sleek'].setUser = {
// mail: user.email,
Expand Down Expand Up @@ -753,10 +756,33 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
);
}

getPAYValue() {
this.public_Key = this.appConfigService.getConfig().t2y12PruGU9wUtEGzBJfolMIgK;

let parts = this.public_Key.split('-');
// this.logger.log('[BOTS-SIDEBAR] getAppConfig parts ', parts);

let pay = parts.find((part) => part.startsWith('PAY'));
this.logger.log('[APP-COMPONENT] pay ', pay);
let payParts = pay.split(':');
this.logger.log('[APP-COMPONENT] payParts ', payParts);
let payValue = payParts[1]
this.logger.log('[APP-COMPONENT] payParts ', payParts);
if (payValue === 'T') {
return true
} else if (payValue === 'F') {
return false
}

}

getCurrentUserAndConnectToWs() {
let isActivePAY = this.getPAYValue()
this.auth.user_bs.subscribe((user) => {
this.logger.log('% »»» WebSocketJs WF - APP-COMPONENT - LoggedUser ', user);
if (user) {

this.logger.log('% »»» WebSocketJs WF - APP-COMPONENT - isActivePAY ', isActivePAY);
if (user && isActivePAY) {
this.sleekplanSso(user)
}
if (!user) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ <h2 class="quota-title">{{'Email' | translate}}</h2>
<!-- -------------------------------------------- -->
<!-- Sleekplan -->
<!-- -------------------------------------------- -->
<!-- <button (click)="openFeedback()">Give Feedback</button> -->

<ng-container *ngIf="isVisiblePay" style="position: relative;">
<li *ngIf="project">
<a>
Expand Down
105 changes: 62 additions & 43 deletions src/app/core/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class AuthService {
prjct_profile_name_for_segment: string;
customRedirectAfterLogout: boolean;
afterLogoutRedirectURL: string
isActivePAY: boolean;

constructor(
private _httpClient: HttpClient,
Expand All @@ -110,9 +111,12 @@ export class AuthService {
// private projectService: ProjectService,
// public myapp: AppComponent
// private prjctPlanService: ProjectPlanService,

) // public ssoService: SsoService
{

{
this.isActivePAY = this.getPAYValue()
this.logger.log('[AUTH-SERV] isActivePAY ', this.isActivePAY)
const brand = brandService.getBrand();
this.customRedirectAfterLogout = brand['custom_redirect_after_logout'];
this.logger.log('[AUTH-SERV] customRedirectAfterLogout ', this.customRedirectAfterLogout)
Expand All @@ -139,6 +143,25 @@ export class AuthService {
// this.getProjectPlan()
}

getPAYValue() {
this.public_Key = this.appConfigService.getConfig().t2y12PruGU9wUtEGzBJfolMIgK;

let parts = this.public_Key.split('-');

let pay = parts.find((part) => part.startsWith('PAY'));
this.logger.log('[AUTH-SERV] pay ', pay);
let payParts = pay.split(':');
this.logger.log('[AUTH-SERV] payParts ', payParts);
let payValue = payParts[1]
this.logger.log('[AUTH-SERV] payParts ', payParts);
if (payValue === 'T') {
return true
} else if (payValue === 'F') {
return false
}

}



browserNameAndVersion(browserName, browserVersion) {
Expand Down Expand Up @@ -568,6 +591,9 @@ export class AuthService {

}




/**
* NODEJS SIGN-IN: SIGN-IN THE USER AND CREATE THE 'OBJECT USER' INCLUDED THE RETURNED (FROM SIGNIN) JWT TOKEN
* NODEJS FIREBASE SIGN-IN: GET FIREBASE TOKEN THEN USED FOR
Expand All @@ -578,6 +604,7 @@ export class AuthService {
signin(email: string, password: string, baseUrl: string, callback) {
const self = this


const httpOptions = {
headers: new HttpHeaders({
'Accept': 'application/json',
Expand All @@ -604,11 +631,12 @@ export class AuthService {
// used in signOut > removeInstanceId
this.userId = user._id;


this.sleekplanSso(user)
// console.log('[AUTH-SERV] isActivePAY in signin ', this.isActivePAY)
this.sleekplanSso(user, this.isActivePAY)

}


// ASSIGN THE RETURNED TOKEN TO THE USER OBJECT
user.token = jsonRes['token']

Expand Down Expand Up @@ -693,8 +721,9 @@ export class AuthService {
})
}

sleekplanSso(user) {

sleekplanSso(user, isActivePAY) {
this.logger.log('[AUTH-SERV] isActivePAY in sleekplanSso ', isActivePAY)

// this.logger.log('AUT-SERV sleekplanSs')
// window['$sleek'].setUser = {
// mail: user.email,
Expand All @@ -707,44 +736,34 @@ export class AuthService {
// id: user._id,
// name: user.firstname,
// }

this.sleekplanSsoService.getSsoToken(user).subscribe(
(response) => {
this.logger.log('[Auth-SERV] sleekplanSso response ', response)
this.logger.log('[Auth-SERV] sleekplanSso response token', response['token'])
this.logger.log('[Auth-SERV] sleekplanSso response $sleek', window['$sleek'])
// Configure Sleekplan with SSO
// window['Sleekplan'] = {
// id: 'YOUR_SLEEKPLAN_ID',
// sso: response.token,
// };

// window['$sleek'].setUser({
// token: response['token'],
// });

// window.document.addEventListener('sleek:init', () => {
// window['$sleek'].setUser({ token: response['token'] });
// }, false);

// window['$sleek'].sso = { token: response['token'] }

window['SLEEK_USER'] = { token: response['token'] }

// Load the Sleekplan widget
this.sleekplanService.loadSleekplan()

// .then(() => {
// this.logger.log('[Auth-SERV] - Sleekplan successfully initialized');
// })
// .catch(err => {
// this.logger.error('[Auth-SERV] - Sleekplan initialization failed', err);
// });
},
(error) => {
this.logger.error('[Auth-SERV] - Failed to fetch Sleekplan SSO token', error);
}
);
if (isActivePAY) {
// this.logger.log('[Auth-SERV] calling sleekplanSso ')
this.sleekplanSsoService.getSsoToken(user).subscribe(
(response) => {
this.logger.log('[Auth-SERV] sleekplanSso response ', response)
this.logger.log('[Auth-SERV] sleekplanSso response token', response['token'])
this.logger.log('[Auth-SERV] sleekplanSso response $sleek', window['$sleek'])


window['SLEEK_USER'] = { token: response['token'] }

// Load the Sleekplan widget
this.sleekplanService.loadSleekplan()

// .then(() => {
// this.logger.log('[Auth-SERV] - Sleekplan successfully initialized');
// })
// .catch(err => {
// this.logger.error('[Auth-SERV] - Sleekplan initialization failed', err);
// });
},
(error) => {
this.logger.error('[Auth-SERV] - Failed to fetch Sleekplan SSO token', error);
}
);
} else {
this.logger.log('[Auth-SERV] NOT calling sleekplanSso ')
}
}


Expand Down

0 comments on commit 43cb86e

Please sign in to comment.