126 lines
4.7 KiB
TypeScript
126 lines
4.7 KiB
TypeScript
import {Component, ViewChild, OnInit} from '@angular/core';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import {ActivatedRoute, Params} from '@angular/router';
|
|
import {ProjectService} from '../../services/project.service';
|
|
import {ProjectInfo} from '../../utils/entities/projectInfo';
|
|
import {InlineClaimResultComponent} from '../../claimPages/inlineClaims/inlineClaimResult.component';
|
|
|
|
@Component({
|
|
selector: 'project',
|
|
templateUrl: 'project.component.html',
|
|
})
|
|
export class ProjectComponent implements OnInit{
|
|
constructor (private _projectService: ProjectService,
|
|
private route: ActivatedRoute) {
|
|
console.info('project constructor');
|
|
// this.projectId = 'corda_______::2c37878a0cede85dbbd1081bb9b4a2f8';
|
|
// console.info("1 Id is :"+this.projectId);
|
|
// if(this.projectId){
|
|
// this.getProjectInfo(this.projectId);
|
|
// }else{
|
|
// this.warningMessage=" 1 No valid project id";
|
|
// }
|
|
}
|
|
ngOnInit() {
|
|
// this.sub = this.route.params.subscribe(params => {
|
|
// this.projectId = params['projectId'];
|
|
// console.info('project init');
|
|
// this.getProjectInfo(this.projectId);
|
|
// });
|
|
//PArameter with format ;id=
|
|
//corda_______::2c37878a0cede85dbbd1081bb9b4a2f8
|
|
// this.projectId = 'corda_______::2c37878a0cede85dbbd1081bb9b4a2f8';
|
|
// console.info("1 Id is :"+this.projectId);
|
|
// if(this.projectId){
|
|
// this.getProjectInfo(this.projectId);
|
|
// }else{
|
|
// this.warningMessage=" 1 No valid project id";
|
|
// }
|
|
// this.route.params.forEach((params: Params) => {
|
|
// console.info("this.route.params.forEach");
|
|
// let id = +params['id'];
|
|
// this.projectId = params['id'];
|
|
// console.info("1 Id is :"+this.projectId);
|
|
// if(this.projectId){
|
|
// this.getProjectInfo(this.projectId);
|
|
// }else{
|
|
// this.warningMessage=" 1 No valid project id";
|
|
// }
|
|
//
|
|
// });
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
this.projectId = params['projectId'];
|
|
console.info("Id is :"+this.projectId);
|
|
if(this.projectId){
|
|
this.getProjectInfo(this.projectId);
|
|
}else{
|
|
this.warningMessage="No valid project id";
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
private projectId : string ;
|
|
private projectInfo: ProjectInfo;
|
|
|
|
private project ;
|
|
|
|
@ViewChild (InlineClaimResultComponent) inlineClaimResult : InlineClaimResultComponent ;
|
|
|
|
|
|
public warningMessage = "";
|
|
public errorMessage = "";
|
|
ngOnDestroy() {
|
|
this.sub.unsubscribe();
|
|
}
|
|
sub: any;
|
|
|
|
getProjectInfo (id:string) {
|
|
console.info("inside getProjectInfo of component");
|
|
this.warningMessage = '';
|
|
this.errorMessage=""
|
|
this._projectService.getProjectInfo(id).subscribe(
|
|
data => {
|
|
this.projectInfo = data;
|
|
/*
|
|
<dt *ngIf="projectInfo.title != undefined && projectInfo.title != ''">Title: </dt>
|
|
<dd *ngIf="projectInfo.title != undefined && projectInfo.title != ''">{{projectInfo.title}}</dd>
|
|
<dt *ngIf="projectInfo.funding != undefined && projectInfo.funding != ''">Funding: </dt>
|
|
<dd *ngIf="projectInfo.funding != undefined && projectInfo.funding != ''">{{projectInfo.funding}}</dd>
|
|
<dt *ngIf="projectInfo.callIdentifier != undefined && projectInfo.callIdentifier != ''">Call: </dt>
|
|
<dd *ngIf="projectInfo.callIdentifier != undefined && projectInfo.callIdentifier != ''">{{projectInfo.callIdentifier}}</dd>
|
|
<dt *ngIf="projectInfo.contractNum != undefined && projectInfo.contractNum != ''">Contract (GA) number: </dt>
|
|
<dd *ngIf="projectInfo.contractNum != undefined && projectInfo.contractNum != ''">{{projectInfo.contractNum}}</dd>
|
|
<dt *ngIf="projectInfo.startDate != undefined && projectInfo.startDate != ''">Start Date: </dt>
|
|
<dd *ngIf="projectInfo.startDate != undefined && projectInfo.startDate != ''">{{projectInfo.startDate}}</dd>
|
|
<dt *ngIf="projectInfo.endDate != undefined && projectInfo.endDate != ''">End Date: </dt>
|
|
<dd *ngIf="projectInfo.endDate != undefined && projectInfo.endDate != ''">{{projectInfo.endDate}}</dd>
|
|
*/
|
|
this.project= { funderId: "", funderName: this.projectInfo.funder, projectId: this.projectId, projectName: this.projectInfo.title, projectAcronym: this.projectInfo.acronym, startDate: this.projectInfo.startDate, endDate: this.projectInfo.endDate };
|
|
},
|
|
err => {
|
|
console.error(err);
|
|
this.errorMessage = 'No project found';
|
|
}
|
|
);
|
|
}
|
|
|
|
/*
|
|
********* Methods for Inline Claim of results *****
|
|
*/
|
|
toggleClaimResult(){
|
|
this.inlineClaimResult.toggle();
|
|
}
|
|
publicationAdded($event){
|
|
//TODO
|
|
}
|
|
|
|
datasetAdded($event){
|
|
var contexts =$event.value;
|
|
|
|
//TODO
|
|
}
|
|
|
|
}
|