Landing page: add link to RC dashboards in community context
This commit is contained in:
parent
aafe917099
commit
9da11820aa
|
@ -1,4 +1,11 @@
|
||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
|
import {Subscriber} from 'rxjs';
|
||||||
|
|
||||||
|
import {properties} from 'src/environments/environment';
|
||||||
|
|
||||||
|
import {CommunityService} from '../../connect/community/community.service';
|
||||||
|
import {ConnectHelper} from '../../connect/connectHelper';
|
||||||
|
import {UserManagementService} from '../../services/user-management.service';
|
||||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -7,7 +14,10 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
<div class="uk-text-muted">Communities</div>
|
<div class="uk-text-muted">Communities</div>
|
||||||
<div class="uk-margin-small-left" *ngFor="let item of contexts.slice(0, showNum); let i=index">
|
<div class="uk-margin-small-left" *ngFor="let item of contexts.slice(0, showNum); let i=index">
|
||||||
<span>
|
<span>
|
||||||
<span>{{item['labelContext']}}</span>
|
<a *ngIf="item['link']; else noLink" [href]="item['link']" target="_blank">{{item['labelContext']}}</a>
|
||||||
|
<ng-template #noLink>
|
||||||
|
<span>{{item['labelContext']}}</span>
|
||||||
|
</ng-template>
|
||||||
<span *ngIf="item['labelCategory']"><span
|
<span *ngIf="item['labelCategory']"><span
|
||||||
uk-icon="icon: arrow-right"></span>{{item['labelCategory']}}</span>
|
uk-icon="icon: arrow-right"></span>{{item['labelCategory']}}</span>
|
||||||
<span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
|
<span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
|
||||||
|
@ -27,16 +37,51 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
})
|
})
|
||||||
|
|
||||||
export class RelatedToComponent {
|
export class RelatedToComponent {
|
||||||
@Input() contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string }[];
|
@Input() contexts: { "idContext": string, "labelContext": string, "labelCategory": string, "labelConcept": string, "link": string }[];
|
||||||
|
|
||||||
public threshold: number = 5;
|
public threshold: number = 5;
|
||||||
public showNum: number = 5;
|
public showNum: number = 5;
|
||||||
|
private subscriptions = [];
|
||||||
|
|
||||||
constructor() {
|
constructor(private communityService: CommunityService,
|
||||||
|
private userManagementService: UserManagementService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.contexts.forEach( context => {
|
||||||
|
if(context.idContext) {
|
||||||
|
this.subscriptions.push(
|
||||||
|
this.userManagementService.getUserInfo().subscribe( user => {
|
||||||
|
//- handling subscribe errors?
|
||||||
|
this.subscriptions.push(
|
||||||
|
this.communityService.getCommunity(context.idContext).subscribe( community => {
|
||||||
|
// swap the == of the last condition to != // testing this way for now
|
||||||
|
if(community && !ConnectHelper.isPrivate(community,user) && (ConnectHelper.getCommunityFromDomain(properties.domain) != context.idContext)) {
|
||||||
|
// creating the link, based on the enviroment
|
||||||
|
let url = '';
|
||||||
|
if(properties.environment == "beta") {
|
||||||
|
url = 'https://beta.' + context.idContext + '.openaire.eu';
|
||||||
|
} else {
|
||||||
|
url = 'https://' + context.idContext + '.openaire.eu';
|
||||||
|
}
|
||||||
|
console.log(url);
|
||||||
|
context.link = url;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.subscriptions.forEach(subscription => {
|
||||||
|
if(subscription instanceof Subscriber) {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public scroll() {
|
public scroll() {
|
||||||
HelperFunctions.scroll();
|
HelperFunctions.scroll();
|
||||||
|
|
Loading…
Reference in New Issue