1
|
import {Component, OnInit} from "@angular/core";
|
2
|
import {Title} from "@angular/platform-browser";
|
3
|
import {ActivatedRoute} from "@angular/router";
|
4
|
import {CommunityService} from "../../../openaireLibrary/connect/community/community.service";
|
5
|
import {Subscriber} from "rxjs";
|
6
|
|
7
|
@Component({
|
8
|
selector: 'users-subscribers',
|
9
|
template: `
|
10
|
<subscribers [id]="communityId" [type]="type" [name]="name" [inviteDisableMessage]="inviteDisableMessage">
|
11
|
<users-tabs tab="members"></users-tabs>
|
12
|
</subscribers>
|
13
|
`
|
14
|
})
|
15
|
export class UsersSubscribersComponent implements OnInit {
|
16
|
public communityId: string;
|
17
|
public name: string;
|
18
|
public type: string;
|
19
|
public loading: boolean;
|
20
|
public inviteDisableMessage: string;
|
21
|
private subscriptions: any[] = [];
|
22
|
|
23
|
constructor(private communityService: CommunityService,
|
24
|
private route: ActivatedRoute,
|
25
|
private title: Title) {
|
26
|
}
|
27
|
|
28
|
ngOnInit() {
|
29
|
this.loading = true;
|
30
|
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
|
31
|
if(community) {
|
32
|
this.communityId = community.communityId;
|
33
|
this.name = community.shortTitle;
|
34
|
this.title.setTitle(this.communityId.toUpperCase() + " | Subscribers");
|
35
|
this.type = 'community';
|
36
|
if(community.status !== "all") {
|
37
|
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>"
|
38
|
}
|
39
|
this.loading = false;
|
40
|
}
|
41
|
}));
|
42
|
}
|
43
|
|
44
|
ngOnDestroy() {
|
45
|
this.subscriptions.forEach(value => {
|
46
|
if (value instanceof Subscriber) {
|
47
|
value.unsubscribe();
|
48
|
}
|
49
|
});
|
50
|
}
|
51
|
}
|