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
|
import {Email} from "../../../openaireLibrary/utils/email/email";
|
7
|
import {Composer} from "../../../openaireLibrary/utils/email/composer";
|
8
|
import {properties} from "../../../../environments/environment";
|
9
|
|
10
|
@Component({
|
11
|
selector: 'users-managers',
|
12
|
template: `
|
13
|
<role-users [id]="communityId" [type]="type" [name]="name" [inviteDisableMessage]="inviteDisableMessage"
|
14
|
[link]="link" [role]="'manager'" [message]="message" [emailComposer]="emailComposer">
|
15
|
<users-tabs tab="manager"></users-tabs>
|
16
|
</role-users>
|
17
|
`
|
18
|
})
|
19
|
export class UsersManagersComponent implements OnInit {
|
20
|
public communityId: string;
|
21
|
public name: string;
|
22
|
public type: string;
|
23
|
public link: string;
|
24
|
public loading: boolean;
|
25
|
public message: string;
|
26
|
public inviteDisableMessage: string;
|
27
|
public emailComposer: Function = (name, recipient, role):Email => {
|
28
|
return Composer.composeEmailForCommunityDashboard(name, recipient);
|
29
|
}
|
30
|
private subscriptions: any[] = [];
|
31
|
|
32
|
constructor(private communityService: CommunityService,
|
33
|
private route: ActivatedRoute,
|
34
|
private title: Title) {
|
35
|
}
|
36
|
|
37
|
ngOnInit() {
|
38
|
this.loading = true;
|
39
|
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
|
40
|
if(community) {
|
41
|
this.communityId = community.communityId;
|
42
|
this.name = community.shortTitle;
|
43
|
this.title.setTitle(this.communityId.toUpperCase() + " | Managers");
|
44
|
this.type = 'community';
|
45
|
this.link = this.getURL(this.communityId);
|
46
|
this.message = 'A manager has the right to access the administration part of Research Community Dashboard, ' +
|
47
|
'where he is able to customize and manage the content, invite other users as managers or to subscribe.';
|
48
|
if(community.status === "hidden") {
|
49
|
this.inviteDisableMessage = "<div class='uk-padding-small'>Community's status is Hidden and invitation to manage the Research community dashboard is disabled. Update the community status to enable invitations.</div>"
|
50
|
}
|
51
|
this.loading = false;
|
52
|
}
|
53
|
}));
|
54
|
}
|
55
|
|
56
|
ngOnDestroy() {
|
57
|
this.subscriptions.forEach(value => {
|
58
|
if (value instanceof Subscriber) {
|
59
|
value.unsubscribe();
|
60
|
}
|
61
|
});
|
62
|
}
|
63
|
|
64
|
private getURL(id: string): string {
|
65
|
return 'https://' + (properties.environment !== "production"?'beta.':'') + id + ".openaire.eu?verify=";
|
66
|
}
|
67
|
}
|