Change parseResults for communities and url for parsing communities
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@50950 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e7edd72071
commit
0c58b059c7
|
@ -58,15 +58,7 @@ properties:EnvProperties;
|
|||
|
||||
});
|
||||
|
||||
// waiting... for response from Claudio
|
||||
// this._communitiesService.getResults('https://dev-openaire.d4science.org/openaire/community/communities').subscribe(
|
||||
// communitiesResults => {
|
||||
// this.communitiesResults = communitiesResults;
|
||||
// console.log(communitiesResults);
|
||||
// });
|
||||
|
||||
// this is a draft
|
||||
this._communitiesService.getResults('http://rudie.di.uoa.gr:8080/uoa-admin-tools/mock/communities/').subscribe(
|
||||
this._communitiesService.getResults('https://dev-openaire.d4science.org/openaire/community/communities').subscribe(
|
||||
communitiesResults => {
|
||||
this.communitiesResults = communitiesResults;
|
||||
console.log(communitiesResults);
|
||||
|
|
|
@ -18,33 +18,6 @@ export class CommunitiesService {
|
|||
return this.http.get(url).map(res => <any> res.json()).map(res => this.parseCommunities(id,res));
|
||||
}
|
||||
|
||||
// this is for https://dev-openaire.d4science.org/openaire/community/communities
|
||||
// parseResults(data: any): CommunityInfo[] {
|
||||
// let communities: CommunityInfo[] = [];
|
||||
//
|
||||
// let length = Array.isArray(data) ? data.length :1;
|
||||
//
|
||||
// for (let i=0; i<length; i++) {
|
||||
// let resData = Array.isArray(data) ? data[i] : data;
|
||||
//
|
||||
// var result: CommunityInfo = new CommunityInfo();
|
||||
//
|
||||
// if(Array.isArray(resData)) {
|
||||
// result['title'] = resData[0].name;
|
||||
// result['logoUrl'] = resData[0].logoUrl;
|
||||
// result['description'] = resData[0].description;
|
||||
// } else {
|
||||
// result['title'] = resData.name;
|
||||
// result['logoUrl'] = resData.logoUrl;
|
||||
// result['description'] = resData.description;
|
||||
// }
|
||||
// communities.push(result);
|
||||
// }
|
||||
//
|
||||
// return communities;
|
||||
// }
|
||||
|
||||
//this is for http://rudie.di.uoa.gr:8080/uoa-admin-tools/mock/communities/
|
||||
parseResults(data: any): CommunityInfo[] {
|
||||
let communities: CommunityInfo[] = [];
|
||||
|
||||
|
@ -58,14 +31,14 @@ export class CommunitiesService {
|
|||
if(Array.isArray(resData)) {
|
||||
result['title'] = resData[0].name;
|
||||
result['shortTitle'] = resData[0].shortName;
|
||||
result['communityId'] = resData[0].communityId;
|
||||
result['logoUrl'] = resData[0].logo;
|
||||
result['communityId'] = resData[0].id;
|
||||
result['logoUrl'] = resData[0].logoUrl;
|
||||
result['description'] = resData[0].description;
|
||||
} else {
|
||||
result['title'] = resData.name;
|
||||
result['shortTitle'] = resData.shortName;
|
||||
result['communityId'] = resData.communityId;
|
||||
result['logoUrl'] = resData.logo;
|
||||
result['communityId'] = resData.id;
|
||||
result['logoUrl'] = resData.logoUrl;
|
||||
result['description'] = resData.description;
|
||||
}
|
||||
communities.push(result);
|
||||
|
@ -74,6 +47,7 @@ export class CommunitiesService {
|
|||
return communities;
|
||||
}
|
||||
|
||||
|
||||
parseCommunities(id:string, data:any): CommunityInfo[] {
|
||||
let community: CommunityInfo[] = [];
|
||||
|
||||
|
@ -87,24 +61,24 @@ export class CommunitiesService {
|
|||
|
||||
var result: CommunityInfo = new CommunityInfo();
|
||||
|
||||
if(Array.isArray(resData) && id == resData[0].communityId) {
|
||||
if(Array.isArray(resData) && id == resData[0].id) {
|
||||
|
||||
notFound = false;
|
||||
|
||||
result['title'] = resData[0].name;
|
||||
result['shortTitle'] = resData[0].shortName;
|
||||
result['communityId'] = resData[0].communityId;
|
||||
result['logoUrl'] = resData[0].logo;
|
||||
result['communityId'] = resData[0].id;
|
||||
result['logoUrl'] = resData[0].logoUrl;
|
||||
result['description'] = resData[0].description;
|
||||
|
||||
} else if(!Array.isArray(resData) && id == resData.communityId) {
|
||||
} else if(!Array.isArray(resData) && id == resData.id) {
|
||||
|
||||
notFound = false;
|
||||
|
||||
result['title'] = resData.name;
|
||||
result['shortTitle'] = resData.shortName;
|
||||
result['communityId'] = resData.communityId;
|
||||
result['logoUrl'] = resData.logo;
|
||||
result['communityId'] = resData.id;
|
||||
result['logoUrl'] = resData.logoUrl;
|
||||
result['description'] = resData.description;
|
||||
}
|
||||
community.push(result);
|
||||
|
|
|
@ -104,13 +104,13 @@ export class CommunityComponent {
|
|||
this.route.queryParams.subscribe(
|
||||
communityId => {
|
||||
this.communityId = communityId['communityId'];
|
||||
console.log(communityId);
|
||||
//console.log(communityId);
|
||||
});
|
||||
|
||||
this._communitiesService.getCommunity(this.communityId,'http://rudie.di.uoa.gr:8080/uoa-admin-tools/mock/communities/').subscribe (
|
||||
this._communitiesService.getCommunity(this.communityId,'https://dev-openaire.d4science.org/openaire/community/communities').subscribe (
|
||||
communityInfo => {
|
||||
this.communityInfo = communityInfo;
|
||||
console.log(communityInfo);
|
||||
//console.log(communityInfo);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue