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" ;
import { Email } from "../../../openaireLibrary/utils/email/email" ;
import { Composer } from "../../../openaireLibrary/utils/email/composer" ;
import { properties } from "../../../../environments/environment" ;
2022-06-26 22:33:02 +02:00
import { CommunityInfo } from "../../../openaireLibrary/connect/community/communityInfo" ;
2021-05-19 13:40:29 +02:00
@Component ( {
selector : 'users-managers' ,
template : `
2022-06-26 22:33:02 +02:00
< role - users [ id ] = " community.communityId " [ type ] = " community.type " [ name ] = " community.shortTitle " [ inviteDisableMessage ] = " inviteDisableMessage "
2023-02-09 15:31:54 +01:00
[ link ] = "link" [ role ] = "'manager'" [ deleteAuthorizationLevel ] = "'manager'"
[ message ] = "message" [ emailComposer ] = "emailComposer" >
2021-05-19 13:40:29 +02:00
< users - tabs tab = "manager" > < / u s e r s - t a b s >
< / r o l e - u s e r s >
`
} )
export class UsersManagersComponent implements OnInit {
2022-06-26 22:33:02 +02:00
public community : CommunityInfo ;
2021-05-19 13:40:29 +02:00
public link : string ;
public loading : boolean ;
public message : string ;
public inviteDisableMessage : string ;
public emailComposer : Function = ( name , recipient , role ) : Email = > {
2023-10-10 11:30:47 +02:00
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-26 22:33:02 +02:00
this . community = community ;
this . title . setTitle ( this . community . communityId . toUpperCase ( ) + " | Managers" ) ;
this . link = this . getURL ( this . community . communityId ) ;
2021-05-19 13:40:29 +02:00
this . message = 'A manager has the right to access the administration part of Research Community Dashboard, ' +
2022-09-27 10:11:25 +02:00
'where he is able to customize and manage the content, invite other users as managers or members.' ;
2021-05-19 13:40:29 +02:00
if ( community . status === "hidden" ) {
2022-07-13 19:26:10 +02:00
this . inviteDisableMessage = "Community's status is Hidden and invitation to manage 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 ( ) ;
}
} ) ;
}
private getURL ( id : string ) : string {
return 'https://' + ( properties . environment !== "production" ? 'beta.' : '' ) + id + ".openaire.eu?verify=" ;
}
}