Skip to content

Commit f537aa0

Browse files
authored
Merge pull request #17 from iyilm4z/master
#17 - Migrate account login to @angular/material components
2 parents c650223 + cbd8626 commit f537aa0

File tree

3 files changed

+75
-66
lines changed

3 files changed

+75
-66
lines changed
Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
1-
<div class="card" id="LoginArea" [@routerTransition]>
2-
<div #cardBody class="body">
3-
<form #loginForm="ngForm" id="LoginForm" method="post" novalidate (ngSubmit)="login()">
1+
<div class="card" [@routerTransition]>
2+
<div class="body">
3+
<form novalidate
4+
autocomplete="off"
5+
#loginForm="ngForm"
6+
(ngSubmit)="login()">
47
<h4 class="text-center">{{ "LogIn" | localize }}</h4>
5-
6-
<div class="input-group">
7-
<span class="input-group-addon">
8-
<i class="material-icons">person</i>
8+
<mat-form-field>
9+
<span matPrefix>
10+
<mat-icon matPrefix>person</mat-icon>&nbsp;
911
</span>
10-
<div class="form-line">
11-
<input materialInput [(ngModel)]="loginService.authenticateModel.userNameOrEmailAddress" autoFocus class="form-control" type="text" autocomplete="off" placeholder="{{ 'UserNameOrEmail' | localize }}" name="userNameOrEmailAddress" required maxlength="255" />
12-
</div>
13-
</div>
14-
15-
<div class="input-group">
16-
<span class="input-group-addon">
17-
<i class="material-icons">lock</i>
12+
<input matInput
13+
name="userNameOrEmailAddress"
14+
[(ngModel)]="loginService.authenticateModel.userNameOrEmailAddress"
15+
[placeholder]="'UserNameOrEmail' | localize"
16+
autocomplete="off"
17+
required
18+
maxlength="255">
19+
</mat-form-field>
20+
<mat-form-field>
21+
<span matPrefix>
22+
<mat-icon matPrefix>lock</mat-icon>&nbsp;
1823
</span>
19-
<div class="form-line">
20-
<input materialInput type="password" [(ngModel)]="loginService.authenticateModel.password" class="form-control" name="password" placeholder="{{ 'Password' | localize }}" required maxlength="32">
21-
</div>
22-
</div>
24+
<input matInput
25+
type="password"
26+
name="password"
27+
[(ngModel)]="loginService.authenticateModel.password"
28+
[placeholder]="'Password' | localize"
29+
required
30+
maxlength="32">
31+
</mat-form-field>
2332
<div class="row">
2433
<div class="col-xs-8 p-t-5">
25-
<input type="checkbox" [(ngModel)]="loginService.rememberMe" name="rememberMe" id="rememberme" class="filled-in chk-col-pink" value="true">
26-
<label for="rememberme">{{ "RememberMe" | localize }}</label>
34+
<mat-checkbox name="rememberMe" [(ngModel)]="loginService.rememberMe">
35+
{{ "RememberMe" | localize }}
36+
</mat-checkbox>
2737
</div>
2838
<div class="col-xs-4">
29-
<button id="LoginButton" class="btn btn-block bg-pink waves-effect" type="submit">{{ "LogIn" | localize }}</button>
39+
<button mat-flat-button
40+
type="submit"
41+
flex="15"
42+
color="accent"
43+
[disabled]="!loginForm.form.valid || submitting">
44+
{{ "LogIn" | localize }}
45+
</button>
3046
</div>
3147
</div>
32-
3348
<div class="row m-t-15 m-b--20" *ngIf="isSelfRegistrationAllowed">
3449
<div class="col-xs-12">
3550
<a [routerLink]="['../register']">{{ "Register" | localize }}</a>
3651
</div>
3752
</div>
3853
</form>
3954
</div>
40-
</div>
55+
</div>

angular/src/account/login/login.component.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@
1010
}
1111
}
1212
}
13+
14+
mat-form-field {
15+
width: 100%;
16+
}
17+
mat-checkbox {
18+
padding-bottom: 5px;
19+
}
Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,39 @@
1-
import { Component, Injector, ElementRef, ViewChild } from '@angular/core';
2-
import { Router } from '@angular/router';
1+
import { Component, Injector } from '@angular/core';
2+
import { AbpSessionService } from '@abp/session/abp-session.service';
33
import { AppComponentBase } from '@shared/app-component-base';
4-
import { LoginService } from './login.service';
54
import { accountModuleAnimation } from '@shared/animations/routerTransition';
6-
import { AbpSessionService } from '@abp/session/abp-session.service';
5+
import { LoginService } from './login.service';
76

87
@Component({
9-
templateUrl: './login.component.html',
10-
styleUrls: [
11-
'./login.component.less'
12-
],
13-
animations: [accountModuleAnimation()]
8+
templateUrl: './login.component.html',
9+
styleUrls: ['./login.component.less'],
10+
animations: [accountModuleAnimation()]
1411
})
1512
export class LoginComponent extends AppComponentBase {
16-
17-
@ViewChild('cardBody') cardBody: ElementRef;
18-
19-
submitting: boolean = false;
20-
21-
constructor(
22-
injector: Injector,
23-
public loginService: LoginService,
24-
private _router: Router,
25-
private _sessionService: AbpSessionService
26-
) {
27-
super(injector);
13+
submitting: boolean = false;
14+
15+
constructor(
16+
injector: Injector,
17+
private loginService: LoginService,
18+
private _sessionService: AbpSessionService
19+
) {
20+
super(injector);
21+
}
22+
23+
get multiTenancySideIsTeanant(): boolean {
24+
return this._sessionService.tenantId > 0;
25+
}
26+
27+
get isSelfRegistrationAllowed(): boolean {
28+
if (!this._sessionService.tenantId) {
29+
return false;
2830
}
2931

30-
ngAfterViewInit(): void {
31-
$(this.cardBody.nativeElement).find('input:first').focus();
32-
}
33-
34-
get multiTenancySideIsTeanant(): boolean {
35-
return this._sessionService.tenantId > 0;
36-
}
37-
38-
get isSelfRegistrationAllowed(): boolean {
39-
if (!this._sessionService.tenantId) {
40-
return false;
41-
}
32+
return true;
33+
}
4234

43-
return true;
44-
}
45-
46-
login(): void {
47-
this.submitting = true;
48-
this.loginService.authenticate(
49-
() => this.submitting = false
50-
);
51-
}
35+
login(): void {
36+
this.submitting = true;
37+
this.loginService.authenticate(() => (this.submitting = false));
38+
}
5239
}

0 commit comments

Comments
 (0)