Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sören Giller authored and Sören Giller committed Aug 28, 2018
2 parents 656fb93 + aa48c12 commit 8b2cab2
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 42 deletions.
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@
}
}
}

30 changes: 30 additions & 0 deletions src/app/api-connector/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,36 @@ export class GroupService {

}


getGroupApplications(group:number): Observable<any>{
return this.http.get(this.settings.getApiBaseURL() + 'group/' + group + '/applications/', {
withCredentials: true,
}).pipe(catchError((error: any) => throwError(error.error)));


}

approveGroupApplication(groupid:number,application:number) : Observable<any> {


return this.http.get(this.settings.getApiBaseURL() + 'group/'+ groupid +'/applications/' + application + '/approve/', {
withCredentials: true,
headers: header
}).pipe(catchError((error: any) => throwError(error.error)));

}

rejectGroupApplication(groupid:number,application:number) : Observable<any> {


return this.http.get(this.settings.getApiBaseURL() + 'group/'+ groupid +'/applications/' + application + '/reject/', {
withCredentials: true,
headers: header
}).pipe(catchError((error: any) => throwError(error.error)));

}


getMemberGroupsStatus(): Observable<any> {

return this.http.get(this.settings.getApiBaseURL() + 'group/getMemberGroupsStatus/', {
Expand Down
4 changes: 3 additions & 1 deletion src/app/applications/applications.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class ApplicationsComponent {
private userservice: UserService,
private groupservice: GroupService,
private voService: VoService) {
this.groupservice.getGroupApplications(10599).subscribe();
this.groupservice.rejectGroupApplication(10599,22367).subscribe()

this.getUserApplications();
this.getAllApplications();
Expand Down Expand Up @@ -164,7 +166,7 @@ export class ApplicationsComponent {
this.user_applications.push(a)
}
this.isLoaded_userApplication = true;

});
}

Expand Down
10 changes: 5 additions & 5 deletions src/app/layouts/full-layout.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<button class="navbar-toggler d-lg-none" type="button" appMobileSidebarToggler>&#9776;</button>
<a class="navbar-brand d-none d-md-block" href="#"></a>
<ul class="nav navbar-nav ml-md-auto">
<li><strong class="text-info">{{login_name}}</strong></li>
<li><strong class="text-muted" style="padding-right: 2pc">{{login_name}}</strong></li>
</ul>
</header>
<div class="app-body">
Expand Down Expand Up @@ -68,22 +68,22 @@
<li class="nav-item" *ngIf="vm_project_member || get_is_vo_admin()">
<a style="padding-left: 25px" class="nav-link" routerLinkActive="active"
[routerLink]="['/virtualmachines/vmOverview']"><i
class="icon-list"></i> Instance</a>
class="icon-list"></i> Instances</a>
</li>
<li class="nav-item" *ngIf="get_is_vo_admin()">
<a style="padding-left: 25px" class="nav-link" routerLinkActive="active"
[routerLink]="['/virtualmachines/clientOverview']"><i
class="icon-list"></i> Client</a>
class="icon-list"></i> Clients</a>
</li>
<li class="nav-item" *ngIf="vm_project_member || get_is_vo_admin()">
<a style="padding-left: 25px" class="nav-link" routerLinkActive="active"
[routerLink]="['/virtualmachines/volumeOverview']"><i
class="icon-list"></i> Volume</a>
class="icon-list"></i> Volumes</a>
</li>
<li class="nav-item" *ngIf="vm_project_member || get_is_vo_admin()">
<a style="padding-left: 25px" class="nav-link" routerLinkActive="active"
[routerLink]="['/virtualmachines/snapshotOverview']"><i
class="icon-list"></i>Snapshot</a>
class="icon-list"></i>Snapshots</a>
</li>

</ul>
Expand Down
88 changes: 79 additions & 9 deletions src/app/projectmanagement/overview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ <h1>Projects Overview</h1>
[ngStyle]="{'color':lifeTimeReached(project.LifetimeDays,project.DaysRunning)}">
<td>{{ project.Id }}</td>
<td>{{ project.Name }}</td>
<td><button class="btn btn-secondary" (click)="selectedProject=project;infoModal.show();">Show Description</button></td>
<td>
<button class="btn btn-secondary"
(click)="selectedProject=project;infoModal.show();">Show Description
</button>
</td>

<td>
<p *ngIf="project.ComputeCenter[0] == 'None'">None</p>
Expand Down Expand Up @@ -68,6 +72,13 @@ <h1>Projects Overview</h1>
type="button" style="margin-bottom: 5px"
class="btn btn-secondary"><i class="fa fa-plus"></i>&nbsp; Add Member
</button>
<button
*ngIf="(project.UserIsPi == true) || (project.UserIsAdmin == true)"
type="button" style="margin-bottom: 5px"
(click)="selectedProject = project;applicationModal.show();"
class="btn btn-secondary"><i class="fa fa-list-alt"></i>&nbsp; Applications
({{project.ProjectMemberApplications.length}})
</button>
</div>
</td>
</tr>
Expand Down Expand Up @@ -211,7 +222,7 @@ <h4 class="modal-title">Add member to the project {{ addUserModalProjectID }}
name:</p>

<input placeholder="first name" #firstName> <input placeholder="last name" #lastName>
<button type="button" class="btn btn-primary"
<button style="margin-left: 10px" type="button" class="btn btn-primary"
(click)="filterMembers(firstName.value,lastName.value,addUserModalProjectID )"><i
class="fa fa-search"></i> Search
</button>
Expand All @@ -220,15 +231,12 @@ <h4 class="modal-title">Add member to the project {{ addUserModalProjectID }}
<br>
<strong>Please note</strong> that if you can not find the user, he is not a member of the de.NBI
vo. In that case you can invite him by sending him
one of the following links:
the following link:
<br>
<br>
<ul>
<li>If the user does have an elixir account:
<pre>{{voRegistrationLink}}</pre>
</li>
<li>If the user does not have an elixir account:
<pre>https://perun.elixir-czech.cz/registrar/?vo=elixir&targetnew={{voRegistrationLink}}</pre>
<li>Invite Member
<pre>{{invitation_group_pre}}{{ addUserModalProjectName }}</pre>
</li>
</ul>
</div>
Expand Down Expand Up @@ -405,8 +413,70 @@ <h4 class="modal-title">Description</h4>
{{ selectedProject?.Description }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" (click)="selectedProject=undefined;infoModal.hide();">Close</button>
<button type="button" class="btn btn-secondary" (click)="selectedProject=undefined;infoModal.hide();">
Close
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>


<div bsModal #applicationModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-info modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Applications for {{selectedProject?.Name}}</h4>
<button type="button" class="close" (click)="infoModal.hide()" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div *ngIf="!loaded" style="text-align: center"><i class="fa fa-spinner fa-spin" style="font-size:100px; margin: auto;margin-left: auto;margin-right: auto"></i>
</div>

<div *ngIf="loaded" class="table-responsive">
<table class="table table-bordered table-striped table-sm">
<thead>

<th>Name</th>
<th>Date Submitted</th>
<th>Actions</th>
</thead>
<tbody *ngFor=" let application of selectedProject?.ProjectMemberApplications">

<td>{{application.Name}}</td>
<td>{{application.DateCreated}}</td>
<td>
<button
(click)="approveMemberApplication(selectedProject?.Id,application.Id,application.Name); "
class="btn btn-success"><i class="fa fa-check"></i> Approve
</button>
<button style="margin-left: 10px"
(click)="appication_action='rejected';application_member_name=application.Name;rejectMemberApplication(selectedProject?.Id,application.Id,application.Name); "
class="btn btn-danger"><i class="fa fa-times"></i> Reject
</button>
</td>
</tbody>
</table>
</div>


<div class="modal-footer">
<p *ngIf="application_action_success && application_action_done" class="alert alert-success mr-auto">
<strong>Success:</strong> Succesfully {{application_action}} the application of
{{application_member_name}}.
</p>
<p *ngIf="!application_action_success && application_action_done" class="alert alert-danger mr-auto">
<strong>Failed:</strong> The application of {{application_member_name}} could not be
{{application_action}} .
</p>
<button type="button" class="btn btn-secondary"
(click)="selectedProject=undefined;applicationModal.hide();">
Close
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>

96 changes: 89 additions & 7 deletions src/app/projectmanagement/overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {UserService} from "../api-connector/user.service";
import * as moment from 'moment';
import {VoService} from "../api-connector/vo.service";
import {catchError} from 'rxjs/operators';
import {ProjectMemberApplication} from "./project_member_application";


@Component({
Expand All @@ -22,12 +23,18 @@ export class OverviewComponent {
debug_module = false;

@Input() voRegistrationLink: string = environment.voRegistrationLink;
@Input() invitation_group_pre: string = environment.invitation_group_pre
is_admin = false;
userprojects: {};
member_id: number;
admingroups: {};
filteredMembers = null;
application_action = '';
application_member_name = '';
application_action_done = false;
application_action_success: boolean;
projects: Project[] = new Array();
loaded = true;


// modal variables for User list
Expand Down Expand Up @@ -144,6 +151,16 @@ export class OverviewComponent {
if (expirationDate) {
newProject.DateEnd = moment(expirationDate).date() + "." + (moment(expirationDate).month() + 1) + "." + moment(expirationDate).year();
}
let newProjectApplications = [];
for (let application of group['applications']) {
let dateApplicationCreated = moment(application['createdAt'], "YYYY-MM-DD HH:mm:ss.SSS")
let membername = application['user']['firstName'] + ' ' + application['user']['lastName']
let newMemberApplication = new ProjectMemberApplication(
application['id'], membername, dateApplicationCreated.date() + "." + (dateApplicationCreated.month() + 1) + "." + dateApplicationCreated.year(),
)
newProjectApplications.push(newMemberApplication)
}
newProject.ProjectMemberApplications = newProjectApplications;
this.projects.push(newProject);
}
this.isLoaded = true;
Expand Down Expand Up @@ -209,6 +226,71 @@ export class OverviewComponent {
});
}

approveMemberApplication(project: number, application: number, membername: string) {
this.loaded = false;
this.application_action_done = false;
this.groupservice.approveGroupApplication(project, application).subscribe(result => {
let application = result;
this.groupservice.getGroupApplications(project).subscribe(result => {
let newProjectApplications = [];
for (let application of result) {
let dateApplicationCreated = moment(application['createdAt'], "YYYY-MM-DD HH:mm:ss.SSS")
let membername = application['user']['firstName'] + ' ' + application['user']['lastName']
let newMemberApplication = new ProjectMemberApplication(
application['id'], membername, dateApplicationCreated.date() + "." + (dateApplicationCreated.month() + 1) + "." + dateApplicationCreated.year(),
)
newProjectApplications.push(newMemberApplication)
}
this.selectedProject.ProjectMemberApplications = newProjectApplications;
if (application['state'] == 'APPROVED') {
this.application_action_success = true;
}
else {
this.application_action_success = false;
}
this.application_action = 'approved';
this.application_member_name = membername;
this.loaded = true;
this.application_action_done = true

})
});
}

rejectMemberApplication(project: number, application: number, membername: string) {
this.loaded = false;
this.application_action_done = false;

this.groupservice.rejectGroupApplication(project, application).subscribe(result => {
let application = result;

this.groupservice.getGroupApplications(project).subscribe(result => {
let newProjectApplications = [];
for (let application of result) {
let dateApplicationCreated = moment(application['createdAt'], "YYYY-MM-DD HH:mm:ss.SSS");
let membername = application['user']['firstName'] + ' ' + application['user']['lastName'];
let newMemberApplication = new ProjectMemberApplication(
application['id'], membername, dateApplicationCreated.date() + "." + (dateApplicationCreated.month() + 1) + "." + dateApplicationCreated.year(),
)
newProjectApplications.push(newMemberApplication)
}
this.selectedProject.ProjectMemberApplications = newProjectApplications;
if (application['state'] == 'REJECTED') {
this.application_action_success = true;
}
else {
this.application_action_success = false;
}
this.application_action = 'rejected';
this.application_member_name = membername;
this.loaded = true;
this.application_action_done=true;


})
});
}

isPi(member: ProjectMember): string {

if (member.IsPi) {
Expand Down Expand Up @@ -341,13 +423,13 @@ export class OverviewComponent {
this.updateNotificaitonModal("Failed", "Admin could not be added!", true, "danger");
}
}, error => {
if (error['name'] == 'AlreadyAdminException') {
this.updateNotificaitonModal("Info", firstName + " " + lastName + " is already a admin of the project.", true, "info");
}
else {
this.updateNotificaitonModal("Failed", "Admin could not be added!", true, "danger");
}
})
if (error['name'] == 'AlreadyAdminException') {
this.updateNotificaitonModal("Info", firstName + " " + lastName + " is already a admin of the project.", true, "info");
}
else {
this.updateNotificaitonModal("Failed", "Admin could not be added!", true, "danger");
}
})
})
}

Expand Down
11 changes: 11 additions & 0 deletions src/app/projectmanagement/project.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {ProjectMemberApplication} from "./project_member_application";

export class Project {
get UserIsAdmin(): boolean {
return this._UserIsAdmin;
Expand All @@ -20,6 +22,7 @@ export class Project {
private _ComputeCenter:[string,number];
private _ComputeCenterDetails:[string,string][];
private _PerunId:number;
private _ProjectMemberApplications:ProjectMemberApplication[];


constructor(Id: number, Name: string, Description: string, DateCreated: string, DaysRunning: number, UserIsAdmin: boolean, UserIsPi: boolean,ComputeCenter: [string,number]) {
Expand All @@ -36,6 +39,14 @@ export class Project {

//todo exdend with additional information

get ProjectMemberApplications():ProjectMemberApplication[]{
return this._ProjectMemberApplications;
}

set ProjectMemberApplications(value:ProjectMemberApplication[]){
this._ProjectMemberApplications=value;
}

get LifetimeDays():number{
return this._LifetimeDays
}
Expand Down
Loading

0 comments on commit 8b2cab2

Please sign in to comment.