mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#17 Added onSuccess and onError eventEmitter
This commit is contained in:
@@ -5,4 +5,6 @@ export declare class AppComponent {
|
||||
auth: AlfrescoAuthenticationService;
|
||||
router: Router;
|
||||
constructor(auth: AlfrescoAuthenticationService, router: Router, alfrescoSettingsService: AlfrescoSettingsService);
|
||||
mySuccessMethod($event: any): void;
|
||||
myErrorMethod($event: any): void;
|
||||
}
|
||||
|
@@ -34,10 +34,16 @@ System.register(['angular2/core', 'ng2-alfresco-login/ng2-alfresco-login', 'angu
|
||||
this.router = router;
|
||||
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
|
||||
}
|
||||
AppComponent.prototype.mySuccessMethod = function ($event) {
|
||||
console.log('Success Login EventEmitt called with: ' + $event.value);
|
||||
};
|
||||
AppComponent.prototype.myErrorMethod = function ($event) {
|
||||
console.log('Error Login EventEmitt called with: ' + $event.value);
|
||||
};
|
||||
AppComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'my-app',
|
||||
template: '<alfresco-login></alfresco-login>',
|
||||
template: '<alfresco-login method="POST" (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>',
|
||||
directives: [router_1.ROUTER_DIRECTIVES, ng2_alfresco_login_1.AlfrescoLoginComponent]
|
||||
}),
|
||||
router_1.RouteConfig([
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAgBA;gBAEI,sBAAmB,IAAkC,EAClC,MAAa,EACpB,uBAA+C;oBAFxC,SAAI,GAAJ,IAAI,CAA8B;oBAClC,WAAM,GAAN,MAAM,CAAO;oBAE5B,uBAAuB,CAAC,IAAI,GAAG,4BAA4B,CAAC;gBAEhE,CAAC;gBAhBL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,mCAAmC;wBAC7C,UAAU,EAAE,CAAC,0BAAiB,EAAE,2CAAsB,CAAC;qBAC1D,CAAC;oBAED,oBAAW,CAAC;wBACT,EAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,2CAAsB,EAAE,YAAY,EAAE,IAAI,EAAC;qBACpF,CAAC;;gCAAA;gBAUF,mBAAC;YAAD,CAAC,AATD,IASC;YATD,uCASC,CAAA"}
|
||||
{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAgBA;gBAEI,sBAAmB,IAAkC,EAClC,MAAa,EACpB,uBAA+C;oBAFxC,SAAI,GAAJ,IAAI,CAA8B;oBAClC,WAAM,GAAN,MAAM,CAAO;oBAE5B,uBAAuB,CAAC,IAAI,GAAG,4BAA4B,CAAC;gBAEhE,CAAC;gBAED,sCAAe,GAAf,UAAgB,MAAM;oBAClB,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,CAAC;gBAED,oCAAa,GAAb,UAAc,MAAM;oBAChB,OAAO,CAAC,GAAG,CAAC,sCAAsC,GAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrE,CAAC;gBAxBL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,yHAAyH;wBACnI,UAAU,EAAE,CAAC,0BAAiB,EAAE,2CAAsB,CAAC;qBAC1D,CAAC;oBAED,oBAAW,CAAC;wBACT,EAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,2CAAsB,EAAE,YAAY,EAAE,IAAI,EAAC;qBACpF,CAAC;;gCAAA;gBAkBF,mBAAC;YAAD,CAAC,AAjBD,IAiBC;YAjBD,uCAiBC,CAAA"}
|
@@ -7,7 +7,7 @@ import {AlfrescoAuthenticationService} from 'ng2-alfresco-login/ng2-alfresco-log
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
template: '<alfresco-login></alfresco-login>',
|
||||
template: '<alfresco-login method="POST" (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>',
|
||||
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent]
|
||||
})
|
||||
|
||||
@@ -23,4 +23,12 @@ export class AppComponent {
|
||||
|
||||
}
|
||||
|
||||
mySuccessMethod($event) {
|
||||
console.log('Success Login EventEmitt called with: '+$event.value);
|
||||
}
|
||||
|
||||
myErrorMethod($event) {
|
||||
console.log('Error Login EventEmitt called with: '+$event.value);
|
||||
}
|
||||
|
||||
}
|
@@ -1,3 +1,20 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { EventEmitter } from 'angular2/core';
|
||||
import { Router } from 'angular2/router';
|
||||
import { ControlGroup, FormBuilder } from 'angular2/common';
|
||||
import { AlfrescoAuthenticationService } from '../services/alfresco-authentication';
|
||||
@@ -6,6 +23,8 @@ export declare class AlfrescoLoginComponent {
|
||||
auth: AlfrescoAuthenticationService;
|
||||
router: Router;
|
||||
method: string;
|
||||
onSuccess: EventEmitter<{}>;
|
||||
onError: EventEmitter<{}>;
|
||||
translate: TranslateService;
|
||||
form: ControlGroup;
|
||||
error: boolean;
|
||||
|
@@ -41,6 +41,8 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', '../serv
|
||||
this.auth = auth;
|
||||
this.router = router;
|
||||
this.method = 'POST';
|
||||
this.onSuccess = new core_1.EventEmitter();
|
||||
this.onError = new core_1.EventEmitter();
|
||||
this.error = false;
|
||||
this.success = false;
|
||||
this.form = fb.group({
|
||||
@@ -64,6 +66,9 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', '../serv
|
||||
.subscribe(function (token) {
|
||||
try {
|
||||
_this.success = true;
|
||||
_this.onSuccess.emit({
|
||||
value: 'Login OK'
|
||||
});
|
||||
_this.router.navigate(['Home']);
|
||||
}
|
||||
catch (error) {
|
||||
@@ -71,6 +76,9 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', '../serv
|
||||
}
|
||||
}, function (err) {
|
||||
_this.error = true;
|
||||
_this.onError.emit({
|
||||
value: 'Login KO'
|
||||
});
|
||||
console.log(err);
|
||||
_this.success = false;
|
||||
}, function () { return console.log('Login done'); });
|
||||
@@ -106,6 +114,14 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', '../serv
|
||||
core_1.Input(),
|
||||
__metadata('design:type', String)
|
||||
], AlfrescoLoginComponent.prototype, "method", void 0);
|
||||
__decorate([
|
||||
core_1.Output(),
|
||||
__metadata('design:type', Object)
|
||||
], AlfrescoLoginComponent.prototype, "onSuccess", void 0);
|
||||
__decorate([
|
||||
core_1.Output(),
|
||||
__metadata('design:type', Object)
|
||||
], AlfrescoLoginComponent.prototype, "onError", void 0);
|
||||
AlfrescoLoginComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'alfresco-login',
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"alfresco-login.js","sourceRoot":"","sources":["alfresco-login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCA;gBAQI;;;;;mBAKG;gBACH,gCAAY,EAAc,EACP,IAAkC,EAClC,MAAa,EACpB,SAA0B;oBAFnB,SAAI,GAAJ,IAAI,CAA8B;oBAClC,WAAM,GAAN,MA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AAC,CAAC,CAAC,kCAAkC;oBACnF,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;oBAExD,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAEpC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACjC,CAAC;gBA5FD;oBAAC,YAAK,EAAE;;sEAAA;gBACR;oBAAC,aAAM,EAAE;;yEAAA;gBACT;oBAAC,aAAM,EAAE;;uEAAA;gBAZb;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,gBAAgB;wBAC1B,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,0BAAiB,EAAE,wBAAe,CAAC;wBAChD,WAAW,EAAE,uBAAuB;wBACpC,SAAS,EAAE,CAAC,sBAAsB,CAAC;wBACnC,KAAK,EAAE,CAAC,6BAAa,CAAC;qBAEzB,CAAC;;0CAAA;gBA+FF,6BAAC;YAAD,CAAC,AA9FD,IA8FC;YA9FD,2DA8FC,CAAA"}
|
@@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {Component, Input} from 'angular2/core';
|
||||
import {Component, Input, Output, EventEmitter} from 'angular2/core';
|
||||
import {Router, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||
import {FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators} from 'angular2/common';
|
||||
import {AlfrescoAuthenticationService} from '../services/alfresco-authentication';
|
||||
@@ -33,6 +33,8 @@ declare let __moduleName:string;
|
||||
})
|
||||
export class AlfrescoLoginComponent {
|
||||
@Input() method:string = 'POST';
|
||||
@Output() onSuccess = new EventEmitter();
|
||||
@Output() onError = new EventEmitter();
|
||||
translate: TranslateService;
|
||||
|
||||
form:ControlGroup;
|
||||
@@ -73,6 +75,9 @@ export class AlfrescoLoginComponent {
|
||||
(token:any) => {
|
||||
try {
|
||||
this.success = true;
|
||||
this.onSuccess.emit({
|
||||
value: 'Login OK'
|
||||
});
|
||||
this.router.navigate(['Home']);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
@@ -81,6 +86,9 @@ export class AlfrescoLoginComponent {
|
||||
},
|
||||
(err:any) => {
|
||||
this.error = true;
|
||||
this.onError.emit({
|
||||
value: 'Login KO'
|
||||
});
|
||||
console.log(err);
|
||||
this.success = false;
|
||||
},
|
||||
|
Reference in New Issue
Block a user