diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts index e72f85c22c..5323da124d 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts @@ -17,14 +17,21 @@ import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; -import { FileUploadingDialogComponent } from './file-uploading-dialog.component'; -import { FileModel } from '../models/file.model'; -import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; -import { TranslationMock } from '../assets/translation.service.mock'; -import { UploadService } from '../services/upload.service'; import { Observable } from 'rxjs/Observable'; import { HTTP_PROVIDERS } from '@angular/http'; +import { + AlfrescoTranslationService, + AlfrescoSettingsService, + AlfrescoAuthenticationService, + AlfrescoApiService +} from 'ng2-alfresco-core'; + +import { FileUploadingDialogComponent } from './file-uploading-dialog.component'; +import { FileModel } from '../models/file.model'; +import { TranslationMock } from '../assets/translation.service.mock'; +import { UploadService } from '../services/upload.service'; + describe('FileUploadDialog', () => { let componentFixture; @@ -33,6 +40,7 @@ describe('FileUploadDialog', () => { beforeEachProviders(() => { return [ HTTP_PROVIDERS, + AlfrescoApiService, AlfrescoSettingsService, AlfrescoAuthenticationService, { provide: AlfrescoTranslationService, useClass: TranslationMock }, diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts index 25081c240b..ad311a00ba 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts @@ -17,11 +17,18 @@ import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; +import { HTTP_PROVIDERS } from '@angular/http'; + +import { + AlfrescoTranslationService, + AlfrescoSettingsService, + AlfrescoAuthenticationService, + AlfrescoApiService +} from 'ng2-alfresco-core'; + import { UploadButtonComponent } from './upload-button.component'; -import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { TranslationMock } from '../assets/translation.service.mock'; import { UploadService } from '../services/upload.service'; -import { HTTP_PROVIDERS } from '@angular/http'; declare var AlfrescoApi: any; @@ -71,6 +78,7 @@ describe('AlfrescoUploadButton', () => { HTTP_PROVIDERS, AlfrescoSettingsService, AlfrescoAuthenticationService, + AlfrescoApiService, { provide: AlfrescoTranslationService, useClass: TranslationMock }, UploadService ]; diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts index d90e49f0f9..c4c79ae0ec 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts @@ -18,7 +18,7 @@ import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; import { UploadDragAreaComponent } from './upload-drag-area.component'; -import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core'; import { TranslationMock } from '../assets/translation.service.mock'; import { UploadService } from '../services/upload.service'; import { HTTP_PROVIDERS } from '@angular/http'; @@ -39,6 +39,7 @@ describe('AlfrescoUploadDragArea', () => { HTTP_PROVIDERS, AlfrescoSettingsService, AlfrescoAuthenticationService, + AlfrescoApiService, { provide: AlfrescoTranslationService, useClass: TranslationMock }, UploadService ]; diff --git a/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts b/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts index b0b220c4e5..289b92cb40 100644 --- a/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts @@ -18,7 +18,7 @@ import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing'; import { EventEmitter } from '@angular/core'; import { UploadService } from './upload.service'; -import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { AlfrescoSettingsService, AlfrescoApiService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; declare let AlfrescoApi: any; declare let jasmine: any; @@ -39,14 +39,16 @@ describe('AlfrescoUploadService', () => { beforeEachProviders(() => { return [ AlfrescoSettingsService, + AlfrescoApiService, AlfrescoAuthenticationService, UploadService ]; }); - beforeEach( inject([UploadService], (uploadService: UploadService) => { + beforeEach( inject([UploadService, AlfrescoApiService], (uploadService: UploadService, apiService: AlfrescoApiService) => { jasmine.Ajax.install(); service = uploadService; + apiService.setInstance(new AlfrescoApi({})); })); afterEach(() => { @@ -85,7 +87,7 @@ describe('AlfrescoUploadService', () => { service.uploadFilesInTheQueue('fake-dir', emitter); let request = jasmine.Ajax.requests.mostRecent(); - expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children'); + expect(request.url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children'); expect(request.method).toBe('POST'); jasmine.Ajax.requests.mostRecent().respondWith({ @@ -107,7 +109,7 @@ describe('AlfrescoUploadService', () => { service.addToQueue(filesFake); service.uploadFilesInTheQueue('', emitter); expect(jasmine.Ajax.requests.mostRecent().url) - .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children'); + .toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children'); jasmine.Ajax.requests.mostRecent().respondWith({ 'status': 404, contentType: 'text/plain', diff --git a/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts b/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts index 897787dbe9..edb55caac0 100644 --- a/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts +++ b/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts @@ -19,7 +19,7 @@ import { EventEmitter, Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; import { Observer } from 'rxjs/Observer'; -import { AlfrescoAuthenticationService} from 'ng2-alfresco-core'; +import { AlfrescoApiService } from 'ng2-alfresco-core'; import { FileModel } from '../models/file.model'; /** @@ -42,7 +42,7 @@ export class UploadService { filesUpload$: Observable; totalCompleted$: Observable; - constructor(private authService: AlfrescoAuthenticationService) { + constructor(private apiService: AlfrescoApiService) { this.filesUpload$ = new Observable(observer => this.filesUploadObserverProgressBar = observer).share(); this.totalCompleted$ = new Observable(observer => this.totalCompletedObserver = observer).share(); } @@ -91,7 +91,7 @@ export class UploadService { filesToUpload.forEach((uploadingFileModel: FileModel) => { uploadingFileModel.setUploading(); - let promiseUpload = this.authService.getAlfrescoApi(). + let promiseUpload = this.apiService.getInstance(). upload.uploadFile(uploadingFileModel.file, directory, null, null, {renditions: 'doclib'}) .on('progress', (progress: any) => { uploadingFileModel.setProgres(progress); @@ -161,7 +161,7 @@ export class UploadService { } private callApiCreateFolder(relativePath: string, name: string) { - return this.authService.getAlfrescoApi().node.createFolder(name, relativePath); + return this.apiService.getInstance().nodes.createFolder(name, relativePath); } /**