[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 {Component, Input} from '@angular/core';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {ContextsService} from './service/contexts.service'; 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 {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {UserManagementService} from "../../services/user-management.service";
declare var UIkit: any; declare var UIkit: any;
@ -14,7 +15,7 @@ declare var UIkit: any;
}) })
export class ClaimContextSearchFormComponent { export class ClaimContextSearchFormComponent {
@Input() public results:ClaimEntity[]; @Input() public results: ClaimEntity[];
@Input() public sources; @Input() public sources;
@Input() public properties: EnvProperties; @Input() public properties: EnvProperties;
@Input() communityId: string = null; @Input() communityId: string = null;
@ -44,7 +45,9 @@ export class ClaimContextSearchFormComponent {
this.getCommunities(); this.getCommunities();
} }
constructor(private _contextService: ContextsService, private router: Router) { constructor(private _contextService: ContextsService,
private router: Router,
private userManagementService: UserManagementService) {
} }
@ -95,7 +98,7 @@ export class ClaimContextSearchFormComponent {
// }); // });
// return; // return;
// } // }
const entity: ClaimEntity = new ClaimEntity() ; const entity: ClaimEntity = new ClaimEntity();
entity.type = "community"; entity.type = "community";
entity.context = {community: community, category: category, concept: concept}; entity.context = {community: community, category: category, concept: concept};
@ -109,7 +112,8 @@ export class ClaimContextSearchFormComponent {
} }
getCommunities() { getCommunities() {
if (!Session.isLoggedIn()) { this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this.saveStateAndRedirectLogin(); this.saveStateAndRedirectLogin();
} else { } else {
@ -145,16 +149,17 @@ export class ClaimContextSearchFormComponent {
} }
); );
} }
});
} }
getCategories() { getCategories() {
this.loading = true; this.loading = true;
// this.categories=[]; // this.categories=[];
if (this.selectedCommunityId != '0') { if (this.selectedCommunityId != '0') {
if (!Session.isLoggedIn()) { this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this.saveStateAndRedirectLogin(); this.saveStateAndRedirectLogin();
} else { } else {
if (this.categories[this.selectedCommunityId]) { if (this.categories[this.selectedCommunityId]) {
this.loading = false; this.loading = false;
@ -178,9 +183,11 @@ export class ClaimContextSearchFormComponent {
} }
); );
} }
});
} }
} }
/*
/*
getConcepts() { getConcepts() {
this.loading = true; this.loading = true;
if (this.selectedCategoryId != '0') { if (this.selectedCategoryId != '0') {
@ -218,7 +225,8 @@ export class ClaimContextSearchFormComponent {
this.loading = false; this.loading = false;
} }
}*/ }*/
/*
/*
getSubConcepts(conceptId) { getSubConcepts(conceptId) {
this.loading = true; this.loading = true;
if (this.selectedCategoryId != '0') { if (this.selectedCategoryId != '0') {
@ -261,8 +269,10 @@ export class ClaimContextSearchFormComponent {
} }
browseConcepts(categoryId) { browseConcepts(categoryId) {
if (!Session.isLoggedIn()) { this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
this.saveStateAndRedirectLogin(); this.saveStateAndRedirectLogin();
} else { } else {
if (this.conceptsClass[categoryId] != null) { if (this.conceptsClass[categoryId] != null) {
this.conceptsClassDisplay[categoryId] = !this.conceptsClassDisplay[categoryId]; this.conceptsClassDisplay[categoryId] = !this.conceptsClassDisplay[categoryId];
@ -292,7 +302,7 @@ export class ClaimContextSearchFormComponent {
} }
); );
} }
});
} }
browseSubConcepts(categoryId, conceptId) { browseSubConcepts(categoryId, conceptId) {
@ -340,7 +350,7 @@ export class ClaimContextSearchFormComponent {
// } // }
// this.getConcepts(); // this.getConcepts();
// } // }
/* addCommunityInConcepts() { /* addCommunityInConcepts() {
this.concepts.push({"id": this.selectedCommunityId, "label": this.selectedCommunityLabel}); this.concepts.push({"id": this.selectedCommunityId, "label": this.selectedCommunityLabel});
// if(this.autocomplete){ // if(this.autocomplete){
// this.autocomplete.updateList(this.concepts); // this.autocomplete.updateList(this.concepts);

View File

@ -2,11 +2,11 @@ import {Component, Input, ViewChild} from '@angular/core';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Subject} from 'rxjs'; import {Subject} from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
import {ClaimsService} from '../service/claims.service'; import {ClaimsService} from '../service/claims.service';
import {ModalLoading} from '../../../utils/modal/loading.component'; import {ModalLoading} from '../../../utils/modal/loading.component';
import {AlertModal} from '../../../utils/modal/alert'; 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 {EnvProperties} from '../../../utils/properties/env-properties';
import {LoginErrorCodes} from '../../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../../login/utils/guardHelper.class';
import {SEOService} from '../../../sharedComponents/SEO/SEO.service'; 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 {HelperService} from "../../../utils/helper/helper.service";
import {Meta, Title} from "@angular/platform-browser"; import {Meta, Title} from "@angular/platform-browser";
import {PiwikService} from "../../../utils/piwik/piwik.service"; import {PiwikService} from "../../../utils/piwik/piwik.service";
import {UserManagementService} from "../../../services/user-management.service";
@Component({ @Component({
@ -27,7 +28,7 @@ import {PiwikService} from "../../../utils/piwik/piwik.service";
export class DisplayClaimsComponent { export class DisplayClaimsComponent {
@Input() piwikSiteId = null; @Input() piwikSiteId = null;
@Input() title: string = ""; @Input() title: string = "";
piwiksub:any; piwiksub: any;
properties: EnvProperties; properties: EnvProperties;
public searchTermStream = new Subject<string>(); public searchTermStream = new Subject<string>();
@ -37,15 +38,15 @@ export class DisplayClaimsComponent {
@Input() showUserEmail: boolean = true; @Input() showUserEmail: boolean = true;
@Input() myClaims: boolean = false; @Input() myClaims: boolean = false;
@Input() isAdmin: boolean = false; @Input() isAdmin: boolean = false;
page: number=1; page: number = 1;
size: number=10; size: number = 10;
sizes = [10, 20, 30, 50]; sizes = [10, 20, 30, 50];
keyword: string; // the keyword string to give to the request as parameter keyword: string; // the keyword string to give to the request as parameter
inputkeyword: string; // the string written in the input field (keyword=inputkeyword when its length is bigger than 3 and the user stops typing) inputkeyword: string; // the string written in the input field (keyword=inputkeyword when its length is bigger than 3 and the user stops typing)
types = ["All", "Project", "Context", "Result", "User"]; types = ["All", "Project", "Context", "Result", "User"];
@Input() fetchBy: string; @Input() fetchBy: string;
@Input() fetchId: string; @Input() fetchId: string;
@Input() user: User;
resultsNum: number; resultsNum: number;
claims: ClaimDBRecord[]; claims: ClaimDBRecord[];
@Input() externalPortalUrl: string = null; @Input() externalPortalUrl: string = null;
@ -83,8 +84,8 @@ export class DisplayClaimsComponent {
public pageContents = null; public pageContents = null;
constructor(private _claimService: ClaimsService, private route: ActivatedRoute, private _router: Router, private location: Location, constructor(private _claimService: ClaimsService, private route: ActivatedRoute, private _router: Router, private location: Location,
private _meta: Meta, private _title: Title, private _piwikService:PiwikService, private _meta: Meta, private _title: Title, private _piwikService: PiwikService,
private seoService: SEOService, private indexInfoService:IndexInfoService, private helper: HelperService) { private seoService: SEOService, private indexInfoService: IndexInfoService, private helper: HelperService) {
} }
ngOnInit() { ngOnInit() {
@ -98,7 +99,7 @@ export class DisplayClaimsComponent {
this.updateDescription(description); this.updateDescription(description);
this.updateUrl(this.url); this.updateUrl(this.url);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe(); this.piwiksub = this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe();
} }
@ -113,7 +114,7 @@ export class DisplayClaimsComponent {
if (this.myClaims) { if (this.myClaims) {
this.fetchBy = "User"; this.fetchBy = "User";
this.fetchId = Session.getUserEmail(); this.fetchId = this.user.email;
} else { } else {
this.fetchBy = (this.fetchBy) ? this.fetchBy : params['fetchBy']; this.fetchBy = (this.fetchBy) ? this.fetchBy : params['fetchBy'];
@ -134,7 +135,7 @@ export class DisplayClaimsComponent {
this.setSortby(params['sort']); this.setSortby(params['sort']);
this.getClaims(); this.getClaims();
this.searchTermStream this.searchTermStream
.pipe(debounceTime(300),distinctUntilChanged()) .pipe(debounceTime(300), distinctUntilChanged())
.subscribe((term: string) => { .subscribe((term: string) => {
this.keyword = term; this.keyword = term;
this.page = 1; this.page = 1;
@ -149,14 +150,14 @@ export class DisplayClaimsComponent {
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
if(this.piwiksub){ if (this.piwiksub) {
this.piwiksub.unsubscribe(); this.piwiksub.unsubscribe();
} }
//this.searchTermStreamSub.unsubscribe(); //this.searchTermStreamSub.unsubscribe();
} }
getClaims() { getClaims() {
if (!Session.isLoggedIn()) { if (!this.user) {
this.userValidMessage = "User session has expired. Please login again."; this.userValidMessage = "User session has expired. Please login again.";
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {
queryParams: { queryParams: {
@ -277,7 +278,8 @@ export class DisplayClaimsComponent {
this.location.go(location.pathname, this.getParametersString()); this.location.go(location.pathname, this.getParametersString());
this.getClaims(); this.getClaims();
} }
/*
/*
getParameters() { getParameters() {
var params = {} var params = {}
if (this.myClaims) { if (this.myClaims) {
@ -330,7 +332,6 @@ export class DisplayClaimsComponent {
} }
changeOrderby(sortby: string) { changeOrderby(sortby: string) {
if (sortby == this.sortby) { if (sortby == this.sortby) {
this.descending = !this.descending; this.descending = !this.descending;
@ -497,7 +498,7 @@ export class DisplayClaimsComponent {
} else { } else {
this.alert.cancelButton = true; this.alert.cancelButton = true;
this.alert.okButton = true; this.alert.okButton = true;
this.alert.alertTitle ="";// "Delete " + this.selected.length + " links(s)"; this.alert.alertTitle = "";// "Delete " + this.selected.length + " links(s)";
this.alert.okButtonLeft = false; this.alert.okButtonLeft = false;
// this.alert.message = this.selected.length + " links will be deleted. Do you want to proceed? "; // this.alert.message = this.selected.length + " links will be deleted. Do you want to proceed? ";
this.alert.okButtonText = "Delete"; this.alert.okButtonText = "Delete";
@ -524,7 +525,7 @@ export class DisplayClaimsComponent {
} }
batchDeleteById(ids: string[]) { batchDeleteById(ids: string[]) {
if (!Session.isLoggedIn()) { if (!this.user) {
this.userValidMessage = "User session has expired. Please login again."; this.userValidMessage = "User session has expired. Please login again.";
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {
queryParams: { queryParams: {
@ -565,8 +566,8 @@ export class DisplayClaimsComponent {
this.deleteMessage = this.deleteMessage + '<div class = "uk-alert uk-alert-warning " >' + res.notFoundIds.length + ' link(s) couldn\'t be deleted.</div>'; this.deleteMessage = this.deleteMessage + '<div class = "uk-alert uk-alert-warning " >' + res.notFoundIds.length + ' link(s) couldn\'t be deleted.</div>';
} }
let goToPage = this.page; let goToPage = this.page;
if(this.totalPages(this.resultsNum)< this.page && this.page>0){ if (this.totalPages(this.resultsNum) < this.page && this.page > 0) {
goToPage = this.page -1; goToPage = this.page - 1;
} }
this.goTo(goToPage); this.goTo(goToPage);
}, err => { }, err => {
@ -584,44 +585,47 @@ export class DisplayClaimsComponent {
this.goTo(page); this.goTo(page);
} }
isClaimAvailable(claim:ClaimDBRecord): boolean { isClaimAvailable(claim: ClaimDBRecord): boolean {
//claim.target.collectedFrom == "infrastruct_::openaire" && //claim.target.collectedFrom == "infrastruct_::openaire" &&
let lastUpdateDate = new Date( (this.lastIndexDate != null)?this.lastIndexDate:this.properties.lastIndexUpdate); let lastUpdateDate = new Date((this.lastIndexDate != null) ? this.lastIndexDate : this.properties.lastIndexUpdate);
let lastUpdateDateStr = Dates.getDateToString(lastUpdateDate); let lastUpdateDateStr = Dates.getDateToString(lastUpdateDate);
let claimDate = new Date( claim.date); let claimDate = new Date(claim.date);
let claimDateStr = Dates.getDateToString(claimDate); let claimDateStr = Dates.getDateToString(claimDate);
if (claimDateStr< lastUpdateDateStr) { if (claimDateStr < lastUpdateDateStr) {
return true; return true;
} else { } else {
if(claim.target.collectedFrom != "infrastruct_::openaire" && claim.indexed){ if (claim.target.collectedFrom != "infrastruct_::openaire" && claim.indexed) {
// check if direct index succeded // check if direct index succeded
return true return true
} }
} }
return false; return false;
} }
totalPages(totalResults: number): number { totalPages(totalResults: number): number {
let totalPages:any = totalResults/(this.size); let totalPages: any = totalResults / (this.size);
if(!(Number.isInteger(totalPages))) { if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1); totalPages = (parseInt(totalPages, 10) + 1);
} }
return totalPages; return totalPages;
} }
private updateDescription(description:string) { private updateDescription(description: string) {
this._meta.updateTag({content:description},"name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content:description},"property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");
} }
private updateTitle(title:string) {
var _prefix =""; private updateTitle(title: string) {
if(!this.communityId) { var _prefix = "";
_prefix ="OpenAIRE | "; if (!this.communityId) {
_prefix = "OpenAIRE | ";
} }
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title); var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title); this._title.setTitle(_title);
this._meta.updateTag({content:_title},"property='og:title'"); this._meta.updateTag({content: _title}, "property='og:title'");
} }
private updateUrl(url:string) {
this._meta.updateTag({content:url},"property='og:url'"); 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 {Component, Input} from '@angular/core';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {User} from "../../login/utils/helper.class";
import {UserManagementService} from "../../services/user-management.service";
@Component({ @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="!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> <a *ngIf="isConnect && fetchBy && fetchBy == 'Context' && externalPortalUrl" [href]="externalPortalUrl+'/participate/claim'" target="_blank">Claim more links?</a>
</div--> </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> [communityId]="(fetchBy && fetchBy == 'Context' && fetchId && fetchId!='openaire')?fetchId:null" [externalPortalUrl]=externalPortalUrl [claimsInfoURL]=claimsInfoURL></displayClaims>
</div> </div>
</div> </div>
@ -35,7 +37,11 @@ export class ClaimsAdminComponent {
@Input() isConnect:boolean = false; @Input() isConnect:boolean = false;
@Input() externalPortalUrl:string; @Input() externalPortalUrl:string;
@Input() claimsInfoURL: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 titleConnect = "OpenAIRE Connect | Manage links ";
var title = "OpenAIRE | Manage links "; var title = "OpenAIRE | Manage links ";
@ -48,5 +54,8 @@ export class ClaimsAdminComponent {
} }
ngOnInit() { 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 {Component, QueryList, ViewChild, ViewChildren, ViewEncapsulation} from '@angular/core';
import {Location} from '@angular/common'; import {ActivatedRoute, Router} from '@angular/router';
import {ActivatedRoute, Params, Router} from '@angular/router'; import {Meta, Title} from '@angular/platform-browser';
import {Title, Meta} from '@angular/platform-browser';
import {DataTableDirective} from 'angular-datatables'; import {DataTableDirective} from 'angular-datatables';
import {Observable, Subject } from 'rxjs'; import {Subject} from 'rxjs';
import{EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {ErrorCodes} from '../../utils/properties/errorCodes'; import {ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
import {RouterHelper} from '../../utils/routerHelper.class'; import {RouterHelper} from '../../utils/routerHelper.class';
import {ModalSelect} from '../../utils/modal/selectModal.component'; import {ModalSelect} from '../../utils/modal/selectModal.component';
@ -21,6 +18,7 @@ import {ClaimsByTokenService} from './claimsByToken.service';
import {Session} from '../../login/utils/helper.class'; import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {UserManagementService} from "../../services/user-management.service";
@Component({ @Component({
@ -28,7 +26,7 @@ import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
templateUrl: 'claimsByToken.component.html', templateUrl: 'claimsByToken.component.html',
styles: [` styles: [`
#table1_info, #table1_paginate, #table1_length, #table1_filter, #table1_info, #table1_paginate, #table1_length, #table1_filter,
#table2_info, #table2_paginate, #table2_length, #table2_filter{ #table2_info, #table2_paginate, #table2_length, #table2_filter {
display: none; display: none;
} }
@ -40,7 +38,7 @@ export class ClaimsByTokenComponent {
public openaireId: string = ""; public openaireId: string = "";
public sub: any; public sub: any;
public project: any; public project: any;
private claims:any = []; private claims: any = [];
public pending_claims: any = []; public pending_claims: any = [];
public curated_claims: any = []; public curated_claims: any = [];
public selectedRight_PendingMode: Set<string>; public selectedRight_PendingMode: Set<string>;
@ -62,13 +60,13 @@ export class ClaimsByTokenComponent {
public showTables: boolean = true; public showTables: boolean = true;
public rowsOnPage = 5; public rowsOnPage = 5;
public sortOrder = "asc"; public sortOrder = "asc";
public keyword1:string = ""; public keyword1: string = "";
public keyword2:string = ""; public keyword2: string = "";
public activePendingPage:any = {page: 1}; public activePendingPage: any = {page: 1};
public totalPendingResults:any = {count: 0}; public totalPendingResults: any = {count: 0};
public activeCuratedPage:any = {page: 1}; public activeCuratedPage: any = {page: 1};
public totalCuratedResults:any = {count: 0}; public totalCuratedResults: any = {count: 0};
dtTrigger: Subject<any>[] = []; dtTrigger: Subject<any>[] = [];
private triggered: boolean = false; private triggered: boolean = false;
@ -79,22 +77,24 @@ export class ClaimsByTokenComponent {
//@ViewChild("table1") table1: DataTableDirective; //@ViewChild("table1") table1: DataTableDirective;
//@ViewChild("table2") table2: DataTableDirective; //@ViewChild("table2") table2: DataTableDirective;
@ViewChild (ModalSelect) selectModal : ModalSelect; @ViewChild(ModalSelect) selectModal: ModalSelect;
@ViewChild (ModalLoading) loading : ModalLoading ; @ViewChild(ModalLoading) loading: ModalLoading;
properties:EnvProperties; properties: EnvProperties;
public routerHelper:RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
constructor (private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _router: Router, private _router: Router,
private claimsByTokenService: ClaimsByTokenService, private claimsByTokenService: ClaimsByTokenService,
private _meta: Meta, private _title: Title) { private _meta: Meta, private _title: Title,
private userManagementService: UserManagementService) {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
this.pending_status = this.errorCodes.LOADING; this.pending_status = this.errorCodes.LOADING;
this.curated_status = this.errorCodes.LOADING; this.curated_status = this.errorCodes.LOADING;
} }
ngOnInit() { ngOnInit() {
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
@ -119,11 +119,11 @@ export class ClaimsByTokenComponent {
//"searching": false, //"searching": false,
//"lengthChange": false, //"lengthChange": false,
"pageLength": this.rowsOnPage, "pageLength": this.rowsOnPage,
"columnDefs": [ { "columnDefs": [{
"type": "date", "type": "date",
"targets": 2 "targets": 2
} ], }],
"order": [[ 2, 'desc' ]] "order": [[2, 'desc']]
//"pagingType": 'full_numbers', //"pagingType": 'full_numbers',
/*"language": { /*"language": {
"search": "", "search": "",
@ -133,11 +133,11 @@ export class ClaimsByTokenComponent {
this.dtOptions[1] = { this.dtOptions[1] = {
"pageLength": this.rowsOnPage, "pageLength": this.rowsOnPage,
"columnDefs": [ { "columnDefs": [{
"type": "date", "type": "date",
"targets": [2,4] "targets": [2, 4]
} ], }],
"order": [[ 4, 'desc' ]] "order": [[4, 'desc']]
}; };
@ -146,17 +146,24 @@ export class ClaimsByTokenComponent {
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (isLoggedIn) {
$.fn['dataTable'].ext.search.push((settings, data, dataIndex) => { $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
if(settings.sTableId == 'table1') { if (settings.sTableId == 'table1') {
if (this.filterData(data, this.keyword1)) { return !!this.filterData(data, this.keyword1);
return true;
} else if (settings.sTableId == 'table2') {
return !!this.filterData(data, this.keyword2);
} }
return false; });
} else if(settings.sTableId == 'table2') { } else {
if (this.filterData(data, this.keyword2)) { this._router.navigate(['/user-info'], {
return true; queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
} }
return false; });
} }
}); });
} }
@ -171,10 +178,10 @@ export class ClaimsByTokenComponent {
/* /*
Trigger a table draw in order to get the initial filtering Trigger a table draw in order to get the initial filtering
*/ */
triggerInitialLoad(){ triggerInitialLoad() {
this.triggered = true; this.triggered = true;
//console.info("triggerInitialLoad"); //console.info("triggerInitialLoad");
setTimeout(function(){ setTimeout(function () {
/*var table1 = <any>$('#table1').DataTable(); /*var table1 = <any>$('#table1').DataTable();
table1.page( 0 ).draw( false ); table1.page( 0 ).draw( false );
@ -201,53 +208,53 @@ export class ClaimsByTokenComponent {
}); });
} }
filterData(row: any, query: string) { filterData(row: any, query: string): boolean {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
let returnValue: boolean = false; let returnValue: boolean = false;
if (query) {
if(query) { for (var i = 0; i < 3; i++) {
for(var i=0; i <3; i++){ var r = this.filterQuery(row[i], query);
var r= this.filterQuery(row[i], query); if (r) {
if(r) {
returnValue = true; returnValue = true;
break; break;
} }
} }
if(!returnValue) { if (!returnValue) {
return false; return false;
} }
} }
return true; return true;
} }
}
filterQuery(data, query){ filterQuery(data, query) {
if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){ if (data.toLowerCase().indexOf(query.toLowerCase()) > -1) {
return true; return true;
}else{
return false;
}
}
refreshTable(page:number, whichTable: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else { } else {
if(whichTable == "pending") { return false;
}
}
refreshTable(page: number, whichTable: string) {
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(); var table = $('#table1').DataTable();
table.page( page - 1 ).draw( false ); table.page(page - 1).draw(false);
var info = table.page.info(); var info = table.page.info();
this.activePendingPage.page = page;//$event.value; this.activePendingPage.page = page;//$event.value;
this.totalPendingResults.count = info.recordsDisplay; this.totalPendingResults.count = info.recordsDisplay;
} else if(whichTable == 'curated') { } else if (whichTable == 'curated') {
var table = $('#table2').DataTable(); var table = $('#table2').DataTable();
table.page( page - 1 ).draw( false ); table.page(page - 1).draw(false);
var info = table.page.info(); var info = table.page.info();
@ -255,16 +262,23 @@ refreshTable(page:number, whichTable: string) {
this.totalCuratedResults.count = info.recordsDisplay; this.totalCuratedResults.count = info.recordsDisplay;
} }
} }
});
//table.mfActivePage=$event.value; //table.mfActivePage=$event.value;
//table.setPage(table.mfActivePage, this.rowsOnPage); //table.setPage(table.mfActivePage, this.rowsOnPage);
} }
validateJWTandToken() { validateJWTandToken() {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else { } else {
if(this.openaireId) { if (this.openaireId) {
this.pending_status = this.errorCodes.LOADING; this.pending_status = this.errorCodes.LOADING;
this.curated_status = this.errorCodes.LOADING; this.curated_status = this.errorCodes.LOADING;
@ -282,13 +296,13 @@ refreshTable(page:number, whichTable: string) {
//this.closeLoading(); //this.closeLoading();
this.accessStatus = "valid"; this.accessStatus = "valid";
this.claims = data.data; this.claims = data.data;
for(let claim of this.claims) { for (let claim of this.claims) {
if(claim.targetType == "project") { if (claim.targetType == "project") {
this.project = claim.target; this.project = claim.target;
} else { } else {
this.project = claim.source; this.project = claim.source;
} }
if(claim.curatedBy) { if (claim.curatedBy) {
this.curated_claims.push(claim); this.curated_claims.push(claim);
} else { } else {
this.pending_claims.push(claim); this.pending_claims.push(claim);
@ -298,12 +312,12 @@ refreshTable(page:number, whichTable: string) {
this.totalPendingResults.count = this.pending_claims.length; this.totalPendingResults.count = this.pending_claims.length;
this.totalCuratedResults.count = this.curated_claims.length; this.totalCuratedResults.count = this.curated_claims.length;
if(this.project) { if (this.project) {
this.updateTitle("Claims For Project Managers - "+this.project.name); this.updateTitle("Claims For Project Managers - " + this.project.name);
} }
this.showTables = true; this.showTables = true;
if(!this.triggered) { if (!this.triggered) {
//console.info("initial load"); //console.info("initial load");
this.triggerInitialLoad(); this.triggerInitialLoad();
} else { } else {
@ -321,7 +335,7 @@ refreshTable(page:number, whichTable: string) {
this.curated_status = this.errorCodes.DONE; this.curated_status = this.errorCodes.DONE;
}, },
err => { err => {
this.handleError("Error getting claims for openaire id: "+this.openaireId, err); this.handleError("Error getting claims for openaire id: " + this.openaireId, err);
this.pending_status = this.errorMessages.getErrorCode(err.status); this.pending_status = this.errorMessages.getErrorCode(err.status);
this.curated_status = this.pending_status; this.curated_status = this.pending_status;
@ -337,7 +351,7 @@ refreshTable(page:number, whichTable: string) {
}*/ }*/
this.showTables = true; this.showTables = true;
if(!this.triggered) { if (!this.triggered) {
this.triggerInitialLoad(); this.triggerInitialLoad();
} else { } else {
var table1 = $('#table1').DataTable(); var table1 = $('#table1').DataTable();
@ -357,23 +371,30 @@ refreshTable(page:number, whichTable: string) {
this.accessStatus = "invalid"; this.accessStatus = "invalid";
} }
} }
});
} }
selectApprove(id:string, event, mode: string) { selectApprove(id: string, event, mode: string) {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else { } else {
var value = event.currentTarget.checked; var value = event.currentTarget.checked;
if(value){ if (value) {
if(mode == "pending") { if (mode == "pending") {
this.selectedRight_PendingMode.add(id); this.selectedRight_PendingMode.add(id);
this.selectedWrong_PendingMode.delete(id); this.selectedWrong_PendingMode.delete(id);
} else { } else {
this.selectedRight_CuratedMode.add(id); this.selectedRight_CuratedMode.add(id);
this.selectedWrong_CuratedMode.delete(id); this.selectedWrong_CuratedMode.delete(id);
} }
}else{ } else {
if(mode == "pending") { if (mode == "pending") {
this.selectedRight_PendingMode.delete(id); this.selectedRight_PendingMode.delete(id);
} }
// } else { // } else {
@ -382,23 +403,30 @@ refreshTable(page:number, whichTable: string) {
// } // }
} }
} }
});
} }
selectDisapprove(id:string, event, mode: string) { selectDisapprove(id: string, event, mode: string) {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else { } else {
var value = event.currentTarget.checked; var value = event.currentTarget.checked;
if(value){ if (value) {
if(mode == "pending") { if (mode == "pending") {
this.selectedWrong_PendingMode.add(id); this.selectedWrong_PendingMode.add(id);
this.selectedRight_PendingMode.delete(id); this.selectedRight_PendingMode.delete(id);
} else { } else {
this.selectedWrong_CuratedMode.add(id); this.selectedWrong_CuratedMode.add(id);
this.selectedRight_CuratedMode.delete(id); this.selectedRight_CuratedMode.delete(id);
} }
}else{ } else {
if(mode == "pending") { if (mode == "pending") {
this.selectedWrong_PendingMode.delete(id); this.selectedWrong_PendingMode.delete(id);
} }
// } else { // } else {
@ -407,20 +435,22 @@ refreshTable(page:number, whichTable: string) {
// } // }
} }
} }
});
} }
isSelected(id:string, set:Set<string>) { isSelected(id: string, set: Set<string>) {
return set.has(id); return set.has(id);
} }
/*
/*
isSelectedWrong(id:string) { isSelectedWrong(id:string) {
return this.selectedWrong.has(id); return this.selectedWrong.has(id);
} }
*/ */
isRight_CuratedMode(claim: any) { isRight_CuratedMode(claim: any) {
if(this.isSelected(claim.id, this.selectedRight_CuratedMode)) { if (this.isSelected(claim.id, this.selectedRight_CuratedMode)) {
return true; return true;
} else if(claim.approved == true && !this.isSelected(claim.id, this.selectedWrong_CuratedMode)) { } else if (claim.approved == true && !this.isSelected(claim.id, this.selectedWrong_CuratedMode)) {
return true; return true;
} }
@ -428,9 +458,9 @@ refreshTable(page:number, whichTable: string) {
} }
isWrong_CuratedMode(claim: any) { isWrong_CuratedMode(claim: any) {
if(this.isSelected(claim.id, this.selectedWrong_CuratedMode)) { if (this.isSelected(claim.id, this.selectedWrong_CuratedMode)) {
return true; return true;
} else if(claim.approved == false && !this.isSelected(claim.id, this.selectedRight_CuratedMode)) { } else if (claim.approved == false && !this.isSelected(claim.id, this.selectedRight_CuratedMode)) {
return true; return true;
} }
@ -438,10 +468,16 @@ refreshTable(page:number, whichTable: string) {
} }
cancelEditOfCuration(claim: any) { cancelEditOfCuration(claim: any) {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else { } else {
if(claim.approved) { if (claim.approved) {
//this.selectedRight_CuratedMode.add(claim.id); //this.selectedRight_CuratedMode.add(claim.id);
this.selectedWrong_CuratedMode.delete(claim.id); this.selectedWrong_CuratedMode.delete(claim.id);
} else { } else {
@ -449,24 +485,31 @@ refreshTable(page:number, whichTable: string) {
//this.selectedWrong_CuratedMode.add(claim.id); //this.selectedWrong_CuratedMode.add(claim.id);
} }
} }
});
} }
saveEdited(claim: any, editable_index: number) { saveEdited(claim: any, editable_index: number) {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else { } else {
this.curated_status = this.errorCodes.LOADING; this.curated_status = this.errorCodes.LOADING;
let approved: boolean = this.isRight_CuratedMode(claim); let approved: boolean = this.isRight_CuratedMode(claim);
if(approved == claim.approved) { if (approved == claim.approved) {
this.selectedRight_CuratedMode.delete(claim.id); this.selectedRight_CuratedMode.delete(claim.id);
this.selectedWrong_CuratedMode.delete(claim.id); this.selectedWrong_CuratedMode.delete(claim.id);
this.editable.delete(editable_index); this.editable.delete(editable_index);
this.curated_status = this.errorCodes.DONE; this.curated_status = this.errorCodes.DONE;
} else { } else {
let claimCurationInfo: {"id": string, "approved": boolean} = {"id": claim.id, "approved": approved}; let claimCurationInfo: { "id": string, "approved": boolean } = {"id": claim.id, "approved": approved};
this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe( this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe(
data => { data => {
@ -478,17 +521,24 @@ refreshTable(page:number, whichTable: string) {
}, },
err => { err => {
//console.log(err); //console.log(err);
this.handleError("Error updating claim curation: "+JSON.stringify(claimCurationInfo), err); this.handleError("Error updating claim curation: " + JSON.stringify(claimCurationInfo), err);
this.curated_status = this.errorCodes.NOT_SAVED; this.curated_status = this.errorCodes.NOT_SAVED;
} }
); );
} }
} }
});
} }
saveChanges() { saveChanges() {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else { } else {
this.pending_status = this.errorCodes.LOADING; this.pending_status = this.errorCodes.LOADING;
//this.openLoading(); //this.openLoading();
@ -503,31 +553,40 @@ refreshTable(page:number, whichTable: string) {
err => { err => {
//this.closeLoading(); //this.closeLoading();
//console.log(err); //console.log(err);
this.handleError("Error updating claims: right: "+JSON.stringify(this.selectedRight_PendingMode)+" and wrong: "+JSON.stringify(this.selectedWrong_PendingMode), err); this.handleError("Error updating claims: right: " + JSON.stringify(this.selectedRight_PendingMode) + " and wrong: " + JSON.stringify(this.selectedWrong_PendingMode), err);
this.pending_status = this.errorCodes.NOT_SAVED; this.pending_status = this.errorCodes.NOT_SAVED;
} }
); );
} }
});
} }
clearCheckboxes() { clearCheckboxes() {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); if (!isLoggedIn) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else { } else {
this.pending_status = this.errorCodes.LOADING; this.pending_status = this.errorCodes.LOADING;
this.selectedRight_PendingMode.clear(); this.selectedRight_PendingMode.clear();
this.selectedWrong_PendingMode.clear(); this.selectedWrong_PendingMode.clear();
this.pending_status = this.errorCodes.DONE; this.pending_status = this.errorCodes.DONE;
} }
});
} }
public openLoading(){ public openLoading() {
if(this.loading){ if (this.loading) {
this.loading.open(); this.loading.open();
} }
} }
public closeLoading(){
if(this.loading){ public closeLoading() {
if (this.loading) {
this.loading.close(); this.loading.close();
} }
} }
@ -536,41 +595,41 @@ refreshTable(page:number, whichTable: string) {
//console.info("selected curator: "+selected); //console.info("selected curator: "+selected);
} }
public openSelect(){ public openSelect() {
if(this.selectModal){ if (this.selectModal) {
this.selectModal.open(); this.selectModal.open();
} }
} }
public setMessageSelect(message: string){ public setMessageSelect(message: string) {
if(this.selectModal){ if (this.selectModal) {
this.selectModal.message = message; this.selectModal.message = message;
} }
} }
public setOptionsSelect(options: string[]){ public setOptionsSelect(options: string[]) {
if(this.selectModal){ if (this.selectModal) {
this.selectModal.options = options; this.selectModal.options = options;
} }
} }
totalPages(totalResults: number): number { totalPages(totalResults: number): number {
let totalPages:any = totalResults/(this.rowsOnPage); let totalPages: any = totalResults / (this.rowsOnPage);
if(!(Number.isInteger(totalPages))) { if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1); totalPages = (parseInt(totalPages, 10) + 1);
} }
return totalPages; return totalPages;
} }
updateTitle(title:string){ updateTitle(title: string) {
var _prefix ="OpenAIRE | "; var _prefix = "OpenAIRE | ";
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title); var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this._meta.updateTag({content:_title},"property='og:title'"); this._meta.updateTag({content: _title}, "property='og:title'");
this._title.setTitle(_title); this._title.setTitle(_title);
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Claims Project Manager Page: "+message, error); console.error("Claims Project Manager Page: " + message, error);
} }
} }

