Skip to content

Commit

Permalink
Allow group creation from project tab
Browse files Browse the repository at this point in the history
  • Loading branch information
mboudet committed Feb 5, 2024
1 parent fd82988 commit e16c78d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
29 changes: 28 additions & 1 deletion manager2/src/app/admin/projects/projects.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ <h3>Project creation</h3>
<option *ngFor="let user of all_users" [value]="user.uid">{{user.uid}}</option>
</select>
</div>
<div class="col-sm-2" *ngIf="!config.project || config.project.enable_group">
<div class="col-sm-4" *ngIf="!config.project || config.project.enable_group">
<label for="project_group">Group&nbsp;
<span style="color:red">(required)&nbsp;</span>
<span class="glyphicon glyphicon-question-sign" data-html="true" title="Unix group: <br> Project members will be added to it" tooltip> </span>
</label>
<select id="project_group" [ngModelOptions]="{standalone: true}" [(ngModel)]="new_project.group" class="form-control">
<option *ngFor="let group of groups" [value]="group.name">{{group.name}}</option>
</select>
<button type="button" class="p-button p-button-sm p-button-primary" data-toggle="modal" data-target="#group_creation">
<span class="oi oi-plus" aria-hidden="true"></span>
</button>
</div>
<div class="col-sm-2">
<label for="project_size">Size (GB)</label>
Expand Down Expand Up @@ -276,3 +279,27 @@ <h3>Expired [{{expired_projects.length}}]</h3>
</div>
</div>
</div>

<!-- Modal -->
<div class="modal" style="z-index: 1500;" id="group_creation" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="panel-title">Group creation</h3>
</div>
<div class="modal-body">
<form role="form" class="user-form form-inline justify-content-center">
<div class="form-group">
<input placeholder="Group name" type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="new_group.name" class="form-control"/>
<input placeholder="Group name" type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="new_group.owner" class="form-control"/>
<input placeholder="Description" type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="new_group.description" class="form-control"/>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="p-button p-button-sm p-button-primary" [disabled]="!new_group.name" data-dismiss="modal" (click)="addGroup()">Create</button>
<button type="button" class="p-button p-button-sm p-button-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
40 changes: 40 additions & 0 deletions manager2/src/app/admin/projects/projects.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class ProjectsComponent implements OnInit {
groups: any[]
all_users: any[]
new_project: any
new_group: any

day_time: number

Expand Down Expand Up @@ -90,6 +91,11 @@ export class ProjectsComponent implements OnInit {
description: '',
access: 'Group',
path: ''
};
this.new_group = {
name: '',
owner: '',
description: '',
}

this.project_list(true);
Expand Down Expand Up @@ -151,6 +157,9 @@ export class ProjectsComponent implements OnInit {
if (!this.new_project.cpu || this.new_project.cpu == 0) {
this.new_project.cpu = this.default_cpu;
}

this.new_group.owner = this.new_project.owner
this.new_group.name = "prj_" + tmpprojectid
}


Expand Down Expand Up @@ -331,4 +340,35 @@ export class ProjectsComponent implements OnInit {
this.pending_msg = "";
this.pending_err_msg = "";
}

addGroup(){
if (this.new_group.name === '') {
return;
}
this.add_project_error_msg = '';
this.add_project_msg = '';

this.groupService.add(this.new_group).subscribe(
resp => {
this.add_project_msg = 'Group was created';
this.groupService.list().subscribe(
resp => {
this.new_project.group = this.new_group.name
this.groupService.list().subscribe(
resp => {
this.groups = resp;
},
err => console.log('failed to get groups')
);
},
err => console.log('failed to get groups')
)
},
err => {
this.add_project_msg = '';
this.add_project_error_msg = err.error.message;
}
)
}

}
2 changes: 0 additions & 2 deletions manager2/src/app/user/user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,6 @@ <h4>Send message to user</h4>
<h3 class="panel-title">Group creation</h3>
</div>
<div class="modal-body">
<div class="alert alert-success" *ngIf="grp_success_msg">{{grp_success_msg}}</div>
<div class="alert alert-danger" *ngIf="grp_err_msg">{{grp_err_msg}}</div>
<form role="form" class="user-form form-inline justify-content-center">
<div class="form-group">
<input placeholder="Group name" type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="new_group.name" class="form-control"/>
Expand Down

0 comments on commit e16c78d

Please sign in to comment.