diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts index 18273cbe1d..97a14e3c9a 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts @@ -15,10 +15,10 @@ * limitations under the License. */ -import {it, describe, beforeEach, afterEach} from '@angular/core/testing'; -import {ReflectiveInjector, provide} from '@angular/core'; -import {AlfrescoSettingsService} from './AlfrescoSettings.service'; -import {AlfrescoAuthenticationService} from './AlfrescoAuthentication.service'; +import { it, describe, beforeEach, afterEach } from '@angular/core/testing'; +import { ReflectiveInjector } from '@angular/core'; +import { AlfrescoSettingsService } from './AlfrescoSettings.service'; +import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service'; import { AlfrescoApiService } from './AlfrescoApi.service'; declare var AlfrescoApi: any; diff --git a/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts b/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts index a54433b541..f5a2fe863d 100644 --- a/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts +++ b/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts @@ -19,7 +19,7 @@ import {describe, expect, it, inject, beforeEachProviders, beforeEach} from '@an import {TestComponentBuilder} from '@angular/compiler/testing'; import {ViewerComponent} from './viewer.component'; import {EventMock} from './assets/event.mock'; -import {AlfrescoAuthenticationService, AlfrescoSettingsService} from 'ng2-alfresco-core'; +import { AlfrescoApiService, AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; describe('ViewerComponent', () => { @@ -27,6 +27,7 @@ describe('ViewerComponent', () => { beforeEachProviders(() => { return [ + AlfrescoApiService, AlfrescoSettingsService, AlfrescoAuthenticationService ]; diff --git a/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts b/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts index 4fb0dfc7f3..de03a029ac 100644 --- a/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts +++ b/ng2-components/ng2-alfresco-viewer/src/viewer.component.ts @@ -20,7 +20,8 @@ import { PdfViewerComponent } from './pdfViewer.component'; import { ImgViewerComponent } from './imgViewer.component'; import { NotSupportedFormat } from './notSupportedFormat.component'; import { DOCUMENT } from '@angular/platform-browser'; -import { AlfrescoAuthenticationService} from 'ng2-alfresco-core'; +import { MinimalNodeEntryEntity } from 'alfresco-js-api'; +import { AlfrescoApiService } from 'ng2-alfresco-core'; declare let __moduleName: string; @@ -61,7 +62,9 @@ export class ViewerComponent { loaded: boolean = false; - constructor(private authService: AlfrescoAuthenticationService, private element: ElementRef, @Inject(DOCUMENT) private document) { + constructor(private apiService: AlfrescoApiService, + private element: ElementRef, + @Inject(DOCUMENT) private document) { } ngOnChanges(changes) { @@ -72,15 +75,16 @@ export class ViewerComponent { throw new Error('Attribute urlFile or fileNodeId is required'); } return new Promise((resolve) => { + let alfrescoApi = this.apiService.getInstance(); if (this.urlFile) { let filenameFromUrl = this.getFilenameFromUrl(this.urlFile); this.displayName = filenameFromUrl ? filenameFromUrl : ''; this.extension = this.getFileExtension(filenameFromUrl); } else if (this.fileNodeId) { - this.authService.getAlfrescoApi().nodes.getNodeInfo(this.fileNodeId).then((data) => { + alfrescoApi.nodes.getNodeInfo(this.fileNodeId).then((data: MinimalNodeEntryEntity) => { this.mimeType = data.content.mimeType; this.displayName = data.name; - this.urlFile = this.authService.getAlfrescoApi().content.getContentUrl(data.id); + this.urlFile = alfrescoApi.content.getContentUrl(data.id); this.loaded = true; }, function (error) { console.log('This node does not exist');