|
|
@ -28,6 +28,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
ChangeDetectionStrategy, |
|
|
|
ChangeDetectionStrategy, |
|
|
|
|
|
|
|
ChangeDetectorRef, |
|
|
|
Component, |
|
|
|
Component, |
|
|
|
Injector, |
|
|
|
Injector, |
|
|
|
OnInit, |
|
|
|
OnInit, |
|
|
@ -38,6 +39,7 @@ import { OpModalService } from 'core-app/shared/components/modal/modal.service'; |
|
|
|
import { EnterpriseTrialService } from 'core-app/features/enterprise/enterprise-trial.service'; |
|
|
|
import { EnterpriseTrialService } from 'core-app/features/enterprise/enterprise-trial.service'; |
|
|
|
import { TimezoneService } from 'core-app/core/datetime/timezone.service'; |
|
|
|
import { TimezoneService } from 'core-app/core/datetime/timezone.service'; |
|
|
|
import { distinctUntilChanged } from 'rxjs/operators'; |
|
|
|
import { distinctUntilChanged } from 'rxjs/operators'; |
|
|
|
|
|
|
|
import { HttpClient, HttpErrorResponse } from '@angular/common/http'; |
|
|
|
|
|
|
|
|
|
|
|
export const freeTrialButtonSelector = 'free-trial-button'; |
|
|
|
export const freeTrialButtonSelector = 'free-trial-button'; |
|
|
|
|
|
|
|
|
|
|
@ -53,25 +55,24 @@ export class FreeTrialButtonComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
public text = { |
|
|
|
public text = { |
|
|
|
button_trial: this.I18n.t('js.admin.enterprise.upsale.button_start_trial'), |
|
|
|
button_trial: this.I18n.t('js.admin.enterprise.upsale.button_start_trial'), |
|
|
|
confirmation_info: (date:string, email:string) => { return this.trialRequested ? this.I18n.t('js.admin.enterprise.trial.confirmation_info', { |
|
|
|
confirmation_info: (date:string, email:string) => { |
|
|
|
|
|
|
|
return this.trialRequested ? this.I18n.t('js.admin.enterprise.trial.confirmation_info', { |
|
|
|
date, |
|
|
|
date, |
|
|
|
email, |
|
|
|
email, |
|
|
|
}) : ''}, |
|
|
|
}) : '' |
|
|
|
|
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
constructor(protected I18n:I18nService, |
|
|
|
constructor(protected I18n:I18nService, |
|
|
|
protected opModalService:OpModalService, |
|
|
|
protected opModalService:OpModalService, |
|
|
|
readonly injector:Injector, |
|
|
|
readonly injector:Injector, |
|
|
|
|
|
|
|
readonly http:HttpClient, |
|
|
|
|
|
|
|
readonly cdRef:ChangeDetectorRef, |
|
|
|
public eeTrialService:EnterpriseTrialService, |
|
|
|
public eeTrialService:EnterpriseTrialService, |
|
|
|
readonly timezoneService:TimezoneService) { |
|
|
|
readonly timezoneService:TimezoneService) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
ngOnInit():void { |
|
|
|
const eeTrialKey = (window as any).gon.ee_trial_key; |
|
|
|
|
|
|
|
if (window.gon.ee_trial_key) { |
|
|
|
|
|
|
|
const savedDateStr = eeTrialKey.created.split(' ')[0]; |
|
|
|
|
|
|
|
this.created = this.timezoneService.formattedDate(savedDateStr); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.eeTrialService.userData$ |
|
|
|
this.eeTrialService.userData$ |
|
|
|
.values$() |
|
|
|
.values$() |
|
|
|
.pipe( |
|
|
|
.pipe( |
|
|
@ -79,9 +80,38 @@ export class FreeTrialButtonComponent implements OnInit { |
|
|
|
) |
|
|
|
) |
|
|
|
.subscribe((userForm) => { |
|
|
|
.subscribe((userForm) => { |
|
|
|
this.email = userForm.email; |
|
|
|
this.email = userForm.email; |
|
|
|
|
|
|
|
this.cdRef.detectChanges(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.initialize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private initialize():void { |
|
|
|
|
|
|
|
const eeTrialKey = (window as any).gon.ee_trial_key; |
|
|
|
|
|
|
|
if (window.gon.ee_trial_key) { |
|
|
|
|
|
|
|
const savedDateStr = eeTrialKey.created.split(' ')[0]; |
|
|
|
|
|
|
|
this.created = this.timezoneService.formattedDate(savedDateStr); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (eeTrialKey && !this.eeTrialService.userData$.hasValue()) { |
|
|
|
|
|
|
|
// after reload: get data from Augur using the trial key saved in gon
|
|
|
|
|
|
|
|
this.eeTrialService.trialLink = `${this.eeTrialService.baseUrlAugur}/public/v1/trials/${eeTrialKey.value}`; |
|
|
|
|
|
|
|
this.getUserDataFromAugur(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private getUserDataFromAugur():void { |
|
|
|
|
|
|
|
this.http |
|
|
|
|
|
|
|
.get<any>(`${this.eeTrialService.trialLink}/details`) |
|
|
|
|
|
|
|
.toPromise() |
|
|
|
|
|
|
|
.then((userForm:any) => { |
|
|
|
|
|
|
|
this.eeTrialService.userData$.putValue(userForm); |
|
|
|
|
|
|
|
this.eeTrialService.retryConfirmation(); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch((error:HttpErrorResponse) => { |
|
|
|
|
|
|
|
// Check whether the mail has been confirmed by now
|
|
|
|
|
|
|
|
this.eeTrialService.getToken(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
public openTrialModal():void { |
|
|
|
public openTrialModal():void { |
|
|
|
// cancel request and open first modal window
|
|
|
|
// cancel request and open first modal window
|
|
|
|
this.eeTrialService.cancelled = true; |
|
|
|
this.eeTrialService.cancelled = true; |
|
|
|