[Library]: Add user management service and change all session methods with new ones.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57058 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-09-13 07:01:19 +00:00
parent 4a541c2c6d
commit 98c98e6625
20 changed files with 1221 additions and 1000 deletions

View File

@ -1,10 +1,11 @@
import {Component, Input} from '@angular/core';
import {Router} from '@angular/router';
import {ContextsService} from './service/contexts.service';
import {ClaimContext, ClaimEntity} from './claimHelper.class';
import {ClaimEntity} from './claimHelper.class';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {EnvProperties} from '../../utils/properties/env-properties';
import {UserManagementService} from "../../services/user-management.service";
declare var UIkit: any;
@ -44,7 +45,9 @@ export class ClaimContextSearchFormComponent {
this.getCommunities();
}
constructor(private _contextService: ContextsService, private router: Router) {
constructor(private _contextService: ContextsService,
private router: Router,
private userManagementService: UserManagementService) {
}
@ -109,7 +112,8 @@ export class ClaimContextSearchFormComponent {
}
getCommunities() {
if (!Session.isLoggedIn()) {
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this.saveStateAndRedirectLogin();
} else {
@ -145,16 +149,17 @@ export class ClaimContextSearchFormComponent {
}
);
}
});
}
getCategories() {
this.loading = true;
// this.categories=[];
if (this.selectedCommunityId != '0') {
if (!Session.isLoggedIn()) {
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this.saveStateAndRedirectLogin();
} else {
if (this.categories[this.selectedCommunityId]) {
this.loading = false;
@ -178,8 +183,10 @@ export class ClaimContextSearchFormComponent {
}
);
}
});
}
}
/*
getConcepts() {
this.loading = true;
@ -218,6 +225,7 @@ export class ClaimContextSearchFormComponent {
this.loading = false;
}
}*/
/*
getSubConcepts(conceptId) {
this.loading = true;
@ -261,8 +269,10 @@ export class ClaimContextSearchFormComponent {
}
browseConcepts(categoryId) {
if (!Session.isLoggedIn()) {
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this.saveStateAndRedirectLogin();
} else {
if (this.conceptsClass[categoryId] != null) {
this.conceptsClassDisplay[categoryId] = !this.conceptsClassDisplay[categoryId];
@ -292,7 +302,7 @@ export class ClaimContextSearchFormComponent {
}
);
}
});
}
browseSubConcepts(categoryId, conceptId) {

View File

@ -6,7 +6,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import {ClaimsService} from '../service/claims.service';
import {ModalLoading} from '../../../utils/modal/loading.component';
import {AlertModal} from '../../../utils/modal/alert';
import {Session} from '../../../login/utils/helper.class';
import {Session, User} from '../../../login/utils/helper.class';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {LoginErrorCodes} from '../../../login/utils/guardHelper.class';
import {SEOService} from '../../../sharedComponents/SEO/SEO.service';
@ -16,6 +16,7 @@ import {Dates} from "../../../utils/string-utils.class";
import {HelperService} from "../../../utils/helper/helper.service";
import {Meta, Title} from "@angular/platform-browser";
import {PiwikService} from "../../../utils/piwik/piwik.service";
import {UserManagementService} from "../../../services/user-management.service";
@Component({
@ -45,7 +46,7 @@ export class DisplayClaimsComponent {
types = ["All", "Project", "Context", "Result", "User"];
@Input() fetchBy: string;
@Input() fetchId: string;
@Input() user: User;
resultsNum: number;
claims: ClaimDBRecord[];
@Input() externalPortalUrl: string = null;
@ -113,7 +114,7 @@ export class DisplayClaimsComponent {
if (this.myClaims) {
this.fetchBy = "User";
this.fetchId = Session.getUserEmail();
this.fetchId = this.user.email;
} else {
this.fetchBy = (this.fetchBy) ? this.fetchBy : params['fetchBy'];
@ -156,7 +157,7 @@ export class DisplayClaimsComponent {
}
getClaims() {
if (!Session.isLoggedIn()) {
if (!this.user) {
this.userValidMessage = "User session has expired. Please login again.";
this._router.navigate(['/user-info'], {
queryParams: {
@ -277,6 +278,7 @@ export class DisplayClaimsComponent {
this.location.go(location.pathname, this.getParametersString());
this.getClaims();
}
/*
getParameters() {
var params = {}
@ -330,7 +332,6 @@ export class DisplayClaimsComponent {
}
changeOrderby(sortby: string) {
if (sortby == this.sortby) {
this.descending = !this.descending;
@ -524,7 +525,7 @@ export class DisplayClaimsComponent {
}
batchDeleteById(ids: string[]) {
if (!Session.isLoggedIn()) {
if (!this.user) {
this.userValidMessage = "User session has expired. Please login again.";
this._router.navigate(['/user-info'], {
queryParams: {
@ -600,6 +601,7 @@ export class DisplayClaimsComponent {
}
return false;
}
totalPages(totalResults: number): number {
let totalPages: any = totalResults / (this.size);
if (!(Number.isInteger(totalPages))) {
@ -612,6 +614,7 @@ export class DisplayClaimsComponent {
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
}
private updateTitle(title: string) {
var _prefix = "";
if (!this.communityId) {
@ -621,6 +624,7 @@ export class DisplayClaimsComponent {
this._title.setTitle(_title);
this._meta.updateTag({content: _title}, "property='og:title'");
}
private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
}

View File

@ -1,5 +1,7 @@
import {Component, Input} from '@angular/core';
import {Title, Meta} from '@angular/platform-browser';
import {User} from "../../login/utils/helper.class";
import {UserManagementService} from "../../services/user-management.service";
@Component({
@ -18,7 +20,7 @@ import {Title, Meta} from '@angular/platform-browser';
<a *ngIf="!fetchBy || fetchBy != 'Context'" routerLink="/participate/claim">Claim more links?</a>
<a *ngIf="isConnect && fetchBy && fetchBy == 'Context' && externalPortalUrl" [href]="externalPortalUrl+'/participate/claim'" target="_blank">Claim more links?</a>
</div-->
<displayClaims [enableDelete]=true [myClaims]=false [isAdmin]=true [fetchBy]= "(fetchId=='openaire')?null:fetchBy" [fetchId]="(fetchId=='openaire')?null:fetchId"
<displayClaims *ngIf="user" [user]="user" [enableDelete]=true [myClaims]=false [isAdmin]=true [fetchBy]= "(fetchId=='openaire')?null:fetchBy" [fetchId]="(fetchId=='openaire')?null:fetchId"
[communityId]="(fetchBy && fetchBy == 'Context' && fetchId && fetchId!='openaire')?fetchId:null" [externalPortalUrl]=externalPortalUrl [claimsInfoURL]=claimsInfoURL></displayClaims>
</div>
</div>
@ -35,7 +37,11 @@ export class ClaimsAdminComponent {
@Input() isConnect:boolean = false;
@Input() externalPortalUrl:string;
@Input() claimsInfoURL:string;
constructor ( private _meta: Meta, private _title: Title) {
@Input() userInfoURL: string;
public user: User = null;
constructor ( private _meta: Meta, private _title: Title,
private userManagementService: UserManagementService) {
var titleConnect = "OpenAIRE Connect | Manage links ";
var title = "OpenAIRE | Manage links ";
@ -48,5 +54,8 @@ export class ClaimsAdminComponent {
}
ngOnInit() {
this.userManagementService.getUserInfo(this.userInfoURL).subscribe(user => {
this.user = user;
});
}
}

View File

@ -1,17 +1,14 @@
import {Component, ViewChild, ViewChildren, QueryList, Input, ViewEncapsulation} from '@angular/core';
import {Location} from '@angular/common';
import {ActivatedRoute, Params, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Component, QueryList, ViewChild, ViewChildren, ViewEncapsulation} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Meta, Title} from '@angular/platform-browser';
import {DataTableDirective} from 'angular-datatables';
import {Observable, Subject } from 'rxjs';
import {Subject} from 'rxjs';
import {EnvProperties} from '../../utils/properties/env-properties';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
import {RouterHelper} from '../../utils/routerHelper.class';
import {ModalSelect} from '../../utils/modal/selectModal.component';
@ -21,6 +18,7 @@ import {ClaimsByTokenService} from './claimsByToken.service';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {UserManagementService} from "../../services/user-management.service";
@Component({
@ -89,12 +87,14 @@ export class ClaimsByTokenComponent {
constructor(private route: ActivatedRoute,
private _router: Router,
private claimsByTokenService: ClaimsByTokenService,
private _meta: Meta, private _title: Title) {
private _meta: Meta, private _title: Title,
private userManagementService: UserManagementService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
this.pending_status = this.errorCodes.LOADING;
this.curated_status = this.errorCodes.LOADING;
}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
@ -146,17 +146,24 @@ export class ClaimsByTokenComponent {
}
ngAfterViewInit(): void {
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (isLoggedIn) {
$.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
if (settings.sTableId == 'table1') {
if (this.filterData(data, this.keyword1)) {
return true;
}
return false;
return !!this.filterData(data, this.keyword1);
} else if (settings.sTableId == 'table2') {
if (this.filterData(data, this.keyword2)) {
return true;
return !!this.filterData(data, this.keyword2);
}
return false;
});
} else {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
});
}
@ -201,12 +208,8 @@ export class ClaimsByTokenComponent {
});
}
filterData(row: any, query: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
filterData(row: any, query: string): boolean {
let returnValue: boolean = false;
if (query) {
for (var i = 0; i < 3; i++) {
var r = this.filterQuery(row[i], query);
@ -220,10 +223,8 @@ export class ClaimsByTokenComponent {
return false;
}
}
return true;
}
}
filterQuery(data, query) {
if (data.toLowerCase().indexOf(query.toLowerCase()) > -1) {
@ -234,8 +235,14 @@ export class ClaimsByTokenComponent {
}
refreshTable(page: number, whichTable: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
if (whichTable == "pending") {
var table = $('#table1').DataTable();
@ -255,14 +262,21 @@ refreshTable(page:number, whichTable: string) {
this.totalCuratedResults.count = info.recordsDisplay;
}
}
});
//table.mfActivePage=$event.value;
//table.setPage(table.mfActivePage, this.rowsOnPage);
}
validateJWTandToken() {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
if (this.openaireId) {
this.pending_status = this.errorCodes.LOADING;
@ -357,11 +371,18 @@ refreshTable(page:number, whichTable: string) {
this.accessStatus = "invalid";
}
}
});
}
selectApprove(id: string, event, mode: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
var value = event.currentTarget.checked;
if (value) {
@ -382,11 +403,18 @@ refreshTable(page:number, whichTable: string) {
// }
}
}
});
}
selectDisapprove(id: string, event, mode: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
var value = event.currentTarget.checked;
if (value) {
@ -407,11 +435,13 @@ refreshTable(page:number, whichTable: string) {
// }
}
}
});
}
isSelected(id: string, set: Set<string>) {
return set.has(id);
}
/*
isSelectedWrong(id:string) {
return this.selectedWrong.has(id);
@ -438,8 +468,14 @@ refreshTable(page:number, whichTable: string) {
}
cancelEditOfCuration(claim: any) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
if (claim.approved) {
//this.selectedRight_CuratedMode.add(claim.id);
@ -449,11 +485,18 @@ refreshTable(page:number, whichTable: string) {
//this.selectedWrong_CuratedMode.add(claim.id);
}
}
});
}
saveEdited(claim: any, editable_index: number) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.curated_status = this.errorCodes.LOADING;
@ -484,11 +527,18 @@ refreshTable(page:number, whichTable: string) {
);
}
}
});
}
saveChanges() {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.pending_status = this.errorCodes.LOADING;
//this.openLoading();
@ -508,17 +558,25 @@ refreshTable(page:number, whichTable: string) {
}
);
}
});
}
clearCheckboxes() {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.pending_status = this.errorCodes.LOADING;
this.selectedRight_PendingMode.clear();
this.selectedWrong_PendingMode.clear();
this.pending_status = this.errorCodes.DONE;
}
});
}
public openLoading() {
@ -526,6 +584,7 @@ refreshTable(page:number, whichTable: string) {
this.loading.open();
}
}
public closeLoading() {
if (this.loading) {
this.loading.close();

View File

@ -14,6 +14,7 @@ import {
DirectIndexRecord,
Message
} from "../../claim-utils/claimHelper.class";
import {UserManagementService} from "../../../services/user-management.service";
@Component({
selector: 'claim-insert',
@ -51,7 +52,8 @@ import {
`
})
export class ClaimInsertComponent {
constructor(private claimService: ClaimsService, private _router: Router, private route: ActivatedRoute,) {
constructor(private claimService: ClaimsService, private _router: Router, private route: ActivatedRoute,
private userManagementService: UserManagementService) {
}
ngOnInit() {
@ -93,7 +95,8 @@ export class ClaimInsertComponent {
this.errorInClaims = [];
this.insertedRecords = [];
this.errorInRecords = [];
if (!Session.isLoggedIn()) {
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
if (!user) {
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
if (this.sources != null) {
localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources));
@ -108,14 +111,16 @@ export class ClaimInsertComponent {
} else {
this.claiming = true;
const user = Session.getUserEmail();
this.loading.open();
let claims: ClaimRecord2Insert[] = [];
let directclaims: DirectIndexRecord[] = [];
for (let j = 0; j < this.sources.length; j++) { // if an external result -> direct insert in the index
const result: ClaimEntity = this.sources[j];
if (result.result && ["crossref", "datacite", "orcid"].indexOf(result.result.source) != -1) {
directclaims.push({"id": result.id, "record": ClaimInsertComponent.createDirectClaim(result, this.results)});
directclaims.push({
"id": result.id,
"record": ClaimInsertComponent.createDirectClaim(result, this.results)
});
}
}
for (let i = 0; i < this.results.length; i++) {
@ -139,11 +144,11 @@ export class ClaimInsertComponent {
for (let j = 0; j < this.sources.length; j++) {
const result: ClaimEntity = this.sources[j]; // this is a research result
if (entity.result) {
claims.push(ClaimInsertComponent.createResultClaim(result, entity, user));
claims.push(ClaimInsertComponent.createResultClaim(result, entity, user.email));
} else if (entity.context) {
claims.push(ClaimInsertComponent.createContextClaim(result, entity, user));
claims.push(ClaimInsertComponent.createContextClaim(result, entity, user.email));
} else if (entity.project) {
claims.push(ClaimInsertComponent.createProjectClaim(result, entity, user));
claims.push(ClaimInsertComponent.createProjectClaim(result, entity, user.email));
}
@ -151,15 +156,15 @@ export class ClaimInsertComponent {
if (this.inlineEntity) {
if (this.inlineEntity.result) {
if (entity.result) {
claims.push(ClaimInsertComponent.createResultClaim(this.inlineEntity, entity, user));
claims.push(ClaimInsertComponent.createResultClaim(this.inlineEntity, entity, user.email));
} else if (entity.context) {
claims.push(ClaimInsertComponent.createContextClaim(this.inlineEntity, entity, user));
claims.push(ClaimInsertComponent.createContextClaim(this.inlineEntity, entity, user.email));
} else if (entity.project) {
claims.push(ClaimInsertComponent.createProjectClaim(this.inlineEntity, entity, user));
claims.push(ClaimInsertComponent.createProjectClaim(this.inlineEntity, entity, user.email));
}
} else if (this.inlineEntity.project) {
if (entity.result) {
claims.push(ClaimInsertComponent.createProjectClaim(entity, this.inlineEntity, user));
claims.push(ClaimInsertComponent.createProjectClaim(entity, this.inlineEntity, user.email));
}
}
}
@ -199,7 +204,7 @@ export class ClaimInsertComponent {
this.isertBulkClaims(claims);
}
}
});
}
private isertBulkClaims(claims: ClaimRecord2Insert[]) {

View File

@ -1,5 +1,7 @@
import {Component, Input} from '@angular/core';
import {Meta, Title} from '@angular/platform-browser';
import {User} from "../../login/utils/helper.class";
import {UserManagementService} from "../../services/user-management.service";
@Component({
selector: 'my-claims',
@ -17,7 +19,7 @@ import {Meta, Title} from '@angular/platform-browser';
Manage your links in OpenAIRE
</div>
<div>
<displayClaims [enableDelete]=true [myClaims]=true [isAdmin]=false [showUserEmail]=false
<displayClaims *ngIf="user" [user]="user" [enableDelete]=true [myClaims]=true [isAdmin]=false [showUserEmail]=false
[claimsInfoURL]=claimsInfoURL [communityId]=communityId
[piwikSiteId]="piwikSiteId" title="My links">
</displayClaims>
@ -33,9 +35,15 @@ export class MyClaimsComponent {
@Input() claimsInfoURL: string;
@Input() communityId:string;
@Input() piwikSiteId = null;
@Input() userInfoURL: string;
public user: User = null;
constructor() {}
constructor(private userManagementService: UserManagementService) {}
ngOnInit() {}
ngOnInit() {
this.userManagementService.getUserInfo(this.userInfoURL).subscribe(user => {
this.user = user;
});
}
}

View File

@ -1,4 +1,3 @@
import {map, filter, mergeMap} from 'rxjs/operators';
import {Injectable} from '@angular/core';
import {
@ -8,44 +7,51 @@ import {
RouterStateSnapshot,
CanLoad, Route, UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs';
import {Observable, of} from 'rxjs';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service';
import {EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper';
import {StringUtils} from '../../utils/string-utils.class';
import {UserManagementService} from "../../services/user-management.service";
@Injectable()
export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
constructor(private router: Router,
private communityService: CommunityService,
private propertiesService: EnvironmentSpecificService) {}
private propertiesService: EnvironmentSpecificService,
private userManagementService: UserManagementService) {
}
check(community: string, path: string): Observable<boolean> | boolean {
let errorCode = LoginErrorCodes.NOT_LOGIN;
if (Session.isLoggedIn()) {
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) {
return true;
let email = null;
const authorized = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
if (user) {
email = user.email;
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user)) {
return of(true);
} else {
const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => res),mergeMap(properties => {
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community, Session.getUserEmail());
}),);
obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['/user-info'], {
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community,
email);
}
} else {
return of(false);
}
}), mergeMap( authorized => {
return authorized;
}));
}));
authorized.pipe(filter(authorized => !authorized)).subscribe(() => {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
'redirectUrl': path
}
}));
return obs;
}
} else {
errorCode = LoginErrorCodes.NOT_LOGIN;
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path}});
return false;
}
})});
return authorized;
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {

View File

@ -1,47 +1,49 @@
import {filter, mergeMap} from 'rxjs/operators';
import {filter, map, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router';
import {Observable} from 'rxjs';
import {Observable, of} from 'rxjs';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper';
import {UserManagementService} from "../../services/user-management.service";
@Injectable()
export class ConnectSubscriberGuard implements CanActivate {
constructor(private router: Router,
private communityService: CommunityService,
private userManagementService: UserManagementService,
private propertiesService: EnvironmentSpecificService) {}
check(community: string, path: string): Observable<boolean> | boolean {
let errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
if (!Session.isLoggedIn()) {
errorCode = LoginErrorCodes.NOT_LOGIN;
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path, communityId:community}});
return false;
} else {
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
let communityDomain = null;
//if(!community){
communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
//}
let email = null;
const subscribed = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
if (user) {
email = user.email;
let communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
if(communityDomain) {
community = communityDomain;
}
return this.communityService.isSubscribedToCommunity( community, Session.getUserEmail(), properties["adminToolsAPIURL"])
return this.communityService.isSubscribedToCommunity( community, email, properties["adminToolsAPIURL"])
} else {
return of(false);
}
}), mergeMap( authorized => {
return authorized;
}));
obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['/user-info'], {
}));
subscribed.pipe(filter(subscribed => !subscribed)).subscribe(() => {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
'redirectUrl': path,
communityId:community
}
}));
return obs;
'redirectUrl': path
}
})});
return subscribed;
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {

View File

@ -1,22 +1,35 @@
import {Injectable} from '@angular/core';
import {
Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad, Route, UrlSegment
} from '@angular/router';
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs';
import {ConnectHelper} from '../connectHelper';
import {Session} from '../../login/utils/helper.class';
import {filter, map, mergeMap} from "rxjs/operators";
import {UserManagementService} from "../../services/user-management.service";
import {EnvironmentSpecificService} from "../../utils/properties/environment-specific.service";
import {Session} from "../../login/utils/helper.class";
@Injectable()
export class IsCommunityOrAdmin implements CanActivate {
constructor(private router: Router) {
constructor(private router: Router,
private userManagementService: UserManagementService,
private propertiesService: EnvironmentSpecificService) {
}
check(community: string): Observable<boolean> | boolean {
if (community && community !== 'undefined') {
return true;
} else {
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
return this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map(user => {
return Session.isPortalAdministrator(user);
}));
}));
obs.pipe(filter( isAdmin => !isAdmin)).subscribe( () => {
this.router.navigate(['/errorCommunity']);
});
return obs;
}
}
/*
check(community: string): Observable<boolean> | boolean {
if(Session.isLoggedIn() && Session.isPortalAdministrator()) {
return true;
@ -27,10 +40,11 @@ export class IsCommunityOrAdmin implements CanActivate {
this.router.navigate(['errorcommunity']);
return false;
}
}
}*/
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.queryParams['communityId']);
}
}

