[Library | Trunk]
Claims: add more checks and redirect to login if the session is expired Sherpa/Romeo: update with new link Search pages: hide table view link update placeholders in simple search form update Advanced search form width, date filter simple search form for smaller devices git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58331 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
7bea361c06
commit
3c9d72a8d4
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ import {EnvProperties} from "../../utils/properties/env-properties";
|
|||
</span>
|
||||
<span *ngIf="journal && (journal['issn'] ||journal['lissn'] || journal['eissn'] ) && !publisher">
|
||||
<a target="_blank"
|
||||
[href]="properties.sherpaURL+(journal['issn']?journal['issn']:(journal['eissn']?journal['eissn']:journal['lissn'] ))"
|
||||
[href]="properties.sherpaURL+(journal['issn']?journal['issn']:(journal['eissn']?journal['eissn']:journal['lissn'] ))+properties.sherpaURLSuffix"
|
||||
uk-tooltip="title: View information on Sherpa/RoMEO ">
|
||||
<img src="assets/common-assets/common/SHERPA-RoMEO-short-logo.gif" width=16 height=16 alt="">
|
||||
Copyright policy<span class="custom-external custom-icon space"></span>
|
||||
|
@ -72,7 +72,7 @@ import {EnvProperties} from "../../utils/properties/env-properties";
|
|||
<span class="uk-text-muted">Publisher: </span> {{publisher}}
|
||||
<span *ngIf="journal && (journal['issn'] ||journal['lissn'] || journal['eissn'] )">
|
||||
(<a target="_blank"
|
||||
[href]="properties.sherpaURL+(journal['issn']?journal['issn']:(journal['eissn']?journal['eissn']:journal['lissn'] ))"
|
||||
[href]="properties.sherpaURL+(journal['issn']?journal['issn']:(journal['eissn']?journal['eissn']:journal['lissn'] ))+properties.sherpaURLSuffix"
|
||||
uk-tooltip="title: View information on Sherpa/RoMEO ">
|
||||
<img src="assets/common-assets/common/SHERPA-RoMEO-short-logo.gif" width=16 height=16 alt="">
|
||||
Copyright policy<span class="custom-external custom-icon space"></span>
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
||||
|
|
|
@ -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..."
|
||||
>
|
||||
</new-search-page>
|
||||
`
|
||||
|
|
|
@ -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..."
|
||||
>
|
||||
</new-search-page>
|
||||
|
||||
|
|
|
@ -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"
|
||||
>
|
||||
</new-search-page>
|
||||
|
|
|
@ -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: `
|
||||
<div class="uk-input ">
|
||||
<div class="">
|
||||
<mat-select *ngIf="dateValue && dateValue.type!='range' " name="{{'select_date_type'+filterId}}" class=" matSelection uk-input" [(ngModel)]=dateValue.type [disableOptionCentering]="true" panelClass="matSelectionPanel">
|
||||
<mat-option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</mat-option>
|
||||
</mat-select>
|
||||
<div *ngIf="dateValue && dateValue.type=='range' ">
|
||||
<div class=" uk-grid uk-" >
|
||||
<div class="uk-padding-remove uk-margin-small-left uk-width-small">
|
||||
<div class=" uk-grid uk-margin-remove-left" >
|
||||
<div class="uk-padding-remove uk-width-small">
|
||||
<mat-select name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type [disableOptionCentering]="true" class="matSelection uk-input" panelClass="matSelectionPanel">
|
||||
<mat-option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</mat-option>
|
||||
</mat-select>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -37,6 +37,7 @@ export class EnvProperties {
|
|||
openDoarURL;
|
||||
r3DataURL;
|
||||
sherpaURL;
|
||||
sherpaURLSuffix;
|
||||
|
||||
// Zenodo's url
|
||||
zenodo;
|
||||
|
|
Loading…
Reference in New Issue