1. approved.component.ts: component to check and show approval of content providers in share result pages by current community.

2. searchResult.component.html: approved.component moved to openaireLibrary: 'connect/approvedByCommunity/'.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51580 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-03-29 14:15:47 +00:00
parent 51cbc6e01f
commit 11d936d51b
4 changed files with 98 additions and 1 deletions

View File

@ -0,0 +1,60 @@
import { Component, Input } from '@angular/core';
import { Location } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
import { EnvProperties} from '../../utils/properties/env-properties';
import {ConnectHelper} from '../connectHelper';
import {ApprovedByCommunityService} from './approved.service';
@Component({
selector: 'approved-by-community',
template: `
<span *ngIf="approved" class="uk-align-right uk-label custom-label uk-label-success">Community Approved</span>
`
})
export class ApprovedByCommunityComponent {
@Input() contentProviderId: string;
public communityId:string;
public approved:boolean = false;
private communityContentProviders = [];
properties:EnvProperties;
constructor (private route: ActivatedRoute, private _searchDataprovidersService: ApprovedByCommunityService) {}
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;
});
}
}

View File

@ -0,0 +1,22 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { ApprovedByCommunityComponent } from './approved.component';
import { ApprovedByCommunityService } from './approved.service';
@NgModule({
imports: [
CommonModule, RouterModule
],
declarations: [
ApprovedByCommunityComponent
],
providers:[
ApprovedByCommunityService
],
exports: [
ApprovedByCommunityComponent
]
})
export class ApprovedByCommunityModule { }

View File

@ -0,0 +1,15 @@
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import{EnvProperties} from '../../utils/properties/env-properties';
@Injectable()
export class ApprovedByCommunityService {
constructor(private http: Http ) {}
searchDataproviders (properties:EnvProperties, communityId: string):any {
let url = properties.communityAPI+communityId+"/contentproviders";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
}
}

View File

@ -7,7 +7,7 @@ import {ErrorMessagesModule} from '../../utils/errorMessages.module';
import {SearchResult} from '../../utils/entities/searchResult';
import {SearchResultComponent} from './searchResult.component';
import {ApprovedByCommunityModule} from '../../../utils/approvedByCommunity/approved.module';
import {ApprovedByCommunityModule} from '../../connect/approvedByCommunity/approved.module';
@NgModule({
imports: [