-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create individual group view * secure group delete button * fixes * fixes * close #580 + UI fixes
- Loading branch information
Showing
11 changed files
with
335 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<div class="col-sm-6"> | ||
<a routerLink="/admin/group" class="btn btn-primary">Back to groups</a> | ||
</div> | ||
|
||
<div class="alert alert-danger" *ngIf="del_err_msg">{{ del_err_msg }}</div> | ||
|
||
<div class="card bg-light"> | ||
<div class="card bg-light card-header"> | ||
<div class="row"> | ||
<div class="col-sm-9"> | ||
<h4> | ||
Group <strong>{{ group.name }}</strong> | ||
</h4> | ||
</div> | ||
<div class="col-sm-3"> | ||
<app-my-delete-confirm | ||
[onConfirm]="deleteGroup" | ||
></app-my-delete-confirm> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="card-body"> | ||
<form role="form" class="user-form form-horizontal form-register"> | ||
<div class="form-group row"> | ||
<div class="col-sm-3"> | ||
<label for="group_id" class="col-form-label">Owner</label> | ||
<input | ||
type="text" | ||
placeholder="Owner" | ||
id="group_id" | ||
[ngModelOptions]="{ standalone: true }" | ||
[(ngModel)]="group.owner" | ||
class="form-control" | ||
/> | ||
</div> | ||
<div class="col-sm-9"> | ||
<label for="group_desc" class="col-form-label">Description</label> | ||
<input | ||
type="text" | ||
placeholder="Description" | ||
id="group_desc" | ||
[ngModelOptions]="{ standalone: true }" | ||
[(ngModel)]="group.description" | ||
class="form-control" | ||
/> | ||
</div> | ||
</div> | ||
<button | ||
type="button" | ||
class="p-button p-button-sm p-button-primary" | ||
(click)="updateGroup()" | ||
> | ||
Update | ||
</button> | ||
<div class="form-group"></div> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
<div class="card bg-light"> | ||
<div class="card-header"> | ||
<h3>Group tags</h3> | ||
</div> | ||
<div class="card-body"> | ||
<app-tag [tag]="group.tags" [user]="group.name" kind="group"></app-tag> | ||
</div> | ||
</div> | ||
|
||
<div class="card bg-light"> | ||
<div class="card-header"> | ||
<h3>Projects associated with {{ group.name }} :</h3> | ||
</div> | ||
<div class="card-body"> | ||
<div class="table"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<th>Project</th> | ||
<th>Owner</th> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let project of projects"> | ||
<td> | ||
<a routerLink="/admin/project/{{ project.id }}"> | ||
<span class="p-button p-button-sm p-button-primary"> | ||
{{ project.id }} | ||
</span> | ||
</a> | ||
</td> | ||
<td> | ||
<a routerLink="/user/{{ project.owner }}"> | ||
<span class="p-button p-button-sm p-button-primary"> | ||
{{ project.owner }} | ||
</span> | ||
</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="card bg-light"> | ||
<div class="card-header"> | ||
<h3>Users in {{ group.name }} :</h3> | ||
</div> | ||
<div class="card-body"> | ||
<div class="alert alert-info" *ngIf="msg">{{ msg }}</div> | ||
<div class="alert alert-danger" *ngIf="err_msg">{{ err_msg }}</div> | ||
<div class="table-responsive table-striped"> | ||
<p-table | ||
#dtu | ||
[value]="users" | ||
[paginator]="true" | ||
[rows]="10" | ||
[showCurrentPageReport]="true" | ||
[rowsPerPageOptions]="[10, 25, 50]" | ||
> | ||
<ng-template pTemplate="header"> | ||
<tr> | ||
<th>User</th> | ||
<th>Email</th> | ||
<th>In associated project?</th> | ||
<th>Main group?</th> | ||
</tr> | ||
</ng-template> | ||
<ng-template pTemplate="body" let-user> | ||
<tr *ngFor="let user of users"> | ||
<td> | ||
<a routerLink="/user/{{ user.uid }}"> | ||
<span class="p-button p-button-sm p-button-primary"> | ||
{{ user.uid }} | ||
</span> | ||
</a> | ||
</td> | ||
<td>{{ user.email }}</td> | ||
<td><span *ngIf="user.temp?.authorized">x</span></td> | ||
<td><span *ngIf="user.group == group.name">x</span></td> | ||
</tr> | ||
</ng-template> | ||
</p-table> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Component, OnInit, ViewChild } from "@angular/core"; | ||
import { ActivatedRoute, Router } from "@angular/router"; | ||
import { Group, GroupsService } from "../groups/groups.service"; | ||
import { Project, ProjectsService } from "../projects/projects.service"; | ||
import { User } from "../../user/user.service"; | ||
import { Table } from "primeng/table"; | ||
|
||
@Component({ | ||
selector: "app-groups", | ||
templateUrl: "./group.component.html" | ||
// styleUrls: ['./group.component.css'] | ||
}) | ||
export class GroupComponent implements OnInit { | ||
@ViewChild("dtg") tableGroups: Table; | ||
@ViewChild("dtu") tableUsers: Table; | ||
|
||
msg: string; | ||
err_msg: string; | ||
del_err_msg: string; | ||
group: Group; | ||
projects: Project[]; | ||
users: User[]; | ||
|
||
constructor( | ||
private route: ActivatedRoute, | ||
private router: Router, | ||
private groupsService: GroupsService, | ||
private projectsService: ProjectsService | ||
) { | ||
this.group = new Group(); | ||
this.projects = null; | ||
this.users = null; | ||
} | ||
|
||
ngOnDestroy(): void {} | ||
|
||
ngAfterViewInit(): void {} | ||
|
||
ngOnInit() { | ||
this.deleteGroup = this.deleteGroup.bind(this); | ||
this.route.params.subscribe((params) => { | ||
let group_name = params.id; | ||
this.groupsService.get(group_name).subscribe( | ||
(group) => (this.group = group), | ||
(err) => console.log("failed to get group") | ||
); | ||
this.projectsService.getProjectsInGroup(group_name).subscribe( | ||
(project_list) => (this.projects = project_list), | ||
(err) => console.log("failed to get projects in group") | ||
); | ||
this.groupsService.getUsers(group_name).subscribe( | ||
(user_list) => { | ||
this.users = user_list; | ||
for (var i = 0; i < user_list.length; i++) { | ||
var is_authorized = false; | ||
if (user_list[i].projects) { | ||
for (var j = 0; j < this.projects.length; j++) { | ||
if (user_list[i].projects.indexOf(this.projects[j].id) >= 0) { | ||
is_authorized = true; | ||
break; | ||
} | ||
} | ||
} | ||
this.users[i].temp = { | ||
...this.users[i].temp, | ||
authorized: is_authorized | ||
}; | ||
} | ||
}, | ||
(err) => console.log("failed to get group's users") | ||
); | ||
}); | ||
} | ||
|
||
deleteGroup() { | ||
this.groupsService.delete(this.group.name).subscribe( | ||
(resp) => | ||
this.router.navigate(["/admin/group"], { | ||
queryParams: { deleted: "ok" } | ||
}), | ||
(err) => (this.del_err_msg = err.error.message) | ||
); | ||
} | ||
|
||
updateGroup() { | ||
this.msg = ""; | ||
this.err_msg = ""; | ||
this.groupsService.update(this.group).subscribe( | ||
(resp) => (this.msg = "Group updated"), | ||
(err) => (this.err_msg = err.error.message) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.