Change community link for getCommunity
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@50974 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
130fb88464
commit
9520d42028
|
@ -5,17 +5,18 @@
|
|||
<article class="uk-article ">
|
||||
<a class="uk-button uk-button-primary uk-align-right"> Subscribe</a>
|
||||
<blockquote>
|
||||
<div *ngIf="communityId != null && communityInfo != null">
|
||||
<div *ngFor="let item of communityInfo; let i = index">
|
||||
<div *ngIf="item.title != null">
|
||||
<p> {{item.title}}</p>
|
||||
<div *ngIf="communityId != null && community != null">
|
||||
<div *ngIf="community.title != null">
|
||||
<p> {{community.title}}</p>
|
||||
</div>
|
||||
<div *ngIf="item.title == null && item.shortTitle != null">
|
||||
<p> {{item.shortTitle}}</p>
|
||||
<div *ngIf="community.title == null && community.shortTitle != null">
|
||||
<p> {{community.shortTitle}}</p>
|
||||
</div>
|
||||
<div *ngIf="item.description != null">
|
||||
<p> {{item.description}}</p>
|
||||
<div *ngIf="community.description != null">
|
||||
<p> {{community.description}}</p>
|
||||
</div>
|
||||
<div *ngIf="community.queryId != null">
|
||||
<p> {{community.queryId}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</blockquote>
|
||||
|
@ -24,7 +25,6 @@
|
|||
<div class="uk-child-width-1-6@l uk-child-width-1-6@m uk-child-width-1-3@s uk-text-center uk-grid" uk-grid="">
|
||||
<div class="uk-first-column">
|
||||
<div class="uk-card uk-card-default uk-card-small uk-card-body">
|
||||
|
||||
<div *ngIf="publicationTotal != null">
|
||||
<a [queryParams]=params routerLinkActive="router-link-active" routerLink="/search/find/publications" ><h3 class="uk-card-title">{{publicationTotal}}</h3>
|
||||
<p>publications</p></a>
|
||||
|
@ -34,24 +34,29 @@
|
|||
<div>
|
||||
|
||||
<div class="uk-card uk-card-default uk-card-small uk-card-body">
|
||||
<div *ngIf="researchDataTotal != null">
|
||||
<a [queryParams]=params routerLinkActive="router-link-active" routerLink="/search/find/datasets"><h3 class="uk-card-title">{{researchDataTotal}}</h3>
|
||||
<p>research data</p></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<div class="uk-card uk-card-default uk-card-small uk-card-body">
|
||||
<div *ngIf="softwareTotal != null">
|
||||
<a [queryParams]=params routerLinkActive="router-link-active" routerLink="/search/find/software"><h3 class="uk-card-title">{{softwareTotal}}</h3>
|
||||
<p>software</p></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-grid-small uk-margin-medium uk-grid" uk-grid="">
|
||||
<div class="uk-width-expand@m uk-first-column">
|
||||
<h3 class="uk-margin-small uk-h3 uk-heading-line uk-text-primary">
|
||||
<span>Most recent publications</span>
|
||||
</h3>
|
||||
|
||||
<results-comp [(results)]=publicationResults resultType="publication" [params]=params></results-comp>
|
||||
</div>
|
||||
<div class="uk-width-expand@m">
|
||||
|
|
|
@ -36,7 +36,7 @@ export class CommunityComponent {
|
|||
public softwareResults = null;
|
||||
|
||||
public communityId = null;
|
||||
public communityInfo = null;
|
||||
public community = null;
|
||||
|
||||
constructor (
|
||||
private route: ActivatedRoute,
|
||||
|
@ -78,10 +78,10 @@ export class CommunityComponent {
|
|||
//console.log(communityId);
|
||||
});
|
||||
|
||||
this._communityService.getCommunity(this.communityId,'https://dev-openaire.d4science.org/openaire/community/communities').subscribe (
|
||||
communityInfo => {
|
||||
this.communityInfo = communityInfo;
|
||||
console.log(communityInfo);
|
||||
this._communityService.getCommunity('https://dev-openaire.d4science.org/openaire/community/'+this.communityId).subscribe (
|
||||
community => {
|
||||
this.community = community;
|
||||
console.log(community);
|
||||
});
|
||||
|
||||
this._communityService.getTotal('http://beta.services.openaire.eu:8480/search/rest/v2/api/publications/count?format=json&fq=communityid='+this.communityId).subscribe(
|
||||
|
|
|
@ -85,49 +85,40 @@ export class CommunityService {
|
|||
return results;
|
||||
}
|
||||
|
||||
getCommunity(id:string , url: string) {
|
||||
return this.http.get(url).map(res => <any> res.json()).map(res => this.searchCommunity(id,res));
|
||||
getCommunity(url: string) {
|
||||
return this.http.get(url).map(res => <any> res.json()).map(res => this.parseCommunity(res));
|
||||
}
|
||||
|
||||
searchCommunity(id:string, data:any): CommunityInfo[] {
|
||||
let community: CommunityInfo[] = [];
|
||||
|
||||
let notFound:boolean = true;
|
||||
parseCommunity(data:any): CommunityInfo {
|
||||
|
||||
let length = Array.isArray(data) ? data.length :1;
|
||||
|
||||
for (let i=0; i<length && notFound; i++) {
|
||||
for (let i=0; i<length; i++) {
|
||||
|
||||
let resData = Array.isArray(data) ? data[i] : data;
|
||||
|
||||
var result: CommunityInfo = new CommunityInfo();
|
||||
var community: CommunityInfo = new CommunityInfo();
|
||||
|
||||
if(Array.isArray(resData) && id == resData[0].id) {
|
||||
if(Array.isArray(resData)) {
|
||||
|
||||
notFound = false;
|
||||
community['title'] = resData[0].name;
|
||||
community['shortTitle'] = resData[0].shortName;
|
||||
community['communityId'] = resData[0].id;
|
||||
community['queryId'] = resData[0].queryId;
|
||||
community['logoUrl'] = resData[0].logoUrl;
|
||||
community['description'] = resData[0].description;
|
||||
|
||||
result['title'] = resData[0].name;
|
||||
result['shortTitle'] = resData[0].shortName;
|
||||
result['communityId'] = resData[0].id;
|
||||
result['queryId'] = resData[0].queryId;
|
||||
result['logoUrl'] = resData[0].logoUrl;
|
||||
result['description'] = resData[0].description;
|
||||
} else if(!Array.isArray(resData)) {
|
||||
|
||||
} else if(!Array.isArray(resData) && id == resData.id) {
|
||||
|
||||
notFound = false;
|
||||
|
||||
result['title'] = resData.name;
|
||||
result['shortTitle'] = resData.shortName;
|
||||
result['communityId'] = resData.id;
|
||||
result['queryId'] = resData.queryId;
|
||||
result['logoUrl'] = resData.logoUrl;
|
||||
result['description'] = resData.description;
|
||||
community['title'] = resData.name;
|
||||
community['shortTitle'] = resData.shortName;
|
||||
community['communityId'] = resData.id;
|
||||
community['queryId'] = resData.queryId;
|
||||
community['logoUrl'] = resData.logoUrl;
|
||||
community['description'] = resData.description;
|
||||
}
|
||||
community.push(result);
|
||||
}
|
||||
return community;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import { ResultInfo } from './resultInfo';
|
||||
import { CommunityInfo } from '../../utils/communityInfo';
|
||||
|
||||
@Component({
|
||||
selector: 'results-comp',
|
||||
|
@ -66,5 +67,6 @@ export class ResultsComponent {
|
|||
@Input() public results : ResultInfo[];
|
||||
@Input() public resultType: string;
|
||||
@Input() public params: any;
|
||||
@Input() public community : CommunityInfo;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue