#17 Added "method" property to alfresco login component

This commit is contained in:
mauriziovitale84
2016-04-22 17:33:29 +01:00
parent b1f884401b
commit 66f2e380ab
5 changed files with 14 additions and 5 deletions

View File

@@ -85,6 +85,7 @@
</div>
<main class="mdl-layout__content">
<div class="page-content">
<alfresco-login method="{{methodName}}"></alfresco-login>
<!--<router-outlet></router-outlet>-->
<auth-router-outlet></auth-router-outlet>
</div>

View File

@@ -13,10 +13,11 @@ import {Login} from 'ng2-alfresco-login/ng2-alfresco-login';
@Component({
selector: 'my-login',
template: ' <alfresco-login></alfresco-login>',
template: ' <alfresco-login method="{{methodName}}"></alfresco-login>',
directives: [Login]
})
export class MyLoginComponent {
methodName: string = 'POST';
}
```

View File

@@ -37,6 +37,7 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe
function Login(fb, auth, router) {
this.auth = auth;
this.router = router;
this.method = 'GET';
this.error = false;
this.form = fb.group({
username: ['', common_1.Validators.compose([common_1.Validators.required, common_1.Validators.minLength(4)])],
@@ -53,7 +54,7 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe
if (event) {
event.preventDefault();
}
this.auth.login('POST', value.username, value.password)
this.auth.login(this.method, value.username, value.password)
.subscribe(function (token) { return _this.router.navigate(['Home']); }, function () {
_this.error = true;
});
@@ -72,6 +73,10 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe
return true;
}
};
__decorate([
core_1.Input(),
__metadata('design:type', String)
], Login.prototype, "method", void 0);
Login = __decorate([
core_1.Component({
selector: 'alfresco-login',

View File

@@ -1 +1 @@
{"version":3,"file":"login.component.js","sourceRoot":"","sources":["login.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAcA;gBAII;;;;;mBAKG;gBACH,eAAY,EAAc,EAAS,IAAmB,EAAS,MAAa;oBAAzC,SAAI,GAAJ,IAAI,CAAe;oBAAS,WAAM,GAAN,MAAM,CAAO;oBAR5E,UAAK,GAAW,KAAK,CAAC;oBASlB,IAAI,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4BAAY,GAAZ,UAAa,KAAkB;oBAC3B,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;oBACxC,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;wBACd,MAAM,CAAC,KAAK,CAAC;oBACjB,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,MAAM,CAAC,IAAI,CAAC;oBAChB,CAAC;gBACL,CAAC;gBAhDD;oBAAC,YAAK,EAAE;;qDAAA;gBATZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,gBAAgB;wBAC1B,QAAQ,EAAE,sCAAsC;wBAChD,UAAU,EAAE,CAAC,0BAAiB,EAAE,wBAAe,CAAC;wBAChD,WAAW,EAAE,sBAAsB;wBACnC,SAAS,EAAE,CAAC,qBAAqB,CAAC;qBAErC,CAAC;;yBAAA;gBAmDF,YAAC;YAAD,CAAC,AAlDD,IAkDC;YAlDD,yBAkDC,CAAA"}

View File

@@ -1,4 +1,4 @@
import {Component} from 'angular2/core';
import {Component, Input} from 'angular2/core';
import {Router, ROUTER_DIRECTIVES} from 'angular2/router';
import {FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators} from 'angular2/common';
import {Authentication} from './authentication.service';
@@ -13,6 +13,8 @@ declare let componentHandler;
})
export class Login {
@Input() method: string = 'GET';
form:ControlGroup;
error:boolean = false;
@@ -38,7 +40,7 @@ export class Login {
if (event) {
event.preventDefault();
}
this.auth.login('POST', value.username, value.password)
this.auth.login(this.method, value.username, value.password)
.subscribe(
(token:any) => this.router.navigate(['Home']),
() => {