View File

@ -1,9 +1,6 @@
import {Component, ViewChild, Input} from '@angular/core';
import {Component, Input} from '@angular/core';
import {Location} from '@angular/common';
import {Observable} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router';
import {ModalLoading} from '../../utils/modal/loading.component';
import {AlertModal} from '../../utils/modal/alert';
import {Session} from '../../login/utils/helper.class';
import {EnvProperties} from '../../utils/properties/env-properties';
import {MailPrefsService} from './mailPrefs.service';
@ -11,6 +8,7 @@ import {ConnectHelper} from '../connectHelper';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {UserManagementService} from "../../services/user-management.service";
declare var UIkit: any;
@ -34,7 +32,6 @@ export class MailPrefsComponent {
//public showForbiddenMessage:boolean = false;
public userValidMessage: string = "";
public savedMessage: string = "";
public fetchId: string;
private errorCodes: ErrorCodes;
@ -42,7 +39,10 @@ export class MailPrefsComponent {
@Input() showSaveResetButtons: boolean = true;
constructor (private _mailPrefsService: MailPrefsService, private route: ActivatedRoute, private _router:Router, private location: Location) {
constructor(private _mailPrefsService: MailPrefsService,
private route: ActivatedRoute, private _router: Router,
private location: Location,
private userManagementService: UserManagementService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
this.status = this.errorCodes.LOADING;
@ -57,21 +57,26 @@ export class MailPrefsComponent {
if (!this.communityId) {
this.communityId = params['communityId'];
}
this.fetchId = Session.getUserEmail();
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
this.fetchId = user.email;
this.getEmailPreferences();
});
});
});
}
getEmailPreferences() {
if(!Session.isLoggedIn()){
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
//this.userValidMessage = "User session has expired. Please login again.";
if (this.showSaveResetButtons) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
} else {
this.status = this.errorCodes.LOADING;
@ -120,13 +125,20 @@ export class MailPrefsComponent {
);
}
}
});
}
changeNotify(notification: any, checked: boolean, index: number) {
if(!Session.isLoggedIn()){
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
//this.userValidMessage = "User session has expired. Please login again.";
if (this.showSaveResetButtons) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
} else {
this.savedMessage = "";
@ -134,13 +146,20 @@ export class MailPrefsComponent {
notification.notify = checked;
this.prefsChanged[index] = true;
}
});
}
changeFrequency(index: number) {
if(!Session.isLoggedIn()){
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
//this.userValidMessage = "User session has expired. Please login again.";
if (this.showSaveResetButtons) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
} else {
this.savedMessage = "";
@ -149,14 +168,21 @@ export class MailPrefsComponent {
this.prefsChanged[index] = true;
}
}
});
}
saveNotification(index: number) {
if (this.notifications.length > 0 && this.initialNotifications.length > 0) {
if(!Session.isLoggedIn()){
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
//this.userValidMessage = "User session has expired. Please login again.";
if (this.showSaveResetButtons) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
} else {
if (JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) {
@ -184,8 +210,7 @@ export class MailPrefsComponent {
this.status = this.errorCodes.NOT_SAVED;
}
);
}
else {
} else {
/*UIkit.notification({
message : '<strong>No changes selected for '+this.notifications[index].openaireName+' email preferences<strong>',
status : 'primary',
@ -195,14 +220,21 @@ export class MailPrefsComponent {
this.savedMessage = "Notification settings for claims saved!";
}
}
});
}
}
restoreNotification(index: number) {
if(!Session.isLoggedIn()){
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
//this.userValidMessage = "User session has expired. Please login again.";
if (this.showSaveResetButtons) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
} else {
if (this.notifications.length > 0 && this.initialNotifications.length > 0) {
@ -213,7 +245,9 @@ export class MailPrefsComponent {
this.prefsChanged[index] = false;
}
}
});
}
/*
prefsChanged(index: number) : boolean {
if(this.notifications.length > 0 && this.initialNotifications.length > 0) {

View File

@ -11,14 +11,40 @@ import {
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class';
import {UserManagementService} from "../services/user-management.service";
import {EnvironmentSpecificService} from "../utils/properties/environment-specific.service";
import {filter, map, mergeMap} from "rxjs/operators";
@Injectable()
export class AdminLoginGuard implements CanActivate{
constructor(private router: Router) {
constructor(private router: Router,
private userManagementService: UserManagementService,
private propertiesService: EnvironmentSpecificService) {
}
check(path: string): boolean {
check(path: string): Observable<boolean> {
let errorCode = LoginErrorCodes.NOT_LOGIN;
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
return this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map( user => {
if(user) {
errorCode = LoginErrorCodes.NOT_ADMIN;
}
return Session.isPortalAdministrator(user);
}));
}));
obs.pipe(filter( isAdmin => !isAdmin)).subscribe( () => {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
'redirectUrl': path
}
});
});
return obs;
}
/* check(path: string): boolean {
let loggedIn = false;
let isAdmin = false;
let errorCode = LoginErrorCodes.NOT_LOGIN;
@ -38,7 +64,7 @@ export class AdminLoginGuard implements CanActivate{
});
}
return loggedIn && isAdmin;
}
}*/
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(state.url);

View File

@ -11,35 +11,37 @@ import {
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class';
import {filter, map, mergeMap} from "rxjs/operators";
import {EnvironmentSpecificService} from "../utils/properties/environment-specific.service";
import {UserManagementService} from "../services/user-management.service";
@Injectable()
export class ClaimsCuratorGuard implements CanActivate {
constructor(private router: Router) {
constructor(private router: Router,
private userManagementService: UserManagementService,
private propertiesService: EnvironmentSpecificService) {
}
check(path: string): boolean {
let loggedIn = false;
let isAuthorized = false;
check(path: string): Observable<boolean> |boolean {
let errorCode = LoginErrorCodes.NOT_LOGIN;
if (Session.isLoggedIn()) {
loggedIn = true;
if (Session.isClaimsCurator() || Session.isPortalAdministrator()) {
isAuthorized = true;
} else {
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
return this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map( user => {
if(user) {
errorCode = LoginErrorCodes.NOT_ADMIN;
}
}
if (!loggedIn || !isAuthorized) {
return Session.isClaimsCurator(user) || Session.isPortalAdministrator(user);
}));
}));
obs.pipe(filter( isAdmin => !isAdmin)).subscribe( () => {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
'redirectUrl': path
}
});
}
return loggedIn && isAuthorized;
});
return obs;
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {

View File

@ -11,26 +11,33 @@ import {
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class';
import {filter, map, mergeMap} from "rxjs/operators";
import {CommunityService} from "../connect/community/community.service";
import {UserManagementService} from "../services/user-management.service";
import {EnvironmentSpecificService} from "../utils/properties/environment-specific.service";
@Injectable()
export class LoginGuard implements CanActivate {
constructor(private router: Router) {
constructor(private router: Router,
private userManagementService: UserManagementService,
private propertiesService: EnvironmentSpecificService) {
}
check(path: string): boolean {
let loggedIn = false;
if (Session.isLoggedIn()) {
loggedIn = true;
}
if (!loggedIn) {
check(path: string): Observable<boolean> |boolean {
const loggedIn = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
return this.userManagementService.isLoggedIn(properties['userInfoUrl']).pipe(map( isLoggedIn => {
return isLoggedIn;
}));
}));
loggedIn.pipe(filter( isLoggedIn => !isLoggedIn)).subscribe( () => {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': path
}
});
}
});
return loggedIn;
}

View File

@ -18,10 +18,10 @@
<div class="uk-margin-top " *ngIf="user.role.length > 1">
<a class="uk-button uk-button-primary" href="https://aai.openaire.eu/roles/index.php"
target="_blank">Manage your roles</a> {{" "}}
<a *ngIf="isUSerManager()" class="uk-button uk-button-primary"
<a *ngIf="user && isUserManager()" class="uk-button uk-button-primary"
href="https://aai.openaire.eu/roles/admin.php"
target="_blank">Manage role requests</a>{{" "}}
<a *ngIf="isUSerManager()" class="uk-button uk-button-primary" href="https://aai.openaire.eu/registry"
<a *ngIf="user && isUserManager()" class="uk-button uk-button-primary" href="https://aai.openaire.eu/registry"
target="_blank">Manage users</a>
</div>

View File

@ -6,6 +6,7 @@ import {User,Session} from './utils/helper.class';
import {RouterHelper} from '../utils/routerHelper.class';
import {EnvProperties} from '../utils/properties/env-properties';
import {UserManagementService} from "../services/user-management.service";
@Component({
selector: 'user',
@ -30,7 +31,8 @@ export class UserComponent {
constructor( private router: Router,
private route: ActivatedRoute,
private _meta: Meta,
private _title: Title) {
private _title: Title,
private userManagementsService: UserManagementService) {
var title = "OpenAIRE | Login";
this._title.setTitle(title);
@ -46,14 +48,18 @@ export class UserComponent {
if( typeof document !== 'undefined') {
this.server = false;
}
this.loggedIn = Session.isLoggedIn();
this.user = Session.getUser();
this.userManagementsService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
this.user = user;
this.loggedIn = !!this.user;
});
this.errorMessage = "";
this.sub = this.route.queryParams.subscribe(params => {
this.errorCode = params["errorCode"];
this.redirectUrl = params["redirectUrl"];
this.loggedIn = Session.isLoggedIn();
this.user = Session.getUser();
this.userManagementsService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
this.user = user;
this.loggedIn = !!this.user;
});
this.errorMessage = "";
if(this.loggedIn && this.errorCode == '1'){
this.redirect();
@ -124,8 +130,8 @@ export class UserComponent {
}
return formattedRoles.join(", ");
}
isUSerManager(){
return Session.isUserManager();
isUserManager(){
return Session.isUserManager(this.user);
}
}

View File

@ -71,7 +71,7 @@ import{EnvProperties} from '../utils/properties/env-properties';
})
export class UserMiniComponent {
public user: User;
@Input() user: User;
public loggedIn: boolean = false;
public isAuthorized: boolean = false;
@Input() public mobileView:boolean = false ;
@ -108,14 +108,9 @@ export class UserMiniComponent {
if(!this.redirectUrl && location) {
this.redirectUrl = location.pathname;
}
if(Session.isLoggedIn()){
if(this.user){
this.loggedIn = true;
this.user = Session.getUser();
if(Session.isClaimsCurator() || Session.isPortalAdministrator()){
this.isAuthorized = true;
} else {
this.isAuthorized = false;
}
this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user);
}else {
this.loggedIn = false;
@ -126,7 +121,7 @@ export class UserMiniComponent {
}
logOut(){
if(Session.isLoggedIn()){
if(this.user){
Session.removeUser();
window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);

View File

@ -126,7 +126,8 @@ export class Session{
}
//Methods to check roles
public static isClaimsCurator():boolean {
// OLD
/* public static isClaimsCurator():boolean {
var isAuthorized = false;
if(Session.isLoggedIn()){
var roles = ["urn:geant:openaire.eu:group:Curator+-+Claim#aai.openaire.eu"]
@ -195,6 +196,33 @@ export class Session{
return isAuthorized;
}
return isAuthorized;
}*/
// NEW
public static isClaimsCurator(user: User): boolean {
return user !== null &&
user.role.indexOf('urn:geant:openaire.eu:group:Curator+-+Claim#aai.openaire.eu') !== -1;
}
public static isCommunityCurator(user: User): boolean {
return user !== null &&
user.role.indexOf('urn:geant:openaire.eu:group:Curator+-+Community#aai.openaire.eu') !== -1;
}
public static isPortalAdministrator(user: User): boolean {
return user !== null &&
user.role.indexOf('urn:geant:openaire.eu:group:Portal+Administrator#aai.openaire.eu') !== -1;
}
public static isUserManager(user: User): boolean {
return user !== null &&
user.role.indexOf('urn:geant:openaire.eu:group:User+Manager#aai.openaire.eu') !== -1;
}
public static isRegisteredUser(user: User): boolean {
return user !== null &&
user.role.indexOf('urn:geant:openaire.eu:group:Registered+User#aai.openaire.eu') !== -1;
}

View File

@ -69,7 +69,7 @@
</ng-container>
</ng-container>
<ng-container *ngIf="userMenu">
<user-mini mobileView=true [redirectUrl]="(communityId)?null:properties.afterLoginRedirectLink" [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
<user-mini [user]="user" mobileView=true [redirectUrl]="(communityId)?null:properties.afterLoginRedirectLink" [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
</ng-container>
</ul>
</div>
@ -196,7 +196,7 @@
<!-- </div> -->
<!-- <div *ngIf="userMenu" class="uk-navbar-right"> -->
<!-- <div *ngIf="userMenu" class="uk-navbar-right"> -->
<user-mini *ngIf="userMenu" [redirectUrl]="(communityId)?null:properties.afterLoginRedirectLink" [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
<user-mini [user]="user" [redirectUrl]="(communityId)?null:properties.afterLoginRedirectLink" [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
</div>
</nav>

View File

@ -1,6 +1,6 @@
import {Component, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Session} from '../login/utils/helper.class';
import {Session, User} from '../login/utils/helper.class';
import {ConfigurationService} from '../utils/configuration/configuration.service';
import {MenuItem, RootMenuItem} from './menu';
import {EnvProperties} from '../utils/properties/env-properties';
@ -23,6 +23,7 @@ export class NavigationBarComponent {
@Input() showMenu: boolean = true;
@Input() homeurl: boolean = true;
@Input() properties: EnvProperties;
@Input() user: User;
@Input() enableSearch: boolean = false;
@Input() searchRoute: string = "/search/find";
@Input() searchPlaceHolder: string = "Search for research results";
@ -38,7 +39,9 @@ export class NavigationBarComponent {
activeRouteEnabled = false;
constructor( private router: Router, private route: ActivatedRoute, private config: ConfigurationService) {
constructor(private router: Router,
private route: ActivatedRoute,
private config: ConfigurationService) {
}
ngOnInit() {
@ -55,17 +58,14 @@ export class NavigationBarComponent {
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
initialize() {
this.activeRouteEnabled = false;
if(Session.isLoggedIn() && (Session.isClaimsCurator() || Session.isPortalAdministrator())){
this.isAuthorized = true;
}else {
this.isAuthorized = false;
}
this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user);
if (this.properties.adminToolsAPIURL && this.communityId) {
this.config.getCommunityInformation(this.properties, this.communityId).subscribe(data => {
for (var i = 0; i < data['entities'].length; i++) {
@ -84,10 +84,12 @@ if( this.properties.adminToolsAPIURL && this.communityId ){
}
}
onClick(id: string) {
var el: HTMLElement = document.getElementById(id);
el.classList.remove('uk-open');
}
isEnabled(required, enabled) {
if (!required) {
return true;
@ -101,6 +103,7 @@ if( this.properties.adminToolsAPIURL && this.communityId ){
}
return true;
}
isAtleastOneEnabled(required, enabled) {
if (!required || required.length == 0) {
return true;
@ -118,9 +121,11 @@ if( this.properties.adminToolsAPIURL && this.communityId ){
private handleError(message: string, error) {
console.error("NavigationBar (component): " + message, error);
}
getCurrentRoute() {
return this.router.url.split('?')[0];
}
isTheActiveMenu(menu: RootMenuItem): boolean {
let currentRoute = this.getCurrentRoute();
if (!menu.rootItem.markAsActive) {

View File

@ -61,6 +61,7 @@ export class EnvProperties {
logoutUrl;
userInfoUrl;
cookieDomain;