mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-19 04:57:51 +00:00
Rename user management server ref to controller
This commit is contained in:
parent
a79d6c916f
commit
c59dd035eb
@ -103,7 +103,7 @@ const routes: Routes = [
|
|||||||
user: UserDetailResolver,
|
user: UserDetailResolver,
|
||||||
groups: UserGroupsResolver,
|
groups: UserGroupsResolver,
|
||||||
permissions: UserPermissionsResolver,
|
permissions: UserPermissionsResolver,
|
||||||
server: ServerResolve},
|
controller: ControllerResolve},
|
||||||
},
|
},
|
||||||
{ path: 'installed-software', component: InstalledSoftwareComponent },
|
{ path: 'installed-software', component: InstalledSoftwareComponent },
|
||||||
{ path: 'controller/:controller_id/systemstatus', component: SystemStatusComponent, canActivate: [LoginGuard] },
|
{ path: 'controller/:controller_id/systemstatus', component: SystemStatusComponent, canActivate: [LoginGuard] },
|
||||||
@ -238,7 +238,8 @@ const routes: Routes = [
|
|||||||
path: 'roles',
|
path: 'roles',
|
||||||
component: RoleManagementComponent
|
component: RoleManagementComponent
|
||||||
},
|
},
|
||||||
{path: 'permissions',
|
{
|
||||||
|
path: 'permissions',
|
||||||
component: PermissionsManagementComponent
|
component: PermissionsManagementComponent
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -248,7 +249,7 @@ const routes: Routes = [
|
|||||||
component: GroupDetailsComponent,
|
component: GroupDetailsComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
members: GroupMembersResolver,
|
members: GroupMembersResolver,
|
||||||
server: ServerResolve,
|
controller: ControllerResolve,
|
||||||
group: GroupResolver,
|
group: GroupResolver,
|
||||||
roles: GroupRoleResolver
|
roles: GroupRoleResolver
|
||||||
}
|
}
|
||||||
@ -258,7 +259,7 @@ const routes: Routes = [
|
|||||||
component: RoleDetailComponent,
|
component: RoleDetailComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
role: RoleDetailResolver,
|
role: RoleDetailResolver,
|
||||||
server: ServerResolve
|
controller: ControllerResolve
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -266,7 +267,7 @@ const routes: Routes = [
|
|||||||
component: RolePermissionsComponent,
|
component: RolePermissionsComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
role: RoleDetailResolver,
|
role: RoleDetailResolver,
|
||||||
server: ServerResolve,
|
controller: ControllerResolve,
|
||||||
permissions: PermissionResolver
|
permissions: PermissionResolver
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -276,7 +277,7 @@ const routes: Routes = [
|
|||||||
resolve: {
|
resolve: {
|
||||||
user: UserDetailResolver,
|
user: UserDetailResolver,
|
||||||
userPermissions: UserPermissionsResolver,
|
userPermissions: UserPermissionsResolver,
|
||||||
server: ServerResolve,
|
controller: ControllerResolve,
|
||||||
permissions: PermissionResolver
|
permissions: PermissionResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import {Component, Inject, OnInit} from '@angular/core';
|
|||||||
import {BehaviorSubject, forkJoin, timer} from "rxjs";
|
import {BehaviorSubject, forkJoin, timer} from "rxjs";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Group} from "@models/groups/group";
|
import {Group} from "@models/groups/group";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {GroupService} from "@services/group.service";
|
import {GroupService} from "@services/group.service";
|
||||||
@ -35,7 +35,7 @@ export class AddRoleToGroupComponent implements OnInit {
|
|||||||
loading = false;
|
loading = false;
|
||||||
|
|
||||||
constructor(private dialog: MatDialogRef<AddRoleToGroupComponent>,
|
constructor(private dialog: MatDialogRef<AddRoleToGroupComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: { server: Server; group: Group },
|
@Inject(MAT_DIALOG_DATA) public data: { controller: Controller; group: Group },
|
||||||
private groupService: GroupService,
|
private groupService: GroupService,
|
||||||
private roleService: RoleService,
|
private roleService: RoleService,
|
||||||
private toastService: ToasterService) {
|
private toastService: ToasterService) {
|
||||||
@ -58,8 +58,8 @@ export class AddRoleToGroupComponent implements OnInit {
|
|||||||
|
|
||||||
getRoles() {
|
getRoles() {
|
||||||
forkJoin([
|
forkJoin([
|
||||||
this.roleService.get(this.data.server),
|
this.roleService.get(this.data.controller),
|
||||||
this.groupService.getGroupRole(this.data.server, this.data.group.user_group_id)
|
this.groupService.getGroupRole(this.data.controller, this.data.group.user_group_id)
|
||||||
]).subscribe((results) => {
|
]).subscribe((results) => {
|
||||||
const [globalRoles, groupRoles] = results;
|
const [globalRoles, groupRoles] = results;
|
||||||
const roles = globalRoles.filter((role: Role) => {
|
const roles = globalRoles.filter((role: Role) => {
|
||||||
@ -76,7 +76,7 @@ export class AddRoleToGroupComponent implements OnInit {
|
|||||||
addRole(role: Role) {
|
addRole(role: Role) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.groupService
|
this.groupService
|
||||||
.addRoleToGroup(this.data.server, this.data.group, role)
|
.addRoleToGroup(this.data.controller, this.data.group, role)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`role ${role.name} was added`);
|
this.toastService.success(`role ${role.name} was added`);
|
||||||
this.getRoles();
|
this.getRoles();
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import {Component, Inject, OnInit} from '@angular/core';
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {BehaviorSubject, forkJoin, observable, Observable, timer} from "rxjs";
|
import {BehaviorSubject, forkJoin, observable, Observable, timer} from "rxjs";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {GroupService} from "@services/group.service";
|
import {GroupService} from "@services/group.service";
|
||||||
@ -34,7 +34,7 @@ export class AddUserToGroupDialogComponent implements OnInit {
|
|||||||
loading = false;
|
loading = false;
|
||||||
|
|
||||||
constructor(private dialog: MatDialogRef<AddUserToGroupDialogComponent>,
|
constructor(private dialog: MatDialogRef<AddUserToGroupDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: { server: Server; group: Group },
|
@Inject(MAT_DIALOG_DATA) public data: { controller: Controller; group: Group },
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private groupService: GroupService,
|
private groupService: GroupService,
|
||||||
private toastService: ToasterService) {
|
private toastService: ToasterService) {
|
||||||
@ -57,8 +57,8 @@ export class AddUserToGroupDialogComponent implements OnInit {
|
|||||||
|
|
||||||
getUsers() {
|
getUsers() {
|
||||||
forkJoin([
|
forkJoin([
|
||||||
this.userService.list(this.data.server),
|
this.userService.list(this.data.controller),
|
||||||
this.groupService.getGroupMember(this.data.server, this.data.group.user_group_id)
|
this.groupService.getGroupMember(this.data.controller, this.data.group.user_group_id)
|
||||||
]).subscribe((results) => {
|
]).subscribe((results) => {
|
||||||
const [userList, members] = results;
|
const [userList, members] = results;
|
||||||
const users = userList.filter((user: User) => {
|
const users = userList.filter((user: User) => {
|
||||||
@ -75,7 +75,7 @@ export class AddUserToGroupDialogComponent implements OnInit {
|
|||||||
addUser(user: User) {
|
addUser(user: User) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.groupService
|
this.groupService
|
||||||
.addMemberToGroup(this.data.server, this.data.group, user)
|
.addMemberToGroup(this.data.controller, this.data.group, user)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`user ${user.username} was added`);
|
this.toastService.success(`user ${user.username} was added`);
|
||||||
this.getUsers();
|
this.getUsers();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
mat-icon-button
|
mat-icon-button
|
||||||
matTooltip="Back to group management"
|
matTooltip="Back to group management"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
[routerLink]="['/server', server.id, 'management', 'groups']">
|
[routerLink]="['/controller', controller.id, 'management', 'groups']">
|
||||||
<mat-icon aria-label="Back to group management">keyboard_arrow_left</mat-icon>
|
<mat-icon aria-label="Back to group management">keyboard_arrow_left</mat-icon>
|
||||||
</a>
|
</a>
|
||||||
<h1 class="col">Groups {{group.name}} details</h1>
|
<h1 class="col">Groups {{group.name}} details</h1>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div *ngFor="let user of members | membersFilter: searchMembers | paginator: pageEvent">
|
<div *ngFor="let user of members | membersFilter: searchMembers | paginator: pageEvent">
|
||||||
<a href="/server/{{server.id}}/management/users/{{user.user_id}}">
|
<a href="/controller/{{controller.id}}/management/users/{{user.user_id}}">
|
||||||
<div>{{user.username}}</div>
|
<div>{{user.username}}</div>
|
||||||
</a>
|
</a>
|
||||||
<mat-icon class="clickable" (click)="openRemoveUserDialog(user)">delete</mat-icon>
|
<mat-icon class="clickable" (click)="openRemoveUserDialog(user)">delete</mat-icon>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import {ActivatedRoute} from "@angular/router";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Group} from "@models/groups/group";
|
import {Group} from "@models/groups/group";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {FormControl, FormGroup} from "@angular/forms";
|
import {FormControl, FormGroup} from "@angular/forms";
|
||||||
@ -31,7 +31,7 @@ import {AddRoleToGroupComponent} from "@components/group-details/add-role-to-gro
|
|||||||
styleUrls: ['./group-details.component.scss']
|
styleUrls: ['./group-details.component.scss']
|
||||||
})
|
})
|
||||||
export class GroupDetailsComponent implements OnInit {
|
export class GroupDetailsComponent implements OnInit {
|
||||||
server: Server;
|
controller: Controller;
|
||||||
group: Group;
|
group: Group;
|
||||||
members: User[];
|
members: User[];
|
||||||
editGroupForm: FormGroup;
|
editGroupForm: FormGroup;
|
||||||
@ -48,9 +48,9 @@ export class GroupDetailsComponent implements OnInit {
|
|||||||
groupname: new FormControl(''),
|
groupname: new FormControl(''),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.route.data.subscribe((d: { server: Server; group: Group, members: User[], roles: Role[] }) => {
|
this.route.data.subscribe((d: { controller: Controller; group: Group, members: User[], roles: Role[] }) => {
|
||||||
|
|
||||||
this.server = d.server;
|
this.controller = d.controller;
|
||||||
this.group = d.group;
|
this.group = d.group;
|
||||||
this.roles = d.roles;
|
this.roles = d.roles;
|
||||||
this.members = d.members.sort((a: User, b: User) => a.username.toLowerCase().localeCompare(b.username.toLowerCase()));
|
this.members = d.members.sort((a: User, b: User) => a.username.toLowerCase().localeCompare(b.username.toLowerCase()));
|
||||||
@ -63,7 +63,7 @@ export class GroupDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onUpdate() {
|
onUpdate() {
|
||||||
this.groupService.update(this.server, this.group)
|
this.groupService.update(this.controller, this.group)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`group updated`);
|
this.toastService.success(`group updated`);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
@ -77,7 +77,7 @@ export class GroupDetailsComponent implements OnInit {
|
|||||||
.open<AddRoleToGroupComponent>(AddRoleToGroupComponent,
|
.open<AddRoleToGroupComponent>(AddRoleToGroupComponent,
|
||||||
{
|
{
|
||||||
width: '700px', height: '500px',
|
width: '700px', height: '500px',
|
||||||
data: {server: this.server, group: this.group}
|
data: {controller: this.controller, group: this.group}
|
||||||
})
|
})
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
@ -89,7 +89,7 @@ export class GroupDetailsComponent implements OnInit {
|
|||||||
.open<AddUserToGroupDialogComponent>(AddUserToGroupDialogComponent,
|
.open<AddUserToGroupDialogComponent>(AddUserToGroupDialogComponent,
|
||||||
{
|
{
|
||||||
width: '700px', height: '500px',
|
width: '700px', height: '500px',
|
||||||
data: {server: this.server, group: this.group}
|
data: {controller: this.controller, group: this.group}
|
||||||
})
|
})
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
@ -103,7 +103,7 @@ export class GroupDetailsComponent implements OnInit {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((confirm: boolean) => {
|
.subscribe((confirm: boolean) => {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
this.groupService.removeUser(this.server, this.group, user)
|
this.groupService.removeUser(this.controller, this.group, user)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`User ${user.username} was removed`);
|
this.toastService.success(`User ${user.username} was removed`);
|
||||||
this.reloadMembers();
|
this.reloadMembers();
|
||||||
@ -123,7 +123,7 @@ export class GroupDetailsComponent implements OnInit {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((confirm: string) => {
|
.subscribe((confirm: string) => {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
this.groupService.removeRole(this.server, this.group, role)
|
this.groupService.removeRole(this.controller, this.group, role)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`Role ${role.name} was removed`);
|
this.toastService.success(`Role ${role.name} was removed`);
|
||||||
this.reloadRoles();
|
this.reloadRoles();
|
||||||
@ -137,14 +137,14 @@ export class GroupDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reloadMembers() {
|
reloadMembers() {
|
||||||
this.groupService.getGroupMember(this.server, this.group.user_group_id)
|
this.groupService.getGroupMember(this.controller, this.group.user_group_id)
|
||||||
.subscribe((members: User[]) => {
|
.subscribe((members: User[]) => {
|
||||||
this.members = members;
|
this.members = members;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadRoles() {
|
reloadRoles() {
|
||||||
this.groupService.getGroupRole(this.server, this.group.user_group_id)
|
this.groupService.getGroupRole(this.controller, this.group.user_group_id)
|
||||||
.subscribe((roles: Role[]) => {
|
.subscribe((roles: Role[]) => {
|
||||||
this.roles = roles;
|
this.roles = roles;
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@ import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
|
|||||||
import {groupNameAsyncValidator} from "@components/group-management/add-group-dialog/groupNameAsyncValidator";
|
import {groupNameAsyncValidator} from "@components/group-management/add-group-dialog/groupNameAsyncValidator";
|
||||||
import {GroupNameValidator} from "@components/group-management/add-group-dialog/GroupNameValidator";
|
import {GroupNameValidator} from "@components/group-management/add-group-dialog/GroupNameValidator";
|
||||||
import {GroupService} from "../../../services/group.service";
|
import {GroupService} from "../../../services/group.service";
|
||||||
import {Server} from "../../../models/server";
|
import {Controller} from "../../../models/controller";
|
||||||
import {BehaviorSubject, forkJoin, timer} from "rxjs";
|
import {BehaviorSubject, forkJoin, timer} from "rxjs";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
@ -35,7 +35,7 @@ import {map, startWith} from "rxjs/operators";
|
|||||||
export class AddGroupDialogComponent implements OnInit {
|
export class AddGroupDialogComponent implements OnInit {
|
||||||
|
|
||||||
groupNameForm: FormGroup;
|
groupNameForm: FormGroup;
|
||||||
server: Server;
|
controller: Controller;
|
||||||
|
|
||||||
users: User[];
|
users: User[];
|
||||||
usersToAdd: Set<User> = new Set([]);
|
usersToAdd: Set<User> = new Set([]);
|
||||||
@ -46,7 +46,7 @@ export class AddGroupDialogComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
constructor(private dialogRef: MatDialogRef<AddGroupDialogComponent>,
|
constructor(private dialogRef: MatDialogRef<AddGroupDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: { server: Server },
|
@Inject(MAT_DIALOG_DATA) public data: { controller: Controller },
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private groupNameValidator: GroupNameValidator,
|
private groupNameValidator: GroupNameValidator,
|
||||||
private groupService: GroupService,
|
private groupService: GroupService,
|
||||||
@ -55,15 +55,15 @@ export class AddGroupDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.server = this.data.server;
|
this.controller = this.data.controller;
|
||||||
this.groupNameForm = this.formBuilder.group({
|
this.groupNameForm = this.formBuilder.group({
|
||||||
groupName: new FormControl(
|
groupName: new FormControl(
|
||||||
null,
|
null,
|
||||||
[Validators.required, this.groupNameValidator.get],
|
[Validators.required, this.groupNameValidator.get],
|
||||||
[groupNameAsyncValidator(this.data.server, this.groupService)]
|
[groupNameAsyncValidator(this.data.controller, this.groupService)]
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
this.userService.list(this.server)
|
this.userService.list(this.controller)
|
||||||
.subscribe((users: User[]) => {
|
.subscribe((users: User[]) => {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
this.filteredUsers = this.autocompleteControl.valueChanges.pipe(
|
this.filteredUsers = this.autocompleteControl.valueChanges.pipe(
|
||||||
@ -91,10 +91,10 @@ export class AddGroupDialogComponent implements OnInit {
|
|||||||
const toAdd = Array.from(this.usersToAdd.values());
|
const toAdd = Array.from(this.usersToAdd.values());
|
||||||
|
|
||||||
|
|
||||||
this.groupService.addGroup(this.server, groupName)
|
this.groupService.addGroup(this.controller, groupName)
|
||||||
.subscribe((group) => {
|
.subscribe((group) => {
|
||||||
toAdd.forEach((user: User) => {
|
toAdd.forEach((user: User) => {
|
||||||
this.groupService.addMemberToGroup(this.server, group, user)
|
this.groupService.addMemberToGroup(this.controller, group, user)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toasterService.success(`user ${user.username} was added`);
|
this.toasterService.success(`user ${user.username} was added`);
|
||||||
},
|
},
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { timer } from 'rxjs';
|
import { timer } from 'rxjs';
|
||||||
import {map, switchMap, tap} from 'rxjs/operators';
|
import { map, switchMap, tap } from 'rxjs/operators';
|
||||||
import {Server} from "../../../models/server";
|
import { Controller } from "../../../models/controller";
|
||||||
import {GroupService} from "../../../services/group.service";
|
import { GroupService } from "../../../services/group.service";
|
||||||
|
|
||||||
export const groupNameAsyncValidator = (server: Server, groupService: GroupService) => {
|
export const groupNameAsyncValidator = (controller: Controller, groupService: GroupService) => {
|
||||||
return (control: FormControl) => {
|
return (control: FormControl) => {
|
||||||
return timer(500).pipe(
|
return timer(500).pipe(
|
||||||
switchMap(() => groupService.getGroups(server)),
|
switchMap(() => groupService.getGroups(controller)),
|
||||||
map((response) => {
|
map((response) => {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
return (response.find((n) => n.name === control.value) ? { projectExist: true } : null);
|
return (response.find((n) => n.name === control.value) ? { projectExist: true } : null);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name</th>
|
||||||
<td mat-cell *matCellDef="let element"><a class="table-link" routerLink="/server/{{server.id}}/management/groups/{{element.user_group_id}}">{{element.name}}</a> </td>
|
<td mat-cell *matCellDef="let element"><a class="table-link" routerLink="/controller/{{controller.id}}/management/groups/{{element.user_group_id}}">{{element.name}}</a> </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="created_at">
|
<ng-container matColumnDef="created_at">
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
import {Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {ServerService} from "../../services/server.service";
|
import {ControllerService} from "../../services/controller.service";
|
||||||
import {ToasterService} from "../../services/toaster.service";
|
import {ToasterService} from "../../services/toaster.service";
|
||||||
import {GroupService} from "../../services/group.service";
|
import {GroupService} from "../../services/group.service";
|
||||||
import {Server} from "../../models/server";
|
import {Controller} from "../../models/controller";
|
||||||
import {Group} from "../../models/groups/group";
|
import {Group} from "../../models/groups/group";
|
||||||
import {MatSort, Sort} from "@angular/material/sort";
|
import {MatSort, Sort} from "@angular/material/sort";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
@ -33,7 +33,7 @@ import {MatTableDataSource} from "@angular/material/table";
|
|||||||
styleUrls: ['./group-management.component.scss']
|
styleUrls: ['./group-management.component.scss']
|
||||||
})
|
})
|
||||||
export class GroupManagementComponent implements OnInit {
|
export class GroupManagementComponent implements OnInit {
|
||||||
server: Server;
|
controller: Controller;
|
||||||
|
|
||||||
@ViewChildren('groupsPaginator') groupsPaginator: QueryList<MatPaginator>;
|
@ViewChildren('groupsPaginator') groupsPaginator: QueryList<MatPaginator>;
|
||||||
@ViewChildren('groupsSort') groupsSort: QueryList<MatSort>;
|
@ViewChildren('groupsSort') groupsSort: QueryList<MatSort>;
|
||||||
@ -47,7 +47,7 @@ export class GroupManagementComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private serverService: ServerService,
|
private controllerService: ControllerService,
|
||||||
private toasterService: ToasterService,
|
private toasterService: ToasterService,
|
||||||
public groupService: GroupService,
|
public groupService: GroupService,
|
||||||
public dialog: MatDialog
|
public dialog: MatDialog
|
||||||
@ -56,9 +56,9 @@ export class GroupManagementComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const serverId = this.route.parent.snapshot.paramMap.get('server_id');
|
const controllerId = this.route.parent.snapshot.paramMap.get('controller_id');
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.server = server;
|
this.controller = controller;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ export class GroupManagementComponent implements OnInit {
|
|||||||
|
|
||||||
addGroup() {
|
addGroup() {
|
||||||
this.dialog
|
this.dialog
|
||||||
.open(AddGroupDialogComponent, {width: '600px', height: '500px', data: {server: this.server}})
|
.open(AddGroupDialogComponent, {width: '600px', height: '500px', data: {controller: this.controller}})
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((added: boolean) => {
|
.subscribe((added: boolean) => {
|
||||||
if (added) {
|
if (added) {
|
||||||
@ -105,7 +105,7 @@ export class GroupManagementComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.groupService.getGroups(this.server).subscribe((groups: Group[]) => {
|
this.groupService.getGroups(this.controller).subscribe((groups: Group[]) => {
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
this.dataSource.data = groups;
|
this.dataSource.data = groups;
|
||||||
@ -119,7 +119,7 @@ export class GroupManagementComponent implements OnInit {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((isDeletedConfirm) => {
|
.subscribe((isDeletedConfirm) => {
|
||||||
if (isDeletedConfirm) {
|
if (isDeletedConfirm) {
|
||||||
const observables = groupsToDelete.map((group: Group) => this.groupService.delete(this.server, group.user_group_id));
|
const observables = groupsToDelete.map((group: Group) => this.groupService.delete(this.controller, group.user_group_id));
|
||||||
forkJoin(observables)
|
forkJoin(observables)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-management',
|
selector: 'app-management',
|
||||||
@ -22,19 +22,19 @@ import {ServerService} from "@services/server.service";
|
|||||||
})
|
})
|
||||||
export class ManagementComponent implements OnInit {
|
export class ManagementComponent implements OnInit {
|
||||||
|
|
||||||
server: Server;
|
controller: Controller;
|
||||||
links = ['users', 'groups', 'roles', 'permissions'];
|
links = ['users', 'groups', 'roles', 'permissions'];
|
||||||
activeLink: string = this.links[0];
|
activeLink: string = this.links[0];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
private serverService: ServerService) { }
|
private controllerService: ControllerService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const serverId = this.route.snapshot.paramMap.get('server_id');
|
const controllerId = this.route.snapshot.paramMap.get('controller_id');
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.server = server;
|
this.controller = controller;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="information-box">
|
<div class="information-box">
|
||||||
<div>
|
<div>
|
||||||
<app-path-auto-complete
|
<app-path-auto-complete
|
||||||
[server]="server"
|
[controller]="controller"
|
||||||
(update)="permission.path = $event"></app-path-auto-complete>
|
(update)="permission.path = $event"></app-path-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div class="methods">
|
<div class="methods">
|
||||||
|
@ -5,7 +5,7 @@ import {ApiInformationService} from "@services/ApiInformation/api-information.se
|
|||||||
import {PermissionsService} from "@services/permissions.service";
|
import {PermissionsService} from "@services/permissions.service";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
import {Methods, Permission, PermissionActions} from "@models/api/permission";
|
import {Methods, Permission, PermissionActions} from "@models/api/permission";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Observable, of, throwError} from "rxjs";
|
import {Observable, of, throwError} from "rxjs";
|
||||||
import {HttpErrorResponse} from "@angular/common/http";
|
import {HttpErrorResponse} from "@angular/common/http";
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ describe('AddPermissionLineComponent', () => {
|
|||||||
comp.permission.action = PermissionActions.DENY;
|
comp.permission.action = PermissionActions.DENY;
|
||||||
comp.permission.description = "john doe is here";
|
comp.permission.description = "john doe is here";
|
||||||
|
|
||||||
permissionService.add = (server: Server, permission: Permission): Observable<Permission> => {
|
permissionService.add = (controller: Controller, permission: Permission): Observable<Permission> => {
|
||||||
return of(permission);
|
return of(permission);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,12 +111,12 @@ describe('AddPermissionLineComponent', () => {
|
|||||||
|
|
||||||
let errorMessage: string;
|
let errorMessage: string;
|
||||||
|
|
||||||
permissionService.add = (server: Server, permission: Permission): Observable<Permission> => {
|
permissionService.add = (controller: Controller, permission: Permission): Observable<Permission> => {
|
||||||
const error = new HttpErrorResponse({
|
const error = new HttpErrorResponse({
|
||||||
error: new Error("An error occur"),
|
error: new Error("An error occur"),
|
||||||
headers: undefined,
|
headers: undefined,
|
||||||
status: 500,
|
status: 500,
|
||||||
statusText: 'error from server'
|
statusText: 'error from controller'
|
||||||
});
|
});
|
||||||
return throwError(error);
|
return throwError(error);
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
||||||
import {Methods, Permission, PermissionActions} from "@models/api/permission";
|
import {Methods, Permission, PermissionActions} from "@models/api/permission";
|
||||||
import {PermissionsService} from "@services/permissions.service";
|
import {PermissionsService} from "@services/permissions.service";
|
||||||
@ -25,7 +25,7 @@ import {HttpErrorResponse} from "@angular/common/http";
|
|||||||
})
|
})
|
||||||
export class AddPermissionLineComponent implements OnInit {
|
export class AddPermissionLineComponent implements OnInit {
|
||||||
|
|
||||||
@Input() server: Server;
|
@Input() controller: Controller;
|
||||||
@Output() addPermissionEvent = new EventEmitter<void>();
|
@Output() addPermissionEvent = new EventEmitter<void>();
|
||||||
permission: Permission = {
|
permission: Permission = {
|
||||||
action: PermissionActions.ALLOW,
|
action: PermissionActions.ALLOW,
|
||||||
@ -69,7 +69,7 @@ export class AddPermissionLineComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.permissionService.add(this.server, this.permission)
|
this.permissionService.add(this.controller, this.permission)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toasterService.success(`permission was created`);
|
this.toasterService.success(`permission was created`);
|
||||||
this.reset();
|
this.reset();
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {PermissionPath} from "@components/permissions-management/add-permission-line/path-auto-complete/PermissionPath";
|
import {PermissionPath} from "@components/permissions-management/add-permission-line/path-auto-complete/PermissionPath";
|
||||||
import {SubPath} from "@components/permissions-management/add-permission-line/path-auto-complete/SubPath";
|
import {SubPath} from "@components/permissions-management/add-permission-line/path-auto-complete/SubPath";
|
||||||
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
||||||
@ -26,7 +26,7 @@ export class PathAutoCompleteComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
@Output() update = new EventEmitter<string>();
|
@Output() update = new EventEmitter<string>();
|
||||||
@Input() server: Server;
|
@Input() controller: Controller;
|
||||||
path: PermissionPath = new PermissionPath();
|
path: PermissionPath = new PermissionPath();
|
||||||
values: string[] = [];
|
values: string[] = [];
|
||||||
private completeData: { data: IGenericApiObject[]; key: string };
|
private completeData: { data: IGenericApiObject[]; key: string };
|
||||||
@ -73,7 +73,7 @@ export class PathAutoCompleteComponent implements OnInit {
|
|||||||
|
|
||||||
valueChanged(value: string) {
|
valueChanged(value: string) {
|
||||||
if (value.match(this.apiInformationService.bracketIdRegex) && !this.path.containStar()) {
|
if (value.match(this.apiInformationService.bracketIdRegex) && !this.path.containStar()) {
|
||||||
this.apiInformationService.getListByObjectId(this.server, value, undefined, this.path.getVariables())
|
this.apiInformationService.getListByObjectId(this.controller, value, undefined, this.path.getVariables())
|
||||||
.subscribe((data) => {
|
.subscribe((data) => {
|
||||||
this.mode = 'COMPLETE';
|
this.mode = 'COMPLETE';
|
||||||
this.completeData = {data, key: value};
|
this.completeData = {data, key: value};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {async, fakeAsync, TestBed, tick} from "@angular/core/testing";
|
import {async, fakeAsync, TestBed, tick} from "@angular/core/testing";
|
||||||
import {DisplayPathPipe} from "@components/permissions-management/display-path.pipe";
|
import {DisplayPathPipe} from "@components/permissions-management/display-path.pipe";
|
||||||
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Observable, of} from "rxjs";
|
import {Observable, of} from "rxjs";
|
||||||
import {IExtraParams} from "@services/ApiInformation/IExtraParams";
|
import {IExtraParams} from "@services/ApiInformation/IExtraParams";
|
||||||
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
||||||
@ -33,7 +33,7 @@ describe('DisplayPathPipe', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
apiService
|
apiService
|
||||||
.getListByObjectId = (server: Server, key: string, value?: string, extraParams?: IExtraParams[]): Observable<IGenericApiObject[]> => {
|
.getListByObjectId = (controller: Controller, key: string, value?: string, extraParams?: IExtraParams[]): Observable<IGenericApiObject[]> => {
|
||||||
if (key === 'project_id') {
|
if (key === 'project_id') {
|
||||||
return of([{id: '1111-2222-3333', name: 'myProject'}]);
|
return of([{id: '1111-2222-3333', name: 'myProject'}]);
|
||||||
}
|
}
|
||||||
@ -44,9 +44,9 @@ describe('DisplayPathPipe', () => {
|
|||||||
|
|
||||||
let result: string;
|
let result: string;
|
||||||
|
|
||||||
const server = new Server();
|
const controller = new Controller();
|
||||||
comp
|
comp
|
||||||
.transform('/project/1111-2222-3333/nodes/2222-2222-2222', server)
|
.transform('/project/1111-2222-3333/nodes/2222-2222-2222', controller)
|
||||||
.subscribe((res: string) => {
|
.subscribe((res: string) => {
|
||||||
result = res;
|
result = res;
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ import {Pipe, PipeTransform} from '@angular/core';
|
|||||||
import {map, switchMap} from "rxjs/operators";
|
import {map, switchMap} from "rxjs/operators";
|
||||||
import {forkJoin, Observable, of} from "rxjs";
|
import {forkJoin, Observable, of} from "rxjs";
|
||||||
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
|
|
||||||
@Pipe({
|
@Pipe({
|
||||||
name: 'displayPath'
|
name: 'displayPath'
|
||||||
@ -24,8 +24,8 @@ export class DisplayPathPipe implements PipeTransform {
|
|||||||
constructor(private apiInformation: ApiInformationService) {
|
constructor(private apiInformation: ApiInformationService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(originalPath: string, server: Server): Observable<string> {
|
transform(originalPath: string, controller: Controller): Observable<string> {
|
||||||
if (!server) {
|
if (!controller) {
|
||||||
return of(originalPath);
|
return of(originalPath);
|
||||||
}
|
}
|
||||||
return this.apiInformation
|
return this.apiInformation
|
||||||
@ -34,7 +34,7 @@ export class DisplayPathPipe implements PipeTransform {
|
|||||||
if (values.length === 0) {
|
if (values.length === 0) {
|
||||||
return of([]);
|
return of([]);
|
||||||
}
|
}
|
||||||
const obs = values.map((k) => this.apiInformation.getListByObjectId(server, k.key, k.value, values));
|
const obs = values.map((k) => this.apiInformation.getListByObjectId(controller, k.key, k.value, values));
|
||||||
return forkJoin(obs);
|
return forkJoin(obs);
|
||||||
}),
|
}),
|
||||||
map((values: { id: string; name: string }[][]) => {
|
map((values: { id: string; name: string }[][]) => {
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
[matTooltip]="permission.path | displayPath: server | async"
|
[matTooltip]="permission.path | displayPath: controller | async"
|
||||||
matTooltipClass="custom-tooltip">
|
matTooltipClass="custom-tooltip">
|
||||||
{{permission.path | displayPath: server | async}}
|
{{permission.path | displayPath: controller | async}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {Methods, Permission} from "@models/api/permission";
|
import {Methods, Permission} from "@models/api/permission";
|
||||||
import {Server} from '@models/server';
|
import {Controller} from '@models/controller';
|
||||||
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
||||||
import {PermissionsService} from "@services/permissions.service";
|
import {PermissionsService} from "@services/permissions.service";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
@ -26,7 +26,7 @@ import {DeletePermissionDialogComponent} from "@components/permissions-managemen
|
|||||||
})
|
})
|
||||||
export class PermissionEditLineComponent {
|
export class PermissionEditLineComponent {
|
||||||
@Input() permission: Permission;
|
@Input() permission: Permission;
|
||||||
@Input() server: Server;
|
@Input() controller: Controller;
|
||||||
|
|
||||||
isEditable = false;
|
isEditable = false;
|
||||||
@Output() update = new EventEmitter<void>();
|
@Output() update = new EventEmitter<void>();
|
||||||
@ -44,7 +44,7 @@ export class PermissionEditLineComponent {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((confirm: boolean) => {
|
.subscribe((confirm: boolean) => {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
this.permissionService.delete(this.server, this.permission.permission_id)
|
this.permissionService.delete(this.controller, this.permission.permission_id)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toasterService.success(`Permission was deleted`);
|
this.toasterService.success(`Permission was deleted`);
|
||||||
this.update.emit();
|
this.update.emit();
|
||||||
@ -58,7 +58,7 @@ export class PermissionEditLineComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSave() {
|
onSave() {
|
||||||
this.permissionService.update(this.server, this.permission)
|
this.permissionService.update(this.controller, this.permission)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toasterService.success(`Permission was updated`);
|
this.toasterService.success(`Permission was updated`);
|
||||||
this.update.emit();
|
this.update.emit();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div class="content" *ngIf="isReady; else loading">
|
<div class="content" *ngIf="isReady; else loading">
|
||||||
<div class="add">
|
<div class="add">
|
||||||
<app-add-permission-line
|
<app-add-permission-line
|
||||||
[server]="server"
|
[controller]="controller"
|
||||||
(addPermissionEvent)="refresh()"></app-add-permission-line>
|
(addPermissionEvent)="refresh()"></app-add-permission-line>
|
||||||
</div>
|
</div>
|
||||||
<div class="permission-content default-content">
|
<div class="permission-content default-content">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div *ngFor="let permission of permissions | permissionsFilter: searchPermissions?.id | paginator: pageEvent">
|
<div *ngFor="let permission of permissions | permissionsFilter: searchPermissions?.id | paginator: pageEvent">
|
||||||
<app-permission-add-edit-line
|
<app-permission-add-edit-line
|
||||||
[permission]="permission"
|
[permission]="permission"
|
||||||
[server]="server"
|
[controller]="controller"
|
||||||
(update)="refresh()"></app-permission-add-edit-line>
|
(update)="refresh()"></app-permission-add-edit-line>
|
||||||
</div>
|
</div>
|
||||||
<mat-paginator [length]="permissions.length" (page)="pageEvent = $event"
|
<mat-paginator [length]="permissions.length" (page)="pageEvent = $event"
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, ComponentFactoryResolver, OnInit, ViewChild, ViewContainerRef} from '@angular/core';
|
import {Component, ComponentFactoryResolver, OnInit, ViewChild, ViewContainerRef} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {PermissionsService} from "@services/permissions.service";
|
import {PermissionsService} from "@services/permissions.service";
|
||||||
import {ProgressService} from "../../common/progress/progress.service";
|
import {ProgressService} from "../../common/progress/progress.service";
|
||||||
import {Permission} from "@models/api/permission";
|
import {Permission} from "@models/api/permission";
|
||||||
import {AddPermissionLineComponent} from "@components/permissions-management/add-permission-line/add-permission-line.component";
|
import {AddPermissionLineComponent} from "@components/permissions-management/add-permission-line/add-permission-line.component";
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
import {PageEvent} from "@angular/material/paginator";
|
import {PageEvent} from "@angular/material/paginator";
|
||||||
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
import {ApiInformationService} from "@services/ApiInformation/api-information.service";
|
||||||
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
||||||
@ -28,7 +28,7 @@ import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
|||||||
styleUrls: ['./permissions-management.component.scss']
|
styleUrls: ['./permissions-management.component.scss']
|
||||||
})
|
})
|
||||||
export class PermissionsManagementComponent implements OnInit {
|
export class PermissionsManagementComponent implements OnInit {
|
||||||
server: Server;
|
controller: Controller;
|
||||||
permissions: Permission[];
|
permissions: Permission[];
|
||||||
addPermissionLineComp = AddPermissionLineComponent;
|
addPermissionLineComp = AddPermissionLineComponent;
|
||||||
newPermissionEdit = false;
|
newPermissionEdit = false;
|
||||||
@ -46,19 +46,19 @@ export class PermissionsManagementComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private permissionService: PermissionsService,
|
private permissionService: PermissionsService,
|
||||||
private progressService: ProgressService,
|
private progressService: ProgressService,
|
||||||
private serverService: ServerService,
|
private controllerService: ControllerService,
|
||||||
private apiInformationService: ApiInformationService) { }
|
private apiInformationService: ApiInformationService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const serverId = this.route.parent.snapshot.paramMap.get('server_id');
|
const controllerId = this.route.parent.snapshot.paramMap.get('controller_id');
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.server = server;
|
this.controller = controller;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.permissionService.list(this.server).subscribe(
|
this.permissionService.list(this.controller).subscribe(
|
||||||
(permissions: Permission[]) => {
|
(permissions: Permission[]) => {
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import {Component, Inject, OnInit} from '@angular/core';
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
|
import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {GroupNameValidator} from "@components/group-management/add-group-dialog/GroupNameValidator";
|
import {GroupNameValidator} from "@components/group-management/add-group-dialog/GroupNameValidator";
|
||||||
import {GroupService} from "@services/group.service";
|
import {GroupService} from "@services/group.service";
|
||||||
import {groupNameAsyncValidator} from "@components/group-management/add-group-dialog/groupNameAsyncValidator";
|
import {groupNameAsyncValidator} from "@components/group-management/add-group-dialog/groupNameAsyncValidator";
|
||||||
@ -28,7 +28,7 @@ export class AddRoleDialogComponent implements OnInit {
|
|||||||
roleNameForm: FormGroup;
|
roleNameForm: FormGroup;
|
||||||
|
|
||||||
constructor(private dialogRef: MatDialogRef<AddRoleDialogComponent>,
|
constructor(private dialogRef: MatDialogRef<AddRoleDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: { server: Server },
|
@Inject(MAT_DIALOG_DATA) public data: { controller: Controller },
|
||||||
private formBuilder: FormBuilder) {
|
private formBuilder: FormBuilder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="center">{{permission.methods.join(",")}}</div>
|
<div class="center">{{permission.methods.join(",")}}</div>
|
||||||
<div class="center">{{permission.path | displayPath: server | async}}</div>
|
<div class="center">{{permission.path | displayPath: controller | async}}</div>
|
||||||
</div>
|
</div>
|
||||||
<button *ngIf="side === 'LEFT'" mat-button (click)="onClick()">
|
<button *ngIf="side === 'LEFT'" mat-button (click)="onClick()">
|
||||||
<mat-icon>keyboard_arrow_right</mat-icon>
|
<mat-icon>keyboard_arrow_right</mat-icon>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {Permission} from "@models/api/permission";
|
import {Permission} from "@models/api/permission";
|
||||||
import { Server } from '@models/server';
|
import {Controller} from '@models/controller';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-editable-permission',
|
selector: 'app-editable-permission',
|
||||||
@ -22,7 +22,7 @@ import { Server } from '@models/server';
|
|||||||
export class EditablePermissionComponent implements OnInit {
|
export class EditablePermissionComponent implements OnInit {
|
||||||
|
|
||||||
@Input() permission: Permission;
|
@Input() permission: Permission;
|
||||||
@Input() server: Server;
|
@Input() controller: Controller;
|
||||||
@Input() side: 'LEFT' | 'RIGHT';
|
@Input() side: 'LEFT' | 'RIGHT';
|
||||||
@Output() click = new EventEmitter();
|
@Output() click = new EventEmitter();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
<app-editable-permission
|
<app-editable-permission
|
||||||
[side]="'LEFT'"
|
[side]="'LEFT'"
|
||||||
[permission]="permission"
|
[permission]="permission"
|
||||||
[server]="server"
|
[controller]="controller"
|
||||||
(click)="remove(permission)"
|
(click)="remove(permission)"
|
||||||
*ngFor="let permission of ownedArray | permissionsFilter: searchPermissions?.id | paginator: pageEventOwned">
|
*ngFor="let permission of ownedArray | permissionsFilter: searchPermissions?.id | paginator: pageEventOwned">
|
||||||
|
|
||||||
@ -58,7 +58,7 @@
|
|||||||
<app-editable-permission
|
<app-editable-permission
|
||||||
[side]="'RIGHT'"
|
[side]="'RIGHT'"
|
||||||
[permission]="permission"
|
[permission]="permission"
|
||||||
[server]="server"
|
[controller]="controller"
|
||||||
(click)="add(permission)"
|
(click)="add(permission)"
|
||||||
*ngFor="let permission of availableArray | permissionsFilter: searchPermissions?.id | paginator: pageEventAvailable">
|
*ngFor="let permission of availableArray | permissionsFilter: searchPermissions?.id | paginator: pageEventAvailable">
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import {Component, Input, OnInit, Output, EventEmitter} from '@angular/core';
|
import {Component, Input, OnInit, Output, EventEmitter} from '@angular/core';
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Permission} from "@models/api/permission";
|
import {Permission} from "@models/api/permission";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import {PermissionEditorValidateDialogComponent} from "@components/role-management/role-detail/permission-editor/permission-editor-validate-dialog/permission-editor-validate-dialog.component";
|
import {PermissionEditorValidateDialogComponent} from "@components/role-management/role-detail/permission-editor/permission-editor-validate-dialog/permission-editor-validate-dialog.component";
|
||||||
@ -33,7 +33,7 @@ export class PermissionEditorComponent implements OnInit {
|
|||||||
pageEventOwned: PageEvent | undefined;
|
pageEventOwned: PageEvent | undefined;
|
||||||
pageEventAvailable: PageEvent | undefined;
|
pageEventAvailable: PageEvent | undefined;
|
||||||
|
|
||||||
@Input() server: Server;
|
@Input() controller: Controller;
|
||||||
@Input() ownedPermissions: Permission[];
|
@Input() ownedPermissions: Permission[];
|
||||||
@Input() availablePermissions: Permission[];
|
@Input() availablePermissions: Permission[];
|
||||||
@Output() updatedPermissions: EventEmitter<any> = new EventEmitter();
|
@Output() updatedPermissions: EventEmitter<any> = new EventEmitter();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
mat-icon-button
|
mat-icon-button
|
||||||
matTooltip="Back to role management"
|
matTooltip="Back to role management"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
[routerLink]="['/server', server.id, 'management', 'roles']">
|
[routerLink]="['/controller', controller.id, 'management', 'roles']">
|
||||||
<mat-icon aria-label="Back to role management">keyboard_arrow_left</mat-icon>
|
<mat-icon aria-label="Back to role management">keyboard_arrow_left</mat-icon>
|
||||||
</a>
|
</a>
|
||||||
<h1 class="col">Role {{role.name}} details</h1>
|
<h1 class="col">Role {{role.name}} details</h1>
|
||||||
@ -44,14 +44,14 @@
|
|||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
mat-button
|
mat-button
|
||||||
[routerLink]="['/server', server.id, 'management', 'roles', role.role_id, 'permissions']">
|
[routerLink]="['/controller', controller.id, 'management', 'roles', role.role_id, 'permissions']">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<app-editable-permission
|
<app-editable-permission
|
||||||
[permission]="permission"
|
[permission]="permission"
|
||||||
[server]="server"
|
[controller]="controller"
|
||||||
*ngFor="let permission of role.permissions">
|
*ngFor="let permission of role.permissions">
|
||||||
</app-editable-permission>
|
</app-editable-permission>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {RoleService} from "@services/role.service";
|
import {RoleService} from "@services/role.service";
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import {ActivatedRoute} from "@angular/router";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
import {Role} from "@models/api/role";
|
import {Role} from "@models/api/role";
|
||||||
import {FormControl, FormGroup} from "@angular/forms";
|
import {FormControl, FormGroup} from "@angular/forms";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
@ -26,12 +26,12 @@ import {HttpErrorResponse} from "@angular/common/http";
|
|||||||
styleUrls: ['./role-detail.component.scss']
|
styleUrls: ['./role-detail.component.scss']
|
||||||
})
|
})
|
||||||
export class RoleDetailComponent implements OnInit {
|
export class RoleDetailComponent implements OnInit {
|
||||||
server: Server;
|
controller: Controller;
|
||||||
role: Role;
|
role: Role;
|
||||||
editRoleForm: FormGroup;
|
editRoleForm: FormGroup;
|
||||||
|
|
||||||
constructor(private roleService: RoleService,
|
constructor(private roleService: RoleService,
|
||||||
private serverService: ServerService,
|
private controllerService: ControllerService,
|
||||||
private toastService: ToasterService,
|
private toastService: ToasterService,
|
||||||
private route: ActivatedRoute) {
|
private route: ActivatedRoute) {
|
||||||
|
|
||||||
@ -42,14 +42,14 @@ export class RoleDetailComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.data.subscribe((d: { server: Server; role: Role }) => {
|
this.route.data.subscribe((d: { controller: Controller; role: Role }) => {
|
||||||
this.server = d.server;
|
this.controller = d.controller;
|
||||||
this.role = d.role;
|
this.role = d.role;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate() {
|
onUpdate() {
|
||||||
this.roleService.update(this.server, this.role)
|
this.roleService.update(this.controller, this.role)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`role: ${this.role.name} was updated`);
|
this.toastService.success(`role: ${this.role.name} was updated`);
|
||||||
},
|
},
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
mat-icon-button
|
mat-icon-button
|
||||||
matTooltip="Back to role detail"
|
matTooltip="Back to role detail"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
[routerLink]="['/server', server.id, 'management', 'roles', role.role_id]">
|
[routerLink]="['/controller', controller.id, 'management', 'roles', role.role_id]">
|
||||||
<mat-icon aria-label="Back to role detail">keyboard_arrow_left</mat-icon>
|
<mat-icon aria-label="Back to role detail">keyboard_arrow_left</mat-icon>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -12,5 +12,5 @@
|
|||||||
Edit {{role.name}} role permissions
|
Edit {{role.name}} role permissions
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<app-permission-editor [ownedPermissions]="role.permissions" [availablePermissions]="permissions" [server]="server"
|
<app-permission-editor [ownedPermissions]="role.permissions" [availablePermissions]="permissions" [controller]="controller"
|
||||||
(updatedPermissions)="updatePermissions($event)"></app-permission-editor>
|
(updatedPermissions)="updatePermissions($event)"></app-permission-editor>
|
||||||
|
@ -15,7 +15,7 @@ import {ActivatedRoute, Router} from "@angular/router";
|
|||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
import {RoleService} from "@services/role.service";
|
import {RoleService} from "@services/role.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Role} from "@models/api/role";
|
import {Role} from "@models/api/role";
|
||||||
import {Permission} from "@models/api/permission";
|
import {Permission} from "@models/api/permission";
|
||||||
import {Observable} from "rxjs/Rx";
|
import {Observable} from "rxjs/Rx";
|
||||||
@ -28,7 +28,7 @@ import {HttpErrorResponse} from "@angular/common/http";
|
|||||||
styleUrls: ['./role-permissions.component.scss']
|
styleUrls: ['./role-permissions.component.scss']
|
||||||
})
|
})
|
||||||
export class RolePermissionsComponent implements OnInit {
|
export class RolePermissionsComponent implements OnInit {
|
||||||
server: Server;
|
controller: Controller;
|
||||||
role: Role;
|
role: Role;
|
||||||
permissions: Permission[];
|
permissions: Permission[];
|
||||||
|
|
||||||
@ -37,8 +37,8 @@ export class RolePermissionsComponent implements OnInit {
|
|||||||
private toastService: ToasterService,
|
private toastService: ToasterService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private roleService: RoleService) {
|
private roleService: RoleService) {
|
||||||
this.route.data.subscribe((data: { server: Server, role: Role, permissions: Permission[] }) => {
|
this.route.data.subscribe((data: { controller: Controller, role: Role, permissions: Permission[] }) => {
|
||||||
this.server = data.server;
|
this.controller = data.controller;
|
||||||
this.role = data.role;
|
this.role = data.role;
|
||||||
this.permissions = data.permissions;
|
this.permissions = data.permissions;
|
||||||
});
|
});
|
||||||
@ -51,16 +51,16 @@ export class RolePermissionsComponent implements OnInit {
|
|||||||
const {add, remove} = toUpdate;
|
const {add, remove} = toUpdate;
|
||||||
const obs: Observable<any>[] = [];
|
const obs: Observable<any>[] = [];
|
||||||
add.forEach((permission: Permission) => {
|
add.forEach((permission: Permission) => {
|
||||||
obs.push(this.roleService.addPermission(this.server, this.role, permission));
|
obs.push(this.roleService.addPermission(this.controller, this.role, permission));
|
||||||
});
|
});
|
||||||
remove.forEach((permission: Permission) => {
|
remove.forEach((permission: Permission) => {
|
||||||
obs.push(this.roleService.removePermission(this.server, this.role, permission));
|
obs.push(this.roleService.removePermission(this.controller, this.role, permission));
|
||||||
});
|
});
|
||||||
|
|
||||||
forkJoin(obs)
|
forkJoin(obs)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`permissions updated`);
|
this.toastService.success(`permissions updated`);
|
||||||
this.router.navigate(['/server', this.server.id, 'management', 'roles', this.role.role_id]);
|
this.router.navigate(['/controller', this.controller.id, 'management', 'roles', this.role.role_id]);
|
||||||
},
|
},
|
||||||
(error: HttpErrorResponse) => {
|
(error: HttpErrorResponse) => {
|
||||||
this.toastService.error(`${error.message}
|
this.toastService.error(`${error.message}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row">
|
<mat-cell *matCellDef="let row">
|
||||||
<a [routerLink]="['/server', server.id, 'management','roles', row.role_id]"
|
<a [routerLink]="['/controller', controller.id, 'management','roles', row.role_id]"
|
||||||
class="table-link" [matTooltip]="row.name">{{ row.name }}</a>
|
class="table-link" [matTooltip]="row.name">{{ row.name }}</a>
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
import {Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {MatTableDataSource} from "@angular/material/table";
|
import {MatTableDataSource} from "@angular/material/table";
|
||||||
import {SelectionModel} from "@angular/cdk/collections";
|
import {SelectionModel} from "@angular/cdk/collections";
|
||||||
import {MatPaginator} from "@angular/material/paginator";
|
import {MatPaginator} from "@angular/material/paginator";
|
||||||
import {MatSort} from "@angular/material/sort";
|
import {MatSort} from "@angular/material/sort";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {ProgressService} from "../../common/progress/progress.service";
|
import {ProgressService} from "../../common/progress/progress.service";
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
import {Role} from "@models/api/role";
|
import {Role} from "@models/api/role";
|
||||||
@ -35,7 +35,7 @@ import {HttpErrorResponse} from "@angular/common/http";
|
|||||||
styleUrls: ['./role-management.component.scss']
|
styleUrls: ['./role-management.component.scss']
|
||||||
})
|
})
|
||||||
export class RoleManagementComponent implements OnInit {
|
export class RoleManagementComponent implements OnInit {
|
||||||
server: Server;
|
controller: Controller;
|
||||||
dataSource = new MatTableDataSource<Role>();
|
dataSource = new MatTableDataSource<Role>();
|
||||||
displayedColumns = ['select', 'name', 'description', 'permissions', 'delete'];
|
displayedColumns = ['select', 'name', 'description', 'permissions', 'delete'];
|
||||||
selection = new SelectionModel<Role>(true, []);
|
selection = new SelectionModel<Role>(true, []);
|
||||||
@ -51,15 +51,15 @@ export class RoleManagementComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private roleService: RoleService,
|
private roleService: RoleService,
|
||||||
private progressService: ProgressService,
|
private progressService: ProgressService,
|
||||||
private serverService: ServerService,
|
private controllerService: ControllerService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private toasterService: ToasterService) {
|
private toasterService: ToasterService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const serverId = this.route.parent.snapshot.paramMap.get('server_id');
|
const controllerId = this.route.parent.snapshot.paramMap.get('controller_id');
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.server = server;
|
this.controller = controller;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ export class RoleManagementComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.roleService.get(this.server).subscribe(
|
this.roleService.get(this.controller).subscribe(
|
||||||
(roles: Role[]) => {
|
(roles: Role[]) => {
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
this.dataSource.data = roles;
|
this.dataSource.data = roles;
|
||||||
@ -101,12 +101,12 @@ export class RoleManagementComponent implements OnInit {
|
|||||||
width: '400px',
|
width: '400px',
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
disableClose: true,
|
disableClose: true,
|
||||||
data: {server: this.server},
|
data: {controller: this.controller},
|
||||||
})
|
})
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((role: { name: string; description: string }) => {
|
.subscribe((role: { name: string; description: string }) => {
|
||||||
if (role) {
|
if (role) {
|
||||||
this.roleService.create(this.server, role)
|
this.roleService.create(this.controller, role)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toasterService.success(`${role.name} role created`);
|
this.toasterService.success(`${role.name} role created`);
|
||||||
this.refresh();
|
this.refresh();
|
||||||
@ -135,7 +135,7 @@ export class RoleManagementComponent implements OnInit {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((isDeletedConfirm) => {
|
.subscribe((isDeletedConfirm) => {
|
||||||
if (isDeletedConfirm) {
|
if (isDeletedConfirm) {
|
||||||
const observables = rolesToDelete.map((role: Role) => this.roleService.delete(this.server, role.role_id));
|
const observables = rolesToDelete.map((role: Role) => this.roleService.delete(this.controller, role.role_id));
|
||||||
forkJoin(observables)
|
forkJoin(observables)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
@ -14,7 +14,7 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import {FormControl, FormGroup, Validators} from "@angular/forms";
|
import {FormControl, FormGroup, Validators} from "@angular/forms";
|
||||||
import {MatDialogRef} from "@angular/material/dialog";
|
import {MatDialogRef} from "@angular/material/dialog";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
import {userNameAsyncValidator} from "@components/user-management/add-user-dialog/userNameAsyncValidator";
|
import {userNameAsyncValidator} from "@components/user-management/add-user-dialog/userNameAsyncValidator";
|
||||||
@ -34,7 +34,7 @@ import {matchingPassword} from "@components/user-management/ConfirmPasswordValid
|
|||||||
})
|
})
|
||||||
export class AddUserDialogComponent implements OnInit {
|
export class AddUserDialogComponent implements OnInit {
|
||||||
addUserForm: FormGroup;
|
addUserForm: FormGroup;
|
||||||
server: Server;
|
controller: Controller;
|
||||||
|
|
||||||
groups: Group[];
|
groups: Group[];
|
||||||
groupsToAdd: Set<Group> = new Set([]);
|
groupsToAdd: Set<Group> = new Set([]);
|
||||||
@ -52,11 +52,11 @@ export class AddUserDialogComponent implements OnInit {
|
|||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(3),
|
Validators.minLength(3),
|
||||||
Validators.pattern("[a-zA-Z0-9_-]+$")],
|
Validators.pattern("[a-zA-Z0-9_-]+$")],
|
||||||
[userNameAsyncValidator(this.server, this.userService)]),
|
[userNameAsyncValidator(this.controller, this.userService)]),
|
||||||
full_name: new FormControl(),
|
full_name: new FormControl(),
|
||||||
email: new FormControl(null,
|
email: new FormControl(null,
|
||||||
[Validators.email, Validators.required],
|
[Validators.email, Validators.required],
|
||||||
[userEmailAsyncValidator(this.server, this.userService)]),
|
[userEmailAsyncValidator(this.controller, this.userService)]),
|
||||||
password: new FormControl(null,
|
password: new FormControl(null,
|
||||||
[Validators.required, Validators.minLength(6), Validators.maxLength(100)]),
|
[Validators.required, Validators.minLength(6), Validators.maxLength(100)]),
|
||||||
confirmPassword: new FormControl(null,
|
confirmPassword: new FormControl(null,
|
||||||
@ -65,7 +65,7 @@ export class AddUserDialogComponent implements OnInit {
|
|||||||
},{
|
},{
|
||||||
validators: [matchingPassword]
|
validators: [matchingPassword]
|
||||||
});
|
});
|
||||||
this.groupService.getGroups(this.server)
|
this.groupService.getGroups(this.controller)
|
||||||
.subscribe((groups: Group[]) => {
|
.subscribe((groups: Group[]) => {
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
this.filteredGroups = this.autocompleteControl.valueChanges.pipe(
|
this.filteredGroups = this.autocompleteControl.valueChanges.pipe(
|
||||||
@ -99,11 +99,11 @@ export class AddUserDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
const newUser = this.addUserForm.value;
|
const newUser = this.addUserForm.value;
|
||||||
const toAdd = Array.from(this.groupsToAdd.values());
|
const toAdd = Array.from(this.groupsToAdd.values());
|
||||||
this.userService.add(this.server, newUser)
|
this.userService.add(this.controller, newUser)
|
||||||
.subscribe((user: User) => {
|
.subscribe((user: User) => {
|
||||||
this.toasterService.success(`User ${user.username} added`);
|
this.toasterService.success(`User ${user.username} added`);
|
||||||
toAdd.forEach((group: Group) => {
|
toAdd.forEach((group: Group) => {
|
||||||
this.groupService.addMemberToGroup(this.server, group, user)
|
this.groupService.addMemberToGroup(this.controller, group, user)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toasterService.success(`user ${user.username} was added to group ${group.name}`);
|
this.toasterService.success(`user ${user.username} was added to group ${group.name}`);
|
||||||
},
|
},
|
||||||
|
@ -10,16 +10,16 @@
|
|||||||
*
|
*
|
||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import {Server} from "../../../models/server";
|
import {Controller} from "../../../models/controller";
|
||||||
import {UserService} from "../../../services/user.service";
|
import {UserService} from "../../../services/user.service";
|
||||||
import {FormControl} from "@angular/forms";
|
import {FormControl} from "@angular/forms";
|
||||||
import {timer} from "rxjs";
|
import {timer} from "rxjs";
|
||||||
import {map, switchMap} from "rxjs/operators";
|
import {map, switchMap} from "rxjs/operators";
|
||||||
|
|
||||||
export const userEmailAsyncValidator = (server: Server, userService: UserService, except: string = '') => {
|
export const userEmailAsyncValidator = (controller: Controller, userService: UserService, except: string = '') => {
|
||||||
return (control: FormControl) => {
|
return (control: FormControl) => {
|
||||||
return timer(500).pipe(
|
return timer(500).pipe(
|
||||||
switchMap(() => userService.list(server)),
|
switchMap(() => userService.list(controller)),
|
||||||
map((response) => {
|
map((response) => {
|
||||||
return (response.find((n) => n.email === control.value && control.value !== except) ? { emailExists: true } : null);
|
return (response.find((n) => n.email === control.value && control.value !== except) ? { emailExists: true } : null);
|
||||||
})
|
})
|
||||||
|
@ -10,16 +10,16 @@
|
|||||||
*
|
*
|
||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import {Server} from "../../../models/server";
|
import {Controller} from "../../../models/controller";
|
||||||
import {FormControl} from "@angular/forms";
|
import {FormControl} from "@angular/forms";
|
||||||
import {timer} from "rxjs";
|
import {timer} from "rxjs";
|
||||||
import {map, switchMap} from "rxjs/operators";
|
import {map, switchMap} from "rxjs/operators";
|
||||||
import {UserService} from "../../../services/user.service";
|
import {UserService} from "../../../services/user.service";
|
||||||
|
|
||||||
export const userNameAsyncValidator = (server: Server, userService: UserService, except: string = '') => {
|
export const userNameAsyncValidator = (controller: Controller, userService: UserService, except: string = '') => {
|
||||||
return (control: FormControl) => {
|
return (control: FormControl) => {
|
||||||
return timer(500).pipe(
|
return timer(500).pipe(
|
||||||
switchMap(() => userService.list(server)),
|
switchMap(() => userService.list(controller)),
|
||||||
map((response) => {
|
map((response) => {
|
||||||
return (response.find((n) => n.username === control.value && control.value !== except) ? { userExists: true } : null);
|
return (response.find((n) => n.username === control.value && control.value !== except) ? { userExists: true } : null);
|
||||||
})
|
})
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, Inject, OnInit} from '@angular/core';
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
import {FormControl, FormGroup, Validators} from "@angular/forms";
|
import {FormControl, FormGroup, Validators} from "@angular/forms";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
@ -32,7 +32,7 @@ export class EditUserDialogComponent implements OnInit {
|
|||||||
constructor(public dialogRef: MatDialogRef<EditUserDialogComponent>,
|
constructor(public dialogRef: MatDialogRef<EditUserDialogComponent>,
|
||||||
public userService: UserService,
|
public userService: UserService,
|
||||||
private toasterService: ToasterService,
|
private toasterService: ToasterService,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: { user: User, server: Server }) {}
|
@Inject(MAT_DIALOG_DATA) public data: { user: User, controller: Controller }) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.editUserForm = new FormGroup({
|
this.editUserForm = new FormGroup({
|
||||||
@ -40,11 +40,11 @@ export class EditUserDialogComponent implements OnInit {
|
|||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(3),
|
Validators.minLength(3),
|
||||||
Validators.pattern("[a-zA-Z0-9_-]+$")],
|
Validators.pattern("[a-zA-Z0-9_-]+$")],
|
||||||
[userNameAsyncValidator(this.data.server, this.userService, this.data.user.username)]),
|
[userNameAsyncValidator(this.data.controller, this.userService, this.data.user.username)]),
|
||||||
full_name: new FormControl(this.data.user.full_name),
|
full_name: new FormControl(this.data.user.full_name),
|
||||||
email: new FormControl(this.data.user.email,
|
email: new FormControl(this.data.user.email,
|
||||||
[Validators.email, Validators.required],
|
[Validators.email, Validators.required],
|
||||||
[userEmailAsyncValidator(this.data.server, this.userService, this.data.user.email)]),
|
[userEmailAsyncValidator(this.data.controller, this.userService, this.data.user.email)]),
|
||||||
password: new FormControl(null,
|
password: new FormControl(null,
|
||||||
[Validators.minLength(6), Validators.maxLength(100)]),
|
[Validators.minLength(6), Validators.maxLength(100)]),
|
||||||
is_active: new FormControl(this.data.user.is_active)
|
is_active: new FormControl(this.data.user.is_active)
|
||||||
@ -67,7 +67,7 @@ export class EditUserDialogComponent implements OnInit {
|
|||||||
|
|
||||||
updatedUser.user_id = this.data.user.user_id;
|
updatedUser.user_id = this.data.user.user_id;
|
||||||
console.log(updatedUser)
|
console.log(updatedUser)
|
||||||
this.userService.update(this.data.server, updatedUser)
|
this.userService.update(this.data.controller, updatedUser)
|
||||||
.subscribe((user: User) => {
|
.subscribe((user: User) => {
|
||||||
console.log("Done ", user)
|
console.log("Done ", user)
|
||||||
this.toasterService.success(`User ${user.username} updated`);
|
this.toasterService.success(`User ${user.username} updated`);
|
||||||
|
@ -3,7 +3,7 @@ import {AbstractControl, FormControl, FormGroup, ValidationErrors, ValidatorFn,
|
|||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
import {matchingPassword} from "@components/user-management/ConfirmPasswordValidator";
|
import {matchingPassword} from "@components/user-management/ConfirmPasswordValidator";
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export class ChangeUserPasswordComponent implements OnInit {
|
|||||||
user: User;
|
user: User;
|
||||||
|
|
||||||
constructor(private dialogRef: MatDialogRef<ChangeUserPasswordComponent>,
|
constructor(private dialogRef: MatDialogRef<ChangeUserPasswordComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: { user: User, server: Server },
|
@Inject(MAT_DIALOG_DATA) public data: { user: User, controller: Controller },
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private toasterService: ToasterService) { }
|
private toasterService: ToasterService) { }
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export class ChangeUserPasswordComponent implements OnInit {
|
|||||||
|
|
||||||
console.log(updatedUser);
|
console.log(updatedUser);
|
||||||
|
|
||||||
this.userService.update(this.data.server, updatedUser)
|
this.userService.update(this.data.controller, updatedUser)
|
||||||
.subscribe((user: User) => {
|
.subscribe((user: User) => {
|
||||||
this.toasterService.success(`User ${user.username} password updated`);
|
this.toasterService.success(`User ${user.username} password updated`);
|
||||||
this.editPasswordForm.reset();
|
this.editPasswordForm.reset();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
mat-icon-button
|
mat-icon-button
|
||||||
matTooltip="Back to user management"
|
matTooltip="Back to user management"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
[routerLink]="['/server', server.id, 'management', 'users']">
|
[routerLink]="['/controller', controller.id, 'management', 'users']">
|
||||||
<mat-icon aria-label="Back to user management">keyboard_arrow_left</mat-icon>
|
<mat-icon aria-label="Back to user management">keyboard_arrow_left</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<h1 class="col">User Details</h1>
|
<h1 class="col">User Details</h1>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
<div class="user-groups">
|
<div class="user-groups">
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let group of groups">
|
<li *ngFor="let group of groups">
|
||||||
<a [routerLink]="['/server', server.id, 'management','groups', group.user_group_id]"
|
<a [routerLink]="['/controller', controller.id, 'management','groups', group.user_group_id]"
|
||||||
class="table-link">{{ group.name }}</a>
|
class="table-link">{{ group.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -84,14 +84,14 @@
|
|||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
mat-button
|
mat-button
|
||||||
[routerLink]="['/server', server.id, 'management', 'users', user.user_id, 'permissions']">
|
[routerLink]="['/controller', controller.id, 'management', 'users', user.user_id, 'permissions']">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<app-editable-permission
|
<app-editable-permission
|
||||||
[permission]="permission"
|
[permission]="permission"
|
||||||
[server]="server"
|
[controller]="controller"
|
||||||
*ngFor="let permission of permissions">
|
*ngFor="let permission of permissions">
|
||||||
</app-editable-permission>
|
</app-editable-permission>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
@ -4,7 +4,7 @@ import {Group} from "@models/groups/group";
|
|||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {userNameAsyncValidator} from "@components/user-management/add-user-dialog/userNameAsyncValidator";
|
import {userNameAsyncValidator} from "@components/user-management/add-user-dialog/userNameAsyncValidator";
|
||||||
import {userEmailAsyncValidator} from "@components/user-management/add-user-dialog/userEmailAsyncValidator";
|
import {userEmailAsyncValidator} from "@components/user-management/add-user-dialog/userEmailAsyncValidator";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
@ -25,7 +25,7 @@ export class UserDetailComponent implements OnInit {
|
|||||||
editUserForm: FormGroup;
|
editUserForm: FormGroup;
|
||||||
groups: Group[];
|
groups: Group[];
|
||||||
user: User;
|
user: User;
|
||||||
server: Server;
|
controller: Controller;
|
||||||
user_id: string;
|
user_id: string;
|
||||||
permissions: Permission[];
|
permissions: Permission[];
|
||||||
changingPassword: boolean = false;
|
changingPassword: boolean = false;
|
||||||
@ -39,10 +39,10 @@ export class UserDetailComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.server = this.route.snapshot.data['server'];
|
this.controller = this.route.snapshot.data['controller'];
|
||||||
if (!this.server) this.router.navigate(['/servers']);
|
if (!this.controller) this.router.navigate(['/controllers']);
|
||||||
|
|
||||||
this.route.data.subscribe((d: { server: Server; user: User, groups: Group[], permissions: Permission[]}) => {
|
this.route.data.subscribe((d: { controller: Controller; user: User, groups: Group[], permissions: Permission[]}) => {
|
||||||
this.user = d.user;
|
this.user = d.user;
|
||||||
this.user_id = this.user.user_id;
|
this.user_id = this.user.user_id;
|
||||||
this.groups = d.groups;
|
this.groups = d.groups;
|
||||||
@ -58,11 +58,11 @@ export class UserDetailComponent implements OnInit {
|
|||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(3),
|
Validators.minLength(3),
|
||||||
Validators.pattern("[a-zA-Z0-9_-]+$")],
|
Validators.pattern("[a-zA-Z0-9_-]+$")],
|
||||||
[userNameAsyncValidator(this.server, this.userService, this.user.username)]),
|
[userNameAsyncValidator(this.controller, this.userService, this.user.username)]),
|
||||||
full_name: new FormControl(this.user.full_name),
|
full_name: new FormControl(this.user.full_name),
|
||||||
email: new FormControl(this.user.email,
|
email: new FormControl(this.user.email,
|
||||||
[Validators.email, Validators.required],
|
[Validators.email, Validators.required],
|
||||||
[userEmailAsyncValidator(this.server, this.userService, this.user.email)]),
|
[userEmailAsyncValidator(this.controller, this.userService, this.user.email)]),
|
||||||
is_active: new FormControl(this.user.is_active)
|
is_active: new FormControl(this.user.is_active)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ export class UserDetailComponent implements OnInit {
|
|||||||
const updatedUser = this.getUpdatedValues();
|
const updatedUser = this.getUpdatedValues();
|
||||||
updatedUser['user_id'] = this.user.user_id;
|
updatedUser['user_id'] = this.user.user_id;
|
||||||
|
|
||||||
this.userService.update(this.server, updatedUser)
|
this.userService.update(this.controller, updatedUser)
|
||||||
.subscribe((user: User) => {
|
.subscribe((user: User) => {
|
||||||
this.toasterService.success(`User ${user.username} updated`);
|
this.toasterService.success(`User ${user.username} updated`);
|
||||||
},
|
},
|
||||||
@ -105,6 +105,6 @@ export class UserDetailComponent implements OnInit {
|
|||||||
|
|
||||||
onChangePassword() {
|
onChangePassword() {
|
||||||
this.dialog.open<ChangeUserPasswordComponent>(ChangeUserPasswordComponent,
|
this.dialog.open<ChangeUserPasswordComponent>(ChangeUserPasswordComponent,
|
||||||
{width: '400px', height: '300px', data: {user: this.user, server: this.server}});
|
{width: '400px', height: '300px', data: {user: this.user, controller: this.controller}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
mat-icon-button
|
mat-icon-button
|
||||||
matTooltip="Back to user detail"
|
matTooltip="Back to user detail"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
[routerLink]="['/server', server.id, 'management', 'users', user.user_id]">
|
[routerLink]="['/controller', controller.id, 'management', 'users', user.user_id]">
|
||||||
<mat-icon aria-label="Back to user detail">keyboard_arrow_left</mat-icon>
|
<mat-icon aria-label="Back to user detail">keyboard_arrow_left</mat-icon>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -12,5 +12,5 @@
|
|||||||
Edit {{user.username}} role permissions
|
Edit {{user.username}} role permissions
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<app-permission-editor [ownedPermissions]="userPermissions" [availablePermissions]="permissions" [server]="server"
|
<app-permission-editor [ownedPermissions]="userPermissions" [availablePermissions]="permissions" [controller]="controller"
|
||||||
(updatedPermissions)="updatePermissions($event)"></app-permission-editor>
|
(updatedPermissions)="updatePermissions($event)"></app-permission-editor>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Role} from "@models/api/role";
|
import {Role} from "@models/api/role";
|
||||||
import {Permission} from "@models/api/permission";
|
import {Permission} from "@models/api/permission";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
@ -19,7 +19,7 @@ import {HttpErrorResponse} from "@angular/common/http";
|
|||||||
})
|
})
|
||||||
export class UserPermissionsComponent implements OnInit {
|
export class UserPermissionsComponent implements OnInit {
|
||||||
|
|
||||||
server: Server;
|
controller: Controller;
|
||||||
user: User;
|
user: User;
|
||||||
userPermissions: Permission[];
|
userPermissions: Permission[];
|
||||||
permissions: Permission[];
|
permissions: Permission[];
|
||||||
@ -29,8 +29,8 @@ export class UserPermissionsComponent implements OnInit {
|
|||||||
private toastService: ToasterService,
|
private toastService: ToasterService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private userService: UserService) {
|
private userService: UserService) {
|
||||||
this.route.data.subscribe((data: { server: Server, user: User, userPermissions: Permission[], permissions: Permission[] }) => {
|
this.route.data.subscribe((data: { controller: Controller, user: User, userPermissions: Permission[], permissions: Permission[] }) => {
|
||||||
this.server = data.server;
|
this.controller = data.controller;
|
||||||
this.user = data.user;
|
this.user = data.user;
|
||||||
this.userPermissions = data.userPermissions;
|
this.userPermissions = data.userPermissions;
|
||||||
this.permissions = data.permissions;
|
this.permissions = data.permissions;
|
||||||
@ -44,16 +44,16 @@ export class UserPermissionsComponent implements OnInit {
|
|||||||
const {add, remove} = toUpdate;
|
const {add, remove} = toUpdate;
|
||||||
const obs: Observable<any>[] = [];
|
const obs: Observable<any>[] = [];
|
||||||
add.forEach((permission: Permission) => {
|
add.forEach((permission: Permission) => {
|
||||||
obs.push(this.userService.addPermission(this.server, this.user.user_id, permission));
|
obs.push(this.userService.addPermission(this.controller, this.user.user_id, permission));
|
||||||
});
|
});
|
||||||
remove.forEach((permission: Permission) => {
|
remove.forEach((permission: Permission) => {
|
||||||
obs.push(this.userService.removePermission(this.server, this.user.user_id, permission));
|
obs.push(this.userService.removePermission(this.controller, this.user.user_id, permission));
|
||||||
});
|
});
|
||||||
|
|
||||||
forkJoin(obs)
|
forkJoin(obs)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.toastService.success(`permissions updated`);
|
this.toastService.success(`permissions updated`);
|
||||||
this.router.navigate(['/server', this.server.id, 'management', 'users', this.user.user_id]);
|
this.router.navigate(['/controller', this.controller.id, 'management', 'users', this.user.user_id]);
|
||||||
},
|
},
|
||||||
(error: HttpErrorResponse) => {
|
(error: HttpErrorResponse) => {
|
||||||
this.toastService.error(`${error.message}
|
this.toastService.error(`${error.message}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<ng-container matColumnDef="username">
|
<ng-container matColumnDef="username">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Username</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Username</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row">
|
<mat-cell *matCellDef="let row">
|
||||||
<a [routerLink]="['/server', server.id, 'management','users', row.user_id]"
|
<a [routerLink]="['/controller', controller.id, 'management','users', row.user_id]"
|
||||||
class="table-link" [matTooltip]="row.username">{{ row.username }}</a>
|
class="table-link" [matTooltip]="row.username">{{ row.username }}</a>
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
import {Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {MatSort} from "@angular/material/sort";
|
import {MatSort} from "@angular/material/sort";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {ProgressService} from "../../common/progress/progress.service";
|
import {ProgressService} from "../../common/progress/progress.service";
|
||||||
@ -24,7 +24,7 @@ import {DeleteUserDialogComponent} from "@components/user-management/delete-user
|
|||||||
import {ToasterService} from "@services/toaster.service";
|
import {ToasterService} from "@services/toaster.service";
|
||||||
import {MatPaginator} from "@angular/material/paginator";
|
import {MatPaginator} from "@angular/material/paginator";
|
||||||
import {MatTableDataSource} from "@angular/material/table";
|
import {MatTableDataSource} from "@angular/material/table";
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-management',
|
selector: 'app-user-management',
|
||||||
@ -32,7 +32,7 @@ import {ServerService} from "@services/server.service";
|
|||||||
styleUrls: ['./user-management.component.scss']
|
styleUrls: ['./user-management.component.scss']
|
||||||
})
|
})
|
||||||
export class UserManagementComponent implements OnInit {
|
export class UserManagementComponent implements OnInit {
|
||||||
server: Server;
|
controller: Controller;
|
||||||
dataSource = new MatTableDataSource<User>();
|
dataSource = new MatTableDataSource<User>();
|
||||||
displayedColumns = ['select', 'username', 'full_name', 'email', 'is_active', 'last_login', 'updated_at', 'delete'];
|
displayedColumns = ['select', 'username', 'full_name', 'email', 'is_active', 'last_login', 'updated_at', 'delete'];
|
||||||
selection = new SelectionModel<User>(true, []);
|
selection = new SelectionModel<User>(true, []);
|
||||||
@ -47,14 +47,14 @@ export class UserManagementComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private progressService: ProgressService,
|
private progressService: ProgressService,
|
||||||
private serverService: ServerService,
|
private controllerService: ControllerService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private toasterService: ToasterService) { }
|
private toasterService: ToasterService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const serverId = this.route.parent.snapshot.paramMap.get('server_id');
|
const controllerId = this.route.parent.snapshot.paramMap.get('controller_id');
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.server = server;
|
this.controller = controller;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ export class UserManagementComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.userService.list(this.server).subscribe(
|
this.userService.list(this.controller).subscribe(
|
||||||
(users: User[]) => {
|
(users: User[]) => {
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
this.dataSource.data = users;
|
this.dataSource.data = users;
|
||||||
@ -99,7 +99,7 @@ export class UserManagementComponent implements OnInit {
|
|||||||
disableClose: true,
|
disableClose: true,
|
||||||
});
|
});
|
||||||
let instance = dialogRef.componentInstance;
|
let instance = dialogRef.componentInstance;
|
||||||
instance.server = this.server;
|
instance.controller = this.controller;
|
||||||
dialogRef.afterClosed().subscribe(() => this.refresh());
|
dialogRef.afterClosed().subscribe(() => this.refresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ export class UserManagementComponent implements OnInit {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe((isDeletedConfirm) => {
|
.subscribe((isDeletedConfirm) => {
|
||||||
if (isDeletedConfirm) {
|
if (isDeletedConfirm) {
|
||||||
this.userService.delete(this.server, user.user_id)
|
this.userService.delete(this.controller, user.user_id)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.refresh()
|
this.refresh()
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
@ -140,7 +140,7 @@ export class UserManagementComponent implements OnInit {
|
|||||||
.subscribe((isDeletedConfirm) => {
|
.subscribe((isDeletedConfirm) => {
|
||||||
if (isDeletedConfirm) {
|
if (isDeletedConfirm) {
|
||||||
this.selection.selected.forEach((user: User) => {
|
this.selection.selected.forEach((user: User) => {
|
||||||
this.userService.delete(this.server, user.user_id)
|
this.userService.delete(this.controller, user.user_id)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.refresh()
|
this.refresh()
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
<span>Settings</span>
|
<span>Settings</span>
|
||||||
</button>
|
</button>
|
||||||
<button mat-menu-item
|
<button mat-menu-item
|
||||||
[disabled]="!serverId"
|
[disabled]="!controllerId"
|
||||||
[routerLink]="['server', serverId, 'management', 'users']">
|
[routerLink]="['controller', controllerId, 'management', 'users']">
|
||||||
<mat-icon>groups</mat-icon>
|
<mat-icon>groups</mat-icon>
|
||||||
<span>Management</span>
|
<span>Management</span>
|
||||||
</button>
|
</button>
|
||||||
@ -34,17 +34,17 @@
|
|||||||
<span>Help</span>
|
<span>Help</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
[disabled]="!serverId"
|
[disabled]="!controllerId"
|
||||||
[routerLink]="['/server', serverId, 'loggeduser']"
|
[routerLink]="['/controller', controllerId, 'loggeduser']"
|
||||||
mat-menu-item>
|
mat-menu-item>
|
||||||
<mat-icon>person</mat-icon>
|
<mat-icon>person</mat-icon>
|
||||||
<span>User info</span>
|
<span>User info</span>
|
||||||
</button>
|
</button>
|
||||||
<button [disabled]="!serverId" mat-menu-item (click)="goToDocumentation()">
|
<button [disabled]="!controllerId" mat-menu-item (click)="goToDocumentation()">
|
||||||
<mat-icon>person</mat-icon>
|
<mat-icon>person</mat-icon>
|
||||||
<span>API documentation</span>
|
<span>API documentation</span>
|
||||||
</button>
|
</button>
|
||||||
<button mat-menu-item [disabled]="!serverId" (click)="logout()">
|
<button mat-menu-item [disabled]="!controllerId" (click)="logout()">
|
||||||
<mat-icon>highlight_off</mat-icon>
|
<mat-icon>highlight_off</mat-icon>
|
||||||
<span>Logout</span>
|
<span>Logout</span>
|
||||||
</button>
|
</button>
|
||||||
@ -56,4 +56,4 @@
|
|||||||
|
|
||||||
<app-progress></app-progress>
|
<app-progress></app-progress>
|
||||||
|
|
||||||
<footer class="footer mat-app-background">GNS3 Web UI © 2021 - v{{ uiVersion }}</footer>
|
<footer class="footer mat-app-background">GNS3 Web UI © 2022 - v{{ uiVersion }}</footer>
|
||||||
|
@ -17,9 +17,9 @@ import {
|
|||||||
ActivatedRouteSnapshot
|
ActivatedRouteSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, Subscriber} from 'rxjs';
|
import {Observable, Subscriber} from 'rxjs';
|
||||||
import {ServerService} from "../services/server.service";
|
import {ControllerService} from "../services/controller.service";
|
||||||
import {GroupService} from "../services/group.service";
|
import {GroupService} from "../services/group.service";
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {Group} from "../models/groups/group";
|
import {Group} from "../models/groups/group";
|
||||||
import {User} from "../models/users/user";
|
import {User} from "../models/users/user";
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ import {User} from "../models/users/user";
|
|||||||
})
|
})
|
||||||
export class GroupMembersResolver implements Resolve<User[]> {
|
export class GroupMembersResolver implements Resolve<User[]> {
|
||||||
|
|
||||||
constructor(private serverService: ServerService,
|
constructor(private controllerService: ControllerService,
|
||||||
private groupService: GroupService) {
|
private groupService: GroupService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,11 +36,11 @@ export class GroupMembersResolver implements Resolve<User[]> {
|
|||||||
|
|
||||||
return new Observable<User[]>((subscriber: Subscriber<User[]>) => {
|
return new Observable<User[]>((subscriber: Subscriber<User[]>) => {
|
||||||
|
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
const groupId = route.paramMap.get('user_group_id');
|
const groupId = route.paramMap.get('user_group_id');
|
||||||
|
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.groupService.getGroupMember(server, groupId).subscribe((users: User[]) => {
|
this.groupService.getGroupMember(controller, groupId).subscribe((users: User[]) => {
|
||||||
subscriber.next(users);
|
subscriber.next(users);
|
||||||
subscriber.complete();
|
subscriber.complete();
|
||||||
});
|
});
|
||||||
|
@ -17,10 +17,10 @@ import {
|
|||||||
ActivatedRouteSnapshot
|
ActivatedRouteSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, of, Subscriber} from 'rxjs';
|
import {Observable, of, Subscriber} from 'rxjs';
|
||||||
import {ServerService} from "../services/server.service";
|
import {ControllerService} from "../services/controller.service";
|
||||||
import {GroupService} from "../services/group.service";
|
import {GroupService} from "../services/group.service";
|
||||||
import {User} from "../models/users/user";
|
import {User} from "../models/users/user";
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {Role} from "../models/api/role";
|
import {Role} from "../models/api/role";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -28,7 +28,7 @@ import {Role} from "../models/api/role";
|
|||||||
})
|
})
|
||||||
export class GroupRoleResolver implements Resolve<Role[]> {
|
export class GroupRoleResolver implements Resolve<Role[]> {
|
||||||
|
|
||||||
constructor(private serverService: ServerService,
|
constructor(private controllerService: ControllerService,
|
||||||
private groupService: GroupService) {
|
private groupService: GroupService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,11 +36,11 @@ export class GroupRoleResolver implements Resolve<Role[]> {
|
|||||||
|
|
||||||
return new Observable<Role[]>((subscriber: Subscriber<Role[]>) => {
|
return new Observable<Role[]>((subscriber: Subscriber<Role[]>) => {
|
||||||
|
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
const groupId = route.paramMap.get('user_group_id');
|
const groupId = route.paramMap.get('user_group_id');
|
||||||
|
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.groupService.getGroupRole(server, groupId).subscribe((role: Role[]) => {
|
this.groupService.getGroupRole(controller, groupId).subscribe((role: Role[]) => {
|
||||||
subscriber.next(role);
|
subscriber.next(role);
|
||||||
subscriber.complete();
|
subscriber.complete();
|
||||||
});
|
});
|
||||||
|
@ -17,10 +17,10 @@ import {
|
|||||||
ActivatedRouteSnapshot
|
ActivatedRouteSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, of, Subscriber} from 'rxjs';
|
import {Observable, of, Subscriber} from 'rxjs';
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
import {GroupService} from "@services/group.service";
|
import {GroupService} from "@services/group.service";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {Group} from "@models/groups/group";
|
import {Group} from "@models/groups/group";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -29,7 +29,7 @@ import {Group} from "@models/groups/group";
|
|||||||
export class GroupResolver implements Resolve<Group> {
|
export class GroupResolver implements Resolve<Group> {
|
||||||
|
|
||||||
|
|
||||||
constructor(private serverService: ServerService,
|
constructor(private controllerService: ControllerService,
|
||||||
private groupService: GroupService) {
|
private groupService: GroupService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,11 +37,11 @@ export class GroupResolver implements Resolve<Group> {
|
|||||||
|
|
||||||
return new Observable<Group>((subscriber: Subscriber<Group>) => {
|
return new Observable<Group>((subscriber: Subscriber<Group>) => {
|
||||||
|
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
const groupId = route.paramMap.get('user_group_id');
|
const groupId = route.paramMap.get('user_group_id');
|
||||||
|
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.groupService.get(server, groupId).subscribe((group: Group) => {
|
this.groupService.get(controller, groupId).subscribe((group: Group) => {
|
||||||
subscriber.next(group);
|
subscriber.next(group);
|
||||||
subscriber.complete();
|
subscriber.complete();
|
||||||
});
|
});
|
||||||
|
@ -19,8 +19,8 @@ import {
|
|||||||
import {Observable, of, Subscriber} from 'rxjs';
|
import {Observable, of, Subscriber} from 'rxjs';
|
||||||
import {Permission} from "@models/api/permission";
|
import {Permission} from "@models/api/permission";
|
||||||
import {PermissionsService} from "@services/permissions.service";
|
import {PermissionsService} from "@services/permissions.service";
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -28,14 +28,14 @@ import {Server} from "@models/server";
|
|||||||
export class PermissionResolver implements Resolve<Permission[]> {
|
export class PermissionResolver implements Resolve<Permission[]> {
|
||||||
|
|
||||||
constructor(private permissionService: PermissionsService,
|
constructor(private permissionService: PermissionsService,
|
||||||
private serverService: ServerService) {
|
private controllerService: ControllerService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Permission[]> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Permission[]> {
|
||||||
return new Observable<Permission[]>((observer: Subscriber<Permission[]>) => {
|
return new Observable<Permission[]>((observer: Subscriber<Permission[]>) => {
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.permissionService.list(server).subscribe((permission: Permission[]) => {
|
this.permissionService.list(controller).subscribe((permission: Permission[]) => {
|
||||||
observer.next(permission);
|
observer.next(permission);
|
||||||
observer.complete();
|
observer.complete();
|
||||||
});
|
});
|
||||||
|
@ -17,9 +17,9 @@ import {
|
|||||||
ActivatedRouteSnapshot
|
ActivatedRouteSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, of, Subscriber} from 'rxjs';
|
import {Observable, of, Subscriber} from 'rxjs';
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {Role} from "../models/api/role";
|
import {Role} from "../models/api/role";
|
||||||
import {ServerService} from "../services/server.service";
|
import {ControllerService} from "../services/controller.service";
|
||||||
import {RoleService} from "../services/role.service";
|
import {RoleService} from "../services/role.service";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -27,17 +27,17 @@ import {RoleService} from "../services/role.service";
|
|||||||
})
|
})
|
||||||
export class RoleDetailResolver implements Resolve<Role> {
|
export class RoleDetailResolver implements Resolve<Role> {
|
||||||
|
|
||||||
constructor(private serverService: ServerService,
|
constructor(private controllerService: ControllerService,
|
||||||
private roleService: RoleService) {
|
private roleService: RoleService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Role> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Role> {
|
||||||
return new Observable<Role>((observer: Subscriber<Role>) => {
|
return new Observable<Role>((observer: Subscriber<Role>) => {
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
const roleId = route.paramMap.get('role_id');
|
const roleId = route.paramMap.get('role_id');
|
||||||
|
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.roleService.getById(server, roleId).subscribe((role: Role) => {
|
this.roleService.getById(controller, roleId).subscribe((role: Role) => {
|
||||||
observer.next( role);
|
observer.next( role);
|
||||||
observer.complete();
|
observer.complete();
|
||||||
});
|
});
|
||||||
|
@ -17,28 +17,28 @@ import {
|
|||||||
ActivatedRouteSnapshot
|
ActivatedRouteSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, of, Subscriber} from 'rxjs';
|
import {Observable, of, Subscriber} from 'rxjs';
|
||||||
import {ServerService} from "@services/server.service";
|
import {ControllerService} from "@services/controller.service";
|
||||||
import {UserService} from "@services/user.service";
|
import {UserService} from "@services/user.service";
|
||||||
import {User} from "@models/users/user";
|
import {User} from "@models/users/user";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class UserDetailResolver implements Resolve<User> {
|
export class UserDetailResolver implements Resolve<User> {
|
||||||
|
|
||||||
constructor(private serverService: ServerService,
|
constructor(private controllerService: ControllerService,
|
||||||
private userService: UserService) {
|
private userService: UserService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<User> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<User> {
|
||||||
return new Observable<User>((subscriber: Subscriber<User>) => {
|
return new Observable<User>((subscriber: Subscriber<User>) => {
|
||||||
|
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
const userId = route.paramMap.get('user_id');
|
const userId = route.paramMap.get('user_id');
|
||||||
|
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.userService.get(server, userId).subscribe((user: User) => {
|
this.userService.get(controller, userId).subscribe((user: User) => {
|
||||||
subscriber.next(user);
|
subscriber.next(user);
|
||||||
subscriber.complete();
|
subscriber.complete();
|
||||||
});
|
});
|
||||||
|
@ -19,26 +19,26 @@ import {
|
|||||||
import {Observable, of, Subscriber} from 'rxjs';
|
import {Observable, of, Subscriber} from 'rxjs';
|
||||||
import {Group} from "../models/groups/group";
|
import {Group} from "../models/groups/group";
|
||||||
import {User} from "../models/users/user";
|
import {User} from "../models/users/user";
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {ServerService} from "../services/server.service";
|
import {ControllerService} from "../services/controller.service";
|
||||||
import {UserService} from "../services/user.service";
|
import {UserService} from "../services/user.service";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class UserGroupsResolver implements Resolve<Group[]> {
|
export class UserGroupsResolver implements Resolve<Group[]> {
|
||||||
constructor(private serverService: ServerService,
|
constructor(private controllerService: ControllerService,
|
||||||
private userService: UserService) {
|
private userService: UserService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Group[]> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Group[]> {
|
||||||
return new Observable<Group[]>((subscriber: Subscriber<Group[]>) => {
|
return new Observable<Group[]>((subscriber: Subscriber<Group[]>) => {
|
||||||
|
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
const userId = route.paramMap.get('user_id');
|
const userId = route.paramMap.get('user_id');
|
||||||
|
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.userService.getGroupsByUserId(server, userId).subscribe((groups: Group[]) => {
|
this.userService.getGroupsByUserId(controller, userId).subscribe((groups: Group[]) => {
|
||||||
subscriber.next(groups);
|
subscriber.next(groups);
|
||||||
subscriber.complete();
|
subscriber.complete();
|
||||||
});
|
});
|
||||||
|
@ -17,9 +17,9 @@ import {
|
|||||||
ActivatedRouteSnapshot
|
ActivatedRouteSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import {Observable, of, Subscriber} from 'rxjs';
|
import {Observable, of, Subscriber} from 'rxjs';
|
||||||
import {ServerService} from "../services/server.service";
|
import {ControllerService} from "../services/controller.service";
|
||||||
import {UserService} from "../services/user.service";
|
import {UserService} from "../services/user.service";
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {Permission} from "../models/api/permission";
|
import {Permission} from "../models/api/permission";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -27,18 +27,18 @@ import {Permission} from "../models/api/permission";
|
|||||||
})
|
})
|
||||||
export class UserPermissionsResolver implements Resolve<Permission[]> {
|
export class UserPermissionsResolver implements Resolve<Permission[]> {
|
||||||
|
|
||||||
constructor(private serverService: ServerService,
|
constructor(private controllerService: ControllerService,
|
||||||
private userService: UserService) {
|
private userService: UserService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Permission[]> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Permission[]> {
|
||||||
return new Observable<Permission[]>((subscriber: Subscriber<Permission[]>) => {
|
return new Observable<Permission[]>((subscriber: Subscriber<Permission[]>) => {
|
||||||
|
|
||||||
const serverId = route.paramMap.get('server_id');
|
const controllerId = route.paramMap.get('controller_id');
|
||||||
const userId = route.paramMap.get('user_id');
|
const userId = route.paramMap.get('user_id');
|
||||||
|
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.controllerService.get(+controllerId).then((controller: Controller) => {
|
||||||
this.userService.getPermissionsByUserId(server, userId).subscribe((permissions: Permission[]) => {
|
this.userService.getPermissionsByUserId(controller, userId).subscribe((permissions: Permission[]) => {
|
||||||
subscriber.next(permissions);
|
subscriber.next(permissions);
|
||||||
subscriber.complete();
|
subscriber.complete();
|
||||||
});
|
});
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
import {IApiData} from "./IApiData";
|
import {IApiData} from "./IApiData";
|
||||||
import {Server} from "../../models/server";
|
import {Controller} from "../../models/controller";
|
||||||
import {IExtraParams} from "./IExtraParams";
|
import {IExtraParams} from "./IExtraParams";
|
||||||
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create cache to keep server information on client side
|
* create cache to keep controller information on client side
|
||||||
* reduce number of requests to the server
|
* reduce number of requests to the controller
|
||||||
*/
|
*/
|
||||||
export class ApiInformationCache {
|
export class ApiInformationCache {
|
||||||
|
|
||||||
private cache = new Map<string, IApiData>();
|
private cache = new Map<string, IApiData>();
|
||||||
|
|
||||||
|
|
||||||
public update(server: Server, key: string, value: string, extraParams: IExtraParams[], data: IGenericApiObject[]) {
|
public update(controller: Controller, key: string, value: string, extraParams: IExtraParams[], data: IGenericApiObject[]) {
|
||||||
const dataKey = this.generateKey(server, key, value, extraParams);
|
const dataKey = this.generateKey(controller, key, value, extraParams);
|
||||||
this.cache.set(dataKey, {expired: Date.now() + 10000, data});
|
this.cache.set(dataKey, {expired: Date.now() + 10000, data});
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(server: Server, key: string, value: string, extraParams: IExtraParams[]): IGenericApiObject[] | undefined {
|
public get(controller: Controller, key: string, value: string, extraParams: IExtraParams[]): IGenericApiObject[] | undefined {
|
||||||
const dataKey = this.generateKey(server, key, value, extraParams);
|
const dataKey = this.generateKey(controller, key, value, extraParams);
|
||||||
const data = this.cache.get(dataKey);
|
const data = this.cache.get(dataKey);
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.expired > Date.now()) {
|
if (data.expired > Date.now()) {
|
||||||
@ -28,8 +28,8 @@ export class ApiInformationCache {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateKey(server: Server, key: string, value: string, extraParams: IExtraParams[]) {
|
private generateKey(controller: Controller, key: string, value: string, extraParams: IExtraParams[]) {
|
||||||
return `${server.id}-${key}-${value}-${extraParams.map(param => `${param.key}+${param.value}`).join('.')}`;
|
return `${controller.id}-${key}-${value}-${extraParams.map(param => `${param.key}+${param.value}`).join('.')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchByName(name: string) {
|
searchByName(name: string) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {ApiInformationService, IApiObject} from "@services/ApiInformation/api-information.service";
|
import {ApiInformationService, IApiObject} from "@services/ApiInformation/api-information.service";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {IExtraParams} from "@services/ApiInformation/IExtraParams";
|
import {IExtraParams} from "@services/ApiInformation/IExtraParams";
|
||||||
import {forkJoin, Observable, of} from "rxjs";
|
import {forkJoin, Observable, of} from "rxjs";
|
||||||
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
||||||
@ -27,13 +27,13 @@ export class GetObjectIdHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the request, append the value if required
|
* Build the request, append the value if required
|
||||||
* @param server
|
* @param controller
|
||||||
* @param value
|
* @param value
|
||||||
* @param extraParams
|
* @param extraParams
|
||||||
*/
|
*/
|
||||||
public static buildRequestURL(server: Server, value: string, extraParams: IExtraParams[]): (elem) => string {
|
public static buildRequestURL(controller: Controller, value: string, extraParams: IExtraParams[]): (elem) => string {
|
||||||
return (elem): string => {
|
return (elem): string => {
|
||||||
let url = `${server.protocol}//${server.host}:${server.port}${elem.path}`;
|
let url = `${controller.protocol}//${controller.host}:${controller.port}${elem.path}`;
|
||||||
if (extraParams) {
|
if (extraParams) {
|
||||||
extraParams.forEach((param) => {
|
extraParams.forEach((param) => {
|
||||||
url = url.replace(param.key, param.value);
|
url = url.replace(param.key, param.value);
|
||||||
@ -48,16 +48,16 @@ export class GetObjectIdHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map the data from server to a generic response object
|
* Map the data from controller to a generic response object
|
||||||
* @param key
|
* @param key
|
||||||
* @param extraParams
|
* @param extraParams
|
||||||
* @param service
|
* @param service
|
||||||
* @param server
|
* @param controller
|
||||||
*/
|
*/
|
||||||
public static createResponseObject(key: string,
|
public static createResponseObject(key: string,
|
||||||
extraParams: IExtraParams[],
|
extraParams: IExtraParams[],
|
||||||
service: ApiInformationService,
|
service: ApiInformationService,
|
||||||
server: Server
|
controller: Controller
|
||||||
): (response) => Observable<IGenericApiObject[]> {
|
): (response) => Observable<IGenericApiObject[]> {
|
||||||
|
|
||||||
const idName = key ? GetObjectIdHelper.getIdNameFromKey(key) : undefined;
|
const idName = key ? GetObjectIdHelper.getIdNameFromKey(key) : undefined;
|
||||||
@ -74,7 +74,7 @@ export class GetObjectIdHelper {
|
|||||||
specific treatment for link_id
|
specific treatment for link_id
|
||||||
*/
|
*/
|
||||||
if (key === '{link_id}') {
|
if (key === '{link_id}') {
|
||||||
return GetObjectIdHelper.setLinkObjectInformation(response, extraParams, service, server);
|
return GetObjectIdHelper.setLinkObjectInformation(response, extraParams, service, controller);
|
||||||
} else {
|
} else {
|
||||||
return GetObjectIdHelper.setGenericObjectInformation(response, idName);
|
return GetObjectIdHelper.setGenericObjectInformation(response, idName);
|
||||||
}
|
}
|
||||||
@ -97,19 +97,19 @@ export class GetObjectIdHelper {
|
|||||||
private static setLinkObjectInformation(links: any[],
|
private static setLinkObjectInformation(links: any[],
|
||||||
extraParams: IExtraParams[],
|
extraParams: IExtraParams[],
|
||||||
service: ApiInformationService,
|
service: ApiInformationService,
|
||||||
server: Server
|
controller: Controller
|
||||||
): Observable<IGenericApiObject[]> {
|
): Observable<IGenericApiObject[]> {
|
||||||
|
|
||||||
return forkJoin(links.map(link => GetObjectIdHelper.getLinkInformation(link, extraParams, service, server)));
|
return forkJoin(links.map(link => GetObjectIdHelper.getLinkInformation(link, extraParams, service, controller)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getLinkInformation(link: any,
|
private static getLinkInformation(link: any,
|
||||||
extraParams: IExtraParams[],
|
extraParams: IExtraParams[],
|
||||||
service: ApiInformationService,
|
service: ApiInformationService,
|
||||||
server: Server
|
controller: Controller
|
||||||
): Observable<IGenericApiObject> {
|
): Observable<IGenericApiObject> {
|
||||||
|
|
||||||
const nodesDataObs = link.nodes.map(node => service.getListByObjectId(server, '{node_id}', node.node_id, extraParams));
|
const nodesDataObs = link.nodes.map(node => service.getListByObjectId(controller, '{node_id}', node.node_id, extraParams));
|
||||||
return forkJoin(nodesDataObs)
|
return forkJoin(nodesDataObs)
|
||||||
.pipe(map((nodes: [any]) => {
|
.pipe(map((nodes: [any]) => {
|
||||||
const name = nodes
|
const name = nodes
|
||||||
|
@ -3,8 +3,8 @@ import {HttpClient} from "@angular/common/http";
|
|||||||
import {fakeAsync, TestBed, tick} from "@angular/core/testing";
|
import {fakeAsync, TestBed, tick} from "@angular/core/testing";
|
||||||
import {DisplayPathPipe} from "@components/permissions-management/display-path.pipe";
|
import {DisplayPathPipe} from "@components/permissions-management/display-path.pipe";
|
||||||
import {Observable, of, ReplaySubject} from "rxjs";
|
import {Observable, of, ReplaySubject} from "rxjs";
|
||||||
import {Server} from "@models/server";
|
import {Controller} from "@models/controller";
|
||||||
import {getTestServer} from "@services/testing";
|
import {getTestController} from "@services/testing";
|
||||||
import {Methods} from "@models/api/permission";
|
import {Methods} from "@models/api/permission";
|
||||||
import {ApiInformationCache} from "@services/ApiInformation/ApiInformationCache";
|
import {ApiInformationCache} from "@services/ApiInformation/ApiInformationCache";
|
||||||
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
||||||
@ -12,7 +12,7 @@ import {IGenericApiObject} from "@services/ApiInformation/IGenericApiObject";
|
|||||||
describe('ApiInformationService', () => {
|
describe('ApiInformationService', () => {
|
||||||
let apiService: ApiInformationService;
|
let apiService: ApiInformationService;
|
||||||
let httpClientSpy: jasmine.SpyObj<HttpClient>;
|
let httpClientSpy: jasmine.SpyObj<HttpClient>;
|
||||||
let server: Server;
|
let controller: Controller;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const spy = jasmine.createSpyObj('HttpClient', ['get']);
|
const spy = jasmine.createSpyObj('HttpClient', ['get']);
|
||||||
@ -22,7 +22,7 @@ describe('ApiInformationService', () => {
|
|||||||
httpClientSpy = TestBed.inject(HttpClient) as jasmine.SpyObj<HttpClient>
|
httpClientSpy = TestBed.inject(HttpClient) as jasmine.SpyObj<HttpClient>
|
||||||
httpClientSpy.get.and.returnValue(new Observable());
|
httpClientSpy.get.and.returnValue(new Observable());
|
||||||
apiService = TestBed.inject(ApiInformationService);
|
apiService = TestBed.inject(ApiInformationService);
|
||||||
server = getTestServer();
|
controller = getTestController();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ApiInformationService.getMethods() tests', () => {
|
describe('ApiInformationService.getMethods() tests', () => {
|
||||||
@ -274,7 +274,7 @@ describe('ApiInformationService', () => {
|
|||||||
let res: IGenericApiObject[];
|
let res: IGenericApiObject[];
|
||||||
const mockGetCache: IGenericApiObject[] = [{id: 'id-tralala', name: 'tralala-project'}];
|
const mockGetCache: IGenericApiObject[] = [{id: 'id-tralala', name: 'tralala-project'}];
|
||||||
spyOn(apiService['cache'], 'get').and.returnValue(mockGetCache);
|
spyOn(apiService['cache'], 'get').and.returnValue(mockGetCache);
|
||||||
apiService.getListByObjectId(server, '{project_id}', 'id-tralala').subscribe(data => {
|
apiService.getListByObjectId(controller, '{project_id}', 'id-tralala').subscribe(data => {
|
||||||
res = data;
|
res = data;
|
||||||
});
|
});
|
||||||
tick();
|
tick();
|
||||||
|
@ -15,8 +15,8 @@ import {HttpClient} from "@angular/common/http";
|
|||||||
import {Observable, of, ReplaySubject} from "rxjs";
|
import {Observable, of, ReplaySubject} from "rxjs";
|
||||||
import {map, switchMap, take, tap} from "rxjs/operators";
|
import {map, switchMap, take, tap} from "rxjs/operators";
|
||||||
import {Methods} from "app/models/api/permission";
|
import {Methods} from "app/models/api/permission";
|
||||||
import {HttpServer} from "app/services/http-server.service";
|
import {HttpController} from "app/services/http-controller.service";
|
||||||
import {Server} from "app/models/server";
|
import {Controller} from "app/models/controller";
|
||||||
import {GetObjectIdHelper} from "@services/ApiInformation/GetObjectIdHelper";
|
import {GetObjectIdHelper} from "@services/ApiInformation/GetObjectIdHelper";
|
||||||
import {IExtraParams} from "@services/ApiInformation/IExtraParams";
|
import {IExtraParams} from "@services/ApiInformation/IExtraParams";
|
||||||
import {ApiInformationCache} from "@services/ApiInformation/ApiInformationCache";
|
import {ApiInformationCache} from "@services/ApiInformation/ApiInformationCache";
|
||||||
@ -249,24 +249,24 @@ export class ApiInformationService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get the value of specific object with his ID
|
* get the value of specific object with his ID
|
||||||
* @param {server} the server object to query
|
* @param {controller} the controller object to query
|
||||||
* @param {key} to query ex :'node_id'
|
* @param {key} to query ex :'node_id'
|
||||||
* @param {value} generally the object uuid
|
* @param {value} generally the object uuid
|
||||||
* @param {extraParams} somes params like the project_id if you query specific node_id
|
* @param {extraParams} somes params like the project_id if you query specific node_id
|
||||||
*/
|
*/
|
||||||
getListByObjectId(server: Server, key: string, value?: string, extraParams?: IExtraParams[]): Observable<IGenericApiObject[]> {
|
getListByObjectId(controller: Controller, key: string, value?: string, extraParams?: IExtraParams[]): Observable<IGenericApiObject[]> {
|
||||||
|
|
||||||
const cachedData = this.cache.get(server, key, value, extraParams);
|
const cachedData = this.cache.get(controller, key, value, extraParams);
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
return of(cachedData);
|
return of(cachedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.objs.pipe(
|
return this.objs.pipe(
|
||||||
map(GetObjectIdHelper.findElementInObjectListFn(key)),
|
map(GetObjectIdHelper.findElementInObjectListFn(key)),
|
||||||
map(GetObjectIdHelper.buildRequestURL(server, value, extraParams)),
|
map(GetObjectIdHelper.buildRequestURL(controller, value, extraParams)),
|
||||||
switchMap(url => this.httpClient.get<any[]>(url, {headers: {Authorization: `Bearer ${server.authToken}`}})),
|
switchMap(url => this.httpClient.get<any[]>(url, {headers: {Authorization: `Bearer ${controller.authToken}`}})),
|
||||||
switchMap(GetObjectIdHelper.createResponseObject(key, extraParams, this, server)),
|
switchMap(GetObjectIdHelper.createResponseObject(key, extraParams, this, controller)),
|
||||||
tap(data => this.cache.update(server, key, value, extraParams, data)),
|
tap(data => this.cache.update(controller, key, value, extraParams, data)),
|
||||||
take(1));
|
take(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,19 +11,19 @@
|
|||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {HttpServer} from "./http-server.service";
|
import { HttpController } from "./http-controller.service";
|
||||||
import {Server} from "../models/server";
|
import { Controller } from "../models/controller";
|
||||||
import {Observable} from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ServerVersionService {
|
export class ControllerVersionService {
|
||||||
|
|
||||||
constructor(private httpServer: HttpServer) { }
|
constructor(private httpController: HttpController) { }
|
||||||
|
|
||||||
|
|
||||||
public checkServerVersion(server: Server): Observable<any> {
|
public checkControllerVersion(controller: Controller): Observable<any> {
|
||||||
return this.httpServer.get(server, '/version');
|
return this.httpController.get(controller, '/version');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,8 +11,8 @@
|
|||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {HttpServer} from "./http-server.service";
|
import {HttpController} from "./http-controller.service";
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {Group} from "../models/groups/group";
|
import {Group} from "../models/groups/group";
|
||||||
import {User} from "../models/users/user";
|
import {User} from "../models/users/user";
|
||||||
import {Observable} from "rxjs";
|
import {Observable} from "rxjs";
|
||||||
@ -24,51 +24,51 @@ import {Role} from "@models/api/role";
|
|||||||
export class GroupService {
|
export class GroupService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private httpServer: HttpServer
|
private httpController: HttpController
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroups(server: Server) {
|
getGroups(controller: Controller) {
|
||||||
return this.httpServer.get<Group[]>(server, '/groups');
|
return this.httpController.get<Group[]>(controller, '/groups');
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupMember(server: Server, groupId: string) {
|
getGroupMember(controller: Controller, groupId: string) {
|
||||||
return this.httpServer.get<User[]>(server, `/groups/${groupId}/members`);
|
return this.httpController.get<User[]>(controller, `/groups/${groupId}/members`);
|
||||||
}
|
}
|
||||||
|
|
||||||
addGroup(server: Server, name: string): Observable<Group> {
|
addGroup(controller: Controller, name: string): Observable<Group> {
|
||||||
return this.httpServer.post<Group>(server, `/groups`, {name});
|
return this.httpController.post<Group>(controller, `/groups`, {name});
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(server: Server, user_group_id: string) {
|
delete(controller: Controller, user_group_id: string) {
|
||||||
return this.httpServer.delete(server, `/groups/${user_group_id}`);
|
return this.httpController.delete(controller, `/groups/${user_group_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
get(server: Server, user_group_id: string) {
|
get(controller: Controller, user_group_id: string) {
|
||||||
return this.httpServer.get(server, `/groups/${user_group_id}`);
|
return this.httpController.get(controller, `/groups/${user_group_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
addMemberToGroup(server: Server, group: Group, user: User) {
|
addMemberToGroup(controller: Controller, group: Group, user: User) {
|
||||||
return this.httpServer.put(server, `/groups/${group.user_group_id}/members/${user.user_id}`, {});
|
return this.httpController.put(controller, `/groups/${group.user_group_id}/members/${user.user_id}`, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUser(server: Server, group: Group, user: User) {
|
removeUser(controller: Controller, group: Group, user: User) {
|
||||||
return this.httpServer.delete(server, `/groups/${group.user_group_id}/members/${user.user_id}`);
|
return this.httpController.delete(controller, `/groups/${group.user_group_id}/members/${user.user_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(server: Server, group: Group) {
|
update(controller: Controller, group: Group) {
|
||||||
return this.httpServer.put(server, `/groups/${group.user_group_id}`, {name: group.name});
|
return this.httpController.put(controller, `/groups/${group.user_group_id}`, {name: group.name});
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupRole(server: Server, groupId: string) {
|
getGroupRole(controller: Controller, groupId: string) {
|
||||||
return this.httpServer.get<Role[]>(server, `/groups/${groupId}/roles`);
|
return this.httpController.get<Role[]>(controller, `/groups/${groupId}/roles`);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeRole(server: Server, group: Group, role: Role) {
|
removeRole(controller: Controller, group: Group, role: Role) {
|
||||||
return this.httpServer.delete(server, `/groups/${group.user_group_id}/roles/${role.role_id}`);
|
return this.httpController.delete(controller, `/groups/${group.user_group_id}/roles/${role.role_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
addRoleToGroup(server: Server, group: Group, role: Role) {
|
addRoleToGroup(controller: Controller, group: Group, role: Role) {
|
||||||
return this.httpServer.put(server, `/groups/${group.user_group_id}/roles/${role.role_id}`, {});
|
return this.httpController.put(controller, `/groups/${group.user_group_id}/roles/${role.role_id}`, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {HttpServer} from "./http-server.service";
|
import {HttpController} from "./http-controller.service";
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {Permission} from "../models/api/permission";
|
import {Permission} from "../models/api/permission";
|
||||||
import {Observable} from "rxjs/Rx";
|
import {Observable} from "rxjs/Rx";
|
||||||
|
|
||||||
@ -21,22 +21,22 @@ import {Observable} from "rxjs/Rx";
|
|||||||
})
|
})
|
||||||
export class PermissionsService {
|
export class PermissionsService {
|
||||||
|
|
||||||
constructor(private httpServer: HttpServer) {
|
constructor(private httpController: HttpController) {
|
||||||
}
|
}
|
||||||
|
|
||||||
list(server: Server) {
|
list(controller: Controller) {
|
||||||
return this.httpServer.get<Permission[]>(server, '/permissions');
|
return this.httpController.get<Permission[]>(controller, '/permissions');
|
||||||
}
|
}
|
||||||
|
|
||||||
add(server: Server, permission: Permission): Observable<Permission> {
|
add(controller: Controller, permission: Permission): Observable<Permission> {
|
||||||
return this.httpServer.post<Permission>(server, '/permissions', permission);
|
return this.httpController.post<Permission>(controller, '/permissions', permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(server: Server, permission: Permission): Observable<Permission> {
|
update(controller: Controller, permission: Permission): Observable<Permission> {
|
||||||
return this.httpServer.put<Permission>(server, `/permissions/${permission.permission_id}`, permission);
|
return this.httpController.put<Permission>(controller, `/permissions/${permission.permission_id}`, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(server: Server, permission_id: string) {
|
delete(controller: Controller, permission_id: string) {
|
||||||
return this.httpServer.delete(server, `/permissions/${permission_id}`);
|
return this.httpController.delete(controller, `/permissions/${permission_id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
* Author: Sylvain MATHIEU, Elise LEBEAU
|
* Author: Sylvain MATHIEU, Elise LEBEAU
|
||||||
*/
|
*/
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {HttpServer} from "./http-server.service";
|
import {HttpController} from "./http-controller.service";
|
||||||
import {Server} from "../models/server";
|
import {Controller} from "../models/controller";
|
||||||
import {Group} from "../models/groups/group";
|
import {Group} from "../models/groups/group";
|
||||||
import {Role} from "../models/api/role";
|
import {Role} from "../models/api/role";
|
||||||
import {Permission} from "@models/api/permission";
|
import {Permission} from "@models/api/permission";
|
||||||
@ -22,34 +22,34 @@ import {Permission} from "@models/api/permission";
|
|||||||
})
|
})
|
||||||
export class RoleService {
|
export class RoleService {
|
||||||
|
|
||||||
constructor(private httpServer: HttpServer) { }
|
constructor(private httpController: HttpController) { }
|
||||||
|
|
||||||
get(server: Server) {
|
get(controller: Controller) {
|
||||||
return this.httpServer.get<Role[]>(server, '/roles');
|
return this.httpController.get<Role[]>(controller, '/roles');
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(server: Server, role_id: string) {
|
delete(controller: Controller, role_id: string) {
|
||||||
return this.httpServer.delete(server, `/roles/${role_id}`);
|
return this.httpController.delete(controller, `/roles/${role_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
create(server: Server, newRole: { name: string; description: string }) {
|
create(controller: Controller, newRole: { name: string; description: string }) {
|
||||||
return this.httpServer.post(server, `/roles`, newRole);
|
return this.httpController.post(controller, `/roles`, newRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
getById(server: Server, roleId: string) {
|
getById(controller: Controller, roleId: string) {
|
||||||
return this.httpServer.get<Role>(server, `/roles/${roleId}`);
|
return this.httpController.get<Role>(controller, `/roles/${roleId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(server: Server, role: Role) {
|
update(controller: Controller, role: Role) {
|
||||||
return this.httpServer.put(server, `/roles/${role.role_id}`, {name: role.name, description: role.description});
|
return this.httpController.put(controller, `/roles/${role.role_id}`, {name: role.name, description: role.description});
|
||||||
}
|
}
|
||||||
|
|
||||||
addPermission(server: Server, role: Role, permission: Permission) {
|
addPermission(controller: Controller, role: Role, permission: Permission) {
|
||||||
return this.httpServer.put(server, `/roles/${role.role_id}/permissions/${permission.permission_id}`, {});
|
return this.httpController.put(controller, `/roles/${role.role_id}/permissions/${permission.permission_id}`, {});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removePermission(server: Server, role: Role, permission: Permission) {
|
removePermission(controller: Controller, role: Role, permission: Permission) {
|
||||||
return this.httpServer.delete(server, `/roles/${role.role_id}/permissions/${permission.permission_id}`);
|
return this.httpController.delete(controller, `/roles/${role.role_id}/permissions/${permission.permission_id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
import { Controller } from '../models/controller';
|
import { Controller } from '../models/controller';
|
||||||
import { HttpController } from './http-controller.service';
|
import { HttpController } from './http-controller.service';
|
||||||
import { User } from '../models/users/user';
|
import { User } from '../models/users/user';
|
||||||
|
Loading…
Reference in New Issue
Block a user