Zenodo communities : move or add to library common services and classes for zenodo communities
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@53903 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
f17d4735ea
commit
da3582efd9
|
@ -74,6 +74,7 @@ export class CommunityService {
|
||||||
community['logoUrl'] = resData[0].logoUrl;
|
community['logoUrl'] = resData[0].logoUrl;
|
||||||
community['description'] = resData[0].description;
|
community['description'] = resData[0].description;
|
||||||
community['date'] = resData[0].creationDate;
|
community['date'] = resData[0].creationDate;
|
||||||
|
community['zenodoCommunity'] = resData[0].zenodoCommunity;
|
||||||
community['status'] = "all";
|
community['status'] = "all";
|
||||||
if(resData[0].hasOwnProperty('status')){
|
if(resData[0].hasOwnProperty('status')){
|
||||||
community['status'] = resData[0].status;
|
community['status'] = resData[0].status;
|
||||||
|
@ -123,6 +124,7 @@ export class CommunityService {
|
||||||
community['logoUrl'] = resData.logoUrl;
|
community['logoUrl'] = resData.logoUrl;
|
||||||
community['description'] = resData.description;
|
community['description'] = resData.description;
|
||||||
community['date'] = resData.creationDate;
|
community['date'] = resData.creationDate;
|
||||||
|
community['zenodoCommunity'] = resData.zenodoCommunity;
|
||||||
community['status'] = "all";
|
community['status'] = "all";
|
||||||
if(resData.hasOwnProperty('status')){
|
if(resData.hasOwnProperty('status')){
|
||||||
community['status'] = resData.status;
|
community['status'] = resData.status;
|
||||||
|
|
|
@ -10,4 +10,5 @@ export class CommunityInfo {
|
||||||
date:Date;
|
date:Date;
|
||||||
subjects: string[];
|
subjects: string[];
|
||||||
status:string;
|
status:string;
|
||||||
|
zenodoCommunity:string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {Http} from '@angular/http';
|
||||||
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SearchZenodoCommunitiesService {
|
||||||
|
constructor(private http: Http ) {}
|
||||||
|
|
||||||
|
searchZCommunities (properties:EnvProperties, communityId: string):any {
|
||||||
|
let url = properties.communityAPI+communityId+"/zenodocommunities";
|
||||||
|
|
||||||
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { NgModule} from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import {SearchZenodoCommunitiesService} from './searchZenodoCommunities.service';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule, FormsModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
],
|
||||||
|
providers:[
|
||||||
|
SearchZenodoCommunitiesService
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SearchZenodoCommunitiesServiceModule { }
|
|
@ -0,0 +1,58 @@
|
||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {Http, Response} from '@angular/http';
|
||||||
|
import {Headers, RequestOptions} from '@angular/http';
|
||||||
|
import {Observable} from 'rxjs/Rx';
|
||||||
|
|
||||||
|
import {ZenodoCommunityInfo} from './zenodoCommunityInfo';
|
||||||
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ZenodoCommunitiesService {
|
||||||
|
|
||||||
|
constructor(private http:Http) {
|
||||||
|
}
|
||||||
|
|
||||||
|
getZenodoCommunities(properties:EnvProperties, url: string) {
|
||||||
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
|
||||||
|
.map(res => <any> res.json()).map(res => [this.parseZenodoCommunities(res.hits.hits),res.hits.total]);
|
||||||
|
}
|
||||||
|
getZenodoCommunityById(properties:EnvProperties, url: string, openaireId:string) {
|
||||||
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
|
||||||
|
.map(res => <any> res.json()).map(res => {
|
||||||
|
var community = this.parseZenodoCommunity(res);
|
||||||
|
community["openaireId"]=openaireId;
|
||||||
|
return community;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
parseZenodoCommunities(data: any): ZenodoCommunityInfo[] {
|
||||||
|
let zenodoCommunities: ZenodoCommunityInfo[] = [];
|
||||||
|
|
||||||
|
for (let i=0; i<data.length; i++) {
|
||||||
|
let resData = data[i];
|
||||||
|
|
||||||
|
|
||||||
|
zenodoCommunities.push(this.parseZenodoCommunity(resData));
|
||||||
|
}
|
||||||
|
return zenodoCommunities;
|
||||||
|
}
|
||||||
|
|
||||||
|
parseZenodoCommunity(resData:any):ZenodoCommunityInfo {
|
||||||
|
var result: ZenodoCommunityInfo = new ZenodoCommunityInfo();
|
||||||
|
|
||||||
|
result['title'] = resData.title;
|
||||||
|
result['id'] = resData.id;
|
||||||
|
result['description'] = resData.description;
|
||||||
|
result['link'] = resData.links.html;
|
||||||
|
result['logoUrl'] = resData.logo_url;
|
||||||
|
result['date'] = resData.updated;
|
||||||
|
result['page'] = resData.page;
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getTotalZenodoCommunities(properties:EnvProperties, url: string) {
|
||||||
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
|
||||||
|
.map(res => <any> res.json()).map(res => res.hits.total);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { NgModule} from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import {ZenodoCommunitiesService} from './zenodo-communities.service';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule, FormsModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
],
|
||||||
|
providers:[
|
||||||
|
ZenodoCommunitiesService
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class ZenodoCommunitiesServiceModule { }
|
|
@ -0,0 +1,10 @@
|
||||||
|
export class ZenodoCommunityInfo {
|
||||||
|
title: string;
|
||||||
|
id: string;
|
||||||
|
description: string;
|
||||||
|
link: string;
|
||||||
|
logoUrl: string;
|
||||||
|
date: Date;
|
||||||
|
page: string;
|
||||||
|
openaireId:string;
|
||||||
|
}
|
Loading…
Reference in New Issue