connect-admin/src/app/pages/users/users-subscribers/users-subscribers.component.ts

52 lines
1.8 KiB
TypeScript
Raw Normal View History

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">
<users-tabs tab="subscriber"></users-tabs>
</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();
}
});
}
}