mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Merge pull request #391 from Alfresco/dev-mvitale-343
Adapt the Login component to works also with activiti
This commit is contained in:
@@ -18,15 +18,16 @@
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
|
||||
export class UploadServiceMock extends UploadService {
|
||||
|
||||
filesUpload$: Observable<any>;
|
||||
totalCompleted$: Observable<number>;
|
||||
|
||||
constructor(settings: AlfrescoSettingsService) {
|
||||
super(settings);
|
||||
constructor(settings: AlfrescoSettingsService,
|
||||
authService: AlfrescoAuthenticationService) {
|
||||
super(settings, authService);
|
||||
}
|
||||
|
||||
public setOptions(options: any): void {
|
||||
|
@@ -19,11 +19,12 @@ import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@
|
||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { AlfrescoTranslationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadServiceMock } from '../assets/upload.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
|
||||
describe('FileUploadDialog', () => {
|
||||
|
||||
@@ -32,7 +33,9 @@ describe('FileUploadDialog', () => {
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
HTTP_PROVIDERS,
|
||||
{ provide: AlfrescoSettingsService, useClass: AlfrescoSettingsService },
|
||||
{ provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService },
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||
{ provide: UploadService, useClass: UploadServiceMock }
|
||||
];
|
||||
|
@@ -18,12 +18,13 @@
|
||||
import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { UploadButtonComponent } from './upload-button.component';
|
||||
import { AlfrescoTranslationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadServiceMock } from '../assets/upload.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { AlfrescoApiMock } from '../assets/AlfrescoApi.mock';
|
||||
import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
|
||||
declare var AlfrescoApi: any;
|
||||
|
||||
@@ -38,7 +39,9 @@ describe('AlfrescoUploadButton', () => {
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
HTTP_PROVIDERS,
|
||||
{ provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
|
||||
{ provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService },
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||
{ provide: UploadService, useClass: UploadServiceMock }
|
||||
];
|
||||
|
@@ -18,12 +18,13 @@
|
||||
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 } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadServiceMock } from '../assets/upload.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { AlfrescoApiMock } from '../assets/AlfrescoApi.mock';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
|
||||
declare var AlfrescoApi: any;
|
||||
|
||||
@@ -37,7 +38,9 @@ describe('AlfrescoUploadDragArea', () => {
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
HTTP_PROVIDERS,
|
||||
{ provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
|
||||
{ provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService },
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||
{ provide: UploadService, useClass: UploadServiceMock }
|
||||
];
|
||||
|
@@ -18,9 +18,10 @@
|
||||
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||
import { UploadService } from './upload.service';
|
||||
import { FileModel } from './../models/file.model';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
|
||||
import { AlfrescoApiMock } from '../assets/AlfrescoApi.mock';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
|
||||
declare var AlfrescoApi: any;
|
||||
declare let jasmine: any;
|
||||
@@ -30,8 +31,9 @@ let errorFn = jasmine.createSpy('error');
|
||||
|
||||
class MockUploadService extends UploadService {
|
||||
|
||||
constructor(settings: AlfrescoSettingsService) {
|
||||
super(settings);
|
||||
constructor(settings: AlfrescoSettingsService,
|
||||
authService: AlfrescoAuthenticationService) {
|
||||
super(settings, authService);
|
||||
}
|
||||
|
||||
createXMLHttpRequestInstance() {
|
||||
@@ -65,7 +67,9 @@ describe('AlfrescoUploadService', () => {
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
HTTP_PROVIDERS,
|
||||
{ provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
|
||||
{ provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService },
|
||||
{ provide: UploadService, useClass: MockUploadService }
|
||||
];
|
||||
});
|
||||
|
@@ -20,7 +20,7 @@ import { EventEmitter, Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
|
||||
declare let AlfrescoApi: any;
|
||||
@@ -50,7 +50,8 @@ export class UploadService {
|
||||
|
||||
public totalCompleted: number = 0;
|
||||
|
||||
constructor(private settings: AlfrescoSettingsService) {
|
||||
constructor(private settings: AlfrescoSettingsService,
|
||||
private authService: AlfrescoAuthenticationService) {
|
||||
console.log('UploadService constructor');
|
||||
this.filesUpload$ = new Observable<FileModel[]>(observer => this._filesUploadObserver = observer).share();
|
||||
this.totalCompleted$ = new Observable<number>(observer => this._totalCompletedObserver = observer).share();
|
||||
@@ -92,20 +93,12 @@ export class UploadService {
|
||||
return this._formFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token from the local storage
|
||||
* @returns {any}
|
||||
*/
|
||||
private getAlfrescoTicket(): string {
|
||||
return localStorage.getItem('token');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alfresco client
|
||||
* @returns {AlfrescoApi.ApiClient}
|
||||
*/
|
||||
private getAlfrescoClient() {
|
||||
return AlfrescoApi.getClientWithTicket(this.settings.getApiBaseUrl(), this.getAlfrescoTicket());
|
||||
return AlfrescoApi.getClientWithTicket(this.settings.getApiBaseUrl(), this.authService.getToken());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user