[Admin | Trunk]: change send invitation on managers component to get name of community and link of portal

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@59349 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-09-08 14:33:59 +00:00
parent d6e119ebb9
commit e0b2d8454e
1 changed files with 20 additions and 1 deletions

View File

@ -4,6 +4,8 @@ import {Subscription} from 'rxjs/Rx';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
import {FormBuilder, FormControl, Validators} from '@angular/forms'; import {FormBuilder, FormControl, Validators} from '@angular/forms';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {properties} from '../../../environments/environment';
@Component({ @Component({
selector: 'managers', selector: 'managers',
@ -21,11 +23,13 @@ export class ManagersComponent implements OnInit, OnDestroy {
public error: string; public error: string;
public selectedUser: string = null; public selectedUser: string = null;
public invited: FormControl; public invited: FormControl;
public communityName: string;
@ViewChild('inviteManagerModal') inviteManagerModal: AlertModal; @ViewChild('inviteManagerModal') inviteManagerModal: AlertModal;
@ViewChild('deleteManagerModal') deleteManagerModal: AlertModal; @ViewChild('deleteManagerModal') deleteManagerModal: AlertModal;
@ViewChild('deletePendingModal') deletePendingModal: AlertModal; @ViewChild('deletePendingModal') deletePendingModal: AlertModal;
constructor(private userRegistryService: UserRegistryService, constructor(private userRegistryService: UserRegistryService,
private communityService: CommunityService,
private fb: FormBuilder, private fb: FormBuilder,
private route: ActivatedRoute) { private route: ActivatedRoute) {
} }
@ -34,6 +38,9 @@ export class ManagersComponent implements OnInit, OnDestroy {
this.subs.push(this.route.queryParams.subscribe(params => { this.subs.push(this.route.queryParams.subscribe(params => {
if (params && params['communityId']) { if (params && params['communityId']) {
this.communityId = params['communityId']; this.communityId = params['communityId'];
this.subs.push(this.communityService.getCommunity(properties, properties.communityAPI + this.communityId).subscribe(community => {
this.communityName = community.title;
}));
this.subs.push(this.userRegistryService.getManagersEmail('community', this.communityId).subscribe(managers => { this.subs.push(this.userRegistryService.getManagersEmail('community', this.communityId).subscribe(managers => {
this.managers = managers; this.managers = managers;
this.loadManagers = false; this.loadManagers = false;
@ -107,7 +114,11 @@ export class ManagersComponent implements OnInit, OnDestroy {
inviteManager() { inviteManager() {
this.loadManagers = true; this.loadManagers = true;
this.userRegistryService.invite('community', this.communityId, this.invited.value).subscribe(invitation => { let details = {
name: this.communityName,
link: this.getURL()
}
this.userRegistryService.invite('community', this.communityId, this.invited.value, details).subscribe(invitation => {
this.error = null; this.error = null;
if(!this.pending.includes(this.invited.value)) { if(!this.pending.includes(this.invited.value)) {
this.pending.push(this.invited.value); this.pending.push(this.invited.value);
@ -118,4 +129,12 @@ export class ManagersComponent implements OnInit, OnDestroy {
this.loadManagers = false; this.loadManagers = false;
}) })
} }
private getURL(): string {
if(properties.environment != "production") {
return 'https://beta.' + this.communityId + ".openaire.eu/verify";
} else {
return 'https://' + this.communityId + ".openaire.eu/verify";
}
}
} }