Add communities.service and communityInfo
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@50940 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e99e3456e4
commit
10875b7887
|
@ -20,53 +20,30 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-container uk-margin-top uk-margin-bottom">
|
<div *ngIf= "communitiesResults != null && communitiesResults.length > 0">
|
||||||
<div class="uk-child-width-1-3@m uk-text-center " uk-grid>
|
<div class="uk-container uk-margin-top uk-margin-bottom">
|
||||||
|
<div class="uk-child-width-1-3@m uk-text-center " uk-grid>
|
||||||
<div>
|
<div *ngFor="let item of communitiesResults; let i = index">
|
||||||
<div class="uk-card uk-card-default">
|
<div class="uk-card uk-card-default">
|
||||||
<div class="uk-card-media-top">
|
<span *ngIf= "item.logoUrl != null">
|
||||||
<img src="" alt="A logo goes here">
|
<div class="uk-card-media-top">
|
||||||
</div>
|
<img src="{{item.logoUrl}}" alt="A logo goes here">
|
||||||
<div class="uk-card-body">
|
|
||||||
<h3 class="uk-card-title"><a [queryParams]="{community: 'egi||EGI Federation'}" routerLinkActive="router-link-active" routerLink="/community">
|
|
||||||
EGI Federation</a></h3>
|
|
||||||
<p> EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.
|
|
||||||
|
|
||||||
The EGI e-infrastructure is publicly-funded and comprises hundreds of data centres and cloud providers spread across Europe and worldwide.</p>
|
|
||||||
<a class="uk-button uk-button-primary"> Subscribe</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</span>
|
||||||
|
<div class="uk-card-body">
|
||||||
|
<div *ngIf="item.title != null" >
|
||||||
<div>
|
<h3 class="uk-card-title"><a [queryParams]="{communityId: item.communityId}" routerLinkActive="router-link-active" routerLink="/community">
|
||||||
<div class="uk-card uk-card-default">
|
{{item.title}}</a></h3>
|
||||||
<div class="uk-card-media-top">
|
|
||||||
<img src="logo.png" alt="A logo goes here">
|
|
||||||
</div>
|
|
||||||
<div class="uk-card-body">
|
|
||||||
<h3 class="uk-card-title"><a>Environment and Economy Research Community</a></h3>
|
|
||||||
<p>the national/EU node of the United Nations Sustainable Development Solutions Network sets out to build an infrastructure to gather all publications, data (in repositories and in Public Sector Information portals), and link them to EU and national funding </p>
|
|
||||||
<a class="uk-button uk-button-primary"> Subscribe</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div *ngIf="item.title == null && item.shortTitle != null" >
|
||||||
|
<h3 class="uk-card-title"><a [queryParams]="{communityId: item.communityId}" routerLinkActive="router-link-active" routerLink="/community">
|
||||||
<div>
|
{{item.shortTitle}}</a></h3>
|
||||||
<div class="uk-card uk-card-default">
|
|
||||||
<div class="uk-card-media-top">
|
|
||||||
<img src="logo.png" alt="A logo goes here">
|
|
||||||
</div>
|
|
||||||
<div class="uk-card-body">
|
|
||||||
<h3 class="uk-card-title"><a>Marine environmental science</a></h3>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
||||||
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
||||||
</p>
|
|
||||||
<a class="uk-button uk-button-primary"> Subscribe</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<p *ngIf="item.description != null" >{{item.description}}</p>
|
||||||
|
<a class="uk-button uk-button-primary"> Subscribe</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
||||||
import {Meta} from '../openaireLibrary/sharedComponents/metaService';
|
import {Meta} from '../openaireLibrary/sharedComponents/metaService';
|
||||||
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
||||||
|
|
||||||
|
import {CommunitiesService} from './communities.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'communities',
|
selector: 'communities',
|
||||||
|
@ -22,11 +23,13 @@ export class CommunitiesComponent {
|
||||||
public pageTitle = "OpenAIRE"
|
public pageTitle = "OpenAIRE"
|
||||||
properties:EnvProperties;
|
properties:EnvProperties;
|
||||||
|
|
||||||
|
public communitiesResults = null;
|
||||||
|
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private _router: Router,
|
private _router: Router,
|
||||||
private location: Location, private _meta: Meta,private _piwikService:PiwikService,
|
private location: Location, private _meta: Meta,private _piwikService:PiwikService, private _communitiesService:CommunitiesService,
|
||||||
private config: ConfigurationService
|
private config: ConfigurationService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -54,13 +57,30 @@ properties:EnvProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
public ngOnDestroy() {
|
// waiting... for response from Claudio
|
||||||
if(this.piwiksub){
|
// this._communitiesService.getResults('https://dev-openaire.d4science.org/openaire/community/communities').subscribe(
|
||||||
this.piwiksub.unsubscribe();
|
// 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(
|
||||||
|
communitiesResults => {
|
||||||
|
this.communitiesResults = communitiesResults;
|
||||||
|
console.log(communitiesResults);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
public ngOnDestroy() {
|
||||||
|
if(this.piwiksub){
|
||||||
|
this.piwiksub.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import{CommunitiesComponent} from './communities.component';
|
||||||
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
|
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
|
||||||
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
||||||
|
|
||||||
|
import {CommunitiesService} from './communities.service';
|
||||||
|
|
||||||
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
||||||
import {Meta} from '../openaireLibrary/sharedComponents/metaService';
|
import {Meta} from '../openaireLibrary/sharedComponents/metaService';
|
||||||
|
@ -22,7 +23,7 @@ import {ConfigurationService} from '../openaireLibrary/utils/configuration/confi
|
||||||
CommunitiesComponent
|
CommunitiesComponent
|
||||||
],
|
],
|
||||||
providers:[
|
providers:[
|
||||||
FreeGuard, PreviousRouteRecorder, ConfigurationService, Meta, PiwikService
|
FreeGuard, PreviousRouteRecorder, ConfigurationService, Meta, PiwikService, CommunitiesService
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
CommunitiesComponent
|
CommunitiesComponent
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Http, Response, Headers, RequestOptions } from '@angular/http';
|
||||||
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
|
||||||
|
import { CommunityInfo } from './communityInfo';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CommunitiesService {
|
||||||
|
|
||||||
|
constructor(private http:Http) {
|
||||||
|
}
|
||||||
|
|
||||||
|
getResults(url: string) {
|
||||||
|
return this.http.get(url).map(res => <any> res.json()).map(res => this.parseResults(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[] = [];
|
||||||
|
|
||||||
|
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['shortTitle'] = resData[0].shortName;
|
||||||
|
result['communityId'] = resData[0].communityId;
|
||||||
|
result['logoUrl'] = resData[0].logo;
|
||||||
|
result['description'] = resData[0].description;
|
||||||
|
} else {
|
||||||
|
result['title'] = resData.name;
|
||||||
|
result['shortTitle'] = resData.shortName;
|
||||||
|
result['communityId'] = resData.communityId;
|
||||||
|
result['logoUrl'] = resData.logo;
|
||||||
|
result['description'] = resData.description;
|
||||||
|
}
|
||||||
|
communities.push(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return communities;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
export class CommunityInfo {
|
||||||
|
title: string;
|
||||||
|
shortTitle:string;
|
||||||
|
communityId: string;
|
||||||
|
logoUrl: string;
|
||||||
|
description: string;
|
||||||
|
}
|
Loading…
Reference in New Issue