migrate angular 21 finalize
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {User} from '../../../services/user/user';
|
||||
@@ -40,11 +40,11 @@ import {UsersComponent} from './users/users.component';
|
||||
],
|
||||
})
|
||||
export class InfoComponent implements OnInit {
|
||||
private userService = inject(UserService);
|
||||
|
||||
public user$: Observable<User | null> | null = null;
|
||||
public faSignOut = faSignOutAlt;
|
||||
|
||||
public constructor(private userService: UserService) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.user$ = this.userService.user$;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Component, Input, inject} from '@angular/core';
|
||||
import {User} from '../../../../../services/user/user';
|
||||
import {UserService} from '../../../../../services/user/user.service';
|
||||
import {ROLE_TYPES} from '../../../../../services/user/roles';
|
||||
@@ -20,6 +20,8 @@ import {RolePipe} from '../../role.pipe';
|
||||
imports: [MatFormField, MatLabel, MatInput, ReactiveFormsModule, FormsModule, MatSelect, MatOption, MatIconButton, FaIconComponent, RolePipe],
|
||||
})
|
||||
export class UserComponent {
|
||||
private userService = inject(UserService);
|
||||
|
||||
public id = '';
|
||||
public name = '';
|
||||
public roles: string[] = [];
|
||||
@@ -27,8 +29,6 @@ export class UserComponent {
|
||||
public edit = false;
|
||||
public faClose = faTimes;
|
||||
|
||||
public constructor(private userService: UserService) {}
|
||||
|
||||
@Input()
|
||||
public set user(value: User) {
|
||||
this.id = value.id;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {UserService} from '../../../../services/user/user.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {User} from '../../../../services/user/user';
|
||||
@@ -14,9 +14,13 @@ import {SortByPipe} from '../../../../widget-modules/pipes/sort-by/sort-by.pipe'
|
||||
imports: [CardComponent, UserComponent, AsyncPipe, SortByPipe],
|
||||
})
|
||||
export class UsersComponent {
|
||||
private userService = inject(UserService);
|
||||
|
||||
public users$: Observable<User[]>;
|
||||
|
||||
public constructor(private userService: UserService) {
|
||||
public constructor() {
|
||||
const userService = this.userService;
|
||||
|
||||
this.users$ = userService.list$();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||
import {Router, RouterLink} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
@@ -17,6 +17,9 @@ import {AuthMessagePipe} from './auth-message.pipe';
|
||||
imports: [LogoComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, MatButton, RouterLink, AuthMessagePipe],
|
||||
})
|
||||
export class LoginComponent implements OnInit {
|
||||
private userService = inject(UserService);
|
||||
private router = inject(Router);
|
||||
|
||||
public form: UntypedFormGroup = new UntypedFormGroup({
|
||||
user: new UntypedFormControl(null, [Validators.required, Validators.email]),
|
||||
pass: new UntypedFormControl(null, [Validators.required]),
|
||||
@@ -25,13 +28,8 @@ export class LoginComponent implements OnInit {
|
||||
public faSignIn = faSignInAlt;
|
||||
public faNewUser = faUserPlus;
|
||||
|
||||
public constructor(
|
||||
private userService: UserService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form.reset;
|
||||
this.form.reset();
|
||||
}
|
||||
|
||||
public async onLogin(): Promise<void> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AfterViewInit, Component} from '@angular/core';
|
||||
import {AfterViewInit, Component, inject} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
|
||||
@@ -8,13 +8,13 @@ import {UserService} from '../../../services/user/user.service';
|
||||
styleUrls: ['./logout.component.less'],
|
||||
})
|
||||
export class LogoutComponent implements AfterViewInit {
|
||||
public constructor(
|
||||
private userService: UserService,
|
||||
private router: Router
|
||||
) {}
|
||||
private userService = inject(UserService);
|
||||
private router = inject(Router);
|
||||
|
||||
public async ngAfterViewInit(): Promise<void> {
|
||||
await this.userService.logout();
|
||||
await this.router.navigateByUrl('/');
|
||||
public ngAfterViewInit(): void {
|
||||
void (async () => {
|
||||
await this.userService.logout();
|
||||
await this.router.navigateByUrl('/');
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ReactiveFormsModule, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {faUserPlus} from '@fortawesome/free-solid-svg-icons';
|
||||
@@ -15,6 +15,9 @@ import {ButtonComponent} from '../../../widget-modules/components/button/button.
|
||||
imports: [CardComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, ButtonRowComponent, ButtonComponent],
|
||||
})
|
||||
export class NewComponent implements OnInit {
|
||||
private fb = inject(UntypedFormBuilder);
|
||||
private userService = inject(UserService);
|
||||
|
||||
public form: UntypedFormGroup = this.fb.group({
|
||||
email: new UntypedFormControl(null, [Validators.required, Validators.email]),
|
||||
name: new UntypedFormControl(null, [Validators.required]),
|
||||
@@ -22,11 +25,6 @@ export class NewComponent implements OnInit {
|
||||
});
|
||||
public faNewUser = faUserPlus;
|
||||
|
||||
public constructor(
|
||||
private fb: UntypedFormBuilder,
|
||||
private userService: UserService
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form.reset();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
@@ -18,6 +18,9 @@ import {AuthMessagePipe} from '../login/auth-message.pipe';
|
||||
imports: [CardComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, ButtonRowComponent, ButtonComponent, AuthMessagePipe],
|
||||
})
|
||||
export class PasswordComponent implements OnInit {
|
||||
public userService = inject(UserService);
|
||||
private router = inject(Router);
|
||||
|
||||
public form: UntypedFormGroup = new UntypedFormGroup({
|
||||
user: new UntypedFormControl(null, [Validators.required, Validators.email]),
|
||||
});
|
||||
@@ -25,11 +28,6 @@ export class PasswordComponent implements OnInit {
|
||||
public errorMessage = '';
|
||||
public faNewPassword = faWindowRestore;
|
||||
|
||||
public constructor(
|
||||
public userService: UserService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form.reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user