Skip to content

Commit

Permalink
refactor(Members):updated infosx how to add members
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Apr 18, 2024
1 parent 9ddb277 commit 90e3a86
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 259 deletions.
161 changes: 42 additions & 119 deletions src/app/projectmanagement/overview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -1316,135 +1316,58 @@ <h4 class="modal-title">Add member to the project {{ project_application?.projec
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<p style="margin-bottom: 15px">
Search and add a user to your project by providing at least four characters of their name:
</p>
</div>
<div class="row">
<div class="col-md-8">
<input
#searchString
id="add_member_input"
data-test-id="add_member_input"
placeholder=""
style="width: 100%"
/>
</div>
<div class="col-md-4">
<button
(click)="filterMembers(searchString.value)"
class="btn btn-primary"
id="search_member_btn"
data-test-id="search_member_btn"
type="button"
>
<i class="fa fa-search"></i> Search Member
</button>
</div>
<div class="alert alert-info" role="alert">
Please share the following invitation link with users you want to add to the project. As soon as they have
requested membership, project admins can approve their application via the member applications tab.
</div>
<br />
<div class="row">
<div class="col-md-12">
<strong>Please note</strong> that if you can not find the user, they are not registered for a de.NBI Cloud
account. In that case you can invite them by sending them the following link:
<br />
<br />
<ul style="list-style-type: none">
<li>
<pre [hidden]="showLink"><strong>{{ invitation_link }}</strong></pre>
<div class="btn-group-vertical">
<button (click)="showLink = !showLink" class="btn btn-primary" style="margin-bottom: 5px">
<span [hidden]="!showLink">Show</span>
<span [hidden]="showLink">Hide</span>
link
</button>
<button
(click)="copyToClipboard(invitation_link)"
class="btn btn-success"
[closeDelay]="3000"
ngbTooltip="Copied!"
triggers="click:blur"
>
Copy link
</button>
</div>
</li>
</ul>
<br />
After the user registered for ELIXIR/de.NBI and applied for your group, you can approve their application.
Read more about the process
<a href="{{ WIKI_MEMBER_MANAGEMENT }}" rel="noopener noreferrer" target="_blank">here</a>.
</div>
</div>

<div class="table-responsive">
<table *ngIf="filteredMembers !== null" class="table table-bordered table-striped table-sm">
<thead>
<th></th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</thead>
<tbody *ngFor="let member of filteredMembers">
<td>
<button
(click)="
resetNotificationModal();
addMember(member['member_id'], member['firstName'], member['lastName']);
filteredMembers = null;
notificationModal.show()
"
class="btn btn-outline-success"
id="add_member_btn"
data-test-id="add_member_btn"
style="padding: 5px; margin: 5px"
>
<i class="fa fa-plus"></i> Add Member
</button>
</div>
<br />
<div class="row">
<div class="col-md-12">
<ul style="list-style-type: none">
<li>
<pre><strong>{{ invitation_link }}</strong></pre>
<div class="btn-group-vertical">
<button
(click)="
resetNotificationModal();
addAdmin(member['member_id'], member['user_id'], member['firstName'], member['lastName']);
filteredMembers = null;
notificationModal.show()
"
class="btn btn-outline-primary"
style="padding: 5px; margin: 5px"
(click)="copyToClipboard(invitation_link)"
class="btn btn-success"
[closeDelay]="3000"
ngbTooltip="Copied!"
triggers="click:blur"
>
<i class="fa fa-plus"></i> Add Admin
Copy link
</button>
</td>
<td>{{ member['firstName'] }}</td>
<td>{{ member['lastName'] }}</td>
<td>{{ member['mail'] }}</td>
</tbody>
</table>
</div>
</li>
</ul>
<br />
After the user registered for de.NBI and applied for your group, you can approve their application. Read
more about the process
<a href="{{ WIKI_MEMBER_MANAGEMENT }}" rel="noopener noreferrer" target="_blank">here</a>.
</div>
</div>
</div>
<div class="modal-footer">
<!-- <button type="button" (click)="addUserModal.hide();
notificationModal.show();
addMember(addUserModalProjectID, addMemberID.value)" class="btn btn-success"><i class="far fa-dot-circle"></i>
Add User
</button> -->
<button
(click)="filteredMembers = null; addUserModal.hide()"
class="btn btn-danger"
id="close_add_user_modal_btn"
data-test-id="close_add_user_modal_btn"
type="button"
>
<i class="fa fa-times"></i> Close
</button>
</div>
</div>
<!-- /.modal-content -->
<div class="modal-footer">
<!-- <button type="button" (click)="addUserModal.hide();
notificationModal.show();
addMember(addUserModalProjectID, addMemberID.value)" class="btn btn-success"><i class="far fa-dot-circle"></i>
Add User
</button> -->
<button
(click)="addUserModal.hide()"
class="btn btn-danger"
id="close_add_user_modal_btn"
data-test-id="close_add_user_modal_btn"
type="button"
>
<i class="fa fa-times"></i> Close
</button>
</div>
</div>
<!-- /.modal-dialog -->
<!-- /.modal-content -->
</div>
<!-- /.modal -->
<!-- /.modal-dialog -->

<div
#terminateModal="bs-modal"
Expand Down
141 changes: 1 addition & 140 deletions src/app/projectmanagement/overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements
dois: Doi[];
disabledDoiInput: boolean = false;
invitation_link: string;
filteredMembers: any = null;
project_application: Application;
application_action: string = '';
application_member_name: string = '';
Expand Down Expand Up @@ -130,7 +129,6 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements
// modal variables for User list
public project_members: ProjectMember[] = [];
public isLoaded: boolean = false;
public showLink: boolean = true;
creditsChart: any;
ExtensionRequestType: typeof ExtensionRequestType = ExtensionRequestType;
Application_States: typeof Application_States = Application_States;
Expand Down Expand Up @@ -875,13 +873,7 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements

setAddUserInvitationLink(): void {
const project_reg: string = `https://signup.aai.lifescience-ri.eu/fed/registrar/?vo=${this.vo_name}&group=${this.project_application.project_application_shortname}`;
const elixir_reg: string = `https://signup.aai.lifescience-ri.eu/fed/registrar/?vo=elixir&targetnew=${encodeURIComponent(
project_reg,
)}&targetexisting=${encodeURIComponent(project_reg)}&targetextended=${encodeURIComponent(project_reg)}`;
const uri: string = `https://signup.aai.lifescience-ri.eu/fed/registrar/?vo=lifescience&targetnew=${encodeURIComponent(
elixir_reg,
)}&targetexisting=${encodeURIComponent(elixir_reg)}&targetextended=${encodeURIComponent(elixir_reg)}`;
this.invitation_link = uri;
this.invitation_link = project_reg;
}

copyToClipboard(text: string): void {
Expand All @@ -893,137 +885,6 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements
document.execCommand('copy');
}

filterMembers(searchString: string): void {
this.subscription.add(
this.userService.getFilteredMembersOfdeNBIVo(searchString).subscribe((result: any): void => {
this.filteredMembers = [];
for (const entry of result) {
let member_exist: boolean = false;

for (const projectMember of this.project_members) {
if (projectMember.memberId === entry.member_id) {
member_exist = true;
break;
}
}
if (!member_exist) {
this.filteredMembers.push(entry);
}
}
}),
);
}

public addMember(memberid: number, firstName: string, lastName: string): void {
this.subscription.add(
this.groupService
.addMember(
this.project_application.project_application_perun_id,
memberid,
this.project_application.project_application_compute_center.FacilityId,
)
.subscribe(
(result: any): void => {
if (result.status === 200) {
this.updateNotificationModal('Success', `Member ${firstName} ${lastName} added.`, true, 'success');
this.getMembersOfTheProject();
} else {
this.updateNotificationModal('Failed', 'Member could not be added!', true, 'danger');
}
},
(error: any): void => {
if (error['name'] === 'AlreadyMemberException') {
this.updateNotificationModal(
'Info',
`${firstName} ${lastName} is already a member of the project.`,
true,
'info',
);
} else {
this.updateNotificationModal('Failed', 'Member could not be added!', true, 'danger');
}
},
),
);
}

public addAdmin(memberId: number, userId: number, firstName: string, lastName: string): void {
this.subscription.add(
this.groupService
.addMember(
this.project_application.project_application_perun_id,
memberId,
this.project_application.project_application_compute_center.FacilityId,
)
.subscribe(
(): void => {
this.subscription.add(
this.groupService
.addAdmin(
this.project_application.project_application_perun_id,
userId,
this.project_application.project_application_compute_center.FacilityId,
)
.subscribe(
(result: any): void => {
if (result.status === 200) {
this.updateNotificationModal('Success', `Admin ${firstName} ${lastName} added.`, true, 'success');
this.getMembersOfTheProject();
} else {
this.updateNotificationModal('Failed', 'Admin could not be added!', true, 'danger');
}
},
(error: any): void => {
if (error['name'] === 'AlreadyAdminException') {
this.updateNotificationModal(
'Info',
`${firstName} ${lastName} is already a admin of the project.`,
true,
'info',
);
} else {
this.updateNotificationModal('Failed', 'Admin could not be added!', true, 'danger');
}
},
),
);
},
(): void => {
this.subscription.add(
this.groupService
.addAdmin(
this.project_application.project_application_perun_id,
userId,
this.project_application.project_application_compute_center.FacilityId,
)
.subscribe(
(result: any): void => {
if (result.status === 200) {
this.updateNotificationModal('Success', `Admin ${firstName} ${lastName} added.`, true, 'success');
this.getMembersOfTheProject();
} else {
this.updateNotificationModal('Failed', 'Admin could not be added!', true, 'danger');
}
},
(error: any): void => {
if (error['name'] === 'AlreadyAdminException') {
this.updateNotificationModal(
'Info',
`${firstName} ${lastName} is already a admin of the project.`,
true,
'info',
);
} else {
this.updateNotificationModal('Failed', 'Admin could not be added!', true, 'danger');
}
},
),
);
},
),
);
}

public promoteAdmin(userid: number, username: string): void {
this.groupService
.addAdmin(
Expand Down

0 comments on commit 90e3a86

Please sign in to comment.