From 886081d24d75d2eac937937f80f4c90ee8343155 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 29 Mar 2018 13:42:52 +0000 Subject: [PATCH] 1. approved.component.ts: component to check and show approval of content providers in share result pages by current community. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@51577 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../approvedByCommunity/approved.component.ts | 60 +++++++++++++++++++ .../approvedByCommunity/approved.module.ts | 21 +++++++ 2 files changed, 81 insertions(+) create mode 100644 src/app/utils/approvedByCommunity/approved.component.ts create mode 100644 src/app/utils/approvedByCommunity/approved.module.ts diff --git a/src/app/utils/approvedByCommunity/approved.component.ts b/src/app/utils/approvedByCommunity/approved.component.ts new file mode 100644 index 0000000..fc906f9 --- /dev/null +++ b/src/app/utils/approvedByCommunity/approved.component.ts @@ -0,0 +1,60 @@ +import { Component, Input } from '@angular/core'; +import { Location } from '@angular/common'; +import { ActivatedRoute } from '@angular/router'; +import { EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; + +import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; +import {SearchCommunityDataprovidersService} from '../../services/searchDataproviders.service'; + +@Component({ + selector: 'approved-by-community', + template: ` + Community Approved + ` +}) + +export class ApprovedByCommunityComponent { + @Input() contentProviderId: string; + + public communityId:string; + public approved:boolean = false; + private communityContentProviders = []; + + properties:EnvProperties; + + constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchCommunityDataprovidersService) {} + + public ngOnInit() { + this.route.data + .subscribe((data: { envSpecific: EnvProperties }) => { + this.properties = data.envSpecific; + + this.route.queryParams.subscribe( + communityId => { + this.communityId = communityId['communityId']; + + if(!this.communityId){ + this.communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname); + } + + if(this.communityId && this.communityId != "openaire") { + this._searchDataprovidersService.searchDataproviders(this.properties, this.communityId).subscribe ( + contentproviders => { + this.communityContentProviders = contentproviders; + this.approved = this.checkApproval(); + } + ); + } + }); + }); + + + } + + private checkApproval(): boolean { + let self = this; + return this.communityContentProviders.map(contentprovider => contentprovider.openaireId).some(function(id) { + return id == self.contentProviderId; + }); + } +} diff --git a/src/app/utils/approvedByCommunity/approved.module.ts b/src/app/utils/approvedByCommunity/approved.module.ts new file mode 100644 index 0000000..c2e64bd --- /dev/null +++ b/src/app/utils/approvedByCommunity/approved.module.ts @@ -0,0 +1,21 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { RouterModule } from '@angular/router'; + +import { ApprovedByCommunityComponent } from './approved.component'; +import {SearchDataprovidersServiceModule} from '../../services/searchDataprovidersService.module'; + +@NgModule({ + imports: [ + CommonModule, RouterModule, SearchDataprovidersServiceModule + ], + declarations: [ + ApprovedByCommunityComponent + ], + providers:[ + ], + exports: [ + ApprovedByCommunityComponent + ] +}) +export class ApprovedByCommunityModule { }