diff --git a/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.html b/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.html index fc892d0..8712360 100644 --- a/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.html +++ b/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.html @@ -1 +1,82 @@ -

user-view works!

+ + + + diff --git a/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.ts b/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.ts index 0ae6e6c..9db8853 100644 --- a/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.ts +++ b/support-portal-frontend/src/app/component/management/users/user-view/user-view.component.ts @@ -1,4 +1,7 @@ import {Component, OnInit} from '@angular/core'; +import {UserService} from "../../../../service/user.service"; +import {User} from "../../../../model/user"; +import {ActivatedRoute, Router} from "@angular/router"; @Component({ selector: 'app-user-view', @@ -7,9 +10,23 @@ import {Component, OnInit} from '@angular/core'; }) export class UserViewComponent implements OnInit { - constructor() { } + user: User; - ngOnInit(): void { + constructor(private userService: UserService, + private router: Router, + private route: ActivatedRoute) { } + ngOnInit(): void { + this.user = this.userService.getSelectedUser(); + setTimeout(() => this.clickButton('openUserInfo'), 100); + } + + private clickButton(buttonId: string): void { + document.getElementById(buttonId)?.click(); + } + + onCloseModal() { + this.router.navigate(['../../'], {relativeTo: this.route}); + } } diff --git a/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts b/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts index 5d9e56b..a0c39ab 100644 --- a/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts +++ b/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts @@ -6,7 +6,7 @@ import {SubSink} from "subsink"; import {UserService} from "../../../../service/user.service"; import {NotificationService} from "../../../../service/notification.service"; import {AuthenticationService} from "../../../../service/authentication.service"; -import {Router} from "@angular/router"; +import {ActivatedRoute, Router} from "@angular/router"; import {CustomHttpResponse} from "../../../../dto/custom-http-response"; @Component({ @@ -24,7 +24,8 @@ export class UsersTableComponent implements OnInit, OnDestroy { constructor(private userService: UserService, private notificationService: NotificationService, private authenticationService: AuthenticationService, - private router: Router) { + private router: Router, + private route: ActivatedRoute) { } ngOnInit(): void { @@ -63,6 +64,8 @@ export class UsersTableComponent implements OnInit, OnDestroy { onSelectUser(user: User) { console.log(`User ${user.username} is selected`); + this.userService.setSelectedUser(user); + this.router.navigate([user.userId, 'view'], {relativeTo: this.route}); } onEditUser(user: User) { diff --git a/support-portal-frontend/src/app/service/user.service.ts b/support-portal-frontend/src/app/service/user.service.ts index 5f96b53..d1a50b6 100644 --- a/support-portal-frontend/src/app/service/user.service.ts +++ b/support-portal-frontend/src/app/service/user.service.ts @@ -13,6 +13,8 @@ export class UserService { private host: string = environment.apiUrl; private storage = localStorage; + private selectedUser: User; + constructor(private httpClient: HttpClient) { } @@ -79,6 +81,14 @@ export class UserService { return formData; } + public setSelectedUser(user: User): void { + this.selectedUser = user; + } + + public getSelectedUser(): User { + return this.selectedUser; + } + } export interface UserPage {