diff --git a/demo-shell-ng2/systemjs.config.js b/demo-shell-ng2/systemjs.config.js index 70c4466d67..726992d104 100644 --- a/demo-shell-ng2/systemjs.config.js +++ b/demo-shell-ng2/systemjs.config.js @@ -20,7 +20,8 @@ 'ng2-activiti-form': 'node_modules/ng2-activiti-form/dist', 'ng2-alfresco-viewer': 'node_modules/ng2-alfresco-viewer/dist', 'ng2-alfresco-webscript': 'node_modules/ng2-alfresco-webscript/dist', - 'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/dist' + 'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/dist', + 'alfresco-js-api': 'node_modules/alfresco-js-api/dist' }; // packages tells the System loader how to load when no filename and/or no extension var packages = { @@ -39,7 +40,8 @@ 'ng2-alfresco-viewer': { main: 'index.js', defaultExtension: 'js'}, 'ng2-activiti-form': { main: 'index.js', defaultExtension: 'js'}, 'ng2-activiti-tasklist': { main: 'index.js', defaultExtension: 'js'}, - 'ng2-alfresco-webscript': { main: 'index.js', defaultExtension: 'js'} + 'ng2-alfresco-webscript': { main: 'index.js', defaultExtension: 'js'}, + 'alfresco-js-api': { main: 'alfresco-js-api.js', defaultExtension: 'js'} }; var ngPackageNames = [ 'common', diff --git a/ng2-components/ng2-alfresco-core/index.ts b/ng2-components/ng2-alfresco-core/index.ts index 231df2fe5b..be1f41d742 100644 --- a/ng2-components/ng2-alfresco-core/index.ts +++ b/ng2-components/ng2-alfresco-core/index.ts @@ -16,6 +16,7 @@ */ import { + AlfrescoApiService, AlfrescoSettingsService, AlfrescoTranslationLoader, AlfrescoTranslationService, @@ -31,6 +32,7 @@ export * from './src/components/index'; export * from './src/utils/index'; export const ALFRESCO_CORE_PROVIDERS: [any] = [ + AlfrescoApiService, AlfrescoAuthenticationService, AlfrescoContentService, AlfrescoSettingsService, diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoApi.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoApi.service.ts new file mode 100644 index 0000000000..f71d5f5df5 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoApi.service.ts @@ -0,0 +1,34 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Injectable } from '@angular/core'; +import { AlfrescoJsApi } from 'alfresco-js-api'; + +@Injectable() +export class AlfrescoApiService { + + private _instance: AlfrescoJsApi; + + public getInstance(): AlfrescoJsApi { + return this._instance; + } + + public setInstance(value: AlfrescoJsApi) { + this._instance = value; + } + +} 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 ba92bff800..9a22bdbde2 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts @@ -15,11 +15,13 @@ * limitations under the License. */ -import {Injectable} from '@angular/core'; -import {Observable} from 'rxjs/Rx'; -import {AlfrescoSettingsService} from './AlfrescoSettings.service'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Rx'; +import { AlfrescoSettingsService } from './AlfrescoSettings.service'; +import { AlfrescoApiService } from './AlfrescoApi.service'; +import { AlfrescoJsApi } from 'alfresco-js-api'; -declare let AlfrescoApi: any; +declare var AlfrescoApi: AlfrescoJsApi; /** * The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage @@ -27,32 +29,37 @@ declare let AlfrescoApi: any; @Injectable() export class AlfrescoAuthenticationService { - alfrescoApi: any; + alfrescoApi: AlfrescoJsApi; - /**A + /** * Constructor - * @param alfrescoSetting + * @param settingsService + * @param apiService */ - constructor(public alfrescoSetting: AlfrescoSettingsService) { + constructor(private settingsService: AlfrescoSettingsService, + private apiService: AlfrescoApiService) { this.alfrescoApi = new AlfrescoApi({ - provider: this.alfrescoSetting.getProviders(), + provider: this.settingsService.getProviders(), ticketEcm: this.getTicketEcm(), ticketBpm: this.getTicketBpm(), - hostEcm: this.alfrescoSetting.ecmHost, - hostBpm: this.alfrescoSetting.bpmHost + hostEcm: this.settingsService.ecmHost, + hostBpm: this.settingsService.bpmHost, + contextRoot: 'alfresco' }); - alfrescoSetting.bpmHostSubject.subscribe((bpmHost) => { + settingsService.bpmHostSubject.subscribe((bpmHost) => { this.alfrescoApi.changeBpmHost(bpmHost); }); - alfrescoSetting.ecmHostSubject.subscribe((ecmHost) => { + settingsService.ecmHostSubject.subscribe((ecmHost) => { this.alfrescoApi.changeEcmHost(ecmHost); }); - alfrescoSetting.providerSubject.subscribe((value) => { + settingsService.providerSubject.subscribe((value) => { this.alfrescoApi.config.provider = value; }); + + this.apiService.setInstance(this.alfrescoApi); } /** @@ -73,7 +80,7 @@ export class AlfrescoAuthenticationService { return Observable.fromPromise(this.callApiLogin(username, password)) .map((response: any) => { this.saveTickets(); - return {type: this.alfrescoSetting.getProviders(), ticket: response}; + return {type: this.settingsService.getProviders(), ticket: response}; }) .catch(this.handleError); } diff --git a/ng2-components/ng2-alfresco-core/src/services/index.ts b/ng2-components/ng2-alfresco-core/src/services/index.ts index 7c013a4b4c..b4d963d6e1 100644 --- a/ng2-components/ng2-alfresco-core/src/services/index.ts +++ b/ng2-components/ng2-alfresco-core/src/services/index.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +export * from './AlfrescoApi.service'; export * from './AlfrescoSettings.service'; export * from './AlfrescoTranslationLoader.service'; export * from './AlfrescoTranslation.service';