2019-04-05 19:29:28 +02:00
|
|
|
import {Component} from '@angular/core';
|
2018-03-22 16:38:42 +01:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
|
2019-07-18 13:36:05 +02:00
|
|
|
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
|
2020-11-12 16:59:26 +01:00
|
|
|
import {properties} from "../../environments/environment";
|
|
|
|
import {Subscriber} from "rxjs";
|
2018-03-22 16:38:42 +01:00
|
|
|
|
|
|
|
@Component({
|
2019-04-05 19:29:28 +02:00
|
|
|
selector: 'community-wrapper',
|
|
|
|
template:`
|
|
|
|
<community *ngIf="dashboard && communityId" [communityId]=communityId></community>
|
|
|
|
<communities *ngIf="dashboard!=null && !dashboard" ></communities>
|
|
|
|
`
|
2018-03-22 16:38:42 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
export class CommunityWrapperComponent {
|
|
|
|
communityId:string;
|
|
|
|
dashboard:boolean = null;
|
2020-11-12 16:59:26 +01:00
|
|
|
properties;
|
|
|
|
private sub;
|
|
|
|
constructor (private route: ActivatedRoute) {
|
|
|
|
this.properties = properties;
|
|
|
|
this.sub = this.route.queryParams.subscribe(
|
|
|
|
communityId => {
|
|
|
|
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
|
|
|
if(!this.communityId) {
|
|
|
|
this.communityId = communityId['communityId'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.communityId){
|
|
|
|
this.dashboard = true;
|
|
|
|
}else{
|
|
|
|
this.dashboard = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2019-04-05 19:29:28 +02:00
|
|
|
}
|
2018-03-22 16:38:42 +01:00
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
}
|
|
|
|
|
2020-11-12 16:59:26 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
if (this.sub instanceof Subscriber) {
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
2018-03-22 16:38:42 +01:00
|
|
|
|
|
|
|
}
|