From b115829ae7ee9c3c94a2614064f0f55a09dca6dd Mon Sep 17 00:00:00 2001 From: gopi17701 <41270090+gopi17701@users.noreply.github.com> Date: Fri, 28 Sep 2018 12:40:20 -0400 Subject: [PATCH] Add files via upload --- .../src/app/login/login.component.css | 3 ++ .../src/app/login/login.component.html | 19 +++++++++++ .../src/app/login/login.component.spec.ts | 25 ++++++++++++++ .../src/app/login/login.component.ts | 34 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 AstuteClient2/src/app/login/login.component.css create mode 100644 AstuteClient2/src/app/login/login.component.html create mode 100644 AstuteClient2/src/app/login/login.component.spec.ts create mode 100644 AstuteClient2/src/app/login/login.component.ts diff --git a/AstuteClient2/src/app/login/login.component.css b/AstuteClient2/src/app/login/login.component.css new file mode 100644 index 0000000..96b4030 --- /dev/null +++ b/AstuteClient2/src/app/login/login.component.css @@ -0,0 +1,3 @@ +input { + margin-bottom: 10px; +} diff --git a/AstuteClient2/src/app/login/login.component.html b/AstuteClient2/src/app/login/login.component.html new file mode 100644 index 0000000..75191a4 --- /dev/null +++ b/AstuteClient2/src/app/login/login.component.html @@ -0,0 +1,19 @@ +
+
+ + + + + + + + + +
+
diff --git a/AstuteClient2/src/app/login/login.component.spec.ts b/AstuteClient2/src/app/login/login.component.spec.ts new file mode 100644 index 0000000..d6d85a8 --- /dev/null +++ b/AstuteClient2/src/app/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/AstuteClient2/src/app/login/login.component.ts b/AstuteClient2/src/app/login/login.component.ts new file mode 100644 index 0000000..31ac549 --- /dev/null +++ b/AstuteClient2/src/app/login/login.component.ts @@ -0,0 +1,34 @@ +import {Component, OnInit, ViewEncapsulation} from '@angular/core'; +import {NgForm} from '@angular/forms'; +import {Router} from '@angular/router'; +import {AstuteClientService} from '../services/astute-client-service'; + +@Component({ + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.css'], + encapsulation: ViewEncapsulation.None +}) +export class LoginComponent implements OnInit { + + constructor(protected astuteClientService: AstuteClientService, + private router: Router) {} + + ngOnInit() { + localStorage.removeItem('SESSION_ID'); + localStorage.removeItem('SESSION_USER'); + } + + login(form: NgForm) { + const username = form.value.username; + const password = form.value.password; + + this.astuteClientService.login(username, password).then((data) => { + if (data) { + this.router.navigate(['/home']); + } else { + alert('login failed, checked credentials'); + } + }) + } +}