mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Migrate from window.console to LogService
This commit is contained in:
@@ -19,7 +19,7 @@ import { NgModule, Component } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { CoreModule, SettingsService, AuthService, StorageService } from 'ng2-alfresco-core';
|
||||
import { CoreModule, SettingsService, AuthService, StorageService, LogService } from 'ng2-alfresco-core';
|
||||
import { LoginModule } from 'ng2-alfresco-login';
|
||||
|
||||
@Component({
|
||||
@@ -61,41 +61,37 @@ import { LoginModule } from 'ng2-alfresco-login';
|
||||
})
|
||||
export class AppComponent {
|
||||
|
||||
public ecmHost: string = 'http://localhost:8080';
|
||||
ecmHost: string = 'http://localhost:8080';
|
||||
bpmHost: string = 'http://localhost:9999';
|
||||
ticket: string;
|
||||
status: string = '';
|
||||
providers: string = 'ECM';
|
||||
disableCsrf: boolean = false;
|
||||
|
||||
public bpmHost: string = 'http://localhost:9999';
|
||||
|
||||
public ticket: string;
|
||||
|
||||
public status: string = '';
|
||||
|
||||
public providers: string = 'ECM';
|
||||
|
||||
public disableCsrf: boolean = false;
|
||||
|
||||
constructor(public authService: AuthService,
|
||||
constructor(private authService: AuthService,
|
||||
private settingsService: SettingsService,
|
||||
private storage: StorageService) {
|
||||
private storage: StorageService,
|
||||
private logService: LogService) {
|
||||
|
||||
settingsService.ecmHost = this.ecmHost;
|
||||
settingsService.bpmHost = this.bpmHost;
|
||||
}
|
||||
|
||||
public updateEcmHost(): void {
|
||||
updateEcmHost(): void {
|
||||
this.settingsService.ecmHost = this.ecmHost;
|
||||
}
|
||||
|
||||
public updateBpmHost(): void {
|
||||
updateBpmHost(): void {
|
||||
this.settingsService.bpmHost = this.bpmHost;
|
||||
}
|
||||
|
||||
mySuccessMethod($event) {
|
||||
console.log('Success Login EventEmitt called with: ' + $event.value);
|
||||
this.logService.info('Success Login EventEmitt called with: ' + $event.value);
|
||||
this.status = $event.value;
|
||||
}
|
||||
|
||||
myErrorMethod($event) {
|
||||
console.log('Error Login EventEmitt called with: ' + $event.value);
|
||||
this.logService.error('Error Login EventEmitt called with: ' + $event.value);
|
||||
this.status = $event.value;
|
||||
}
|
||||
|
||||
|
@@ -17,13 +17,8 @@
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import {
|
||||
AuthService,
|
||||
SettingsService,
|
||||
AlfrescoApiService,
|
||||
CoreModule
|
||||
} from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { AuthService, CoreModule } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoLoginComponent } from './alfresco-login.component';
|
||||
import { AuthenticationMock } from './../assets/authentication.service.mock';
|
||||
import { TranslationMock } from './../assets/translation.service.mock';
|
||||
@@ -39,15 +34,12 @@ describe('AlfrescoLogin', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
declarations: [AlfrescoLoginComponent],
|
||||
providers: [
|
||||
SettingsService,
|
||||
AuthService,
|
||||
AlfrescoApiService,
|
||||
{provide: AuthService, useClass: AuthenticationMock},
|
||||
{provide: AlfrescoTranslationService, useClass: TranslationMock}
|
||||
{provide: AlfrescoTranslateService, useClass: TranslationMock}
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
@@ -17,11 +17,7 @@
|
||||
|
||||
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import {
|
||||
AlfrescoTranslationService,
|
||||
AuthService,
|
||||
SettingsService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslateService, AuthService, SettingsService, LogService } from 'ng2-alfresco-core';
|
||||
import { FormSubmitEvent } from '../models/form-submit-event.model';
|
||||
|
||||
declare let componentHandler: any;
|
||||
@@ -79,11 +75,14 @@ export class AlfrescoLoginComponent implements OnInit {
|
||||
* @param translate
|
||||
*/
|
||||
constructor(private _fb: FormBuilder,
|
||||
public authService: AuthService,
|
||||
public settingsService: SettingsService,
|
||||
private translate: AlfrescoTranslationService) {
|
||||
private authService: AuthService,
|
||||
private settingsService: SettingsService,
|
||||
private translateService: AlfrescoTranslateService,
|
||||
private logService: LogService) {
|
||||
|
||||
translate.addTranslationFolder('ng2-alfresco-login', 'node_modules/ng2-alfresco-login/src');
|
||||
if (translateService) {
|
||||
translateService.addTranslationFolder('ng2-alfresco-login', 'node_modules/ng2-alfresco-login/src');
|
||||
}
|
||||
|
||||
this.initFormError();
|
||||
this.initFormFieldsMessages();
|
||||
@@ -160,9 +159,9 @@ export class AlfrescoLoginComponent implements OnInit {
|
||||
this.enableError();
|
||||
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CREDENTIALS';
|
||||
this.onError.emit(err);
|
||||
console.log(err);
|
||||
this.logService.error(err);
|
||||
},
|
||||
() => console.log('Login done')
|
||||
() => this.logService.info('Login done')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -175,7 +174,7 @@ export class AlfrescoLoginComponent implements OnInit {
|
||||
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-PROVIDERS';
|
||||
this.enableError();
|
||||
let messageProviders: any;
|
||||
messageProviders = this.translate.get(this.errorMsg);
|
||||
messageProviders = this.translateService.get(this.errorMsg);
|
||||
this.onError.emit(messageProviders.value);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user