Revision 60029
Added by Konstantinos Triantafyllou almost 4 years ago
modules/uoa-admin-portal/trunk/src/app/pages/managers/managers-routing.module.ts | ||
---|---|---|
1 |
import {NgModule} from '@angular/core'; |
|
2 |
import {RouterModule} from '@angular/router'; |
|
3 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
4 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
5 |
import {ManagersComponent} from './managers.component'; |
|
6 |
|
|
7 |
@NgModule({ |
|
8 |
imports:[RouterModule.forChild([ |
|
9 |
{path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: ManagersComponent} |
|
10 |
])] |
|
11 |
}) |
|
12 |
export class ManagersRoutingModule { |
|
13 |
|
|
14 |
} |
modules/uoa-admin-portal/trunk/src/app/pages/managers/managers.component.html | ||
---|---|---|
1 |
<div class="uk-card uk-card-default uk-card-body"> |
|
2 |
<div *ngIf="error" class="uk-alert uk-alert-danger uk-flex uk-flex-top"> |
|
3 |
<span class="uk-margin-small-right uk-icon" uk-icon="warning"></span> |
|
4 |
<div> |
|
5 |
{{error}} |
|
6 |
</div> |
|
7 |
</div> |
|
8 |
<div *ngIf="loadManagers || loadPending" class="loading-gif"></div> |
|
9 |
<div *ngIf="!loadManagers && !loadPending"> |
|
10 |
<div class="uk-text-large uk-text-bold uk-text-center uk-margin-medium-bottom">Managers</div> |
|
11 |
<div class="uk-flex uk-flex-right"> |
|
12 |
<button class="uk-button uk-button-primary" (click)="openInviteModal()">Invite a Manager</button> |
|
13 |
</div> |
|
14 |
<ul uk-tab class="uk-tab links"> |
|
15 |
<li *ngIf="managers" [class.uk-active]="showManagers" (click)="showManagers = true"> |
|
16 |
<a>Managers <span class="uk-badge space">{{managers.length | number}}</span></a> |
|
17 |
</li> |
|
18 |
<li *ngIf="pending" [class.uk-active]="!showManagers" (click)="showManagers = false"> |
|
19 |
<a>Pending Managers <span class="uk-badge space">{{pending.length | number}}</span></a> |
|
20 |
</li> |
|
21 |
</ul> |
|
22 |
<div class="custom-dataTable-content"> |
|
23 |
<div class="uk-overflow-container"> |
|
24 |
<table class="uk-table uk-table-striped divider-table" id="dpTable"> |
|
25 |
<thead> |
|
26 |
<tr> |
|
27 |
<th class="uk-text-center">Email</th> |
|
28 |
<th class="uk-text-center">Action</th> |
|
29 |
</tr> |
|
30 |
</thead> |
|
31 |
<tbody> |
|
32 |
<tr class="uk-table-middle" *ngFor="let item of (showManagers)?managers:pending"> |
|
33 |
<td class="uk-text-center uk-width-1-2"> |
|
34 |
{{(showManagers)?item.email:item}} |
|
35 |
</td> |
|
36 |
<td class="uk-text-center uk-width-1-2"> |
|
37 |
<a (click)="openDeleteModal(item)" class="uk-icon-button remove uk-button-danger" uk-icon="icon: close; ratio: 1" title="Remove"></a> |
|
38 |
</td> |
|
39 |
</tr> |
|
40 |
</tbody> |
|
41 |
</table> |
|
42 |
</div> |
|
43 |
</div> |
|
44 |
</div> |
|
45 |
</div> |
|
46 |
<modal-alert #inviteManagerModal (alertOutput)="inviteManager()" [okDisabled]="invited && invited.invalid"> |
|
47 |
<div *ngIf="invited" class="uk-padding uk-text-center"> |
|
48 |
<span class="uk-text-bold">Email: </span> |
|
49 |
<input class="uk-input space uk-width-medium" [class.uk-form-danger]="invited.invalid" [formControl]="invited"> |
|
50 |
</div> |
|
51 |
</modal-alert> |
|
52 |
<modal-alert #deleteManagerModal (alertOutput)="deleteManager()"></modal-alert> |
|
53 |
<modal-alert #deletePendingModal (alertOutput)="deletePendingManager()"></modal-alert> |
modules/uoa-admin-portal/trunk/src/app/pages/managers/managers.component.ts | ||
---|---|---|
1 |
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; |
|
2 |
import {UserRegistryService} from '../../openaireLibrary/services/user-registry.service'; |
|
3 |
import {Subscription} from 'rxjs/Rx'; |
|
4 |
import {ActivatedRoute} from '@angular/router'; |
|
5 |
import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; |
|
6 |
import {FormBuilder, FormControl, Validators} from '@angular/forms'; |
|
7 |
import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; |
|
8 |
import {properties} from '../../../environments/environment'; |
|
9 |
|
|
10 |
@Component({ |
|
11 |
selector: 'managers', |
|
12 |
templateUrl: 'managers.component.html' |
|
13 |
}) |
|
14 |
export class ManagersComponent implements OnInit, OnDestroy { |
|
15 |
|
|
16 |
public managers: any[]; |
|
17 |
public pending: any[]; |
|
18 |
public communityId: string; |
|
19 |
public showManagers: boolean = true; |
|
20 |
public subs: any[] = []; |
|
21 |
public loadManagers: boolean = true; |
|
22 |
public loadPending: boolean = true; |
|
23 |
public error: string; |
|
24 |
public selectedUser: string = null; |
|
25 |
public invited: FormControl; |
|
26 |
public communityName: string; |
|
27 |
@ViewChild('inviteManagerModal') inviteManagerModal: AlertModal; |
|
28 |
@ViewChild('deleteManagerModal') deleteManagerModal: AlertModal; |
|
29 |
@ViewChild('deletePendingModal') deletePendingModal: AlertModal; |
|
30 |
|
|
31 |
constructor(private userRegistryService: UserRegistryService, |
|
32 |
private communityService: CommunityService, |
|
33 |
private fb: FormBuilder, |
|
34 |
private route: ActivatedRoute) { |
|
35 |
} |
|
36 |
|
|
37 |
ngOnInit() { |
|
38 |
this.subs.push(this.route.queryParams.subscribe(params => { |
|
39 |
if (params && params['communityId']) { |
|
40 |
this.communityId = params['communityId']; |
|
41 |
this.subs.push(this.communityService.getCommunity(properties, properties.communityAPI + this.communityId).subscribe(community => { |
|
42 |
this.communityName = community.title; |
|
43 |
})); |
|
44 |
this.subs.push(this.userRegistryService.getManagersEmail('community', this.communityId).subscribe(managers => { |
|
45 |
this.managers = managers; |
|
46 |
this.loadManagers = false; |
|
47 |
}, error => { |
|
48 |
this.managers = []; |
|
49 |
this.error = error.error.response; |
|
50 |
this.loadManagers = false; |
|
51 |
})); |
|
52 |
this.subs.push(this.userRegistryService.getPendingManagers('community', this.communityId).subscribe(pending => { |
|
53 |
this.pending = pending; |
|
54 |
this.loadPending = false; |
|
55 |
}, error => { |
|
56 |
this.managers = []; |
|
57 |
this.error = error.error.response; |
|
58 |
this.loadManagers = false; |
|
59 |
})); |
|
60 |
} |
|
61 |
})); |
|
62 |
} |
|
63 |
|
|
64 |
ngOnDestroy() { |
|
65 |
this.subs.forEach(sub => { |
|
66 |
if (sub instanceof Subscription) { |
|
67 |
sub.unsubscribe(); |
|
68 |
} |
|
69 |
}); |
|
70 |
} |
|
71 |
|
|
72 |
openDeleteModal(item: any) { |
|
73 |
if(this.showManagers) { |
|
74 |
this.selectedUser = item.email; |
|
75 |
this.deleteManagerModal.alertTitle = 'Delete ' + item.email + ' from managers'; |
|
76 |
this.deleteManagerModal.open(); |
|
77 |
} else { |
|
78 |
this.selectedUser = item; |
|
79 |
this.deletePendingModal.alertTitle = 'Delete ' + item + ' from managers'; |
|
80 |
this.deletePendingModal.open(); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
openInviteModal() { |
|
85 |
this.inviteManagerModal.alertTitle = 'Invite user to be manager'; |
|
86 |
this.inviteManagerModal.okButtonLeft = false; |
|
87 |
this.invited = this.fb.control('', [Validators.required, Validators.email]); |
|
88 |
this.inviteManagerModal.open(); |
|
89 |
} |
|
90 |
|
|
91 |
deleteManager() { |
|
92 |
this.loadManagers = true; |
|
93 |
this.userRegistryService.removeManager('community', this.communityId, this.selectedUser).subscribe(() => { |
|
94 |
this.managers = this.managers.filter(manager => manager.email != this.selectedUser); |
|
95 |
this.loadManagers = false; |
|
96 |
this.error = null; |
|
97 |
},error => { |
|
98 |
this.error = error.error.response; |
|
99 |
this.loadManagers = false; |
|
100 |
}); |
|
101 |
} |
|
102 |
|
|
103 |
deletePendingManager() { |
|
104 |
this.loadPending = true; |
|
105 |
this.userRegistryService.cancelManagerInvitation('community', this.communityId, this.selectedUser).subscribe(() => { |
|
106 |
this.pending = this.pending.filter(manager => manager != this.selectedUser); |
|
107 |
this.error = null; |
|
108 |
this.loadPending = false; |
|
109 |
},error => { |
|
110 |
this.error = error.error.response; |
|
111 |
this.loadPending = false; |
|
112 |
}); |
|
113 |
} |
|
114 |
|
|
115 |
inviteManager() { |
|
116 |
this.loadManagers = true; |
|
117 |
let details = { |
|
118 |
name: this.communityName, |
|
119 |
link: this.getURL() |
|
120 |
} |
|
121 |
this.userRegistryService.inviteManager('community', this.communityId, this.invited.value, details).subscribe(invitation => { |
|
122 |
this.error = null; |
|
123 |
if(!this.pending.includes(this.invited.value)) { |
|
124 |
this.pending.push(this.invited.value); |
|
125 |
} |
|
126 |
this.loadManagers = false; |
|
127 |
},error => { |
|
128 |
this.error = error.error.response; |
|
129 |
this.loadManagers = false; |
|
130 |
}) |
|
131 |
} |
|
132 |
|
|
133 |
private getURL(): string { |
|
134 |
if(properties.environment != "production") { |
|
135 |
return 'https://beta.' + this.communityId + ".openaire.eu/verify/"; |
|
136 |
} else { |
|
137 |
return 'https://' + this.communityId + ".openaire.eu/verify/"; |
|
138 |
} |
|
139 |
} |
|
140 |
} |
modules/uoa-admin-portal/trunk/src/app/pages/managers/managers.module.ts | ||
---|---|---|
1 |
import {NgModule} from '@angular/core'; |
|
2 |
import {CommonModule} from '@angular/common'; |
|
3 |
import {ManagersRoutingModule} from './managers-routing.module'; |
|
4 |
import {ManagersComponent} from './managers.component'; |
|
5 |
import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; |
|
6 |
import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; |
|
7 |
import {EmailService} from '../../openaireLibrary/utils/email/email.service'; |
|
8 |
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; |
|
9 |
import {ReactiveFormsModule} from '@angular/forms'; |
|
10 |
|
|
11 |
@NgModule({ |
|
12 |
imports: [CommonModule, ManagersRoutingModule, AlertModalModule, ReactiveFormsModule], |
|
13 |
declarations: [ManagersComponent], |
|
14 |
exports: [ManagersComponent], |
|
15 |
providers: [IsCommunity, ConnectAdminLoginGuard, EmailService] |
|
16 |
}) |
|
17 |
export class ManagersModule {} |
modules/uoa-admin-portal/trunk/src/app/app.component.ts | ||
---|---|---|
389 | 389 |
'', false, [], [], null), |
390 | 390 |
items: [] |
391 | 391 |
}); |
392 |
if(this.properties.environment === "development") { |
|
393 |
users.items.push({ |
|
394 |
rootItem: new MenuItem('managers', 'Managers', '/managers', |
|
395 |
'/managers', false, [], [], {communityId: this.communityId}), |
|
396 |
items: [] |
|
397 |
}); |
|
398 |
} |
|
399 | 392 |
users.items.push({ |
400 | 393 |
rootItem: new MenuItem('subscribers', 'Subscribers', '/manage-subscribers', |
401 | 394 |
'/manage-subscribers', false, [], [], {communityId: this.communityId}), |
modules/uoa-admin-portal/trunk/src/app/app.routing.ts | ||
---|---|---|
49 | 49 |
resolve: { envSpecific: EnvironmentSpecificResolver } |
50 | 50 |
}, |
51 | 51 |
{ |
52 |
path: 'managers', |
|
53 |
loadChildren: './pages/managers/managers.module#ManagersModule', |
|
54 |
resolve: { envSpecific: EnvironmentSpecificResolver } |
|
55 |
}, |
|
56 |
{ |
|
57 | 52 |
path: 'manage-zenodo-communities', |
58 | 53 |
loadChildren: './pages/zenodo-communities/zenodo-communities.module#ZenodoCommunitiesModule', |
59 | 54 |
resolve: { envSpecific: EnvironmentSpecificResolver } |
Also available in: Unified diff
[Admin | Trunk]: Remove managers page