From 46ce0ddbff396173d58151050e2c4e9e0832822f Mon Sep 17 00:00:00 2001 From: Daniel Lukats Date: Tue, 21 Jul 2020 08:45:59 +0200 Subject: [PATCH] added login component --- src/app/account/login/login.component.css | 22 ++++++++++++ src/app/account/login/login.component.html | 30 ++++++++++++++++ src/app/account/login/login.component.spec.ts | 25 +++++++++++++ src/app/account/login/login.component.ts | 36 +++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 src/app/account/login/login.component.css create mode 100644 src/app/account/login/login.component.html create mode 100644 src/app/account/login/login.component.spec.ts create mode 100644 src/app/account/login/login.component.ts diff --git a/src/app/account/login/login.component.css b/src/app/account/login/login.component.css new file mode 100644 index 0000000..1427fe0 --- /dev/null +++ b/src/app/account/login/login.component.css @@ -0,0 +1,22 @@ +.login-card { + width: 400px; +} + +.login-container { + width: 100%; + height: 100%; + background-color: #333333; +} + +.login-form { + padding: 10px 40px; +} + +.mat-button { + width: 80px; +} + +.mat-form-field { + width: 100%; + padding-top: 15px; +} diff --git a/src/app/account/login/login.component.html b/src/app/account/login/login.component.html new file mode 100644 index 0000000..10816d7 --- /dev/null +++ b/src/app/account/login/login.component.html @@ -0,0 +1,30 @@ +
+ +
diff --git a/src/app/account/login/login.component.spec.ts b/src/app/account/login/login.component.spec.ts new file mode 100644 index 0000000..d6d85a8 --- /dev/null +++ b/src/app/account/login/login.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoginComponent } from './login.component'; + +describe('LoginComponent', () => { + let component: LoginComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ LoginComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(LoginComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/account/login/login.component.ts b/src/app/account/login/login.component.ts new file mode 100644 index 0000000..43674ed --- /dev/null +++ b/src/app/account/login/login.component.ts @@ -0,0 +1,36 @@ +import { Component, OnInit } from '@angular/core'; +import { FormControl, FormGroup } from '@angular/forms'; +import { AccountService } from '../account.service'; +import {ActivatedRoute, Router} from '@angular/router'; + +@Component({ + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.css'] +}) +export class LoginComponent implements OnInit { + form: FormGroup = new FormGroup({ + username: new FormControl(''), + password: new FormControl(''), + }); + loading = false; + returnUrl = this.activatedRoute.snapshot.queryParams['returnUrl'] || '/'; + + onLogin() { + this.loading = true; + if (this.form.invalid) { + return; + } + console.log(this.form.value); + + } + + constructor(private accountService: AccountService, + private activatedRoute: ActivatedRoute, + private router: Router, + ) { } + + ngOnInit(): void { + } + +}