diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 48cd5074..c83e3179 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -56,6 +56,7 @@ import { DefaultLayoutComponent } from './layouts/default-layout/default-layout. import { ServerResolve } from './resolvers/server-resolve'; import { UserManagementComponent } from './components/user-management/user-management.component'; import { LoggedUserComponent } from './components/users/logged-user/logged-user.component'; +import {GroupManagementComponent} from "./components/group-management/group-management.component"; const routes: Routes = [ { @@ -196,6 +197,7 @@ const routes: Routes = [ { path: 'server/:server_id/preferences/iou/templates/:template_id', component: IouTemplateDetailsComponent, canActivate: [LoginGuard] }, { path: 'server/:server_id/preferences/iou/templates/:template_id/copy', component: CopyIouTemplateComponent, canActivate: [LoginGuard] }, { path: 'server/:server_id/preferences/iou/addtemplate', component: AddIouTemplateComponent, canActivate: [LoginGuard] }, + { path: 'server/:server_id/group_management', component: GroupManagementComponent}, ], }, { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7e0df83a..58f46eac 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -269,9 +269,10 @@ import { MarkedDirective } from './directives/marked.directive'; import { LoginComponent } from './components/login/login.component'; import { LoginService } from './services/login.service'; import { HttpRequestsInterceptor } from './interceptors/http.interceptor'; -import { UserManagementComponent } from './components/user-management/user-management.component' +import { UserManagementComponent } from './components/user-management/user-management.component'; import { UserService } from './services/user.service'; import { LoggedUserComponent } from './components/users/logged-user/logged-user.component'; +import { GroupManagementComponent } from './components/group-management/group-management.component'; import { AddUserDialogComponent } from './components/user-management/add-user-dialog/add-user-dialog.component'; import { UserFilterPipe } from './filters/user-filter.pipe'; @@ -462,6 +463,7 @@ import { UserFilterPipe } from './filters/user-filter.pipe'; EditNetworkConfigurationDialogComponent, UserManagementComponent, ProjectReadmeComponent, + GroupManagementComponent, AddUserDialogComponent, UserFilterPipe, ], diff --git a/src/app/components/group-management/group-management.component.html b/src/app/components/group-management/group-management.component.html new file mode 100644 index 00000000..e3eb9982 --- /dev/null +++ b/src/app/components/group-management/group-management.component.html @@ -0,0 +1,43 @@ +
+
+
+

Groups management

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name {{element.name}} Creation date {{element.created_at}} last update {{element.updated_at}} is build in {{element.is_builtin}} delete
+
+
diff --git a/src/app/components/group-management/group-management.component.scss b/src/app/components/group-management/group-management.component.scss new file mode 100644 index 00000000..6a98db4f --- /dev/null +++ b/src/app/components/group-management/group-management.component.scss @@ -0,0 +1,4 @@ +table { + width: 100%; +} + diff --git a/src/app/components/group-management/group-management.component.spec.ts b/src/app/components/group-management/group-management.component.spec.ts new file mode 100644 index 00000000..374c0a34 --- /dev/null +++ b/src/app/components/group-management/group-management.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GroupManagementComponent } from './group-management.component'; + +describe('GroupManagementComponent', () => { + let component: GroupManagementComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ GroupManagementComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(GroupManagementComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/group-management/group-management.component.ts b/src/app/components/group-management/group-management.component.ts new file mode 100644 index 00000000..e20ee78f --- /dev/null +++ b/src/app/components/group-management/group-management.component.ts @@ -0,0 +1,74 @@ +/* +* Software Name : GNS3 Web UI +* Version: 3 +* SPDX-FileCopyrightText: Copyright (c) 2022 Orange Business Services +* SPDX-License-Identifier: GPL-3.0-or-later +* +* This software is distributed under the GPL-3.0 or any later version, +* the text of which is available at https://www.gnu.org/licenses/gpl-3.0.txt +* or see the "LICENSE" file for more details. +* +* Author: Sylvain MATHIEU, Elise LEBEAU +*/ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from "@angular/router"; +import {ServerService} from "../../services/server.service"; +import {ToasterService} from "../../services/toaster.service"; +import {GroupService} from "../../services/group.service"; +import {Server} from "../../models/server"; +import {Group} from "../../models/groups/group"; +import {Sort} from "@angular/material/sort"; + +@Component({ + selector: 'app-group-management', + templateUrl: './group-management.component.html', + styleUrls: ['./group-management.component.scss'] +}) +export class GroupManagementComponent implements OnInit { + server: Server; + + public displayedColumns = ['name', 'created_at', 'updated_at', 'is_builtin', 'delete']; + groups: Group[]; + sortedGroups: Group[]; + + constructor( + private route: ActivatedRoute, + private serverService: ServerService, + private toasterService: ToasterService, + public groupService: GroupService, + ) { + } + + ngOnInit(): void { + const serverId = this.route.snapshot.paramMap.get('server_id'); + this.serverService.get(+serverId).then((server: Server) => { + this.server = server; + this.groupService.getGroups(server).subscribe((groups: Group[]) => { + this.groups = groups; + this.sortedGroups = groups; + }); + }); + } + + sort(sort: Sort) { + const data = this.groups.slice(); + if (!sort.active || sort.direction === '') { + this.sortedGroups = data; + return; + } + + this.sortedGroups = data.sort((a, b) => { + const isAsc = sort.direction === 'asc'; + switch (sort.active) { + case 'name': + return compare(a.name, b.name, isAsc); + default: + return 0; + } + }); + + function compare(a: number | string, b: number | string, isAsc: boolean) { + return (a < b ? -1 : 1) * (isAsc ? 1 : -1); + } + } +} diff --git a/src/app/layouts/default-layout/default-layout.component.html b/src/app/layouts/default-layout/default-layout.component.html index ba883a12..925ab581 100644 --- a/src/app/layouts/default-layout/default-layout.component.html +++ b/src/app/layouts/default-layout/default-layout.component.html @@ -27,6 +27,10 @@ groups User management +