diff --git a/claims/claim-utils/displayClaims/displayClaims.component.ts b/claims/claim-utils/displayClaims/displayClaims.component.ts index ab356150..1c07ec4f 100644 --- a/claims/claim-utils/displayClaims/displayClaims.component.ts +++ b/claims/claim-utils/displayClaims/displayClaims.component.ts @@ -16,7 +16,6 @@ import {Dates} from "../../../utils/string-utils.class"; import {HelperService} from "../../../utils/helper/helper.service"; import {Meta, Title} from "@angular/platform-browser"; import {PiwikService} from "../../../utils/piwik/piwik.service"; -import {UserManagementService} from "../../../services/user-management.service"; @Component({ @@ -181,8 +180,7 @@ export class DisplayClaimsComponent { this.pageLoading = false; }, err => { - this.handleErrors(err); - DisplayClaimsComponent.handleError("Error getting claims for project with id: " + this.fetchId, err); + this.handleErrors(err, "Error getting claims for project with id: " + this.fetchId); } ); } else if (this.fetchBy == "User") { @@ -192,9 +190,8 @@ export class DisplayClaimsComponent { this.pageLoading = false; }, err => { - this.handleErrors(err); + this.handleErrors(err, "Error getting claims for user with id: " + this.fetchId); this.pageLoading = false; - DisplayClaimsComponent.handleError("Error getting claims for user with id: " + this.fetchId, err); } ); } else if (this.fetchBy == "Result") { @@ -204,9 +201,8 @@ export class DisplayClaimsComponent { this.pageLoading = false; }, err => { - this.handleErrors(err); + this.handleErrors(err, "Error getting claims for entity with id: " + this.fetchId); this.pageLoading = false; - DisplayClaimsComponent.handleError("Error getting claims for entity with id: " + this.fetchId, err); } ); } else if (this.fetchBy == "Context") { @@ -216,9 +212,8 @@ export class DisplayClaimsComponent { this.pageLoading = false; }, err => { - this.handleErrors(err); + this.handleErrors(err, "Error getting claims for context with id: " + this.fetchId); this.pageLoading = false; - DisplayClaimsComponent.handleError("Error getting claims for context with id: " + this.fetchId, err); } ); } else { @@ -228,9 +223,8 @@ export class DisplayClaimsComponent { this.pageLoading = false; }, err => { - this.handleErrors(err); + this.handleErrors(err, "Error getting claims"); this.pageLoading = false; - DisplayClaimsComponent.handleError("Error getting claims", err); } ); } @@ -259,27 +253,32 @@ export class DisplayClaimsComponent { } - handleErrors(err) { + handleErrors(err, message) { this.showErrorMessage = true; + console.error("Dispaly Claims (component): " + message +" " + (err && err.error?err.error:'')); try { - let error = err.json(); - let code = error.code; - if (code == 403) { + let error = err && err.error?err.error:err; + if (error.code && error.code == 403) { this.showErrorMessage = false; this.showForbiddenMessage = true; + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } } catch (e) { - //console.log("Couldn't parse answer as json") - DisplayClaimsComponent.handleError("Error parsing answer as json", e); - this.showErrorMessage = true; + } } - private static handleError(message: string, error) { - console.error("Dispaly Claims (component): " + message, error); - } + // private static handleError(message: string, error) { + // console.error("Dispaly Claims (component): " + message, error); + // } goTo(page: number = 1) { @@ -582,7 +581,7 @@ export class DisplayClaimsComponent { this.goTo(goToPage); }, err => { //console.log(err); - DisplayClaimsComponent.handleError("Error deleting claims with ids: " + ids, err); + this.handleErrors(err,"Error deleting claims with ids: " + ids); this.showErrorMessage = true; this.loading.close(); diff --git a/claims/claim-utils/service/claims.service.ts b/claims/claim-utils/service/claims.service.ts index 33667edb..4efbe042 100644 --- a/claims/claim-utils/service/claims.service.ts +++ b/claims/claim-utils/service/claims.service.ts @@ -10,8 +10,7 @@ export class ClaimsService { } private getClaimRequest(size : number, page : number, url :string, fromCache:boolean):any { - return this.http.get(url, CustomOptions.getAuthOptions()) - .pipe(catchError(this.handleError)); + return this.http.get(url, CustomOptions.getAuthOptions()); } getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any { let url = apiUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; @@ -70,7 +69,7 @@ export class ClaimsService { } insertBulkClaims(claims, apiUrl:string):any{ - //console.warn('Trying toinsert claims : '+claims); + // console.warn('Trying toinsert claims : '+claims); let url = apiUrl +"claims/bulk"; let body = JSON.stringify( claims ); //console.warn('Json body: : '+body); diff --git a/claims/claimsAdmin/claimsAdmin.component.ts b/claims/claimsAdmin/claimsAdmin.component.ts index bba38559..a7db85ef 100644 --- a/claims/claimsAdmin/claimsAdmin.component.ts +++ b/claims/claimsAdmin/claimsAdmin.component.ts @@ -1,7 +1,9 @@ import {Component, Input} from '@angular/core'; import {Title, Meta} from '@angular/platform-browser'; -import {User} from "../../login/utils/helper.class"; +import {Session, User} from "../../login/utils/helper.class"; import {UserManagementService} from "../../services/user-management.service"; +import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; +import {Router} from "@angular/router"; @Component({ @@ -45,7 +47,7 @@ export class ClaimsAdminComponent { public user: User = null; constructor(private _meta: Meta, private _title: Title, - private userManagementService: UserManagementService) { + private userManagementService: UserManagementService, private _router: Router) { var titleConnect = "OpenAIRE Connect | Manage links "; var title = "OpenAIRE | Manage links "; @@ -61,6 +63,14 @@ export class ClaimsAdminComponent { ngOnInit() { this.userManagementService.getUserInfo().subscribe(user => { this.user = user; + if (!user) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } }); } } diff --git a/claims/linking/insertClaim/insertClaim.component.ts b/claims/linking/insertClaim/insertClaim.component.ts index ad707b6b..0c61ebe1 100644 --- a/claims/linking/insertClaim/insertClaim.component.ts +++ b/claims/linking/insertClaim/insertClaim.component.ts @@ -4,7 +4,7 @@ import {ClaimsService} from '../../claim-utils/service/claims.service'; import {ModalLoading} from '../../../utils/modal/loading.component'; import {AlertModal} from '../../../utils/modal/alert'; import {Md5} from 'ts-md5/dist/md5'; -import {Session} from '../../../login/utils/helper.class'; +import {Session, User} from '../../../login/utils/helper.class'; import {LoginErrorCodes} from '../../../login/utils/guardHelper.class'; import {EnvProperties} from '../../../utils/properties/env-properties'; import { @@ -88,7 +88,18 @@ export class ClaimInsertComponent { public insert() { this.confirmOpen(); } - + saveAndNavigate(){ + localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results)); + if (this.sources != null) { + localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources)); + } + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } private insertActions() { this.servicesRespond = 0; this.insertedClaims = []; @@ -97,18 +108,7 @@ export class ClaimInsertComponent { this.errorInRecords = []; this.userManagementService.getUserInfo().subscribe(user => { if (!user) { - localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results)); - if (this.sources != null) { - localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources)); - } - - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - + this.saveAndNavigate(); } else { this.claiming = true; this.loading.open(); @@ -186,10 +186,9 @@ export class ClaimInsertComponent { this.isertBulkClaims(claims); }, err => { - try { - err = err.json(); - } catch (error) { - console.log(error); + err = err && err.error?err.error:err; + if (err.code && err.code == 403) { + this.saveAndNavigate(); } if (err.insertedIds && err.insertedIds.length > 0) { this.insertedRecords = err.insertedIds; @@ -236,10 +235,9 @@ export class ClaimInsertComponent { this.afterclaimsInsertion(); }, err => { - try { - err = err.json(); - } catch (e) { - + err = err && err.error?err.error:err; + if (err.code && err.code == 403) { + this.saveAndNavigate(); } let error: ClaimsErrorMessage = new ClaimsErrorMessage(); error.type = "claimServiceFail"; diff --git a/claims/myClaims/myClaims.component.ts b/claims/myClaims/myClaims.component.ts index 6b600c01..9e1435ae 100644 --- a/claims/myClaims/myClaims.component.ts +++ b/claims/myClaims/myClaims.component.ts @@ -2,6 +2,8 @@ import {Component, Input} from '@angular/core'; import {Meta, Title} from '@angular/platform-browser'; import {User} from "../../login/utils/helper.class"; import {UserManagementService} from "../../services/user-management.service"; +import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; +import {Router} from "@angular/router"; @Component({ selector: 'my-claims', @@ -38,11 +40,19 @@ export class MyClaimsComponent { @Input() userInfoURL: string; public user: User = null; - constructor(private userManagementService: UserManagementService) {} + constructor(private userManagementService: UserManagementService, private _router: Router) {} ngOnInit() { this.userManagementService.getUserInfo().subscribe(user => { this.user = user; + if (!user) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } }); } diff --git a/landingPages/landing-utils/showPublisher.component.ts b/landingPages/landing-utils/showPublisher.component.ts index 03c23e07..5f689a4e 100644 --- a/landingPages/landing-utils/showPublisher.component.ts +++ b/landingPages/landing-utils/showPublisher.component.ts @@ -59,7 +59,7 @@ import {EnvProperties} from "../../utils/properties/env-properties"; Copyright policy @@ -72,7 +72,7 @@ import {EnvProperties} from "../../utils/properties/env-properties"; Publisher: {{publisher}} ( Copyright policy @@ -85,6 +85,7 @@ export class ShowPublisherComponent { @Input() publisher; @Input() journal; //@Input() sherpaUrl = 'http://www.sherpa.ac.uk/romeo/search.php?issn='; + //http://sherpa.ac.uk/romeo/issn/2304-6775 @Input() properties: EnvProperties; diff --git a/searchPages/searchDataProviders.component.ts b/searchPages/searchDataProviders.component.ts index 34bd9709..4d4ba7a2 100644 --- a/searchPages/searchDataProviders.component.ts +++ b/searchPages/searchDataProviders.component.ts @@ -34,7 +34,7 @@ import {DatasourcesHelperClass} from "./searchUtils/datasourcesHelper.class"; [searchFormClass]="type!='deposit'?'datasourcesSearchForm':''" [entitiesSelection]="type=='all'" [showAdvancedSearchLink]="type=='all'" [filters]="filters" - [simpleView]="simpleView" formPlaceholderText="Search by title, country, organization, subject, type..." + [simpleView]="simpleView" formPlaceholderText="Search by name, description, subject..." [showResultCount]="(type=='all' || type == 'deposit')" [showLastIndex]="type!='deposit'" [tableViewLink]="tableViewLink"> diff --git a/searchPages/searchOrganizations.component.ts b/searchPages/searchOrganizations.component.ts index eb7e964e..da5803b2 100644 --- a/searchPages/searchOrganizations.component.ts +++ b/searchPages/searchOrganizations.component.ts @@ -31,7 +31,7 @@ import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component"; [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [filters]="filters" - [simpleView]="simpleView" formPlaceholderText="Search by title, author, doi, abstract content..." + [simpleView]="simpleView" formPlaceholderText="Search by organization name..." > ` diff --git a/searchPages/searchProjects.component.ts b/searchPages/searchProjects.component.ts index 716842d0..4ceb951a 100644 --- a/searchPages/searchProjects.component.ts +++ b/searchPages/searchProjects.component.ts @@ -31,7 +31,7 @@ import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [filters]="filters" [rangeFilters]="rangeFilters" [rangeFields]="rangeFields" - [simpleView]="simpleView" formPlaceholderText="Search by title, author, doi, abstract content..." + [simpleView]="simpleView" formPlaceholderText="Search by title, acronym, project code..." > diff --git a/searchPages/searchResearchResults.component.ts b/searchPages/searchResearchResults.component.ts index e4769485..96baa4da 100644 --- a/searchPages/searchResearchResults.component.ts +++ b/searchPages/searchResearchResults.component.ts @@ -32,7 +32,7 @@ import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; [sort]=sort [filters]="filters" [quickFilter]="quickFilter" [rangeFilters]="rangeFilters" [rangeFields]="rangeFields" - [simpleView]="simpleView" formPlaceholderText="Search by title, author, doi, abstract content..." + [simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..." [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" > diff --git a/searchPages/searchUtils/dateFilter.component.ts b/searchPages/searchUtils/dateFilter.component.ts index 2118817b..774e5636 100644 --- a/searchPages/searchUtils/dateFilter.component.ts +++ b/searchPages/searchUtils/dateFilter.component.ts @@ -1,22 +1,19 @@ -import {Component, Input, Output, EventEmitter} from '@angular/core'; -import {Observable} from 'rxjs'; +import {Component, Input} from '@angular/core'; -import { Filter, Value, DateValue} from './searchHelperClasses.class'; -import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index'; -import {Dates} from '../../utils/string-utils.class'; +import {DateValue} from './searchHelperClasses.class'; import {FormControl} from "@angular/forms"; import {MatDatepickerInputEvent} from "@angular/material"; @Component({ selector: 'date-filter', template: ` -
+
{{dateValue.typesTitle[i]}}
-
-
+
+
{{dateValue.typesTitle[i]}} diff --git a/services/servicesUtils/customOptions.class.ts b/services/servicesUtils/customOptions.class.ts index 3f1b8ee0..e9ba152a 100644 --- a/services/servicesUtils/customOptions.class.ts +++ b/services/servicesUtils/customOptions.class.ts @@ -18,7 +18,7 @@ export class CustomOptions { return { headers: new HttpHeaders({ 'Content-Type': 'application/json', - 'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id) + 'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id)?COOKIE.getCookie(COOKIE.cookieName_id):'' }), withCredentials: true }; } @@ -35,7 +35,7 @@ export class CustomOptions { public static getAuthOptions():any { const httpOptions = { headers: new HttpHeaders({ - 'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id), + 'X-XSRF-TOKEN': (COOKIE.getCookie(COOKIE.cookieName_id))?COOKIE.getCookie(COOKIE.cookieName_id):'', }), withCredentials: true }; return httpOptions; diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index d725f496..5ad4535d 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -37,6 +37,7 @@ export class EnvProperties { openDoarURL; r3DataURL; sherpaURL; + sherpaURLSuffix; // Zenodo's url zenodo;