Merge branch 'master' of code-repo.d4science.org:MaDgIK/openaire-library
This commit is contained in:
commit
c5f3c0b744
|
@ -11,12 +11,12 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
|||
@Component({
|
||||
selector: 'relatedTo',
|
||||
template: `
|
||||
<div class="sideInfoTitle">
|
||||
<div *ngIf="(gateways && gateways.length > 0) || (otherCommunities && otherCommunities.length > 0)" class="sideInfoTitle">
|
||||
<span>Communities</span>
|
||||
</div>
|
||||
<!-- If there are any communities with dashboard -->
|
||||
<ng-container *ngIf="gateways && gateways.length > 0">
|
||||
<div class="uk-padding-small uk-margin-small-top uk-flex">
|
||||
<div class="uk-padding-small uk-flex">
|
||||
<div class="uk-width-2-3">
|
||||
<div class="uk-text-muted">Communities with gateway</div>
|
||||
<ul class="custom-list">
|
||||
|
@ -39,7 +39,7 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
|||
<div>
|
||||
<div *ngIf="gateways && gateways.length > 0" class="uk-text-muted">Other Communities</div>
|
||||
<ul class="custom-list" [ngClass]="{'uk-padding-remove uk-margin-remove': !gateways || gateways.length == 0}">
|
||||
<li *ngFor="let community of otherCommunities; let i = index">
|
||||
<li *ngFor="let community of otherCommunities.slice(0, showNum); let i = index">
|
||||
{{community.labelContext}}
|
||||
<span *ngIf="community.labelCategory && (currentCommunity == community.idContext)">
|
||||
<span uk-icon="icon: arrow-right"></span> {{community.labelCategory}}
|
||||
|
@ -48,6 +48,12 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
|||
: {{community.labelConcept}}
|
||||
</span>
|
||||
</li>
|
||||
<div *ngIf="showNum > threshold" class="uk-text-right">
|
||||
<a (click)="showNum = threshold;">View less</a>
|
||||
</div>
|
||||
<div *ngIf="otherCommunities.length > threshold && showNum == threshold" class="uk-text-right">
|
||||
<a (click)="showNum = otherCommunities.length;">View more</a>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -156,8 +162,8 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
|||
export class RelatedToComponent implements OnInit {
|
||||
@Input() contexts: { "idContext": string, "labelContext": string, "labelCategory": string, "labelConcept": string, "link": string, "logo": string }[];
|
||||
|
||||
public threshold: number = 5;
|
||||
public showNum: number = 5;
|
||||
public threshold: number = 3;
|
||||
public showNum: number = 3;
|
||||
public gateways = [];
|
||||
public otherCommunities = [];
|
||||
public currentCommunity = ConnectHelper.getCommunityFromDomain(properties.domain);
|
||||
|
@ -169,52 +175,50 @@ export class RelatedToComponent implements OnInit {
|
|||
|
||||
ngOnInit() {
|
||||
this.contexts.sort(this.compare);
|
||||
if(properties.environment === "development") {
|
||||
let index = 0;
|
||||
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 => {
|
||||
if(community && !ConnectHelper.isPrivate(community,user) && (this.currentCommunity != 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';
|
||||
}
|
||||
context.link = url;
|
||||
for(let gateway of this.gateways) {
|
||||
if(gateway.link == context.link) {
|
||||
return; // skips so that we don't get duplicate gateways
|
||||
}
|
||||
}
|
||||
this.gateways.push(context);
|
||||
let index = 0;
|
||||
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 => {
|
||||
if(community && !ConnectHelper.isPrivate(community,user) && (this.currentCommunity != context.idContext)) {
|
||||
// creating the link, based on the enviroment
|
||||
let url = '';
|
||||
if(properties.environment == "beta") {
|
||||
url = 'https://beta.' + context.idContext + '.openaire.eu';
|
||||
} else {
|
||||
if(this.currentCommunity != context.idContext) {
|
||||
for(let other of this.otherCommunities) {
|
||||
if(other.idContext == context.idContext) {
|
||||
return; // skips so that we don't get duplicate communities because of the multiple concepts
|
||||
}
|
||||
url = 'https://' + context.idContext + '.openaire.eu';
|
||||
}
|
||||
context.link = url;
|
||||
for(let gateway of this.gateways) {
|
||||
if(gateway.link == context.link) {
|
||||
return; // skips so that we don't get duplicate gateways
|
||||
}
|
||||
}
|
||||
this.gateways.push(context);
|
||||
} else {
|
||||
if(this.currentCommunity != context.idContext) {
|
||||
for(let other of this.otherCommunities) {
|
||||
if(other.idContext == context.idContext) {
|
||||
return; // skips so that we don't get duplicate communities because of the multiple concepts
|
||||
}
|
||||
}
|
||||
this.otherCommunities.push(context);
|
||||
}
|
||||
index++;
|
||||
if(index == this.contexts.length) {
|
||||
this.gateways.sort(this.compare);
|
||||
this.otherCommunities.sort(this.compare);
|
||||
}
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.otherCommunities.push(context);
|
||||
}
|
||||
index++;
|
||||
if(index == this.contexts.length) {
|
||||
this.gateways.sort(this.compare);
|
||||
this.otherCommunities.sort(this.compare);
|
||||
}
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
Loading…
Reference in New Issue