mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#17 Added translation service as Login Dependency
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { Http } from 'angular2/http';
|
||||
import { AlfrescoSettingsService } from '../../ng2-alfresco-core/services';
|
||||
/**
|
||||
* The AlfrescoAuthenticationService provide the login service and store the token in the localStorage
|
||||
*/
|
||||
export declare class AlfrescoAuthenticationService {
|
||||
http: Http;
|
||||
private settings;
|
||||
token: string;
|
||||
private _host;
|
||||
private _baseUrl;
|
||||
@@ -9,7 +14,7 @@ export declare class AlfrescoAuthenticationService {
|
||||
* Constructor
|
||||
* @param http
|
||||
*/
|
||||
constructor(http: Http);
|
||||
constructor(http: Http, settings: AlfrescoSettingsService);
|
||||
/**
|
||||
* The method return tru if the user is logged in
|
||||
* @returns {boolean}
|
||||
|
@@ -1,10 +1,12 @@
|
||||
import { Router } from 'angular2/router';
|
||||
import { ControlGroup, FormBuilder } from 'angular2/common';
|
||||
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
|
||||
import { TranslateService } from 'ng2-translate/ng2-translate';
|
||||
export declare class AlfrescoLoginComponent {
|
||||
auth: AlfrescoAuthenticationService;
|
||||
router: Router;
|
||||
method: string;
|
||||
translate: TranslateService;
|
||||
form: ControlGroup;
|
||||
error: boolean;
|
||||
/**
|
||||
@@ -13,7 +15,7 @@ export declare class AlfrescoLoginComponent {
|
||||
* @param auth
|
||||
* @param router
|
||||
*/
|
||||
constructor(fb: FormBuilder, auth: AlfrescoAuthenticationService, router: Router);
|
||||
constructor(fb: FormBuilder, auth: AlfrescoAuthenticationService, router: Router, translate: TranslateService);
|
||||
/**
|
||||
* Method called on submit form
|
||||
* @param value
|
||||
@@ -26,4 +28,9 @@ export declare class AlfrescoLoginComponent {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isErrorStyle(field: ControlGroup): boolean;
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
*/
|
||||
translationInit(translate: TranslateService): void;
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './alfre
|
||||
* @param auth
|
||||
* @param router
|
||||
*/
|
||||
function AlfrescoLoginComponent(fb, auth, router) {
|
||||
function AlfrescoLoginComponent(fb, auth, router, translate) {
|
||||
this.auth = auth;
|
||||
this.router = router;
|
||||
this.method = 'GET';
|
||||
@@ -46,6 +46,7 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './alfre
|
||||
username: ['', common_1.Validators.compose([common_1.Validators.required, common_1.Validators.minLength(4)])],
|
||||
password: ['', common_1.Validators.required]
|
||||
});
|
||||
this.translationInit(translate);
|
||||
}
|
||||
/**
|
||||
* Method called on submit form
|
||||
@@ -78,6 +79,17 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './alfre
|
||||
return true;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
*/
|
||||
AlfrescoLoginComponent.prototype.translationInit = function (translate) {
|
||||
this.translate = translate;
|
||||
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
||||
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
||||
this.translate.setDefaultLang('en');
|
||||
this.translate.use(userLang);
|
||||
};
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', String)
|
||||
@@ -91,7 +103,7 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './alfre
|
||||
styleUrls: ['./alfresco-login.component.css'],
|
||||
pipes: [ng2_translate_1.TranslatePipe]
|
||||
}),
|
||||
__metadata('design:paramtypes', [common_1.FormBuilder, alfresco_authentication_service_1.AlfrescoAuthenticationService, router_1.Router])
|
||||
__metadata('design:paramtypes', [common_1.FormBuilder, alfresco_authentication_service_1.AlfrescoAuthenticationService, router_1.Router, ng2_translate_1.TranslateService])
|
||||
], AlfrescoLoginComponent);
|
||||
return A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AC;oBAExD,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAEpC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACjC,CAAC;gBAvED;oBAAC,YAAK,EAAE;;sEAAA;gBAVZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,gBAAgB;wBAC1B,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,0BAAiB,EAAE,wBAAe,CAAC;wBAChD,WAAW,EAAE,iCAAiC;wBAC9C,SAAS,EAAE,CAAC,gCAAgC,CAAC;wBAC7C,KAAK,EAAE,CAAC,6BAAa,CAAC;qBAEzB,CAAC;;0CAAA;gBA0EF,6BAAC;YAAD,CAAC,AAzED,IAyEC;YAzED,2DAyEC,CAAA"}
|
@@ -18,7 +18,7 @@ import {Component, Input} from 'angular2/core';
|
||||
import {Router, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||
import {FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators} from 'angular2/common';
|
||||
import {AlfrescoAuthenticationService} from './alfresco-authentication.service';
|
||||
import {TranslatePipe} from 'ng2-translate/ng2-translate';
|
||||
import {TranslateService, TranslatePipe} from 'ng2-translate/ng2-translate';
|
||||
declare let componentHandler;
|
||||
declare let __moduleName:string;
|
||||
|
||||
@@ -33,6 +33,7 @@ declare let __moduleName:string;
|
||||
})
|
||||
export class AlfrescoLoginComponent {
|
||||
@Input() method:string = 'GET';
|
||||
translate: TranslateService;
|
||||
|
||||
form:ControlGroup;
|
||||
error:boolean = false;
|
||||
@@ -43,11 +44,17 @@ export class AlfrescoLoginComponent {
|
||||
* @param auth
|
||||
* @param router
|
||||
*/
|
||||
constructor(fb:FormBuilder, public auth:AlfrescoAuthenticationService, public router:Router) {
|
||||
constructor(fb:FormBuilder,
|
||||
public auth:AlfrescoAuthenticationService,
|
||||
public router:Router,
|
||||
translate:TranslateService
|
||||
) {
|
||||
this.form = fb.group({
|
||||
username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
|
||||
password: ['', Validators.required]
|
||||
});
|
||||
|
||||
this.translationInit(translate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,4 +90,18 @@ export class AlfrescoLoginComponent {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
*/
|
||||
translationInit(translate: TranslateService) {
|
||||
this.translate = translate;
|
||||
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
||||
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
||||
|
||||
this.translate.setDefaultLang('en');
|
||||
|
||||
this.translate.use(userLang);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user