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