Migrate from window.console to LogService

This commit is contained in:
Denys Vuika
2017-01-05 21:06:30 +00:00
parent 2d98a04f87
commit d42f41ec00
106 changed files with 1177 additions and 1171 deletions

View File

@@ -19,9 +19,8 @@ import { NgModule, Component, OnInit } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { UserInfoComponentModule } from 'ng2-alfresco-userinfo';
import { CoreModule } from 'ng2-alfresco-core';
import { CoreModule, AuthService, SettingsService, LogService } from 'ng2-alfresco-core';
import { LoginModule } from 'ng2-alfresco-login';
import { AuthService, SettingsService } from 'ng2-alfresco-core';
@Component({
selector: 'alfresco-app-demo',
@@ -74,26 +73,21 @@ import { AuthService, SettingsService } from 'ng2-alfresco-core';
})
class UserInfoDemo implements OnInit {
public ecmHost: string = 'http://localhost:8080';
public bpmHost: string = 'http://localhost:9999';
public userToLogin: string = 'admin';
public password: string = 'admin';
public loginErrorMessage: string;
public providers: string = 'BPM';
ecmHost: string = 'http://localhost:8080';
bpmHost: string = 'http://localhost:9999';
userToLogin: string = 'admin';
password: string = 'admin';
loginErrorMessage: string;
providers: string = 'BPM';
private authenticated: boolean;
private token: any;
public disableCsrf: boolean = false;
disableCsrf: boolean = false;
constructor(private authService: AuthService,
private settingsService: SettingsService) {
private settingsService: SettingsService,
private logService: LogService) {
settingsService.ecmHost = this.ecmHost;
settingsService.bpmHost = this.bpmHost;
}
@@ -110,12 +104,12 @@ class UserInfoDemo implements OnInit {
this.settingsService.setProviders(this.providers);
this.authService.login(user, password).subscribe(
token => {
console.log(token);
this.logService.info(token);
this.token = token;
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
this.loginErrorMessage = error;
});

View File

@@ -15,10 +15,10 @@
* limitations under the License.
*/
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { BpmUserModel } from '../models/bpm-user.model';
/**
*
@@ -29,7 +29,8 @@ import { BpmUserModel } from '../models/bpm-user.model';
@Injectable()
export class BpmUserService {
constructor(private alfrescoJsApi: AlfrescoApiService) {
constructor(private alfrescoJsApi: AlfrescoApiService,
private logService: LogService) {
}
/**
@@ -54,7 +55,7 @@ export class BpmUserService {
private handleError(error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}

View File

@@ -18,7 +18,7 @@
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { ContentService, AlfrescoApiService } from 'ng2-alfresco-core';
import { ContentService, AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { EcmUserModel } from '../models/ecm-user.model';
/**
*
@@ -30,7 +30,8 @@ import { EcmUserModel } from '../models/ecm-user.model';
export class EcmUserService {
constructor(private apiService: AlfrescoApiService,
private contentService: ContentService) {
private contentService: ContentService,
private logService: LogService) {
}
/**
@@ -68,7 +69,7 @@ export class EcmUserService {
private handleError(error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}