In project landing page read also grantId and funder parameter and query based on them

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51318 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2018-03-16 15:56:35 +00:00
parent 09017aee04
commit af9c537025
3 changed files with 112 additions and 57 deletions

View File

@ -115,42 +115,17 @@ properties:EnvProperties;
this.updateDescription("project, funding, open access, publications, research data, software"); this.updateDescription("project, funding, open access, publications, research data, software");
this.projectId = params['projectId']; this.projectId = params['projectId'];
var grantId = params['grantId'];
var funder = params['funder'];
if(this.projectId){ if(this.projectId){
this.publications_dynamic = this.getProjectInfo(this.projectId);
"<script type=\"text/javascript\">" this.actionsAfterLoadId();
+ "\n<!--" }else if(grantId && funder){
+ "\ndocument.write('<div id=\"oa_widget\"></div>');" this.getProjectInfoByGrantId(grantId,funder);
+ "\ndocument.write('<script type=\"text/javascript\""
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
+ this.projectId + "&type=publication\"></script>');"
+ "\n-->"
+ "\n</script>";
this.datasets_dynamic =
"<script type=\"text/javascript\">"
+ "\n<!--"
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
+ "\ndocument.write('<script type=\"text/javascript\""
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
+ this.projectId + "&type=dataset\"></script>');"
+ "\n-->"
+ "\n</script>";
this.software_dynamic =
"<script type=\"text/javascript\">"
+ "\n<!--"
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
+ "\ndocument.write('<script type=\"text/javascript\""
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
+ this.projectId + "&type=software\"></script>');"
+ "\n-->"
+ "\n</script>";
this.getProjectInfo(this.projectId);
this.searchPublications();
this.fetchDatasets.getNumForEntity("project", this.projectId, this.properties);
this.fetchSoftware.getNumForEntity("project", this.projectId, this.properties);
}else{ }else{
this.showLoading = false; this.showLoading = false;
this.warningMessage="No valid project id"; this.warningMessage="No valid project id";
} }
@ -168,7 +143,42 @@ properties:EnvProperties;
}); });
} }
actionsAfterLoadId(){
this.publications_dynamic =
"<script type=\"text/javascript\">"
+ "\n<!--"
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
+ "\ndocument.write('<script type=\"text/javascript\""
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
+ this.projectId + "&type=publication\"></script>');"
+ "\n-->"
+ "\n</script>";
this.datasets_dynamic =
"<script type=\"text/javascript\">"
+ "\n<!--"
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
+ "\ndocument.write('<script type=\"text/javascript\""
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
+ this.projectId + "&type=dataset\"></script>');"
+ "\n-->"
+ "\n</script>";
this.software_dynamic =
"<script type=\"text/javascript\">"
+ "\n<!--"
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
+ "\ndocument.write('<script type=\"text/javascript\""
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
+ this.projectId + "&type=software\"></script>');"
+ "\n-->"
+ "\n</script>";
this.getProjectInfo(this.projectId);
this.searchPublications();
this.fetchDatasets.getNumForEntity("project", this.projectId, this.properties);
this.fetchSoftware.getNumForEntity("project", this.projectId, this.properties);
}
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
if(this.piwiksub){ if(this.piwiksub){
@ -239,33 +249,14 @@ properties:EnvProperties;
this.warningMessage = ''; this.warningMessage = '';
this.errorMessage="" this.errorMessage=""
this.showLoading = true; this.showLoading = true;
var funder = "EC";
var grantId ="654142";
this.infoSub = this._projectService.getProjectInfo(id, this.properties).subscribe( this.infoSub = this._projectService.getProjectInfo(id, this.properties).subscribe(
data => { data => {
this.projectInfo = data; this.projectInfo = data;
this.projectName = this.projectInfo.acronym; this.actionsAfterGettingProjectInfo();
if(this.projectName == undefined || this.projectName == '') {
this.projectName = this.projectInfo.title;
}
this.updateTitle(this.projectName);
this.updateDescription("project, funding, open access, publications, research data, "+this.projectName+ ","+this.projectInfo.funder);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, this.projectName).subscribe();
}
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 };
this.viewsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"projRepoViews","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
this.downloadsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"projRepoDownloads","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
//stats tab charts
this.chartScientificResultsUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
this.chartAccessModeUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projOA","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
this.chartDatasourcesUrl= 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projPubsRepos","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
this.showLoading = false;
}, },
err => { err => {
console.log(err); console.log(err);
@ -274,7 +265,51 @@ properties:EnvProperties;
} }
); );
} }
private getProjectInfoByGrantId (grantId:string, funder:string) {
this.warningMessage = '';
this.errorMessage=""
this.showLoading = true;
this._projectService.getProjectInfoByGrantId(grantId,funder,this.properties).subscribe(
data =>{
this.projectInfo = data;
this.actionsAfterGettingProjectInfo();
this.projectId = this.projectInfo.id;
this.actionsAfterLoadId();
},
err => {
console.log(err);
this.errorMessage = 'No project found';
this.showLoading = false;
}
);
}
actionsAfterGettingProjectInfo(){
this.projectName = this.projectInfo.acronym;
if(this.projectName == undefined || this.projectName == '') {
this.projectName = this.projectInfo.title;
}
this.updateTitle(this.projectName);
this.updateDescription("project, funding, open access, publications, research data, "+this.projectName+ ","+this.projectInfo.funder);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, this.projectName).subscribe();
}
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 };
this.viewsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"projRepoViews","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
this.downloadsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"projRepoDownloads","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
//stats tab charts
this.chartScientificResultsUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
this.chartAccessModeUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projOA","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
this.chartDatasourcesUrl= 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projPubsRepos","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
this.showLoading = false;
}
public downloadfile(url:string){ public downloadfile(url:string){
this.openLoading(); this.openLoading();
this.setMessageLoading("Downloading CSV file"); this.setMessageLoading("Downloading CSV file");

View File

@ -34,7 +34,24 @@ export class ProjectService {
.map(res => this.parseProjectInfo(res, properties)); .map(res => this.parseProjectInfo(res, properties));
} }
getProjectInfoByGrantId (grant: string, funder:string, properties:EnvProperties):any {
let url =properties.searchAPIURLLAst+ 'resources?query=(oaftype exact project)'+
'and (projectcode_nt exact "'+grant+'" ) and (fundershortname exact '+'"'+funder+ '"'+')'+"&format=json&size=1";
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['results'][0])
.map(res => [res['result']['metadata']['oaf:entity']['oaf:project'],res['result']['header']['dri:objIdentifier']])
.map(res => [res[0],
res[0]['fundingtree'],
res[0]['rels']['rel'],res[1]])
.map(res => this.parseProjectInfo(res, properties));
}
/* /*
get project strtDate and endDate get project strtDate and endDate
*/ */
@ -81,7 +98,9 @@ export class ProjectService {
parseProjectInfo (data: any, properties:EnvProperties):any { parseProjectInfo (data: any, properties:EnvProperties):any {
this.projectInfo = new ProjectInfo(); this.projectInfo = new ProjectInfo();
if(data[3] != null) {
this.projectInfo.id =data[3];
}
if(data[0] != null) { if(data[0] != null) {
this.projectInfo.acronym = data[0].acronym; this.projectInfo.acronym = data[0].acronym;
if(Array.isArray(data[0]['title'])) { if(Array.isArray(data[0]['title'])) {

View File

@ -1,4 +1,5 @@
export class ProjectInfo { export class ProjectInfo {
id:string;
acronym: string; acronym: string;
title: string; title: string;
callIdentifier: string; callIdentifier: string;