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, OnInit } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
import { CoreModule, LogService } from 'ng2-alfresco-core';
|
||||
import { SearchModule } from 'ng2-alfresco-search';
|
||||
|
||||
import {
|
||||
@@ -50,16 +50,14 @@ import {
|
||||
class SearchDemo implements OnInit {
|
||||
|
||||
authenticated: boolean;
|
||||
|
||||
public searchTerm: string = 'test';
|
||||
|
||||
public ecmHost: string = 'http://localhost:8080';
|
||||
|
||||
searchTerm: string = 'test';
|
||||
ecmHost: string = 'http://localhost:8080';
|
||||
ticket: string;
|
||||
|
||||
constructor(private authService: AuthService,
|
||||
private settingsService: SettingsService,
|
||||
translation: AlfrescoTranslationService) {
|
||||
translation: AlfrescoTranslationService,
|
||||
private logService: LogService) {
|
||||
|
||||
settingsService.ecmHost = this.ecmHost;
|
||||
settingsService.setProviders('ECM');
|
||||
@@ -79,18 +77,18 @@ class SearchDemo implements OnInit {
|
||||
login() {
|
||||
this.authService.login('admin', 'admin').subscribe(
|
||||
ticket => {
|
||||
console.log(ticket);
|
||||
this.logService.info(ticket);
|
||||
this.ticket = this.authService.getTicketEcm();
|
||||
this.authenticated = true;
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
this.logService.error(error);
|
||||
this.authenticated = false;
|
||||
});
|
||||
}
|
||||
|
||||
searchTermChange(event) {
|
||||
console.log('Search term changed', event);
|
||||
this.logService.info('Search term changed', event);
|
||||
this.searchTerm = event.value;
|
||||
}
|
||||
}
|
||||
|
@@ -28,10 +28,10 @@ import {
|
||||
SettingsService,
|
||||
AlfrescoApiService,
|
||||
AuthService,
|
||||
ContentService,
|
||||
AlfrescoTranslateService,
|
||||
CoreModule,
|
||||
StorageService
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
|
||||
describe('AlfrescoSearchComponent', () => {
|
||||
@@ -102,18 +102,13 @@ describe('AlfrescoSearchComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
declarations: [ AlfrescoSearchComponent ], // declare the test component
|
||||
providers: [
|
||||
AlfrescoSearchService,
|
||||
{provide: AlfrescoTranslateService, useClass: TranslationMock},
|
||||
AlfrescoThumbnailService,
|
||||
SettingsService,
|
||||
AlfrescoApiService,
|
||||
AuthService,
|
||||
ContentService,
|
||||
StorageService
|
||||
AlfrescoThumbnailService
|
||||
]
|
||||
}).compileComponents().then(() => {
|
||||
fixture = TestBed.createComponent(AlfrescoSearchComponent);
|
||||
@@ -123,9 +118,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
}));
|
||||
|
||||
it('should not have a search term by default', () => {
|
||||
let search = new AlfrescoSearchComponent(null, null, null, null);
|
||||
expect(search).toBeDefined();
|
||||
expect(search.searchTerm).toBe('');
|
||||
expect(component.searchTerm).toBe('');
|
||||
});
|
||||
|
||||
it('should take the provided search term from query param provided via RouteParams', () => {
|
||||
@@ -144,6 +137,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
SettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService,
|
||||
{ provide: ActivatedRoute, useValue: { params: Observable.from([{}]) } }
|
||||
]);
|
||||
let search = new AlfrescoSearchComponent(injector.get(AlfrescoSearchService), null, null, injector.get(ActivatedRoute));
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { AlfrescoSearchService } from './alfresco-search.service';
|
||||
import { AuthService, SettingsService, AlfrescoApiService, StorageService } from 'ng2-alfresco-core';
|
||||
import { AuthService, SettingsService, AlfrescoApiService, StorageService, LogService } from 'ng2-alfresco-core';
|
||||
import { fakeApi, fakeSearch, fakeError } from '../assets/alfresco-search.service.mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
@@ -34,7 +34,8 @@ describe('AlfrescoSearchService', () => {
|
||||
SettingsService,
|
||||
AlfrescoApiService,
|
||||
AuthService,
|
||||
StorageService
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
service = injector.get(AlfrescoSearchService);
|
||||
apiService = injector.get(AlfrescoApiService);
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
|
||||
import { AlfrescoApiService, AuthService, ContentService, SettingsService, StorageService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoApiService, AuthService, ContentService, SettingsService, StorageService, LogService } from 'ng2-alfresco-core';
|
||||
|
||||
describe('AlfrescoThumbnailService', () => {
|
||||
|
||||
@@ -31,7 +31,8 @@ describe('AlfrescoThumbnailService', () => {
|
||||
ContentService,
|
||||
SettingsService,
|
||||
AlfrescoThumbnailService,
|
||||
StorageService
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
|
||||
service = injector.get(AlfrescoThumbnailService);
|
||||
|
Reference in New Issue
Block a user