[angular-16-irish-monitor | DONE | CHANGED] UserProfile service: update initialize method - not initialize in constructor
This commit is contained in:
parent
c8404f6acb
commit
e9938bc61d
|
@ -16,6 +16,8 @@ import {ErrorModule} from "./openaireLibrary/error/error.module";
|
|||
import {CookieLawModule} from "./openaireLibrary/sharedComponents/cookie-law/cookie-law.module";
|
||||
import {SearchResearchResultsServiceModule} from "./openaireLibrary/services/searchResearchResultsService.module";
|
||||
import {SearchOrcidService} from "./openaireLibrary/claims/claim-utils/service/searchOrcid.service";
|
||||
import {LoginGuard} from "./openaireLibrary/login/loginGuard.guard";
|
||||
import {HasConsentGuard} from "./shared/hasConsent.guard";
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -48,7 +50,8 @@ import {SearchOrcidService} from "./openaireLibrary/claims/claim-utils/service/s
|
|||
multi: true
|
||||
},
|
||||
[{provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true}],
|
||||
[{provide: DEFAULT_TIMEOUT, useValue: 30000}]
|
||||
[{provide: DEFAULT_TIMEOUT, useValue: 30000}],
|
||||
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 48ce09e400ba9aa3f278aa23a89fd6dd7120b3a1
|
||||
Subproject commit c6dd26dcee5de3ccb19299a03f3866ac36e70831
|
|
@ -0,0 +1,87 @@
|
|||
import {Component, OnInit} from '@angular/core';
|
||||
import {BaseComponent} from '../openaireLibrary/sharedComponents/base/base.component';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
||||
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
||||
import {Meta, Title} from '@angular/platform-browser';
|
||||
import {LogService} from "../openaireLibrary/utils/log/log.service";
|
||||
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||
import {UserProfileService} from "../openaireLibrary/services/userProfile.service";
|
||||
|
||||
@Component({
|
||||
selector: 'user-policy',
|
||||
template: `
|
||||
<div class="uk-container uk-container-large uk-margin-top">
|
||||
<h3>User Policy</h3>
|
||||
<div class="">
|
||||
<div>
|
||||
National Open Access Monitor - Ireland requires users to accept user privacy policy, to proceed with certain actions.<br>
|
||||
Please read the <a href="/assets/National Open Access Monitor, Ireland - Personal data protection policy and public logs consent form.pdf" target="_blank">user privacy policy</a>.
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" (change)="value = !value"> Accept policy</div>
|
||||
<button class="uk-button uk-button-primary uk-margin-top" [class.uk-disabled]="!value" (click)="accept()"> Accept and proceed</button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
`
|
||||
})
|
||||
export class UserPolicyComponent extends BaseComponent implements OnInit {
|
||||
redirectUrl = null;
|
||||
hasConsent = false;
|
||||
value = false;
|
||||
redirectEnabled =true;
|
||||
constructor(protected _router: Router,
|
||||
protected _route: ActivatedRoute,
|
||||
protected seoService: SEOService,
|
||||
protected _piwikService: PiwikService,
|
||||
protected _title: Title,
|
||||
protected _meta: Meta,
|
||||
private _logService:LogService,
|
||||
private userManagementsService: UserManagementService, private _userProfileService: UserProfileService) {
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.title = 'User policy';
|
||||
this.description = 'OA Monitor Ireland - User policy';
|
||||
this.setMetadata();
|
||||
this.subscriptions.push(this._route.queryParams.subscribe(params => {
|
||||
this.redirectUrl = params['redirectUrl'];
|
||||
this.redirectEnabled = params['redirect'] == 'false'?false:true;
|
||||
}));
|
||||
this.subscriptions.push(this._userProfileService.getUserProfile().subscribe(userProfile => {
|
||||
this.hasConsent = userProfile.consent;
|
||||
if(this.hasConsent && this.redirectEnabled){
|
||||
this.redirect();
|
||||
}
|
||||
}, error => {
|
||||
this.hasConsent = false;
|
||||
}));
|
||||
}
|
||||
accept(){
|
||||
this.subscriptions.push(this._userProfileService.saveConsentInUserProfile(this.properties).subscribe(userProfile => {
|
||||
this._userProfileService.setUserProfile(userProfile);
|
||||
this.redirect();
|
||||
}));
|
||||
}
|
||||
undo(){
|
||||
this.subscriptions.push(this._userProfileService.undoConsentInUserProfile(this.properties).subscribe(userProfile => {
|
||||
this._userProfileService.setUserProfile(userProfile);
|
||||
}));
|
||||
}
|
||||
redirect() {
|
||||
//if parameters are not read yet, force them to use the function parameter
|
||||
if (this.redirectUrl && this.redirectUrl != "") {
|
||||
this.redirectUrl = decodeURIComponent(this.redirectUrl);
|
||||
this.userManagementsService.setRedirectUrl(this.redirectUrl);
|
||||
this._router.navigate(['/reload']);
|
||||
}else{
|
||||
this._router.navigate(['/']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {UserPolicyComponent} from "./user-policy.component";
|
||||
import {LogServiceModule} from "../openaireLibrary/utils/log/LogService.module";
|
||||
import {Route, RouterModule} from "@angular/router";
|
||||
|
||||
const routes: Route[] = [
|
||||
{
|
||||
path: '', component: UserPolicyComponent
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [UserPolicyComponent],
|
||||
imports: [
|
||||
CommonModule, RouterModule.forChild(routes), LogServiceModule, RouterModule
|
||||
],
|
||||
exports: [UserPolicyComponent]
|
||||
})
|
||||
export class UserPolicyModule { }
|
Loading…
Reference in New Issue