diff --git a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts index b8405cb3fb..c1836babcc 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts +++ b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts @@ -30,7 +30,6 @@ export class ActivitiTaskListService { constructor(public authService: AlfrescoAuthenticationService) { } - /** * Retrive all the Deployed app * @returns {Observable} @@ -55,7 +54,7 @@ export class ActivitiTaskListService { filters.push(filterModel); }); return filters; - }); + }).catch(this.handleError); } /** @@ -67,7 +66,7 @@ export class ActivitiTaskListService { return Observable.fromPromise(this.callApiTasksFiltered(filter.filter)) .map((res: any) => { return res; - }); + }).catch(this.handleError); } /** @@ -80,7 +79,7 @@ export class ActivitiTaskListService { .map(res => res) .map((details: any) => { return new TaskDetailsModel(details); - }); + }).catch(this.handleError); } /** @@ -99,7 +98,7 @@ export class ActivitiTaskListService { comments.push(new Comment(comment.id, comment.message, comment.created, user)); }); return comments; - }); + }).catch(this.handleError); } /** @@ -116,7 +115,7 @@ export class ActivitiTaskListService { checklists.push(new TaskDetailsModel(checklist)); }); return checklists; - }); + }).catch(this.handleError); } /** @@ -129,7 +128,7 @@ export class ActivitiTaskListService { .map(res => res) .map((response: TaskDetailsModel) => { return new TaskDetailsModel(response); - }); + }).catch(this.handleError); } /** @@ -143,7 +142,8 @@ export class ActivitiTaskListService { .map(res => res) .map((response: Comment) => { return new Comment(response.id, response.message, response.created, response.createdBy); - }); + }).catch(this.handleError); + } /** @@ -192,4 +192,8 @@ export class ActivitiTaskListService { return this.authService.getAlfrescoApi().activiti.taskApi.completeTask(id); } + private handleError(error: any) { + console.error(error); + return Observable.throw(error || 'Server error'); + } } 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 b63d21ecde..8806839543 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 @@ -87,6 +87,7 @@ describe('AlfrescoAuthentication', () => { beforeEach(() => { authService = injector.get(AlfrescoAuthenticationService); + authService.alfrescoSetting.setProviders('ECM'); }); it('should return an ECM ticket after the login done', (done) => { @@ -157,7 +158,7 @@ describe('AlfrescoAuthentication', () => { beforeEach(() => { authService = injector.get(AlfrescoAuthenticationService); - authService.providers = 'BPM'; + authService.alfrescoSetting.setProviders('BPM'); }); @@ -214,6 +215,44 @@ describe('AlfrescoAuthentication', () => { }); }); + describe('Setting service change should reflect in the api', () => { + + beforeEach(() => { + authService = injector.get(AlfrescoAuthenticationService); + authService.alfrescoSetting.setProviders('ALL'); + spyOn(AlfrescoAuthenticationService.prototype, 'callApiLogin').and.returnValue(fakePromiseBPMECM); + }); + + it('should host ecm url change be reflected in the api configuration', (done) => { + authService.alfrescoSetting.ecmHost = '127.99.99.99'; + + authService.login('fake-username', 'fake-password').subscribe(() => { + expect(authService.getAlfrescoApi().config.host).toBe('127.99.99.99'); + done(); + }); + }); + + it('should host bpm url change be reflected in the api configuration', (done) => { + authService.alfrescoSetting.bpmHost = '127.99.99.99'; + + authService.login('fake-username', 'fake-password').subscribe(() => { + expect(authService.getAlfrescoApi().config.hostActiviti).toBe('127.99.99.99'); + done(); + }); + }); + + + it('should host bpm provider change be reflected in the api configuration', (done) => { + authService.alfrescoSetting.setProviders('ECM'); + + authService.login('fake-username', 'fake-password').subscribe(() => { + expect(authService.getAlfrescoApi().config.provider).toBe('ECM'); + done(); + }); + }); + + }); + describe('when the setting is both ECM and BPM ', () => { beforeEach(() => { diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts index 7b8ef12271..cc7e1d84c1 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts @@ -36,10 +36,22 @@ export class AlfrescoAuthenticationService { constructor(public alfrescoSetting: AlfrescoSettingsService) { this.alfrescoApi = new AlfrescoApi({ provider: this.alfrescoSetting.getProviders(), - ticket: this.isLoggedIn() ? this.getTicket() : null, + ticket: this.isLoggedIn() ? this.getTicket().split(',')[0] : null, host: this.alfrescoSetting.ecmHost, hostActiviti: this.alfrescoSetting.bpmHost }); + + alfrescoSetting.bpmHostSubject.subscribe((value) => { + this.alfrescoApi.config.hostActiviti = value; + }); + + alfrescoSetting.ecmHostSubject.subscribe((value) => { + this.alfrescoApi.config.host = value; + }); + + alfrescoSetting.providerSubject.subscribe((value) => { + this.alfrescoApi.config.provider = value; + }); } /** @@ -80,7 +92,6 @@ export class AlfrescoAuthenticationService { * @returns {*|Observable} */ private callApiLogin(username: string, password: string) { - this.alfrescoApi.config.provider = this.alfrescoSetting.getProviders(); return this.alfrescoApi.login(username, password); } diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.service.ts index 0e58aa5b4b..aa2d876107 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.service.ts @@ -16,6 +16,7 @@ */ import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs/Subject'; @Injectable() export class AlfrescoSettingsService { @@ -32,20 +33,26 @@ export class AlfrescoSettingsService { private providers: string = 'ALL'; // ECM, BPM , ALL + bpmHostSubject: Subject = new Subject(); + ecmHostSubject: Subject = new Subject(); + providerSubject: Subject = new Subject(); + public get ecmHost(): string { return this._ecmHost; } - public set ecmHost(value: string) { - this._ecmHost = value; + public set ecmHost(ecmHostUrl: string) { + this.ecmHostSubject.next(ecmHostUrl); + this._ecmHost = ecmHostUrl; } public get bpmHost(): string { return this._bpmHost; } - public set bpmHost(value: string) { - this._bpmHost = value; + public set bpmHost(bpmHostUrl: string) { + this.bpmHostSubject.next(bpmHostUrl); + this._bpmHost = bpmHostUrl; } public getBPMApiBaseUrl(): string { @@ -57,7 +64,7 @@ export class AlfrescoSettingsService { } public setProviders(providers: string) { + this.providerSubject.next(providers); this.providers = providers; } - } diff --git a/scripts/README.md b/scripts/README.md index a3a4f48b7b..37889a212a 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -41,4 +41,10 @@ in the demo shell: ./start-linked.sh ``` +* If you want to build all your local component: + +```sh +./npm-buid-alll.sh +``` + For development environment configuration please refer to [project docs](demo-shell-ng2/README.md). \ No newline at end of file