mirror of
https://github.com/dyiop/astute.git
synced 2025-04-09 06:40:20 -04:00
Add files via upload
This commit is contained in:
parent
cb14fafe06
commit
b115829ae7
3
AstuteClient2/src/app/login/login.component.css
Normal file
3
AstuteClient2/src/app/login/login.component.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
input {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
19
AstuteClient2/src/app/login/login.component.html
Normal file
19
AstuteClient2/src/app/login/login.component.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<div class="page" style="width: 35%; margin: 20px auto auto;">
|
||||||
|
<form class="form-signin" (ngSubmit)="login(f)" #f="ngForm" style="margin-bottom: 10px">
|
||||||
|
<h2 class="form-signin-heading">Login</h2>
|
||||||
|
|
||||||
|
<label for="username" class="sr-only">Username</label>
|
||||||
|
<input class="form-control" type="text" id="username" name="username" ngModel placeholder="Username">
|
||||||
|
|
||||||
|
<label for="password" class="sr-only">Password</label>
|
||||||
|
<input
|
||||||
|
class="form-control"
|
||||||
|
type="password"
|
||||||
|
id="password"
|
||||||
|
name="password"
|
||||||
|
ngModel
|
||||||
|
placeholder="Password">
|
||||||
|
|
||||||
|
<button class="btn btn-primary" type="submit" style="float: right">Log in</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
25
AstuteClient2/src/app/login/login.component.spec.ts
Normal file
25
AstuteClient2/src/app/login/login.component.spec.ts
Normal file
|
@ -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<LoginComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ LoginComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(LoginComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
34
AstuteClient2/src/app/login/login.component.ts
Normal file
34
AstuteClient2/src/app/login/login.component.ts
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user