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" ;
2022-06-28 20:15:05 +02:00
import { CommunityInfo } from "../../../openaireLibrary/connect/community/communityInfo" ;
2023-10-10 11:30:47 +02:00
import { Email } from "../../../openaireLibrary/utils/email/email" ;
import { Composer } from "../../../openaireLibrary/utils/email/composer" ;
import { properties } from "../../../../environments/environment" ;
2021-05-19 13:40:29 +02:00
@Component ( {
selector : 'users-subscribers' ,
template : `
2023-10-10 11:30:47 +02:00
< subscribers * ngIf = "community.isOpen()" [ id ] = " community.communityId " [ type ] = " ' community ' " [ name ] = " community.shortTitle "
2022-07-13 19:26:10 +02:00
[ inviteDisableMessage ] = "inviteDisableMessage" >
2022-06-28 20:15:05 +02:00
< users - tabs tab = "member" > < / u s e r s - t a b s >
2021-05-19 13:40:29 +02:00
< / subscribers >
2023-10-10 11:30:47 +02:00
< role - users * ngIf = "!community.isOpen()" [ id ] = " community.communityId " [ type ] = " community.type " [ name ] = " community.shortTitle " [ inviteDisableMessage ] = " inviteDisableMessage "
[ link ] = "link" [ role ] = "'member'"
[ message ] = "message" [ emailComposer ] = "emailComposer" >
< users - tabs tab = "member" > < / u s e r s - t a b s >
< / r o l e - u s e r s >
2021-05-19 13:40:29 +02:00
`
} )
export class UsersSubscribersComponent implements OnInit {
2022-06-28 20:15:05 +02:00
public community : CommunityInfo ;
2023-10-10 11:30:47 +02:00
public link : string ;
2021-05-19 13:40:29 +02:00
public loading : boolean ;
2023-10-10 11:30:47 +02:00
public message : string ;
2021-05-19 13:40:29 +02:00
public inviteDisableMessage : string ;
2023-10-10 11:30:47 +02:00
public emailComposer : Function = ( name , recipient , role ) : Email = > {
return Composer . composeEmailForCommunityDashboard ( name , role , recipient ) ;
}
2021-05-19 13:40:29 +02:00
private subscriptions : any [ ] = [ ] ;
constructor ( private communityService : CommunityService ,
private title : Title ) {
}
ngOnInit() {
this . loading = true ;
this . subscriptions . push ( this . communityService . getCommunityAsObservable ( ) . subscribe ( community = > {
if ( community ) {
2022-06-28 20:15:05 +02:00
this . community = community ;
2023-10-10 11:30:47 +02:00
this . title . setTitle ( this . community . shortTitle . toUpperCase ( ) + " | Members" ) ;
this . link = this . getURL ( this . community . communityId ) ;
this . message = 'A member can access the community dashboard and link research results with projects, ' +
'communities and other research projects.' ;
2024-02-14 09:47:03 +01:00
if ( ! community . isPublic ( ) ) {
this . inviteDisableMessage = "Community's status is " + ( community . isRestricted ( ) ? 'Visible to managers' : 'Hidden' ) + " and invitation to join the Research community dashboard is disabled. Update the community status to enable invitations."
2021-05-19 13:40:29 +02:00
}
this . loading = false ;
}
} ) ) ;
}
ngOnDestroy() {
this . subscriptions . forEach ( value = > {
if ( value instanceof Subscriber ) {
value . unsubscribe ( ) ;
}
} ) ;
}
2023-10-10 11:30:47 +02:00
private getURL ( id : string ) : string {
return 'https://' + ( properties . environment !== "production" ? 'beta.' : '' ) + id + ".openaire.eu?verify=" ;
}
2021-05-19 13:40:29 +02:00
}