rename two times service class just once

move responsability providers configurration in setting service
refactoring
This commit is contained in:
Eugenio Romano
2016-08-16 17:46:34 +01:00
parent 560bef7c1d
commit dc19e45e7b
18 changed files with 183 additions and 178 deletions

View File

@@ -15,12 +15,13 @@
* limitations under the License.
*/
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from '@angular/common';
import {Component, Input, Output, EventEmitter} from '@angular/core';
import {FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators} from '@angular/common';
import {
AlfrescoTranslationService,
AlfrescoPipeTranslate,
AlfrescoAuthenticationService
AlfrescoAuthenticationService,
AlfrescoSettingsService
} from 'ng2-alfresco-core';
declare let componentHandler: any;
@@ -67,11 +68,13 @@ export class AlfrescoLoginComponent {
/**
* Constructor
* @param _fb
* @param auth
* @param authService
* @param settingService
* @param translate
*/
constructor(private _fb: FormBuilder,
public auth: AlfrescoAuthenticationService,
public authService: AlfrescoAuthenticationService,
public settingService: AlfrescoSettingsService,
private translate: AlfrescoTranslationService) {
this.formError = {
@@ -79,7 +82,7 @@ export class AlfrescoLoginComponent {
'password': ''
};
this.form = this._fb.group({
this.form = this._fb.group({
username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
password: ['', Validators.required]
});
@@ -104,12 +107,15 @@ export class AlfrescoLoginComponent {
* @param value
* @param event
*/
onSubmit(value: any, event) {
onSubmit(value: any, event: any) {
this.error = false;
if (event) {
event.preventDefault();
}
this.auth.login(value.username, value.password, this.providers)
this.settingService.setProviders(this.providers);
this.authService.login(value.username, value.password)
.subscribe(
(token: any) => {
this.success = true;