View File

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

View File

@ -1,5 +1,7 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Meta, Title} from '@angular/platform-browser'; import {Meta, Title} from '@angular/platform-browser';
import {User} from "../../login/utils/helper.class";
import {UserManagementService} from "../../services/user-management.service";
@Component({ @Component({
selector: 'my-claims', selector: 'my-claims',
@ -17,7 +19,7 @@ import {Meta, Title} from '@angular/platform-browser';
Manage your links in OpenAIRE Manage your links in OpenAIRE
</div> </div>
<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 [claimsInfoURL]=claimsInfoURL [communityId]=communityId
[piwikSiteId]="piwikSiteId" title="My links"> [piwikSiteId]="piwikSiteId" title="My links">
</displayClaims> </displayClaims>
@ -33,9 +35,15 @@ export class MyClaimsComponent {
@Input() claimsInfoURL: string; @Input() claimsInfoURL: string;
@Input() communityId:string; @Input() communityId:string;
@Input() piwikSiteId = null; @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,6 +1,5 @@
import {map, filter, mergeMap} from 'rxjs/operators'; import {map, filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core'; import {Injectable} from '@angular/core';
import { import {
Router, Router,
CanActivate, CanActivate,
@ -8,44 +7,51 @@ import {
RouterStateSnapshot, RouterStateSnapshot,
CanLoad, Route, UrlSegment CanLoad, Route, UrlSegment
} from '@angular/router'; } from '@angular/router';
import {Observable} from 'rxjs'; import {Observable, of} from 'rxjs';
import {Session} from '../../login/utils/helper.class'; import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; import {EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper'; import {ConnectHelper} from '../connectHelper';
import {StringUtils} from '../../utils/string-utils.class'; import {StringUtils} from '../../utils/string-utils.class';
import {UserManagementService} from "../../services/user-management.service";
@Injectable() @Injectable()
export class ConnectAdminLoginGuard implements CanActivate, CanLoad { export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
constructor(private router: Router, constructor(private router: Router,
private communityService: CommunityService, private communityService: CommunityService,
private propertiesService: EnvironmentSpecificService) {} private propertiesService: EnvironmentSpecificService,
private userManagementService: UserManagementService) {
}
check(community: string, path: string): Observable<boolean> | boolean { check(community: string, path: string): Observable<boolean> | boolean {
let errorCode = LoginErrorCodes.NOT_LOGIN; let errorCode = LoginErrorCodes.NOT_LOGIN;
if (Session.isLoggedIn()) { let email = null;
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) { const authorized = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
return true; 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 { } else {
const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => res),mergeMap(properties => { return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community,
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community, Session.getUserEmail()); email);
}),); }
obs.pipe(filter(enabled => !enabled)) } else {
.subscribe(() => this.router.navigate(['/user-info'], { return of(false);
}
}), mergeMap( authorized => {
return authorized;
}));
}));
authorized.pipe(filter(authorized => !authorized)).subscribe(() => {
this.router.navigate(['/user-info'], {
queryParams: { queryParams: {
'errorCode': errorCode, 'errorCode': errorCode,
'redirectUrl': path 'redirectUrl': path
} }
})); })});
return obs; return authorized;
}
} else {
errorCode = LoginErrorCodes.NOT_LOGIN;
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path}});
return false;
}
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { 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 { Injectable } from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router'; 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 {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper'; import {ConnectHelper} from '../connectHelper';
import {UserManagementService} from "../../services/user-management.service";
@Injectable() @Injectable()
export class ConnectSubscriberGuard implements CanActivate { export class ConnectSubscriberGuard implements CanActivate {
constructor(private router: Router, constructor(private router: Router,
private communityService: CommunityService, private communityService: CommunityService,
private userManagementService: UserManagementService,
private propertiesService: EnvironmentSpecificService) {} private propertiesService: EnvironmentSpecificService) {}
check(community: string, path: string): Observable<boolean> | boolean { check(community: string, path: string): Observable<boolean> | boolean {
let errorCode = LoginErrorCodes.NOT_SUBSCRIBER; let errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
if (!Session.isLoggedIn()) { let email = null;
errorCode = LoginErrorCodes.NOT_LOGIN; const subscribed = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path, communityId:community}}); return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
return false; if (user) {
} else { email = user.email;
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => { let communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
let communityDomain = null;
//if(!community){
communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
//}
if(communityDomain) { if(communityDomain) {
community = 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: { queryParams: {
'errorCode': errorCode, 'errorCode': errorCode,
'redirectUrl': path, 'redirectUrl': path
communityId:community
}
}));
return obs;
} }
})});
return subscribed;
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {

View File

@ -1,22 +1,35 @@
import { Injectable } from '@angular/core'; import {Injectable} from '@angular/core';
import { import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad, Route, UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {filter, map, mergeMap} from "rxjs/operators";
import {ConnectHelper} from '../connectHelper'; import {UserManagementService} from "../../services/user-management.service";
import {Session} from '../../login/utils/helper.class'; import {EnvironmentSpecificService} from "../../utils/properties/environment-specific.service";
import {Session} from "../../login/utils/helper.class";
@Injectable() @Injectable()
export class IsCommunityOrAdmin implements CanActivate { 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 { check(community: string): Observable<boolean> | boolean {
if(Session.isLoggedIn() && Session.isPortalAdministrator()) { if(Session.isLoggedIn() && Session.isPortalAdministrator()) {
return true; return true;
@ -27,10 +40,11 @@ export class IsCommunityOrAdmin implements CanActivate {
this.router.navigate(['errorcommunity']); this.router.navigate(['errorcommunity']);
return false; return false;
} }
} }*/
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.queryParams['communityId']); 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 {Location} from '@angular/common';
import {Observable} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router'; 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 {Session} from '../../login/utils/helper.class';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {MailPrefsService} from './mailPrefs.service'; import {MailPrefsService} from './mailPrefs.service';
@ -11,17 +8,18 @@ import {ConnectHelper} from '../connectHelper';
import {ErrorCodes} from '../../utils/properties/errorCodes'; import {ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {UserManagementService} from "../../services/user-management.service";
declare var UIkit: any; declare var UIkit: any;
@Component({ @Component({
selector: 'mailPrefs', selector: 'mailPrefs',
templateUrl: 'mailPrefs.component.html', templateUrl: 'mailPrefs.component.html',
providers:[MailPrefsService] providers: [MailPrefsService]
}) })
export class MailPrefsComponent { export class MailPrefsComponent {
properties:EnvProperties; properties: EnvProperties;
sub: any; sub: any;
public communityId: string; public communityId: string;
public preferencesFor: string = "community"; public preferencesFor: string = "community";
@ -32,17 +30,19 @@ export class MailPrefsComponent {
public prefsChanged = {}; public prefsChanged = {};
//public showForbiddenMessage:boolean = false; //public showForbiddenMessage:boolean = false;
public userValidMessage:string = ""; public userValidMessage: string = "";
public savedMessage: string = ""; public savedMessage: string = "";
public fetchId: string;
public fetchId:string;
private errorCodes: ErrorCodes; private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
@Input() showSaveResetButtons: boolean = true; @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.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
@ -54,45 +54,50 @@ export class MailPrefsComponent {
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.sub = this.route.queryParams.subscribe(params => { this.sub = this.route.queryParams.subscribe(params => {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
if(!this.communityId) { if (!this.communityId) {
this.communityId = params['communityId']; this.communityId = params['communityId'];
} }
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
this.fetchId = Session.getUserEmail(); this.fetchId = user.email;
this.getEmailPreferences(); this.getEmailPreferences();
});
}); });
}); });
} }
getEmailPreferences() { getEmailPreferences() {
if(!Session.isLoggedIn()){ this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
if (!isLoggedIn) {
//this.userValidMessage = "User session has expired. Please login again."; //this.userValidMessage = "User session has expired. Please login again.";
if(this.showSaveResetButtons) { 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 { } else {
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.savedMessage = ""; this.savedMessage = "";
if(this.communityId && this.communityId != "openaire") { if (this.communityId && this.communityId != "openaire") {
this.preferencesFor = "community"; this.preferencesFor = "community";
this._mailPrefsService.getUserEmailPreferencesForCommunity(this.communityId, this.properties.claimsAPIURL).subscribe( this._mailPrefsService.getUserEmailPreferencesForCommunity(this.communityId, this.properties.claimsAPIURL).subscribe(
data => { data => {
if(data.code == "204") { if (data.code == "204") {
this.status = this.errorCodes.NONE; this.status = this.errorCodes.NONE;
} else { } else {
this.initialNotifications = data.data; this.initialNotifications = data.data;
this.notifications = JSON.parse(JSON.stringify( this.initialNotifications )); this.notifications = JSON.parse(JSON.stringify(this.initialNotifications));
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
} }
}, },
err => { err => {
this.handleErrors(err); this.handleErrors(err);
this.handleError("Error getting user email preferences for community with id: "+this.communityId, err); this.handleError("Error getting user email preferences for community with id: " + this.communityId, err);
} }
); );
} else { } else {
@ -100,12 +105,12 @@ export class MailPrefsComponent {
this._mailPrefsService.getUserEmailPreferencesForOpenaire(this.properties.claimsAPIURL).subscribe( this._mailPrefsService.getUserEmailPreferencesForOpenaire(this.properties.claimsAPIURL).subscribe(
data => { data => {
if(data.code == "204") { if (data.code == "204") {
this.status = this.errorCodes.NONE; this.status = this.errorCodes.NONE;
} else { } else {
this.initialNotifications = data.data; this.initialNotifications = data.data;
this.notifications = JSON.parse(JSON.stringify( this.initialNotifications )); this.notifications = JSON.parse(JSON.stringify(this.initialNotifications));
//this.notifications = this.initialNotifications.map(x => Object.assign({}, x)); //this.notifications = this.initialNotifications.map(x => Object.assign({}, x));
//this.notifications = this.initialNotifications; //this.notifications = this.initialNotifications;
@ -120,13 +125,20 @@ export class MailPrefsComponent {
); );
} }
} }
});
} }
changeNotify(notification: any, checked: boolean, index: number) { 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."; //this.userValidMessage = "User session has expired. Please login again.";
if(this.showSaveResetButtons) { 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 { } else {
this.savedMessage = ""; this.savedMessage = "";
@ -134,39 +146,53 @@ export class MailPrefsComponent {
notification.notify = checked; notification.notify = checked;
this.prefsChanged[index] = true; this.prefsChanged[index] = true;
} }
});
} }
changeFrequency(index: number) { 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."; //this.userValidMessage = "User session has expired. Please login again.";
if(this.showSaveResetButtons) { 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 { } else {
this.savedMessage = ""; this.savedMessage = "";
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
if(this.initialNotifications[index].frequency != this.notifications[index].frequency) { if (this.initialNotifications[index].frequency != this.notifications[index].frequency) {
this.prefsChanged[index] = true; this.prefsChanged[index] = true;
} }
} }
});
} }
saveNotification(index: number) { saveNotification(index: number) {
if(this.notifications.length > 0 && this.initialNotifications.length > 0) { 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."; //this.userValidMessage = "User session has expired. Please login again.";
if(this.showSaveResetButtons) { 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 { } else {
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) { if (JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) {
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.savedMessage = ""; this.savedMessage = "";
this._mailPrefsService.saveUserEmailPreferences(this.notifications[index], this.properties.claimsAPIURL).subscribe( this._mailPrefsService.saveUserEmailPreferences(this.notifications[index], this.properties.claimsAPIURL).subscribe(
data => { data => {
this.initialNotifications[index] = JSON.parse(JSON.stringify( this.notifications[index] )); this.initialNotifications[index] = JSON.parse(JSON.stringify(this.notifications[index]));
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
@ -180,12 +206,11 @@ export class MailPrefsComponent {
}, },
err => { err => {
//console.log(err); //console.log(err);
this.handleError("Error saving user email preferences: "+JSON.stringify(this.notifications[index]), err); this.handleError("Error saving user email preferences: " + JSON.stringify(this.notifications[index]), err);
this.status = this.errorCodes.NOT_SAVED; this.status = this.errorCodes.NOT_SAVED;
} }
); );
} } else {
else {
/*UIkit.notification({ /*UIkit.notification({
message : '<strong>No changes selected for '+this.notifications[index].openaireName+' email preferences<strong>', message : '<strong>No changes selected for '+this.notifications[index].openaireName+' email preferences<strong>',
status : 'primary', status : 'primary',
@ -195,26 +220,35 @@ export class MailPrefsComponent {
this.savedMessage = "Notification settings for claims saved!"; this.savedMessage = "Notification settings for claims saved!";
} }
} }
});
} }
} }
restoreNotification(index: number) { 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."; //this.userValidMessage = "User session has expired. Please login again.";
if(this.showSaveResetButtons) { 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 { } else {
if(this.notifications.length > 0 && this.initialNotifications.length > 0) { if (this.notifications.length > 0 && this.initialNotifications.length > 0) {
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.savedMessage = ""; this.savedMessage = "";
this.notifications[index] = JSON.parse(JSON.stringify( this.initialNotifications[index] )); this.notifications[index] = JSON.parse(JSON.stringify(this.initialNotifications[index]));
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
this.prefsChanged[index] = false; this.prefsChanged[index] = false;
} }
} }
});
} }
/*
/*
prefsChanged(index: number) : boolean { prefsChanged(index: number) : boolean {
if(this.notifications.length > 0 && this.initialNotifications.length > 0) { if(this.notifications.length > 0 && this.initialNotifications.length > 0) {
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) { if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) {
@ -223,18 +257,18 @@ export class MailPrefsComponent {
} }
return false; return false;
} }
*/ */
ngOnDestroy() { ngOnDestroy() {
if(this.sub) { if (this.sub) {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
} }
handleErrors(err){ handleErrors(err) {
//this.showErrorMessage = true; //this.showErrorMessage = true;
//try{ //try{
var code = ""; var code = "";
if(!err.status) { if (!err.status) {
var error = err.json(); var error = err.json();
code = error.code; code = error.code;
} else { } else {
@ -244,7 +278,7 @@ export class MailPrefsComponent {
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("User mail notification preferences Page (for claims): "+message, error); console.error("User mail notification preferences Page (for claims): " + message, error);
} }

View File

@ -11,14 +11,40 @@ import {
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.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() @Injectable()
export class AdminLoginGuard implements CanActivate{ 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 loggedIn = false;
let isAdmin = false; let isAdmin = false;
let errorCode = LoginErrorCodes.NOT_LOGIN; let errorCode = LoginErrorCodes.NOT_LOGIN;
@ -38,7 +64,7 @@ export class AdminLoginGuard implements CanActivate{
}); });
} }
return loggedIn && isAdmin; return loggedIn && isAdmin;
} }*/
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(state.url); return this.check(state.url);

View File

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

View File

@ -11,26 +11,33 @@ import {
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.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() @Injectable()
export class LoginGuard implements CanActivate { export class LoginGuard 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> |boolean {
let loggedIn = false; const loggedIn = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
if (Session.isLoggedIn()) { return this.userManagementService.isLoggedIn(properties['userInfoUrl']).pipe(map( isLoggedIn => {
loggedIn = true; return isLoggedIn;
} }));
if (!loggedIn) { }));
loggedIn.pipe(filter( isLoggedIn => !isLoggedIn)).subscribe( () => {
this.router.navigate(['/user-info'], { this.router.navigate(['/user-info'], {
queryParams: { queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN, 'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': path 'redirectUrl': path
} }
}); });
} });
return loggedIn; return loggedIn;
} }

View File

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

View File

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

View File

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

View File

@ -126,7 +126,8 @@ export class Session{
} }
//Methods to check roles //Methods to check roles
public static isClaimsCurator():boolean { // OLD
/* public static isClaimsCurator():boolean {
var isAuthorized = false; var isAuthorized = false;
if(Session.isLoggedIn()){ if(Session.isLoggedIn()){
var roles = ["urn:geant:openaire.eu:group:Curator+-+Claim#aai.openaire.eu"] var roles = ["urn:geant:openaire.eu:group:Curator+-+Claim#aai.openaire.eu"]
@ -195,6 +196,33 @@ export class Session{
return isAuthorized; return isAuthorized;
} }
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> </ng-container>
<ng-container *ngIf="userMenu"> <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> </ng-container>
</ul> </ul>
</div> </div>
@ -196,7 +196,7 @@
<!-- </div> --> <!-- </div> -->
<!-- <div *ngIf="userMenu" class="uk-navbar-right"> --> <!-- <div *ngIf="userMenu" class="uk-navbar-right"> -->
<!-- <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> </div>
</nav> </nav>

View File

@ -1,6 +1,6 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; 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 {ConfigurationService} from '../utils/configuration/configuration.service';
import {MenuItem, RootMenuItem} from './menu'; import {MenuItem, RootMenuItem} from './menu';
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
@ -10,43 +10,46 @@ import {EnvProperties} from '../utils/properties/env-properties';
templateUrl: 'navigationBar.component.html' templateUrl: 'navigationBar.component.html'
}) })
export class NavigationBarComponent { export class NavigationBarComponent {
@Input() portal:string = "connect"; @Input() portal: string = "connect";
@Input() onlyTop:boolean ; @Input() onlyTop: boolean;
@Input() logoPath:string = "assets/common-assets/"; @Input() logoPath: string = "assets/common-assets/";
@Input() userMenu:boolean = true; @Input() userMenu: boolean = true;
@Input() showHomeMenuItem:boolean = false; @Input() showHomeMenuItem: boolean = false;
@Input() communityId; @Input() communityId;
@Input() showCommunityName:boolean = false; @Input() showCommunityName: boolean = false;
@Input() userMenuItems:MenuItem[] ; @Input() userMenuItems: MenuItem[];
@Input() menuItems:RootMenuItem [] ; @Input() menuItems: RootMenuItem [];
@Input() community: {id:string, name:string, logoUrl:string}; @Input() community: { id: string, name: string, logoUrl: string };
@Input() showMenu:boolean = true; @Input() showMenu: boolean = true;
@Input() homeurl:boolean = true; @Input() homeurl: boolean = true;
@Input() properties:EnvProperties; @Input() properties: EnvProperties;
@Input() enableSearch:boolean = false; @Input() user: User;
@Input() searchRoute:string = "/search/find"; @Input() enableSearch: boolean = false;
@Input() searchPlaceHolder:string = "Search for research results"; @Input() searchRoute: string = "/search/find";
keyword:string = ""; @Input() searchPlaceHolder: string = "Search for research results";
keyword: string = "";
public isAuthorized: boolean = false; public isAuthorized: boolean = false;
sub:any; sub: any;
isClient:boolean = false; isClient: boolean = false;
showEntity ={}; showEntity = {};
showPage ={}; showPage = {};
specialAnnouncementContent:string= null; specialAnnouncementContent: string = null;
activeRouteEnabled = false; activeRouteEnabled = false;
constructor( private router: Router, private route: ActivatedRoute, private config: ConfigurationService) { constructor(private router: Router,
private route: ActivatedRoute,
private config: ConfigurationService) {
} }
ngOnInit() { ngOnInit() {
//console.log(this.menuItems); //console.log(this.menuItems);
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
try{ try {
this.isClient = true; this.isClient = true;
}catch (e) { } catch (e) {
} }
} }
this.activeRouteEnabled = false; this.activeRouteEnabled = false;
@ -55,83 +58,85 @@ export class NavigationBarComponent {
}); });
} }
ngOnDestroy(){
ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
initialize(){
initialize() {
this.activeRouteEnabled = false; this.activeRouteEnabled = false;
if(Session.isLoggedIn() && (Session.isClaimsCurator() || Session.isPortalAdministrator())){ this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user);
this.isAuthorized = true; if (this.properties.adminToolsAPIURL && this.communityId) {
}else { this.config.getCommunityInformation(this.properties, this.communityId).subscribe(data => {
this.isAuthorized = false; for (var i = 0; i < data['entities'].length; i++) {
}
if( this.properties.adminToolsAPIURL && this.communityId ){ this.showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
this.config.getCommunityInformation(this.properties, this.communityId ).subscribe(data => {
for(var i=0; i< data['entities'].length; i++){
this.showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
} }
for(var i=0; i< data['pages'].length; i++){ for (var i = 0; i < data['pages'].length; i++) {
this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"]; this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
} }
}, },
error => { error => {
this.handleError("Error getting community information (e.g. pages,entities) for community with id: "+this.communityId, error); this.handleError("Error getting community information (e.g. pages,entities) for community with id: " + this.communityId, error);
}); });
} }
} }
onClick(id: string) { onClick(id: string) {
var el: HTMLElement = document.getElementById(id); var el: HTMLElement = document.getElementById(id);
el.classList.remove('uk-open'); el.classList.remove('uk-open');
} }
isEnabled(required, enabled){
if(!required ){ isEnabled(required, enabled) {
if (!required) {
return true; return true;
} }
for(let requiredEntity of required){ for (let requiredEntity of required) {
if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){ if (typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false) {
return false; return false;
} }
} }
return true; return true;
} }
isAtleastOneEnabled(required, enabled){
if(!required ||required.length == 0){ isAtleastOneEnabled(required, enabled) {
if (!required || required.length == 0) {
return true; return true;
} }
var count = required.length; var count = required.length;
for(let requiredEntity of required){ for (let requiredEntity of required) {
if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){ if (typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false) {
count --; count--;
} }
} }
return (count > 0)?true:false; return (count > 0) ? true : false;
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("NavigationBar (component): "+message, error); console.error("NavigationBar (component): " + message, error);
} }
getCurrentRoute(){
getCurrentRoute() {
return this.router.url.split('?')[0]; return this.router.url.split('?')[0];
} }
isTheActiveMenu(menu:RootMenuItem):boolean{
isTheActiveMenu(menu: RootMenuItem): boolean {
let currentRoute = this.getCurrentRoute(); let currentRoute = this.getCurrentRoute();
if(!menu.rootItem.markAsActive){ if (!menu.rootItem.markAsActive) {
return false; return false;
} }
if( currentRoute == menu.rootItem.route){ if (currentRoute == menu.rootItem.route) {
this.activeRouteEnabled = true; this.activeRouteEnabled = true;
return true; return true;
}else if(menu.items.length >0){ } else if (menu.items.length > 0) {
for (let menuItem of menu.items){ for (let menuItem of menu.items) {
if(menuItem.route == currentRoute){ if (menuItem.route == currentRoute) {
this.activeRouteEnabled = true; this.activeRouteEnabled = true;
return true; return true;
} }

View File

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