Adding login token parameter in claim API requests | check for user session expiration before every API call| redirect to login page if needed | keep the current state and current url if needed
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@46951 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
490752b08e
commit
cbd4dd39ea
|
@ -1,9 +1,12 @@
|
|||
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { Router} from '@angular/router';
|
||||
import {ContextsService} from './service/contexts.service';
|
||||
import {ClaimContext} from './claimEntities.class';
|
||||
import { StaticAutoCompleteComponent } from '../../utils/staticAutoComplete/staticAutoComplete.component';
|
||||
declare var UIkit:any;
|
||||
import {Session} from '../../login/utils/helper.class';
|
||||
import {ErrorCodes} from '../../login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
// moduleId: module.id,
|
||||
|
@ -40,10 +43,14 @@ declare var UIkit:any;
|
|||
export class ClaimContextSearchFormComponent {
|
||||
// @Input() public inline:boolean = false ; // for claimed started from landing pages
|
||||
public showComponent:boolean = true ; // for claimed started from landing pages
|
||||
@Input() public selectedList = [];
|
||||
@Input() public selectedList;
|
||||
//The following need to be kept in case we have to save the current state
|
||||
@Input() public projects;
|
||||
@Input() public results;
|
||||
@Input() public inlineEntity;
|
||||
public selectedCommunityId:string = "0";
|
||||
public selectedCategoryId:string ="0";
|
||||
@Output() contextSelected = new EventEmitter();
|
||||
// @Output() contextSelected = new EventEmitter();
|
||||
|
||||
@ViewChild (StaticAutoCompleteComponent) autocomplete : StaticAutoCompleteComponent ;
|
||||
|
||||
|
@ -61,7 +68,7 @@ public loading:boolean = false;
|
|||
ngOnInit() {
|
||||
this.getCommunities();
|
||||
}
|
||||
constructor(private _contextService: ContextsService) {
|
||||
constructor(private _contextService: ContextsService,private router: Router) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -78,11 +85,8 @@ select($event){
|
|||
// this.warningMessage = "Concept already in selected list";
|
||||
}
|
||||
}
|
||||
// var UIkit:any;
|
||||
if (!found) {
|
||||
this.contextSelected.emit({
|
||||
value: true
|
||||
});
|
||||
|
||||
this.selectedList.push(context);
|
||||
UIkit.notify({
|
||||
message : 'A context is selected.',
|
||||
|
@ -102,63 +106,80 @@ select($event){
|
|||
}
|
||||
|
||||
getCommunities () {
|
||||
this.loading = true;
|
||||
this._contextService.getCommunities().subscribe(
|
||||
data => {
|
||||
this.communities = data.communities;
|
||||
this.loading = false;
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
if(!Session.isValidAndRemove()){
|
||||
this.saveStateAndRedirectLogin();
|
||||
|
||||
}else{
|
||||
this.loading = true;
|
||||
var token=Session.getUserJwt();
|
||||
this._contextService.getCommunities(token).subscribe(
|
||||
data => {
|
||||
this.communities = data.communities;
|
||||
this.loading = false;
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
getCategories () {
|
||||
console.log(" Getting Categories... ");
|
||||
this.loading = true;
|
||||
this.categories=[];
|
||||
if(this.selectedCommunityId != '0'){
|
||||
this._contextService.getCategories(this.selectedCommunityId).subscribe(
|
||||
data => {
|
||||
this.categories = data.category;
|
||||
this.concepts = [];
|
||||
this.addCommunityInConcepts();
|
||||
this.filteredList = [];
|
||||
if (this.query !== ""){
|
||||
var event = {value: ""};
|
||||
event.value = this.query;
|
||||
if(!Session.isValidAndRemove()){
|
||||
this.saveStateAndRedirectLogin();
|
||||
|
||||
}else{
|
||||
var token=Session.getUserJwt();
|
||||
this._contextService.getCategories(this.selectedCommunityId, token).subscribe(
|
||||
data => {
|
||||
this.categories = data.category;
|
||||
this.concepts = [];
|
||||
this.addCommunityInConcepts();
|
||||
this.filteredList = [];
|
||||
if (this.query !== ""){
|
||||
var event = {value: ""};
|
||||
event.value = this.query;
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
this.loading = false;
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
getConcepts () {
|
||||
this.loading = true;
|
||||
if(this.selectedCategoryId != '0'){
|
||||
this.concepts = [];
|
||||
this.addCommunityInConcepts();
|
||||
this._contextService.getConcepts(this.selectedCategoryId, "").subscribe(
|
||||
data => {
|
||||
this.concepts = data;
|
||||
this.addCommunityInConcepts();
|
||||
if (this.query !== ""){
|
||||
var event = {value: ""};
|
||||
event.value = this.query;
|
||||
// this.filter(event);
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
if(!Session.isValidAndRemove()){
|
||||
this.saveStateAndRedirectLogin();
|
||||
}else{
|
||||
this.concepts = [];
|
||||
this.addCommunityInConcepts();
|
||||
var token=Session.getUserJwt();
|
||||
this._contextService.getConcepts(this.selectedCategoryId, "",token).subscribe(
|
||||
data => {
|
||||
this.concepts = data;
|
||||
this.addCommunityInConcepts();
|
||||
if (this.query !== ""){
|
||||
var event = {value: ""};
|
||||
event.value = this.query;
|
||||
// this.filter(event);
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}else{
|
||||
this.concepts=[];
|
||||
this.loading = false;
|
||||
|
@ -190,5 +211,18 @@ addCommunityInConcepts(){
|
|||
this.concepts.push({"id":this.selectedCommunityId, "label":this.selectedCommunityLabel});
|
||||
this.autocomplete.updateList(this.concepts);
|
||||
}
|
||||
saveStateAndRedirectLogin(){
|
||||
if(this.projects != null){
|
||||
localStorage.setItem("projects", JSON.stringify(this.projects));
|
||||
}
|
||||
localStorage.setItem("contexts", JSON.stringify(this.selectedList));
|
||||
if(this.results != null){
|
||||
localStorage.setItem("results", JSON.stringify(this.results));
|
||||
}
|
||||
if(this.inlineEntity != null){
|
||||
localStorage.setItem("inlineEntity", JSON.stringify(this.inlineEntity));
|
||||
}
|
||||
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": ErrorCodes.NOT_VALID, "redirectUrl": this.router.url } });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,11 @@ import { SharedModule } from '../../shared/shared.module';
|
|||
import { ClaimContextSearchFormComponent } from './claimContextSearchForm.component';
|
||||
import{ContextsServiceModule} from './service/contextsService.module';
|
||||
import {StaticAutocompleteModule} from '../../utils/staticAutoComplete/staticAutoComplete.module';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
SharedModule,
|
||||
SharedModule,RouterModule,
|
||||
ContextsServiceModule,
|
||||
StaticAutocompleteModule
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
<div *ngIf="showSearchResults" class="uk-margin-top uk-animation">
|
||||
<ul class="uk-tab" data-uk-switcher="{connect:'#claimsearchtabs'}">
|
||||
<li class="active"><a data-toggle="tab" >Crossref ({{(crossrefResultsNum)?crossrefResultsNum:0}})</a></li>
|
||||
<li><a data-toggle="tab" >Openaire ({{ (openairePubsNum)?openairePubsNum:0 }})</a></li>
|
||||
<li><a data-toggle="tab" >Openaire Publications({{ (openairePubsNum)?openairePubsNum:0 }})</a></li>
|
||||
<li><a data-toggle="tab" >Orcid ({{ (orcidResultsNum)?orcidResultsNum:0}})</a></li>
|
||||
<li class="active"><a data-toggle="tab" >Datacite ({{(dataciteResultsNum==null)?'0':dataciteResultsNum}})</a></li>
|
||||
<li><a data-toggle="tab" >Openaire ({{(openaireDataNum==null)?'0':openaireDataNum}})</a></li>
|
||||
<li><a data-toggle="tab" >Openaire Datasets({{(openaireDataNum==null)?'0':openaireDataNum}})</a></li>
|
||||
</ul>
|
||||
<ul id="claimsearchtabs" class="uk-switcher">
|
||||
<li id="crossref" >
|
||||
|
@ -37,9 +37,8 @@
|
|||
<button class="uk-button uk-align-right" *ngIf="!isSelected(item.DOI)" (click)="add(item, item.DOI, 'crossref', 'publication', item.URL, item.title, item.created['date-time'],'OPEN')"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span><span class="uk-article-meta" *ngIf="(item['published-print'] && item['published-print']['date-parts'] && item['published-print']['date-parts'][0])">({{(item['published-print']['date-parts'][0][0])?item['published-print']['date-parts'][0][0]:item['published-print']['date-parts'][0]}})</span>
|
||||
<div *ngIf="item.author" class="uk-article-meta">Authors: <span *ngFor="let author of item.author let i = index">{{author.family}} {{author.given}}{{(i < (item.author.length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="item.editor" class="uk-article-meta">Editors: <span *ngFor="let author of item.editor let i = index">{{author.family}} {{author.given}}{{(i < (item.editor.length-1))?"; ":""}}</span></div>
|
||||
|
||||
<div *ngIf="item.author && item.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of item.author.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (item.author.slice(0,10).length-1))?"; ":""}}{{(i == item.author.slice(0,10).length-1 && item.author.length > 10)?"...":""}}</span></div>
|
||||
<div *ngIf="item.editor && item.editor.length > 0" class="uk-article-meta">Editors: <span *ngFor="let author of item.editor.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (item.editor.slice(0,10).length-1))?"; ":""}}{{(i == item.editor.slice(0,10).length-1 && item.editor.length > 10)?"...":""}}</span></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -65,7 +64,8 @@
|
|||
<button *ngIf="!isSelected(result.id)" (click)="add(result, result.id, 'openaire', 'publication', result['title'].url, result['title'].name, result.year,result['title'].accessMode)" class="uk-button uk-align-right"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span class="uk-article-meta" *ngIf="(result.year)">({{result.year}})</span>
|
||||
<div *ngIf="result.authors" class="uk-article-meta">Authors: <span *ngFor="let author of result.authors let i = index">{{author.name}}{{(i < (result.authors.length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="result.authors && result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (result.authors.slice(0,10).length-1))?"; ":""}}{{(i == result.authors.slice(0,10).length-1 && result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -109,7 +109,7 @@
|
|||
<button class="uk-button uk-align-right" *ngIf="!isSelected(authorId+item['put-code'])" (click)="add(item,authorId+'-'+item['put-code'],'orcid', 'publication', '', item['work-title']['title'].value, item['publication-date']?item['publication-date'].year.value :null,'OPEN')"><i aria-hidden="true" class= " uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="item['journal-title'] && item['journal-title'].value " class="uk-article-meta">Journal: {{item['journal-title'].value}}</span><span class="uk-article-meta" *ngIf="(item['publication-date']&&item['publication-date'].year&&item['publication-date'].year.value)"> ({{item['publication-date'].year.value}})</span>
|
||||
<div *ngIf="item.contributors" class="uk-article-meta">Authors: <span *ngFor="let author of item.contributors let i = index">{{author}}{{(i < (item.contributors.length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="item.contributors && item.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of item.contributors.slice(0,10) let i = index">{{author}}{{(i < (item.contributors.slice(0,10).length-1))?"; ":""}}{{(i == item.contributors.slice(0,10).length-1 && item.contributors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -129,7 +129,6 @@
|
|||
<paging-no-load [currentPage]="datacitePage" [totalResults]="dataciteResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="datacitePageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
</div>
|
||||
<!--div *ngIf="dataciteResultsNum == null || dataciteResultsNum == 0" class="uk-alert uk-alert-info" role="alert">No results found</div-->
|
||||
<div >
|
||||
<ul *ngIf="dataciteResults.length > 0 " class="uk-list uk-list-line">
|
||||
<li *ngFor=" let item of dataciteResults " [class]="(isSelected(item.doi))?'uk-block-muted':''" >
|
||||
|
@ -140,7 +139,7 @@
|
|||
|
||||
</div>
|
||||
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span>
|
||||
<div *ngIf="item.creator" class="uk-article-meta">Authors: <span *ngFor="let author of item.creator let i = index">{{author}}{{(i < (item.creator.length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="item.creator && item.creator.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of item.creator.slice(0,10) let i = index">{{author}}{{(i < (item.creator.slice(0,10).length-1))?"; ":""}}{{(i == item.creator.slice(0,10).length-1 && item.creator.length > 10)?"...":""}}</span></div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -171,11 +170,11 @@
|
|||
(click)="add(result, result.id, 'openaire','dataset', result['title'].url, result['title'].name, result.year, result['title'].accessMode)"> <i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span *ngIf="(result.year)" class="uk-article-meta">({{result.year}})</span>
|
||||
<div *ngIf="result.authors" class="uk-article-meta">Authors: <span *ngFor="let author of result.authors let i = index">{{author.name}}{{(i < (result.authors.length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="result.authors && result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (result.authors.slice(0,10).length-1))?"; ":""}}{{(i == result.authors.slice(0,10).length-1 && result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<!--div *ngIf="openaireData.length == 0" class = "uk-alert uk-alert-info " > No results found </div-->
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
|
|
@ -513,7 +513,7 @@ openaireDataPageChange($event) {
|
|||
result.type = itemType;
|
||||
result.source = itemSource;
|
||||
|
||||
result.title = Array.isArray(itemTitle && itemTitle.length > 0 )?itemTitle[0]:itemTitle;
|
||||
result.title = (Array.isArray(itemTitle) && itemTitle.length > 0 )?itemTitle[0]:itemTitle;
|
||||
result.url = itemUrl;
|
||||
result.accessRights = 'OPEN';
|
||||
result.embargoEndDate = this.nextDate;
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
<div *ngIf="showErrorMessage " class = "uk-alert uk-alert-danger " >
|
||||
An Error occured.
|
||||
</div>
|
||||
|
||||
<div *ngIf="userValidMessage.length > 0 " class = "uk-alert uk-alert-danger " >
|
||||
User session is not valid. Please login again.
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Buttons for selecting and Delete Claims -->
|
||||
|
@ -44,7 +46,7 @@
|
|||
You have selected {{selected.length}} claim(s)
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="deleteMessage.length>0 " [innerHTML]="deleteMessage">
|
||||
<div *ngIf="deleteMessage.length>0 " class = "uk-alert uk-alert-info " [innerHTML]="deleteMessage">
|
||||
|
||||
</div>
|
||||
<button class="uk-button" (click)="selectAll()">Select All</button> <button class="uk-button" (click)="deselectAll()">Deselect All</button> <button class="uk-button" (click)="confirmOpen()">Delete</button>
|
||||
|
|
|
@ -84,6 +84,7 @@ export class DisplayClaimsComponent {
|
|||
selected=[];
|
||||
deleteMessage:string = "";
|
||||
showErrorMessage:boolean = false;
|
||||
userValidMessage:string = "";
|
||||
|
||||
//params for pagingFormatter to use when navigate to page
|
||||
params;
|
||||
|
@ -92,6 +93,11 @@ export class DisplayClaimsComponent {
|
|||
claimsDeleted:number = 0;
|
||||
|
||||
getClaims () {
|
||||
if(!Session.isValidAndRemove()){
|
||||
this.userValidMessage = "User session has expired. Please login again.";
|
||||
|
||||
}else{
|
||||
var token=Session.getUserJwt();
|
||||
this.selected=[];
|
||||
var types = '';
|
||||
this.showErrorMessage = false;
|
||||
|
@ -99,7 +105,7 @@ export class DisplayClaimsComponent {
|
|||
types+=(types.length>0?'&':'')+"types="+type;
|
||||
}
|
||||
if(this.fetchBy =="Project" ){
|
||||
this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
|
||||
this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= data.total;
|
||||
|
@ -110,7 +116,7 @@ export class DisplayClaimsComponent {
|
|||
}
|
||||
);
|
||||
}else if(this.fetchBy =="User"){
|
||||
this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
|
||||
this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= data.total;
|
||||
|
@ -121,7 +127,7 @@ export class DisplayClaimsComponent {
|
|||
}
|
||||
);
|
||||
}else if(this.fetchBy =="Result"){
|
||||
this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
|
||||
this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= data.total;
|
||||
|
@ -132,7 +138,7 @@ export class DisplayClaimsComponent {
|
|||
}
|
||||
);
|
||||
}else if(this.fetchBy =="Context"){
|
||||
this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
|
||||
this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= null;
|
||||
|
@ -144,7 +150,7 @@ export class DisplayClaimsComponent {
|
|||
}
|
||||
);
|
||||
}else{
|
||||
this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types).subscribe(
|
||||
this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types,token).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum = null;
|
||||
|
@ -157,6 +163,7 @@ export class DisplayClaimsComponent {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
goToClaim(claimId: number){
|
||||
this._router.navigate( ['Claim', { id: claimId}] );
|
||||
|
@ -381,10 +388,14 @@ export class DisplayClaimsComponent {
|
|||
}
|
||||
|
||||
deleteById(id:string){
|
||||
if(!Session.isValidAndRemove()){
|
||||
this.userValidMessage = "User session has expired. Please login again.";
|
||||
|
||||
}else{
|
||||
var token=Session.getUserJwt();
|
||||
console.log("Deleting claim with id:"+id);
|
||||
// this._claimService.deleteClaimById(id);
|
||||
this._claimService.deleteClaimById(id).subscribe(
|
||||
this._claimService.deleteClaimById(id,token).subscribe(
|
||||
res => {
|
||||
console.log('Delete response'+res.code );
|
||||
console.log("Deleted claim with id:"+ id);
|
||||
|
@ -407,11 +418,16 @@ export class DisplayClaimsComponent {
|
|||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
batchDeleteById(ids:string[]){
|
||||
if(!Session.isValidAndRemove()){
|
||||
this.userValidMessage = "User session has expired. Please login again.";
|
||||
|
||||
}else{
|
||||
var token=Session.getUserJwt();
|
||||
console.warn("Deleting claim with ids:"+ids);
|
||||
this._claimService.deleteBulk(ids).subscribe(
|
||||
this._claimService.deleteBulk(ids,token).subscribe(
|
||||
res => {
|
||||
console.info('Delete response'+res.code );
|
||||
console.warn("Deleted ids:"+ res.deletedIds);
|
||||
|
@ -442,6 +458,7 @@ export class DisplayClaimsComponent {
|
|||
this.deleteMessage=this.deleteMessage+'<div class = "alert alert-warning " >'+res.notFoundIds.length+' claim(s) couldn\'t be deleted.</div>';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
pageChange($event) {
|
||||
var page:number = +$event.value
|
||||
|
|
|
@ -16,13 +16,13 @@ export class ClaimsService {
|
|||
this.baseUrl = OpenaireProperties.getClaimsAPIURL();
|
||||
}
|
||||
|
||||
private getClaimRequest(size : number, page : number, url :string, fromCache:boolean):any {
|
||||
private getClaimRequest(size : number, page : number, url :string, fromCache:boolean,token:string):any {
|
||||
console.info('ClaimsService: Claims request: '+url);
|
||||
let key = url;
|
||||
if (fromCache && this._cache.has(key)) {
|
||||
return Observable.of(this._cache.get(key));
|
||||
}
|
||||
return this.http.get( url)
|
||||
return this.http.get( url+"&token="+token)
|
||||
.map(request => <any> request.json())
|
||||
.do(request => console.info("Get claims: offset = "+(size*(page-1)) + " limit ="+size ))
|
||||
.catch(this.handleError)
|
||||
|
@ -30,40 +30,40 @@ export class ClaimsService {
|
|||
this._cache.set(key, res);
|
||||
});
|
||||
}
|
||||
getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
|
||||
console.info('ClaimsService: getClaims ' );
|
||||
console.info('ClaimsService: Types : '+types );
|
||||
let url = this.baseUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||
return this.getClaimRequest(size,page,url,true);
|
||||
return this.getClaimRequest(size,page,url,true,token);
|
||||
|
||||
}
|
||||
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
|
||||
console.info('ClaimsService: getClaims for user : '+user);
|
||||
let url = this.baseUrl +"users/"+user+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||
return this.getClaimRequest(size,page,url,false);
|
||||
return this.getClaimRequest(size,page,url,false,token);
|
||||
|
||||
}
|
||||
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
|
||||
console.info('ClaimsService: getClaims for context : '+contextId);
|
||||
let url = this.baseUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||
return this.getClaimRequest(size,page,url,true);
|
||||
return this.getClaimRequest(size,page,url,true,token);
|
||||
|
||||
}
|
||||
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
|
||||
console.info('ClaimsService: getClaims for result : '+resultId);
|
||||
let url = this.baseUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||
return this.getClaimRequest(size,page,url,true);
|
||||
return this.getClaimRequest(size,page,url,true,token);
|
||||
|
||||
}
|
||||
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
|
||||
console.info('ClaimsService: getClaims for project : '+projectId);
|
||||
let url = this.baseUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||
return this.getClaimRequest(size,page,url,true);
|
||||
return this.getClaimRequest(size,page,url,true,token);
|
||||
}
|
||||
|
||||
deleteClaimById(claimId:string):any{
|
||||
deleteClaimById(claimId:string,token:string):any{
|
||||
console.warn('Trying to delete claim with id : '+claimId);
|
||||
let url = this.baseUrl +"claims/"+claimId;
|
||||
let url = this.baseUrl +"claims/"+claimId+"?token="+token;
|
||||
let headers = new Headers({ 'Content-Type': 'application/json' });
|
||||
let options = new RequestOptions({ headers: headers });
|
||||
return this.http.delete( url, options).map(request => <any> request.json())
|
||||
|
@ -71,7 +71,7 @@ export class ClaimsService {
|
|||
.catch(this.handleError);
|
||||
|
||||
}
|
||||
deleteBulk(claimIds:string[]):any{
|
||||
deleteBulk(claimIds:string[],token:string):any{
|
||||
|
||||
console.warn('Trying to delete claims with ids : '+claimIds);
|
||||
var url = "";
|
||||
|
@ -79,7 +79,7 @@ export class ClaimsService {
|
|||
for(var claimId of claimIds){
|
||||
url=url+(url.length >0 ?"&":"")+"claimId="+claimId;
|
||||
}
|
||||
url= this.baseUrl +"claims/bulk?"+url;
|
||||
url= this.baseUrl +"claims/bulk?"+url+"&token="+token;
|
||||
let headers = new Headers({ 'Content-Type': 'application/json' });
|
||||
let options = new RequestOptions({ headers: headers });
|
||||
return this.http.delete( url, options).map(request => <any> request.json())
|
||||
|
@ -87,9 +87,9 @@ export class ClaimsService {
|
|||
.catch(this.handleError);
|
||||
|
||||
}
|
||||
insertBulkClaims(claims):any{
|
||||
insertBulkClaims(claims,token:string):any{
|
||||
console.warn('Trying toinsert claims : '+claims);
|
||||
let url = this.baseUrl +"claims/bulk";
|
||||
let url = this.baseUrl +"claims/bulk"+"?token="+token;
|
||||
let body = JSON.stringify( claims );
|
||||
console.warn('Json body: : '+body);
|
||||
let headers = new Headers({ 'Content-Type': 'application/json' });
|
||||
|
@ -100,9 +100,9 @@ export class ClaimsService {
|
|||
.catch(this.handleError);
|
||||
|
||||
}
|
||||
insertClaim(claim):any{
|
||||
insertClaim(claim,token:string):any{
|
||||
console.warn('Trying toinsert claim : '+claim);
|
||||
let url = this.baseUrl +"claims";
|
||||
let url = this.baseUrl +"claims"+"?token="+token;
|
||||
let body = JSON.stringify( claim );
|
||||
let headers = new Headers({ 'Content-Type': 'application/json' });
|
||||
let options = new RequestOptions({ headers: headers });
|
||||
|
@ -120,8 +120,8 @@ export class ClaimsService {
|
|||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
|
||||
getClaim(id:string):any {
|
||||
let url = this.baseUrl+"claims/"+id;
|
||||
getClaim(id:string,token:string):any {
|
||||
let url = this.baseUrl+"claims/"+id+"?token="+token;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url)
|
||||
.map(res => res.json())
|
||||
|
|
|
@ -17,7 +17,7 @@ export class ContextsService {
|
|||
this.baseUrl = OpenaireProperties.getClaimsAPIURL();
|
||||
}
|
||||
|
||||
public getCommunities():any {
|
||||
public getCommunities(token:string):any {
|
||||
let url = this.baseUrl + 'communities';
|
||||
let key = url;
|
||||
if (this._cache.has(key)) {
|
||||
|
@ -25,7 +25,7 @@ export class ContextsService {
|
|||
}
|
||||
|
||||
console.info('ContextsService: request communities '+url);
|
||||
return this.http.get( url)
|
||||
return this.http.get( url+"?token="+token)
|
||||
.map(request => <any> request.json().data)
|
||||
// .do(request => console.info("Get claims: offset = "))
|
||||
.catch(this.handleError)
|
||||
|
@ -33,7 +33,7 @@ export class ContextsService {
|
|||
this._cache.set(key, res);
|
||||
});
|
||||
}
|
||||
public getCategories(communityId :string):any {
|
||||
public getCategories(communityId :string,token:string):any {
|
||||
console.info('ContextsService: request categories for community with id '+communityId);
|
||||
let url= this.baseUrl + 'communities/' + communityId + '/categories';
|
||||
let key = url;
|
||||
|
@ -41,7 +41,7 @@ export class ContextsService {
|
|||
return Observable.of(this._cache.get(key));
|
||||
}
|
||||
|
||||
return this.http.get( url)
|
||||
return this.http.get( url+"?token="+token)
|
||||
.map(request => <any> request.json().data)
|
||||
// .do(request => console.info("Get claims: offset = " ))
|
||||
.catch(this.handleError)
|
||||
|
@ -49,7 +49,7 @@ export class ContextsService {
|
|||
this._cache.set(key, res);
|
||||
});
|
||||
}
|
||||
public getConcepts(categoryId :string, keyword: string):any {
|
||||
public getConcepts(categoryId :string, keyword: string,token:string):any {
|
||||
console.info('ContextsService: request concept for category with id '+categoryId + ' and keyword '+ keyword);
|
||||
let url= this.baseUrl + 'categories/' + categoryId+ "/concepts";
|
||||
let key = url;
|
||||
|
@ -57,7 +57,7 @@ export class ContextsService {
|
|||
return Observable.of(this._cache.get(key));
|
||||
}
|
||||
|
||||
return this.http.get( url)
|
||||
return this.http.get( url+"?token="+token)
|
||||
.map(request => <any> request.json().data)
|
||||
.map(res => this.parse(res.concept))
|
||||
// .do(res => console.info(res ))
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {OpenaireProperties} from '../../../utils/properties/openaireProperties';
|
||||
import 'rxjs/add/observable/of';
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/share';
|
||||
|
||||
@Injectable()
|
||||
export class DirectIndexClaimService {
|
||||
private baseUrl;
|
||||
constructor(private jsonp: Jsonp, private http: Http) {
|
||||
this.baseUrl = OpenaireProperties.getClaimsAPIURL();
|
||||
}
|
||||
|
||||
public directClaim(record:any):any {
|
||||
console.log("in direct claim service");
|
||||
let url = "http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject";
|
||||
// let body = JSON.stringify( record );
|
||||
// console.warn('Direct Json body: : '+body);
|
||||
console.warn('Direct Json record: : '+record);
|
||||
let headers = new Headers({ 'Content-Type': 'application/json' });
|
||||
let options = new RequestOptions({ headers: headers });
|
||||
return this.http.post(url, record, options)
|
||||
.map(res => res.json())
|
||||
.do(request => console.info("DirectClaim Response:"+request) )
|
||||
.catch(this.handleError);
|
||||
|
||||
|
||||
}
|
||||
private handleError (error: Response) {
|
||||
// in a real world app, we may send the error to some remote logging infrastructure
|
||||
// instead of just logging it to the console
|
||||
console.log(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import {Observable} from 'rxjs/Observable';
|
|||
</div>
|
||||
<div>
|
||||
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>
|
||||
<displayClaims [enableDelete]=false [myClaims]=false [isAdmin]=true></displayClaims>
|
||||
<displayClaims [enableDelete]=true [myClaims]=false [isAdmin]=true></displayClaims>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
|
|
|
@ -28,7 +28,7 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
|||
<a *ngIf="displayedResult.url" target="_blank" href="{{displayedResult.url}}" ><span class="uk-icon-external-link" ></span> {{displayedResult.title}}</a>
|
||||
<span *ngIf="!displayedResult.url" >{{displayedResult.title}}</span>
|
||||
</div>
|
||||
<div *ngIf="displayedResult.result.authors && displayedResult.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of displayedResult.result.authors let i = index">{{author.name}}{{(i < (displayedResult.result.authors.length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="displayedResult.result.authors && displayedResult.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of displayedResult.result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (displayedResult.result.authors.slice(0,10).length-1))?"; ":""}}{{(i == displayedResult.result.authors.slice(0,10).length-1 && displayedResult.result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -43,7 +43,7 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
|||
<div class = "uk-margin-top">
|
||||
|
||||
<div *ngIf=" linkTo =='context' " >
|
||||
<claim-selected-contexts title="with Communities" [contexts]="contexts" [show]="show" [linkType]=linkType
|
||||
<claim-selected-contexts title="with Communities" [contexts]="contexts" [projects]="projects" [results]="results" [inlineEntity] = "inlineResult" [show]="show" [linkType]=linkType
|
||||
(showChange)="showChange($event)" > </claim-selected-contexts>
|
||||
</div>
|
||||
<div *ngIf=" linkTo =='project' " >
|
||||
|
@ -93,6 +93,27 @@ export class DirectLinkingComponent {
|
|||
|
||||
}
|
||||
ngOnInit() {
|
||||
if(localStorage.getItem("projects")){
|
||||
this.projects = JSON.parse(localStorage.getItem("projects"));
|
||||
}
|
||||
if(localStorage.getItem("contexts")){
|
||||
this.contexts = JSON.parse(localStorage.getItem("contexts"));
|
||||
}
|
||||
if(localStorage.getItem("results")){
|
||||
this.results = JSON.parse(localStorage.getItem("results"));
|
||||
}
|
||||
if(localStorage.getItem("results")){
|
||||
this.results = JSON.parse(localStorage.getItem("results"));
|
||||
}
|
||||
if(localStorage.getItem("inlineEntity")){
|
||||
this.inlineResult = JSON.parse(localStorage.getItem("inlineEntity"));
|
||||
}
|
||||
|
||||
localStorage.removeItem("projects");
|
||||
localStorage.removeItem("contexts");
|
||||
localStorage.removeItem("results");
|
||||
localStorage.removeItem("inlineEntity");
|
||||
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.id = params['id'];
|
||||
this.type = params['type'];
|
||||
|
|
|
@ -2,10 +2,14 @@ import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
|
|||
import {Observable} from 'rxjs/Observable';
|
||||
import {Router} from '@angular/router';
|
||||
import {ClaimsService} from '../../claim-utils/service/claims.service';
|
||||
import {DirectIndexClaimService} from '../../claim-utils/service/directIndexClaim.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 {ErrorCodes} from '../../../login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'claim-insert',
|
||||
template: `
|
||||
|
@ -16,6 +20,8 @@ import {Session} from '../../../login/utils/helper.class';
|
|||
<div *ngIf="warningMessage.length > 0">
|
||||
<div class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
||||
</div>
|
||||
|
||||
|
||||
<modal-loading [message]= "'Please wait...'"></modal-loading>
|
||||
<modal-alert (alertOutput)="confirmClose($event)">
|
||||
</modal-alert>
|
||||
|
@ -23,7 +29,7 @@ import {Session} from '../../../login/utils/helper.class';
|
|||
`
|
||||
})
|
||||
export class ClaimInsertComponent {
|
||||
constructor (private claimService: ClaimsService, private _router:Router) {}
|
||||
constructor (private claimService: ClaimsService,private directIndexClaimService:DirectIndexClaimService, private _router:Router) {}
|
||||
ngOnInit() {
|
||||
// console.info("Inlineentity:" +(this.inlineEntity)?this.inlineEntity+(this.inlineEntity.id)?this.inlineEntity.id:"no id":"null"+ + " show "+ (!this.claiming && this.showButton) );
|
||||
}
|
||||
|
@ -59,9 +65,21 @@ public validateInsertions(){
|
|||
return
|
||||
}
|
||||
private insert(){
|
||||
if(!Session.isValidAndRemove()){
|
||||
this.showButton = false;
|
||||
localStorage.setItem("projects", JSON.stringify(this.projects));
|
||||
localStorage.setItem("contexts", JSON.stringify(this.contexts));
|
||||
localStorage.setItem("results", JSON.stringify(this.results));
|
||||
if(this.inlineEntity != null){
|
||||
localStorage.setItem("inlineEntity", JSON.stringify(this.inlineEntity));
|
||||
}
|
||||
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": ErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
|
||||
}else{
|
||||
this.claiming = true;
|
||||
var user=Session.getUserEmail();
|
||||
var jwt=Session.getUserJwt();
|
||||
var token=Session.getUserJwt();
|
||||
this.loading.open();
|
||||
var claims = [];
|
||||
var directclaims = [];
|
||||
|
@ -70,7 +88,7 @@ private insert(){
|
|||
|
||||
for (var i = 0; i < this.results.length; i++) {
|
||||
var result=this.results[i];
|
||||
if(["crosreff","datacite","orcid"].indexOf(result.source) != -1){
|
||||
if(["crossref","datacite","orcid"].indexOf(result.source) != -1){
|
||||
directclaims.push(this.createDirectClaim(result,this.projects,this.contexts));
|
||||
}
|
||||
if(this.contexts){
|
||||
|
@ -94,9 +112,30 @@ private insert(){
|
|||
|
||||
}
|
||||
}
|
||||
var created =[];
|
||||
var failed =[];
|
||||
console.info("\n\ndirectclaims: "+directclaims.length+"\n\n");
|
||||
for(var i = 0; i<directclaims.length; i++){
|
||||
// console.info("\n\ntry to direct insert: "+JSON.stringify(directclaims[i])+"\n\n");
|
||||
|
||||
this.directIndexClaimService.directClaim(directclaims[i]).subscribe(
|
||||
data => {
|
||||
console.log("AAA" + data);
|
||||
created.push(directclaims[i].originalId)
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
failed.push(directclaims[i].originalId)
|
||||
if(failed.length + created.length == directclaims.length){
|
||||
console.log("failed:"+failed);
|
||||
console.log("created:"+created);
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
console.info("try to insert "+claims.length+" claims");
|
||||
this.claimService.insertBulkClaims(claims).subscribe(
|
||||
this.claimService.insertBulkClaims(claims,token).subscribe(
|
||||
data => {
|
||||
var inserted = data.insertedIds.length;
|
||||
|
||||
|
@ -108,6 +147,8 @@ private insert(){
|
|||
this.errorsInClaimsInsertion(err.insertedIds,err.errorInClaims);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
private validate(){
|
||||
this.warningMessage = "";
|
||||
|
@ -212,6 +253,8 @@ createDirectClaim(result, projects, contexts){
|
|||
var md5_id = Md5.hashStr(result.id);
|
||||
entity["originalId"]="user:claim__"+md5_id;
|
||||
entity["title"]=result.title;
|
||||
entity["title"] =(Array.isArray(result.title) && result.title.length > 0 )?result.title[0]:result.title;
|
||||
|
||||
if(result.authors && result.authors.length > 0){
|
||||
entity["authors"]=result.authors;
|
||||
}
|
||||
|
@ -225,7 +268,7 @@ createDirectClaim(result, projects, contexts){
|
|||
entity["type"]=result.type;
|
||||
if(result.source == "crossref" || result.source == "datacite"){
|
||||
entity["pids"]= [];//{type:string, value:string}[];
|
||||
entity["pids"].push({type:"DOI",value:result.id})
|
||||
entity["pids"].push({type:"doi",value:result.id})
|
||||
}
|
||||
entity["licenseCode"]=result.accessRights;
|
||||
if(result.accessRights == "EMBARGO"){
|
||||
|
|
|
@ -5,13 +5,14 @@ import {AlertModalModule} from '../../../utils/modal/alertModal.module';
|
|||
import {LoadingModalModule} from '../../../utils/modal/loadingModal.module';
|
||||
import {ClaimInsertComponent} from './insertClaim.component';
|
||||
import {ClaimServiceModule} from '../../claim-utils/service/claimsService.module';
|
||||
import {DirectIndexClaimService} from '../../claim-utils/service/directIndexClaim.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
SharedModule, AlertModalModule, LoadingModalModule, ClaimServiceModule
|
||||
],
|
||||
declarations: [
|
||||
ClaimInsertComponent
|
||||
], exports:[ ClaimInsertComponent]
|
||||
declarations: [ClaimInsertComponent],
|
||||
providers:[DirectIndexClaimService],
|
||||
exports:[ ClaimInsertComponent]
|
||||
})
|
||||
export class InsertClaimsModule { }
|
||||
|
|
|
@ -26,7 +26,7 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
|||
<!-- link with Projects & Contexts -->
|
||||
<div class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 ">
|
||||
<claim-selected-contexts title="link Communities" [contexts]="contexts" [show]="show" [linkType]=linkType
|
||||
<claim-selected-contexts title="link Communities" [contexts]="contexts" [projects]="projects" [results]="results" [inlineEntity] = "inlineResult" [show]="show" [linkType]=linkType
|
||||
(showChange)="showChange($event)" > </claim-selected-contexts>
|
||||
</div>
|
||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 ">
|
||||
|
@ -83,6 +83,22 @@ export class LinkingGenericComponent {
|
|||
|
||||
}
|
||||
ngOnInit() {
|
||||
if( typeof localStorage !== 'undefined') {
|
||||
if(localStorage.getItem("projects")){
|
||||
this.projects = JSON.parse(localStorage.getItem("projects"));
|
||||
|
||||
}
|
||||
if(localStorage.getItem("contexts")){
|
||||
this.contexts = JSON.parse(localStorage.getItem("contexts"));
|
||||
}
|
||||
if(localStorage.getItem("results")){
|
||||
this.results = JSON.parse(localStorage.getItem("results"));
|
||||
|
||||
}
|
||||
localStorage.removeItem("projects");
|
||||
localStorage.removeItem("contexts");
|
||||
localStorage.removeItem("results");
|
||||
}
|
||||
}
|
||||
|
||||
next(){
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {Component, Input,Output, EventEmitter} from '@angular/core';
|
||||
import {ClaimContext} from '../../claim-utils/claimEntities.class';
|
||||
|
||||
@Component({
|
||||
selector: 'claim-selected-contexts',
|
||||
template: `
|
||||
|
@ -8,9 +9,9 @@ import {ClaimContext} from '../../claim-utils/claimEntities.class';
|
|||
|
||||
<div class="uk-accordion" data-uk-accordion="{showfirst:true}">
|
||||
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> {{title}} ({{(contexts.length)}})</h3>
|
||||
<div class="uk-accordion-content" >
|
||||
<div class="uk-accordion-content" ><!--(contextSelected)="contextSelected($event)"-->
|
||||
<div class="uk-clearfix"><button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button uk-animation uk-float-right">Add more <i class="uk-icon-plus"></i></button></div>
|
||||
<claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" (contextSelected)="contextSelected($event)" > </claim-contexts-search-form>
|
||||
<claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" [projects]="projects" [results]="results" [inlineEntity]="inlineEntity" > </claim-contexts-search-form>
|
||||
<ul class="uk-list uk-list-line">
|
||||
<li class="list-group-item" *ngFor="let context of contexts" >
|
||||
<span *ngIf="context.community != context.concept.label">{{context.community }} > {{context.category}} ></span><span> {{context.concept.label}} </span>
|
||||
|
@ -21,21 +22,6 @@ import {ClaimContext} from '../../claim-utils/claimEntities.class';
|
|||
<div *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no communities</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--div *ngIf="this.linkType != 'context'" class="uk-accordion" data-uk-accordion="{showfirst:false}">
|
||||
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i>{{title}} ({{(contexts.length)}})</h3>
|
||||
<div class="uk-accordion-content" >
|
||||
<div class="uk-clearfix"><button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button uk-float-right">Add more <i class="uk-icon-plus"></i></button></div>
|
||||
<claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" (contextSelected)="contextSelected($event)" > </claim-contexts-search-form>
|
||||
<ul class="uk-list uk-list-line">
|
||||
<li class="list-group-item" *ngFor="let context of contexts" >
|
||||
<span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span>
|
||||
<span (click)="removeContext(context)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no communities.</div>
|
||||
</div>
|
||||
</div-->
|
||||
|
||||
|
||||
`
|
||||
|
@ -55,6 +41,10 @@ export class ClaimSelectedContextsComponent {
|
|||
|
||||
|
||||
@Input() contexts:ClaimContext[];
|
||||
//The following need to be kept in case we have to save the current state
|
||||
@Input() public projects;
|
||||
@Input() public results;
|
||||
@Input() public inlineEntity;
|
||||
@Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects)
|
||||
@Input() show='home';
|
||||
@Input() title='Communities';
|
||||
|
@ -63,6 +53,7 @@ export class ClaimSelectedContextsComponent {
|
|||
@Input() hideType;
|
||||
@Input() bulkMode:boolean = false;
|
||||
@Output() showChange = new EventEmitter();
|
||||
|
||||
showsearch:boolean = false;
|
||||
|
||||
todayDate = '';
|
||||
|
|
|
@ -39,18 +39,17 @@ import {Dates} from '../../../utils/string-utils.class';
|
|||
</div>
|
||||
<!-- Crossref -->
|
||||
<span *ngIf="pub.result.publisher" class="uk-article-meta">Publisher: {{pub.result.publisher}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span>
|
||||
<div *ngIf="pub.result.author && pub.result.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.author.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.author.slice(0,10).length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="pub.result.editor && pub.result.editor.length" class="uk-article-meta">Editors: <span *ngFor="let author of pub.result.editor.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.editor.slice(0,10).length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="pub.result.author && pub.result.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.author.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.author.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.author.slice(0,10).length-1 && pub.result.author.length > 10)?"...":""}}</span></div>
|
||||
<div *ngIf="pub.result.editor && pub.result.editor.length > 0" class="uk-article-meta">Editors: <span *ngFor="let author of pub.result.editor.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.editor.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.editor.slice(0,10).length-1 && pub.result.editor.length > 10)?"...":""}}</span></div>
|
||||
|
||||
<!-- Openaire -->
|
||||
<div *ngIf="pub.result.authors && pub.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (pub.result.authors.slice(0,10).length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="pub.result.authors && pub.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (pub.result.authors.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.authors.slice(0,10).length-1 && pub.result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
<!-- Orcid -->
|
||||
<span *ngIf="pub.result['journal-title'] && pub.result['journal-title'].value " class="uk-article-meta">Journal: {{pub.result['journal-title'].value}}</span>
|
||||
<div *ngIf="pub.result.contributors && pub.result.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.contributors.slice(0,10) let i = index">{{author}}{{(i < (pub.result.contributors.slice(0,10).length-1))?"; ":""}}</span></div>
|
||||
<div *ngIf="pub.result.contributors && pub.result.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.contributors.slice(0,10) let i = index">{{author}}{{(i < (pub.result.contributors.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.contributors.slice(0,10).length-1 && pub.result.contributors.length > 10)?"...":""}}</span></div>
|
||||
<!-- Datacite -->
|
||||
<div *ngIf="pub.result.creator" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.creator.slice(0,10) let i = index">{{author}}{{(i < (pub.result.creator.slice(0,10).length-1))?"; ":""}}</span></div>
|
||||
<br>****sliced***<br>
|
||||
<div *ngIf="pub.result.creator && pub.result.creator.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.creator.slice(0,10) let i = index">{{author}}{{(i < (pub.result.creator.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.creator.slice(0,10).length-1 && pub.result.creator.length > 10)?"...":""}}</span></div>
|
||||
</div>
|
||||
<div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-3-10">
|
||||
<span *ngIf="showAccessRights && pub.source != 'openaire' " class="dropdown">
|
||||
|
|
|
@ -12,7 +12,7 @@ import {Observable} from 'rxjs/Observable';
|
|||
</div>
|
||||
<div>
|
||||
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>
|
||||
<displayClaims [enableDelete]=false [myClaims]=true [isAdmin]=false ></displayClaims>
|
||||
<displayClaims [enableDelete]=true [myClaims]=true [isAdmin]=false ></displayClaims>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||
import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Session} from './utils/helper.class';
|
||||
import {ErrorCodes} from './utils/guardHelper.class';
|
||||
@Injectable()
|
||||
export class AdminLoginGuard implements CanActivate {
|
||||
|
||||
|
@ -11,28 +12,30 @@ export class AdminLoginGuard implements CanActivate {
|
|||
var user;
|
||||
var loggedIn = false;
|
||||
var isAdmin = false;
|
||||
var errorCode = 1;
|
||||
var errorCode = ErrorCodes.NOT_LOGGIN;
|
||||
|
||||
if(Session.isLoggedIn()){
|
||||
loggedIn = true;
|
||||
if(!Session.isValidAndRemove()){
|
||||
loggedIn = false;
|
||||
errorCode = 3;
|
||||
errorCode = ErrorCodes.NOT_VALID;
|
||||
}else {
|
||||
isAdmin = Session.isAdminUser();
|
||||
if(!isAdmin){
|
||||
errorCode = 2;
|
||||
errorCode = ErrorCodes.NOT_ADMIN;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
errorCode =1;
|
||||
errorCode =ErrorCodes.NOT_LOGGIN;
|
||||
}
|
||||
|
||||
if(!loggedIn){
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
|
||||
return false;
|
||||
}else if(!isAdmin){
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
return false;
|
||||
}else{
|
||||
|
|
|
@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
|
|||
import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Session} from './utils/helper.class';
|
||||
import {ErrorCodes} from './utils/guardHelper.class';
|
||||
|
||||
@Injectable()
|
||||
export class FreeGuard implements CanActivate {
|
||||
|
||||
|
@ -11,18 +13,20 @@ export class FreeGuard implements CanActivate {
|
|||
var user;
|
||||
var valid = true;
|
||||
var loggedIn = false;
|
||||
var errorCode = 1;
|
||||
var errorCode = ErrorCodes.NOT_LOGGIN;
|
||||
|
||||
if(Session.isLoggedIn()){
|
||||
loggedIn = true;
|
||||
if(!Session.isValidAndRemove()){
|
||||
loggedIn = false;
|
||||
valid = false;
|
||||
errorCode = 3;
|
||||
errorCode = ErrorCodes.NOT_VALID;
|
||||
}
|
||||
}
|
||||
|
||||
if(!valid){
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||
import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Session} from './utils/helper.class';
|
||||
import {ErrorCodes} from './utils/guardHelper.class';
|
||||
|
||||
@Injectable()
|
||||
export class LoginGuard implements CanActivate {
|
||||
|
@ -11,18 +12,19 @@ export class LoginGuard implements CanActivate {
|
|||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
var user;
|
||||
var loggedIn = false;
|
||||
var errorCode = 1;
|
||||
var errorCode = ErrorCodes.NOT_LOGGIN;
|
||||
|
||||
if(Session.isLoggedIn()){
|
||||
loggedIn = true;
|
||||
if(!Session.isValidAndRemove()){
|
||||
loggedIn = false;
|
||||
errorCode = 3;
|
||||
errorCode = ErrorCodes.NOT_VALID;
|
||||
}
|
||||
}else{
|
||||
errorCode = 1;
|
||||
errorCode = ErrorCodes.NOT_LOGGIN;
|
||||
}
|
||||
if(!loggedIn){
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
return false;
|
||||
}else{
|
||||
|
|
|
@ -74,8 +74,8 @@ export class Session{
|
|||
if(Session.isLoggedIn()){
|
||||
var expires = Session.getUser().expirationDate;
|
||||
var now = new Date().getTime() / 1000;
|
||||
console.log(" is still valid ? "+(now < expires) + " now is:"+now + "expires at:"+expires);
|
||||
return now < expires;
|
||||
console.log(" is still valid ? "+(now +0 < expires) +" Remaining:"+ (expires - (now+0))+ " now is:"+now + "expires at:"+expires);
|
||||
return now +0 < expires;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -84,9 +84,12 @@ export class Session{
|
|||
if(!Session.isUserValid()){
|
||||
Session.removeUser();
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { Component } from '@angular/core';
|
||||
import 'rxjs/Rx';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
|
||||
import {Session} from '../login/utils/helper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'navbar',
|
||||
|
@ -80,7 +83,8 @@ import 'rxjs/Rx';
|
|||
<div class="uk-dropdown uk-dropdown-navbar uk-dropdown-bottom" aria-hidden="true" style="top: 40px; left: 0px;" tabindex="">
|
||||
<ul class="uk-nav uk-nav-navbar">
|
||||
<li><a routerLinkActive="router-link-active" routerLink="/participate/claim">Linking</a></li>
|
||||
<li><a routerLinkActive="router-link-active" routerLink="/claims">Claims Admin</a></li>
|
||||
<li><a routerLinkActive="router-link-active" routerLink="/myclaims">My Claims</a></li>
|
||||
<li *ngIf="isAuthorized"><a routerLinkActive="router-link-active" routerLink="/claims">Manage all Claims</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -146,7 +150,7 @@ import 'rxjs/Rx';
|
|||
</li-->
|
||||
|
||||
<li class="" aria-expanded="false" >
|
||||
<a href="#">Deposit</a>
|
||||
<a >Deposit</a>
|
||||
|
||||
<div ><ul class="uk-nav-sub" role="menu">
|
||||
<li><a routerLinkActive="router-link-active" routerLink="/participate/deposit-publications">Deposit Publications</a></li>
|
||||
|
@ -155,6 +159,17 @@ import 'rxjs/Rx';
|
|||
</div>
|
||||
|
||||
</li>
|
||||
<li class="" aria-expanded="false">
|
||||
<a >Linking</a>
|
||||
|
||||
<div ><ul class="uk-nav-sub" role="menu">
|
||||
<li><a routerLinkActive="router-link-active" routerLink="/participate/claim">Linking</a></li>
|
||||
<li><a routerLinkActive="router-link-active" routerLink="/myclaims">My Claims</a></li>
|
||||
<li *ngIf="isAuthorized"><a routerLinkActive="router-link-active" routerLink="/claims">Manage all Claims</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
@ -169,5 +184,27 @@ import 'rxjs/Rx';
|
|||
`
|
||||
})
|
||||
export class NavigationBarComponent {
|
||||
public isAuthorized: boolean = false;
|
||||
sub:any;
|
||||
constructor( private router: Router, private route: ActivatedRoute) {}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.initialize();
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.initialize();
|
||||
});
|
||||
}
|
||||
ngOnDestroy(){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
initialize(){
|
||||
if(Session.isLoggedIn() && Session.isUserValid() && Session.isAdminUser()){
|
||||
this.isAuthorized = true;
|
||||
}else {
|
||||
this.isAuthorized = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue