@@ -67,6 +67,7 @@ export class ClaimProjectsComponent {
this.getFunders();
}
+@Input() public inline= 'false' ; // for claimed started from landing pages
public query = '';
public filteredList = [];
@Input() public selectedProjects=[] ;
@@ -82,7 +83,7 @@ public projects:string[];
public warningMessage = "";
public infoMessage = "";
-@ViewChild (Loading) loading : Loading ;
+// @ViewChild (Loading) loading : Loading ;
constructor(private _projectService: OpenaireProjectsService,myElement: ElementRef) {
@@ -100,16 +101,16 @@ filter() {
}else{
this.warningMessage = "";
this.infoMessage = "";
- this.loading.open();
+ // this.loading.open();
this._projectService.searchForProjects(this.query, this.selectedFunderId).subscribe(
data => {
this.filteredList =(data == null)?[]:data;
this.infoMessage = (data == null)?"No Results found":"";
- this.loading.close();
+ // this.loading.close();
},
err => {
console.error(err);
- this.loading.close();
+ // this.loading.close();
this.warningMessage = "An error occured";
}
diff --git a/src/app/claimPages/linking/insertClaim/insertClaim.component.ts b/src/app/claimPages/linking/insertClaim/insertClaim.component.ts
index eadce319..17ac74c8 100644
--- a/src/app/claimPages/linking/insertClaim/insertClaim.component.ts
+++ b/src/app/claimPages/linking/insertClaim/insertClaim.component.ts
@@ -12,7 +12,7 @@ import {Loading} from '../../../common/modal/loading.component';
directives: [...ROUTER_DIRECTIVES, Loading],
template: `
-
0 && claimsTODO == claims" >
@@ -30,12 +30,13 @@ export class ClaimInsertComponent {
}
- @Input() contexts=[];
- @Input() projects=[];
- @Input() publications=[];
- @Input() datasets=[];
-
+ @Input() public contexts;
+ @Input() public projects;
+ @Input() public publications;
+ @Input() public datasets;
+ @Input() public showButton:string = 'false';
@Input() show='claim';
+ @Input() inline='false';
@Output() showChange = new EventEmitter();
@ViewChild (Loading) loading : Loading ;
@@ -45,69 +46,112 @@ export class ClaimInsertComponent {
errorMessage = "";
claimsTODO:number = 0;
claims:number = 0;
+ errorclaims:number = 0;
insert(){
this.claiming = true;
var user="argirok@di.uoa.gr"
- if( this.datasets.length == 0 && this.publications.length == 0){
- this.errorMessage = "There are no publications or datasets selected.";
- this.error = true;
- }else if(this.contexts.length == 0 && this.projects.length == 0){
- this.errorMessage = "There are no projects or concepts to link.";
- this.error = true;
+ if( this.datasets && this.datasets.length == 0 && this.publications && this.publications.length == 0){
+ this.showError("There are no publications or datasets selected.");
+ }else if((!this.contexts|| this.contexts.length==0 )&&(!this.projects|| this.projects.length==0 )){
+ this.showError("There are no projects or concepts to link.");
+ }else if((!this.publications|| this.publications.length==0 )&&(!this.datasets|| this.datasets.length==0 )){
+ this.showError("There are no publications or datasets to link.");
}else{
this.loading.open();
- for (var i = 0; i < this.publications.length; i++) {
- var result=this.publications[i];
+ if(this.publications){
+
+ for (var i = 0; i < this.publications.length; i++) {
+
+ var result=this.publications[i];
+ this.insertClaim(result,user);
+
+ }
+ }
+ if(this.datasets){
+ for (var i = 0; i < this.datasets.length; i++) {
+ var result=this.datasets[i];
this.insertClaim(result,user);
- }
- for (var i = 0; i < this.datasets.length; i++) {
- var result=this.datasets[i];
- this.insertClaim(result,user);
-
+ }
}
}
}
- claimInserted(){
+ private claimInserted(){
this.claims+=1;
if(this.claims == this.claimsTODO){
- this.show = "myclaims";
+ this.show = "context";
this.loading.close();
- // this.showChange.emit({
- // value: this.show
- // });
- this._router.navigate( ['MyClaims'] );
+ if(this.inline == "true"){
+ this.show = "end";
+ }else{
+ this._router.navigate( ['MyClaims'] );
+ }
+ this.showChange.emit({
+ value: this.show
+ });
}
}
- insertClaim(result:any, user:any){
- for (var j = 0; j < this.contexts.length; j++) {
- var context=this.contexts[j];
-
- var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"", targetId : result.id , targetType : result.type,
- targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate:result.embargoEndDate};
- console.info("Trying to insert context - result relation: contextId: "+claim.sourceId +" resultId : " + claim.targetId + " "+ claim.targetEmbargoEndDate );
- this.claimsTODO +=1;
- this.claimService.insertClaim(claim).subscribe(
- data => {
- this.claimInserted();
- },
- err => console.error(err)
- );
+ private showError(error:string){
+ this.errorMessage = error;
+ this.error = true;
+ if(this.inline == "true"){
+ this.show = "error";
+ this.showChange.emit({
+ value: this.show
+ });
}
- for (var j = 0; j < this.projects.length; j++) {
- var project=this.projects[j];
+ }
+ private claimFailed(){
+ this.errorMessage = "An Error Occured.";
+ this.errorclaims++;
+ if((this.claims+this.errorclaims) == this.claimsTODO){
+ this.show = "context";
+ this.loading.close();
+ if(this.inline == "true"){
+ this.show = "end";
+ }else{
+ this._router.navigate( ['MyClaims'] );
+ }
+ this.showChange.emit({
+ value: this.show
+ });
+ }
+ }
+ insertClaim(result:any, user:any){
+ if(this.contexts){
+ for (var j = 0; j < this.contexts.length; j++) {
+ var context=this.contexts[j];
+ var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"no", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate:result.embargoEndDate};
+ this.claimsTODO +=1;
+ this.claimService.insertClaim(claim).subscribe(
+ data => {
+ this.claimInserted();
+ },
+ err => {
+ console.error(err);
+ this.claimFailed();
+ }
+ );
+ }
+ }
+ if(this.projects){
+ for (var j = 0; j < this.projects.length; j++) {
+ var project=this.projects[j];
- var claim = { claimedBy : user, sourceId : project.projectId, sourceType : "project", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"", targetId : result.id , targetType : result.type,
- targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate:result.embargoEndDate};
- console.info("Trying to insert project - result relation: projectId: "+claim.sourceId +" resultId : " + claim.targetId + " "+ claim.targetEmbargoEndDate );
- this.claimsTODO +=1;
- this.claimService.insertClaim(claim).subscribe(
- data => {
- this.claimInserted();
- },
- err => console.error(err)
- );
+ var claim = { claimedBy : user, sourceId : project.projectId, sourceType : "project", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate:result.embargoEndDate};
+ console.info("Trying to insert project - result relation: projectId: "+claim.sourceId +" resultId : " + claim.targetId + " "+ claim.targetEmbargoEndDate );
+ this.claimsTODO +=1;
+ this.claimService.insertClaim(claim).subscribe(
+ data => {
+ this.claimInserted();
+ },
+ err => {
+ console.error(err);
+ this.claimFailed();
+ }
+ );
+ }
}
}
}
diff --git a/src/app/claimPages/linking/selected/selected.component.ts b/src/app/claimPages/linking/selected/selected.component.ts
index 51dd6e11..f76cdfcd 100644
--- a/src/app/claimPages/linking/selected/selected.component.ts
+++ b/src/app/claimPages/linking/selected/selected.component.ts
@@ -5,12 +5,29 @@ import {Component, Input,Output, EventEmitter} from '@angular/core';
template: `
+
-
+
- Selected Concepts ({{(contexts.length)}})
-
+
-
{{context.community }} > {{context.category}} > {{context.concept.label}}
@@ -24,15 +41,15 @@ import {Component, Input,Output, EventEmitter} from '@angular/core';
-
+
- Selected Projects ({{(projects.length)}})
-
+
-
{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}}
-
+
- There are no projects
@@ -40,41 +57,15 @@ import {Component, Input,Output, EventEmitter} from '@angular/core';
-
-
-