Added login page

This commit is contained in:
2026-05-28 14:27:46 +01:00
parent 4de58d6f6e
commit 82aef7da0a
19 changed files with 628 additions and 250 deletions
+43
View File
@@ -0,0 +1,43 @@
import {Component, inject, OnInit} from '@angular/core';
import {NzColDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {AuthService} from "../../services/auth.service";
import {Router} from "@angular/router";
@Component({
selector: 'app-login',
imports: [
NzColDirective,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzInputDirective,
ReactiveFormsModule,
NzButtonComponent
],
templateUrl: './login.html',
styleUrl: './login.css',
})
export class Login implements OnInit {
private authService = inject(AuthService);
private router = inject(Router);
ngOnInit() {
this.authService.logout();
}
loginForm: FormGroup = new FormGroup({
name: new FormControl<string>(null, [Validators.required]),
password: new FormControl<string>(null, [Validators.required])
})
async connectUser() {
if (this.loginForm.invalid) return;
const ok = await this.authService.connectUser(this.loginForm.value.name, this.loginForm.value.password);
if (ok) await this.router.navigate(['/dashboard']);
}
}