2021-05-19 13:40:29 +02:00
import { Component , OnInit } from "@angular/core" ;
import { Title } from "@angular/platform-browser" ;
import { ActivatedRoute } from "@angular/router" ;
import { CommunityService } from "../../../openaireLibrary/connect/community/community.service" ;
import { Subscriber } from "rxjs" ;
@Component ( {
selector : 'users-subscribers' ,
template : `
< subscribers [ id ] = " communityId " [ type ] = " type " [ name ] = " name " [ inviteDisableMessage ] = " inviteDisableMessage " >
2022-06-26 22:33:02 +02:00
< users - tabs tab = "subscriber" > < / u s e r s - t a b s >
2021-05-19 13:40:29 +02:00
< / subscribers >
`
} )
export class UsersSubscribersComponent implements OnInit {
public communityId : string ;
public name : string ;
public type : string ;
public loading : boolean ;
public inviteDisableMessage : string ;
private subscriptions : any [ ] = [ ] ;
constructor ( private communityService : CommunityService ,
private route : ActivatedRoute ,
private title : Title ) {
}
ngOnInit() {
this . loading = true ;
this . subscriptions . push ( this . communityService . getCommunityAsObservable ( ) . subscribe ( community = > {
if ( community ) {
this . communityId = community . communityId ;
this . name = community . shortTitle ;
this . title . setTitle ( this . communityId . toUpperCase ( ) + " | Subscribers" ) ;
this . type = 'community' ;
if ( community . status !== "all" ) {
this . inviteDisableMessage = "<div class='uk-padding-small'>Community's status is " + ( community . status === 'manager' ? 'Visible to managers' : 'Hidden' ) + " and invitation to subscribe to the Research community dashboard is disabled. Update the community status to enable invitations.</div>"
}
this . loading = false ;
}
} ) ) ;
}
ngOnDestroy() {
this . subscriptions . forEach ( value = > {
if ( value instanceof Subscriber ) {
value . unsubscribe ( ) ;
}
} ) ;
}
}