mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
40
demo-shell-ng2/app/components/login.component.css
Normal file
40
demo-shell-ng2/app/components/login.component.css
Normal file
@@ -0,0 +1,40 @@
|
||||
body {
|
||||
padding-top: 40px;
|
||||
padding-bottom: 40px;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.form-signin {
|
||||
max-width: 330px;
|
||||
padding: 15px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.form-signin .form-signin-heading,
|
||||
.form-signin .checkbox {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.form-signin .checkbox {
|
||||
font-weight: normal;
|
||||
}
|
||||
.form-signin .form-control {
|
||||
position: relative;
|
||||
height: auto;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
padding: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.form-signin .form-control:focus {
|
||||
z-index: 2;
|
||||
}
|
||||
.form-signin input[type="username"] {
|
||||
margin-bottom: -1px;
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
.form-signin input[type="password"] {
|
||||
margin-bottom: 10px;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
29
demo-shell-ng2/app/components/login.component.html
Normal file
29
demo-shell-ng2/app/components/login.component.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<form [ngFormModel]="form" (submit)="onSubmit(form.value, $event)" class="form-signin">
|
||||
<div [ngClass]="{'has-error': isErrorStyle(form.controls.username)}" class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input id="username" class="form-control " type="text" placeholder="username" ngControl="username">
|
||||
<div [hidden]="form.controls.username.valid || form.controls.username.pristine" class="alert alert-danger">
|
||||
<p *ngIf="form.controls.username.dirty && form.controls.username.errors && form.controls.username.errors.minlength">
|
||||
Your username needs to be at least 4 characters.
|
||||
</p>
|
||||
<p *ngIf="form.controls.username.hasError('required')">
|
||||
Username is required
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div [ngClass]="{'has-error': isErrorStyle(form.controls.password)}" class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input id="password" class="form-control" type="password" placeholder="password" ngControl="password">
|
||||
<div [hidden]="form.controls.password.valid || form.controls.password.pristine" class="alert alert-danger">
|
||||
<p *ngIf="form.controls.password.hasError('required')">
|
||||
Password is required
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-lg btn-primary btn-block" [disabled]="!form.valid">Login</button>
|
||||
<div *ngIf="error" class="alert alert-danger">You have entered an invalid username or password</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@@ -5,9 +5,10 @@ import {Authentication} from '../services/authentication';
|
||||
|
||||
@Component({
|
||||
selector: 'login',
|
||||
moduleId: 'app/components/login',
|
||||
directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
|
||||
templateUrl: 'app/template/login.component.html',
|
||||
styleUrls: ['app/style/login.component.css'],
|
||||
templateUrl: 'login.component.html',
|
||||
styleUrls: ['login.component.css'],
|
||||
})
|
||||
export class Login {
|
||||
form:ControlGroup;
|
||||
@@ -29,7 +30,9 @@ export class Login {
|
||||
}
|
||||
|
||||
onSubmit(value:any, event) {
|
||||
event.preventDefault();
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
this.auth.login('POST', value.username, value.password)
|
||||
.subscribe(
|
||||
(token:any) => this.router.navigate(['Home']),
|
||||
|
Reference in New Issue
Block a user