62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
import {Component, OnDestroy, OnInit} from "@angular/core";
|
|
import {UserRegistryService} from "../openaireLibrary/services/user-registry.service";
|
|
import {ActivatedRoute} from "@angular/router";
|
|
import {Subscriber, Subscription} from "rxjs";
|
|
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
|
|
import {properties} from "../../environments/environment";
|
|
|
|
@Component({
|
|
selector: 'verification-manager',
|
|
template: `
|
|
<div class="uk-section uk-container">
|
|
<div class="uk-card uk-card-default uk-card-body">
|
|
<div *ngIf="loading" class="loading-gif"></div>
|
|
<div *ngIf="!loading && invitation">
|
|
<verification [name]="name" [invitation]="invitation"></verification>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`
|
|
})
|
|
export class VerificationManagerComponent implements OnInit, OnDestroy {
|
|
|
|
private subscriptions: any[] = [];
|
|
public loading = true;
|
|
public invitation;
|
|
public name;
|
|
|
|
constructor(private userRegistryService: UserRegistryService,
|
|
private communityService: CommunityService,
|
|
private route: ActivatedRoute) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
|
if (params && params['id']) {
|
|
this.subscriptions.push(this.userRegistryService.getInvitation(params['id']).subscribe(invitation => {
|
|
this.invitation = invitation;
|
|
this.subscriptions.push(this.communityService.
|
|
getCommunityByState(properties, properties.communityAPI + invitation.entity).subscribe(community => {
|
|
this.name = community.title;
|
|
this.loading = false;
|
|
}));
|
|
}, error => {
|
|
this.loading = false;
|
|
console.error(error);
|
|
}));
|
|
}
|
|
}));
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.subscriptions.forEach(sub => {
|
|
if (sub instanceof Subscription) {
|
|
if (sub instanceof Subscriber) {
|
|
sub.unsubscribe();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|