From 7542d5eb2877c1dfbcac73878f9e7fb4b2a4b41f Mon Sep 17 00:00:00 2001 From: "sofia.baltzi" Date: Tue, 20 Feb 2018 11:13:44 +0000 Subject: [PATCH] Update community page git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@50822 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/community/community.component.html | 141 ++---------------- src/app/community/community.component.ts | 63 ++++---- src/app/community/community.module.ts | 9 +- src/app/community/community.service.ts | 119 +++++++++------ src/app/community/results/resultInfo.ts | 9 ++ .../community/results/results.component.ts | 70 +++++++++ .../htmlProjectReport-routing.module.ts | 7 +- .../software/software-routing.module.ts | 5 +- 8 files changed, 208 insertions(+), 215 deletions(-) create mode 100644 src/app/community/results/resultInfo.ts create mode 100644 src/app/community/results/results.component.ts diff --git a/src/app/community/community.component.html b/src/app/community/community.component.html index d344165..9633d09 100644 --- a/src/app/community/community.component.html +++ b/src/app/community/community.component.html @@ -12,42 +12,24 @@
- +
- +
- -
@@ -55,114 +37,19 @@

Most recent publications

- -
-
  • -
    -
    -
    - - - {{item.title}} -
    -
    {{item.bestaccessright}}
    - - - {{item1["content"]}}, - - - - -
    {{item.dateofacceptance}}
    - -
    -
    -
  • -
    - - -
    - +

    Most recent research data

    -
    -
  • -
    -
    -
    - - {{item.title}} -
    -
    {{item.bestaccessright}}
    - - - {{item1["content"]}}, - - - - -
    {{item.dateofacceptance}}
    - -
    -
    -
  • -
    -
    No results found
    - -
    - - - - +

    Most recent software

    - -
    -
  • -
    -
    -
    - - {{item.title}} -
    -
    {{item.bestaccessright}}
    - - - {{item1["content"]}}, - - - - -
    {{item.dateofacceptance}}
    - -
    -
    -
  • -
    - -
    - - - - +
    diff --git a/src/app/community/community.component.ts b/src/app/community/community.component.ts index c1bd1dd..177cae9 100644 --- a/src/app/community/community.component.ts +++ b/src/app/community/community.component.ts @@ -12,7 +12,6 @@ import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {Meta} from '../openaireLibrary/sharedComponents/metaService'; import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service'; -//import { PublicationInfo } from '../../publicationInfo'; @Component({ selector: 'community', @@ -24,16 +23,16 @@ export class CommunityComponent { public pageTitle = "OpenAIRE" - public publications; - public reasearchData; - public software; - public publicationsInfo=[]; - public researchDataInfo=[]; - public softwareInfo=[]; + public publicationTotal = null; + public researchDataTotal = null; + public softwareTotal = null; + params = {community: encodeURIComponent('"egi||EGI Federation"')}; properties:EnvProperties; - //public publicationsInfo: PublicationInfo[] = []; + public publicationResults = null; + public researchDataResults = null; + public softwareResults = null; constructor ( private route: ActivatedRoute, @@ -68,46 +67,40 @@ export class CommunityComponent { }); this._communityService.getNumberOfPublications().subscribe( - publications => { - this.publications = publications; - console.log(publications); + publicationTotal => { + this.publicationTotal = publicationTotal; + //console.log(publications); }); this._communityService.getNumberOfResearchData().subscribe( - reasearchData => { - this.reasearchData = reasearchData; - console.log(reasearchData); + researchDataTotal => { + this.researchDataTotal = researchDataTotal; + //console.log(reasearchData); }); this._communityService.getNumberOfSoftware().subscribe( - software => { - this.software = software; - console.log(software); + softwareTotal => { + this.softwareTotal = softwareTotal; + //console.log(software); }); - this._communityService.getPublicationsInfo().subscribe( - publicationsInfo => { - this.publicationsInfo = publicationsInfo; - console.log(publicationsInfo); + this._communityService.getResults('http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?fq=communityid%20exact%20%22egi%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( + publicationResults => { + this.publicationResults = publicationResults; + //console.log(publicationResults); }); - this._communityService.getResearchDataInfo().subscribe( - researchDataInfo => { - this.researchDataInfo = researchDataInfo; - console.log(researchDataInfo); + this._communityService.getResults('http://beta.services.openaire.eu:8480/search/rest/v2/api/datasets?fq=communityid%20exact%20%22egi%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( + researchDataResults => { + this.researchDataResults = researchDataResults; + console.log(researchDataResults); }); - this._communityService.getSoftwareInfo().subscribe( - softwareInfo => { - this.softwareInfo = softwareInfo; - console.log(softwareInfo); + this._communityService.getResults('http://beta.services.openaire.eu:8480/search/rest/v2/api/software?fq=communityid%20exact%20%22egi%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( + softwareResults => { + this.softwareResults = softwareResults; + //console.log(softwareResults); }); - - // this._communityService - // .getPublicationInfo('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/publications?fq=communityid exact "egi"&sortBy=resultdateofacceptance,descending&format=json') - // .subscribe( - // - // }); } public ngOnDestroy() { if(this.piwiksub){ diff --git a/src/app/community/community.module.ts b/src/app/community/community.module.ts index 698873a..0836578 100644 --- a/src/app/community/community.module.ts +++ b/src/app/community/community.module.ts @@ -5,6 +5,11 @@ import { RouterModule } from '@angular/router'; import{CommunityRoutingModule} from './community-routing.module'; import{CommunityComponent} from './community.component'; + +import { CommunityService } from './community.service'; + +import {ResultsComponent} from './results/results.component'; + import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {Meta} from '../openaireLibrary/sharedComponents/metaService'; import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service'; @@ -18,10 +23,10 @@ import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRout CommunityRoutingModule ], declarations: [ - CommunityComponent + CommunityComponent, ResultsComponent ], providers:[ - FreeGuard, PreviousRouteRecorder, ConfigurationService, Meta, PiwikService + FreeGuard, PreviousRouteRecorder, ConfigurationService, Meta, PiwikService, CommunityService ], exports: [ CommunityComponent diff --git a/src/app/community/community.service.ts b/src/app/community/community.service.ts index 4e069ec..042b98a 100644 --- a/src/app/community/community.service.ts +++ b/src/app/community/community.service.ts @@ -2,75 +2,96 @@ import { Injectable } from '@angular/core'; import { Http, Response, Headers, RequestOptions } from '@angular/http'; import { Observable } from 'rxjs/Rx'; -import { PublicationInfo } from '../../publicationInfo'; +import { ResultInfo } from './results/resultInfo'; @Injectable() export class CommunityService { + private sizeOfDescription: number = 135; + constructor(private http:Http) { } getNumberOfPublications() { - return this.http.get('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/publications/count?format=json&fq=communityid=egi') - .map(res => res.json()).do(res => {console.log(res)}); - } - - // Most recent publications - getPublicationsInfo(){ - return this.http.get('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/publications?fq=communityid exact "egi"&sortBy=resultdateofacceptance,descending&format=json&size=5') - .map(res => res.json()).map(res => this.parse(res)).do(res => {console.log(res)}); - - } - getDatasetsInfo(){ - return this.http.get('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/datasets?fq=communityid exact "egi"&sortBy=resultdateofacceptance,descending&format=json&size=5') - .map(res => res.json()).map(res => this.parse(res)).do(res => {console.log(res)}); - + return this.http.get('http://beta.services.openaire.eu:8480/search/rest/v2/api/publications/count?format=json&fq=communityid=egi') + .map(res => res.json()).map(res => res.total).do(res => {console.log(res)}); } getNumberOfResearchData() { - return this.http.get('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/datasets/count?format=json&fq=communityid=egi') - .map(res => res.json()).do(res => {console.log(res)}); - } - - getResearchDataInfo() { - return this.http.get('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/datasets?fq=communityid exact "egi"&sortBy=resultdateofacceptance,descending&format=json&size=5') - .map(res => res.json()).map(res => res.results).do(res => {console.log(res)}); + return this.http.get('http://beta.services.openaire.eu:8480/search/rest/v2/api/datasets/count?format=json&fq=communityid=egi') + .map(res => res.json()).map(res => res.total).do(res => {console.log(res)}); } getNumberOfSoftware() { - return this.http.get('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/software/count?format=json&fq=communityid=egi') - .map(res => res.json()).do(res => {console.log(res)}); + return this.http.get('http://beta.services.openaire.eu:8480/search/rest/v2/api/software/count?format=json&fq=communityid=egi') + .map(res => res.json()).map(res => res.total).do(res => {console.log(res)}); } - getSoftwareInfo() { - return this.http.get('http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/software?fq=communityid exact "egi"&sortBy=resultdateofacceptance,descending&format=json') - .map(res => res.json()).map(res => this.parse(res)).do(res => {console.log(res)}); + getResults(url: string) { + return this.http.get(url).map(res => res.json()).map(res => this.parseResults(res['results'])); } - parse(res){ - var results =[]; - for(let item of res.results){ - var result= {}; - result["id"] = item.result["header"]["dri:objIdentifier"]; - result["title"] = item.result["metadata"]["oaf:entity"]["oaf:result"]["title"]["content"]; - result["bestaccessright"] = item.result["metadata"]["oaf:entity"]["oaf:result"]["bestaccessright"]["classid"]; - result["date"]=item.result["metadata"]["oaf:entity"]["oaf:result"]["dateofacceptance"]; - result["description"]= item.result["metadata"]["oaf:entity"]["oaf:result"]["description"]; + parseResults(data: any): ResultInfo[] { + let results: ResultInfo[] = []; - result["authors"] = []; - if(Array.isArray(item.result["metadata"]["oaf:entity"]["oaf:result"]["creator"])){ - result["authors"] = item.result["metadata"]["oaf:entity"]["oaf:result"]["creator"]; - }else{ - result["authors"].push(item.result["metadata"]["oaf:entity"]["oaf:result"]["creator"]); + let length = Array.isArray(data) ? data.length :1; + + for (let i=0; i(); + } + + let authors = resData['creator']; + let length = Array.isArray(authors) ? authors.length : 1; + + for(let i=0; i this.sizeOfDescription) { + result.description = result.description.substring(0, this.sizeOfDescription) + "..."; + } + + results.push(result); } - result["authors"] = result["authors"].slice(0,10); - - results.push(result); - } - return results; + return results; } - // getPublicationInfo(url: string) { - // return this.http.get(url).map(res => res.json()).map(res => res.results).do(res => {console.log(res)}); - // } } diff --git a/src/app/community/results/resultInfo.ts b/src/app/community/results/resultInfo.ts new file mode 100644 index 0000000..cbead40 --- /dev/null +++ b/src/app/community/results/resultInfo.ts @@ -0,0 +1,9 @@ +export class ResultInfo { + title: string; + id: string; + accessRights: string; + authors: string[]; + year: string; + description: string; + type: string; +} diff --git a/src/app/community/results/results.component.ts b/src/app/community/results/results.component.ts new file mode 100644 index 0000000..d4a5563 --- /dev/null +++ b/src/app/community/results/results.component.ts @@ -0,0 +1,70 @@ +import {Component, Input} from '@angular/core'; +import { ResultInfo } from './resultInfo'; + +@Component({ + selector: 'results-comp', + template: ` +
    +
    +
  • +
    +
    +
    + + + +
    +
    {{item.accessRights}}
    + + {{author}} + +
    {{item.year}}
    +
    {{item.description}}
    +
    +
    +
  • +
    +
    + +
    No results found
    + +
    + + ` + +}) + +export class ResultsComponent { + + @Input() public results : ResultInfo[]; + @Input() public resultType: string; + @Input() public params: any; + +} diff --git a/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts b/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts index 544468f..53a70ea 100644 --- a/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts +++ b/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts @@ -5,10 +5,15 @@ import { OpenaireHtmlProjectReportComponent } from './htmlProjectReport.componen import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'; +import {Properties} from '../../utils/properties'; + @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: OpenaireHtmlProjectReportComponent , canActivate: [FreeGuard, IsRouteEnabled],canDeactivate: [PreviousRouteRecorder]} + { path: '', component: OpenaireHtmlProjectReportComponent , canActivate: [FreeGuard, IsRouteEnabled], + data: { + redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity + },canDeactivate: [PreviousRouteRecorder]} ]) ] }) diff --git a/src/app/landingPages/software/software-routing.module.ts b/src/app/landingPages/software/software-routing.module.ts index 50f6a3e..a52bd26 100644 --- a/src/app/landingPages/software/software-routing.module.ts +++ b/src/app/landingPages/software/software-routing.module.ts @@ -5,11 +5,14 @@ import {OpenaireSoftwareComponent } from './software.component'; import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'; +import {Properties} from '../../utils/properties'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: OpenaireSoftwareComponent, canActivate: [FreeGuard, IsRouteEnabled],canDeactivate: [PreviousRouteRecorder] } + { path: '', component: OpenaireSoftwareComponent, canActivate: [FreeGuard, IsRouteEnabled], data: { + redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity + },canDeactivate: [PreviousRouteRecorder] } ]) ] })